Wonderware-InTouch 历史报警过滤器无弹窗关键字筛查
我們做歷史報警/事件的查詢功能時會用到“AlmDbViewCtrl”這個歷史控件,經常需要對歷史記錄的某些關鍵字進行篩查,以更加精確的得到查詢結果。就目前的查詢功能而言完全可以實現,但我們點擊篩查按鈕時,總會先彈出一個條件過濾器,再次選擇查詢條件方可得出結果。這個重復的操作真的不友好,對于完美主義者而言。
?
為了解決這個痛點,講一下如何實現關鍵字篩查無過濾器彈窗,現以這兩種方式做個對比。
一. 有過濾器彈窗篩查
1. 在“AlmDbViewCtrl”控件的屬性界面找到“查詢過濾器”,可新建編輯一個過濾器收藏文件夾名為:MYFILTER.xml,放在本工程的文件目錄下。
?
2. 在控件向導“魔法帽”找到“單選按鈕組”控件
3. 設置“單選按鈕組”控件,新建index內存整型標記名,做4個單選項,分別為:TgaName,AlarmGroup,Operator,Description,作為篩查關鍵字。選擇后的index的值分別為:1,2,3,4
4. 窗口顯示時腳本,即切換到歷史報警界面時初始化時間以及默認查詢當天報警歷史記錄:
#AlmDbViewCtrl1.StartTime = Text(#DTPicker2.month,"00") + "/" + Text(#DTPicker2.day,"00") + "/" + Text(#DTPicker2.year,"0000") + " " + Text(#DTPicker2.hour,"00") + ":" + Text(#DTPicker2.minute,"00") + ":" + Text(#DTPicker2.second,"00") ; #AlmDbViewCtrl1.EndTime = Text(#DTPicker3.month,"00") + "/" + Text(#DTPicker3.day,"00") + "/" + Text(#DTPicker3.year,"0000") + " " + Text(#DTPicker3.hour,"00") + ":" + Text(#DTPicker3.minute,"00") + ":" + Text(#DTPicker3.second,"00") ; #AlmDbViewCtrl1.SpecificTime = 1; #AlmDbViewCtrl1.Refresh();5.查詢按鈕腳本:
strPath = InfoInTouchAppDir() + "\MYFILTER1.xml"; CALL ALMSEARCHFILTER(strTagName,strAlarmGroup,strOperator,strDescription); #AlmDbViewCtrl1.StartTime = Text(#DTPicker2.month,"00") + "/" + Text(#DTPicker2.day,"00") + "/" + Text(#DTPicker2.year,"0000") + " " + Text(#DTPicker2.hour,"00") + ":" + Text(#DTPicker2.minute,"00") + ":" + Text(#DTPicker2.second,"00") ; #AlmDbViewCtrl1.EndTime = Text(#DTPicker3.month,"00") + "/" + Text(#DTPicker3.day,"00") + "/" + Text(#DTPicker3.year,"0000") + " " + Text(#DTPicker3.hour,"00") + ":" + Text(#DTPicker3.minute,"00") + ":" + Text(#DTPicker3.second,"00") ; #AlmDbViewCtrl1.SpecificTime = 1; #AlmDbViewCtrl1.ShowFilter();6. CALL ALMSEARCHFILTER(str1,str2,str3,str4)函數腳本為:4個參數均為消息
FileDelete(strPath); FileWriteMessage( InfoInTouchAppDir() + "\MYFILTER1.xml",0,HIST_XMLCODE + "<Filter_Favorites><Record><FilterName>TAGNAME</FilterName><Element>", 0 ); FileWriteMessage( InfoInTouchAppDir() + "\MYFILTER1.xml",-1, "<Name>名稱</Name><OrigName>Name</OrigName><Operator>LIKE</Operator><Value>%"+str1+"%</Value><Parent>0</Parent>", 0); FileWriteMessage( InfoInTouchAppDir() + "\MYFILTER1.xml", -1, "</Element></Record>", 0 ); FileWriteMessage( InfoInTouchAppDir() + "\MYFILTER1.xml",-1, "<Record><FilterName>ALARMGROUP</FilterName><Element>", 0 ); FileWriteMessage( InfoInTouchAppDir() + "\MYFILTER1.xml",-1, "<Name>組</Name><OrigName>Group</OrigName><Operator>LIKE</Operator><Value>%"+str2+"%</Value><Parent>0</Parent>", 0); FileWriteMessage( InfoInTouchAppDir() + "\MYFILTER1.xml", -1, "</Element></Record>", 0 ); FileWriteMessage( InfoInTouchAppDir() + "\MYFILTER1.xml",-1,"<Record><FilterName>OPERATOR</FilterName><Element>", 0 ); FileWriteMessage( InfoInTouchAppDir() + "\MYFILTER1.xml",-1, "<Name>操作</Name><OrigName>Operator</OrigName><Operator>LIKE</Operator><Value>%"+str3+"%</Value><Parent>0</Parent>", 0); FileWriteMessage( InfoInTouchAppDir() + "\MYFILTER1.xml", -1, "</Element></Record>", 0 ); FileWriteMessage( InfoInTouchAppDir() + "\MYFILTER1.xml",-1,"<Record><FilterName>DESCRIPTION</FilterName><Element>", 0 ); FileWriteMessage( InfoInTouchAppDir() + "\MYFILTER1.xml",-1, "<Name>報警注釋</Name><OrigName>Alarm Comment</OrigName><Operator>LIKE</Operator><Value>%"+str4+"%</Value><Parent>0</Parent>", 0); FileWriteMessage( InfoInTouchAppDir() + "\MYFILTER1.xml", -1, "</Element></Record></Filter_Favorites>", 0 ); #AlmDbViewCtrl1.FilterFavoritesFile = strPath;7. 生成的過濾文件內容為:內容可以根據需要篩查的關鍵字進行增減
8. 點擊查詢按鈕后需再次選擇條件確定得出結果:
到此,有過濾器彈窗關鍵字篩查結束。
二. 無過濾器彈窗篩查
從上面第5步開始寫查詢按鈕的腳本就有所不同了,在這里敲黑板,抬頭挺胸劃重點,用到了“AlmDbViewCtrl”控件“SelectQuery”方法實現查詢,腳本格式如下:
#AlmDbViewCTRL1.SelectQuery("filtername");查詢按鈕腳本為:
#AlmDbViewCtrl1.StartTime = Text(#DTPicker2.month,"00") + "/" + Text(#DTPicker2.day,"00") + "/" + Text(#DTPicker2.year,"0000") + " " + Text(#DTPicker2.hour,"00") + ":" + Text(#DTPicker2.minute,"00") + ":" + Text(#DTPicker2.second,"00") ; #AlmDbViewCtrl1.EndTime = Text(#DTPicker3.month,"00") + "/" + Text(#DTPicker3.day,"00") + "/" + Text(#DTPicker3.year,"0000") + " " + Text(#DTPicker3.hour,"00") + ":" + Text(#DTPicker3.minute,"00") + ":" + Text(#DTPicker3.second,"00") ; #AlmDbViewCtrl1.SpecificTime = 1;IF index == 1 THEN #AlmDbViewCTRL1.SelectQuery("TAGNAME"); ELSE IF index == 2 THEN #AlmDbViewCTRL1.SelectQuery("ALARMGROUP"); ELSE IF index == 3 THEN #AlmDbViewCTRL1.SelectQuery("OPERATOR"); ELSE IF index == 4 THEN #AlmDbViewCTRL1.SelectQuery("DESCRIPTION"); ENDIF;ENDIF;ENDIF;ENDIF;到此,無過濾器彈窗關鍵字篩查結束。
InTouch歷史報警無過濾器彈窗關鍵字篩查視頻演示
Wonderware-InTouch歷史報警無過濾器彈窗篩查學習
?
總結
以上是生活随笔為你收集整理的Wonderware-InTouch 历史报警过滤器无弹窗关键字筛查的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: View框架浅析
- 下一篇: Pusher入门:使用Channels,