組態(tài)王作為經(jīng)典的國產(chǎn)組態(tài)軟件,對于一些小的系統(tǒng)特別適用。但是組態(tài)王的歷史報(bào)警記錄需要配置數(shù)據(jù)庫。否則關(guān)機(jī)后,下次打開就沒有了。
首先我們建立一個(gè)測試變量。
建立報(bào)警界面:
建立兩個(gè)時(shí)鐘變量,分別是開始日期和結(jié)束日期。
開始日期設(shè)置:
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;
結(jié)束日期設(shè)置:
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;
【查詢記錄】設(shè)置:
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();
【報(bào)警打印】設(shè)置:
Ctrl14.PrintPreview();
找到【KvAdoDBGrid Class】
以上是畫面的設(shè)計(jì):
下面需要配置歷史記錄。
1)變量設(shè)置報(bào)警記錄
2)報(bào)警配置
3)配置ODBC
注意一定要是以下路徑的ODBCAD32
這個(gè)數(shù)據(jù)庫是自己生成的。
測試效果: