組態王作為(wei) 經典的國產(chan) 組態軟件,對於(yu) 一些小的係統特別適用。但是組態王的曆史報警記錄需要配置數據庫。否則關(guan) 機後,下次打開就沒有了。
首先我們(men) 建立一個(ge) 測試變量。
建立報警界麵:
建立兩(liang) 個(ge) 時鍾變量,分別是開始日期和結束日期。
開始日期設置:
VOID closeup2()
float Ayear;
float Amonth;
float Aday;
string temp52;
Ayear=ADate52.Year;
Amonth=ADate52.Month;
Aday=ADate52.Day;
temp52=StrFromInt( Ayear, 10 );
if(Amonth<10)
temp52=temp52+"/0"+StrFromInt( Amonth, 10 );
else
temp52=temp52+"/"+StrFromInt( Amonth, 10 );
if(Aday<10)
temp52=temp52+"/0"+StrFromInt( Aday, 10 );
else
temp52=temp52+"/"+StrFromInt( Aday, 10 );
\\local\選擇日期52=temp52;
結束日期設置:
VOID closeUP355()
float Ayear;
float Amonth;
float Aday;
string temp55;
Ayear=ADate55.Year;
Amonth=ADate55.Month;
Aday=ADate55.Day;
temp55=StrFromInt( Ayear, 10 );
if(Amonth<10)
temp55=temp55+"/0"+StrFromInt( Amonth, 10 );
else
temp55=temp55+"/"+StrFromInt( Amonth, 10 );
if(Aday<10)
temp55=temp55+"/0"+StrFromInt( Aday, 10 );
else
temp55=temp55+"/"+StrFromInt( Aday, 10 );
\\local\選擇日期55=temp55;
【查詢記錄】設置:
string whe1;
string str = \\local\選擇日期52;
string str1 = ConvertLocalTimeToUTC(str);
str = \\local\選擇日期55;
string str2 = ConvertLocalTimeToUTC(str) ;
whe1 = "AlarmTime >=#"+str1+"# And AlarmTime <=#"+str2+"#";
Trace('test = %2s', whe1);
Ctrl14.Where = whe1;
Ctrl14.FetchData();
Ctrl14.FetchEnd();
【報警打印】設置:
Ctrl14.PrintPreview();
找到【KvAdoDBGrid Class】
以上是畫麵的設計:
下麵需要配置曆史記錄。
1)變量設置報警記錄
2)報警配置
3)配置ODBC
注意一定要是以下路徑的ODBCAD32
這個(ge) 數據庫是自己生成的。
測試效果: