📄 txjunit1.pas
字号:
end;
end;
if nCount=6 then begin
canshuming:='煤气表' ;
ListBox5.Items.Add(ReceBuf);
if ReceBuf=last[2][2][3] then tCount[2][2][3]:=tCount[2][2][3]+1
else begin
last[2][2][3]:=ReceBuf;
tCount[2][2][3]:=0;
end;
end;
if nCount=7 then begin
canshuming:='水表' ;
ListBox1.Items.Add(' ');
ListBox2.Items.Add('B3');
ListBox3.Items.Add(ReceBuf);
if ReceBuf=last[2][3][1] then tCount[2][3][1]:=tCount[2][3][1]+1
else begin
last[2][3][1]:=ReceBuf;
tCount[2][3][1]:=0;
end;
end;
if nCount=8 then begin
canshuming:='电表' ;
ListBox4.Items.Add(ReceBuf);
if ReceBuf=last[2][3][2] then tCount[2][3][2]:=tCount[2][3][2]+1
else begin
last[2][3][2]:=ReceBuf;
tCount[2][3][2]:=0;
end;
end;
if nCount=9 then begin
canshuming:='煤气表' ;
ListBox5.Items.Add(ReceBuf);
if ReceBuf=last[2][3][3] then tCount[2][3][3]:=tCount[2][3][3]+1
else begin
last[2][3][3]:=ReceBuf;
tCount[2][3][3]:=0;
end;
end;
if nCount >=7 then begin
bianhao:='B3' ;
if ((tCount[2][3][1]>=2)and(tCount[2][3][2]>=2)and(tCount[2][3][3]>=2))then
tishi:='异常'
else
tishi:='正常'
end
else if nCount>=4 then begin
bianhao:='B2' ;
if ((tCount[2][2][1]>=2)and(tCount[2][2][2]>=2)and(tCount[2][2][3]>=2))then
tishi:='异常'
else
tishi:='正常'
end
else begin
bianhao:='B1' ;
if ((tCount[2][1][1]>=2)and(tCount[2][1][2]>=2)and(tCount[2][1][3]>=2))then
tishi:='异常'
else
tishi:='正常'
end;
shishu := strtoint(ReceBuf);
strSql:='Insert into 数据信息(编号,表名,示数,记录时间,记录日期,告警提示)';
strSql:=strSql + 'Values(:a,:b,:c,:d,:e,:f)';
self.ADOCommand1.CommandText:=strSql;
self.ADOCommand1.Parameters.ParamByName('a').Value:=bianhao;
self.ADOCommand1.Parameters.ParamByName('b').Value:=canshuming;
self.ADOCommand1.Parameters.ParamByName('c').Value :=shishu;
self.ADOCommand1.Parameters.ParamByName('d').Value:=strTime;
self.ADOCommand1.Parameters.ParamByName('e').Value:=strDate;
self.ADOCommand1.Parameters.ParamByName('f').Value:=tishi;
self.ADOCommand1.Execute;
exit;
end;
if shebexuha=3 then begin
nCount:=nCount+1;
if nCount=1 then begin
canshuming:='水表' ;
ListBox2.Items.Add('C1');
ListBox3.Items.Add(ReceBuf);
if ReceBuf=last[3][1][1] then tCount[3][1][1]:=tCount[3][1][1]+1
else begin
last[3][1][1]:=ReceBuf;
tCount[3][1][1]:=0;
end;
end;
if nCount=2 then begin
canshuming:='电表' ;
ListBox4.Items.Add(ReceBuf);
if ReceBuf=last[3][1][2] then tCount[3][1][2]:=tCount[3][1][2]+1
else begin
last[3][1][2]:=ReceBuf;
tCount[3][1][2]:=0;
end;
end;
if nCount=3 then begin
canshuming:='煤气表' ;
ListBox5.Items.Add(ReceBuf);
if ReceBuf=last[3][1][3] then tCount[3][1][3]:=tCount[3][1][3]+1
else begin
last[3][1][3]:=ReceBuf;
tCount[3][1][3]:=0;
end;
end;
if nCount=4 then begin
canshuming:='水表' ;
ListBox1.Items.Add(' ');
ListBox2.Items.Add('C2');
ListBox3.Items.Add(ReceBuf);
if ReceBuf=last[3][2][1] then tCount[3][2][1]:=tCount[3][2][1]+1
else begin
last[3][2][1]:=ReceBuf;
tCount[3][2][1]:=0;
end;
end;
if nCount=5 then begin
canshuming:='电表' ;
ListBox4.Items.Add(ReceBuf);
if ReceBuf=last[3][2][2] then tCount[3][2][2]:=tCount[3][2][2]+1
else begin
last[3][2][2]:=ReceBuf;
tCount[3][2][2]:=0;
end;
end;
if nCount=6 then begin
canshuming:='煤气表' ;
ListBox5.Items.Add(ReceBuf);
if ReceBuf=last[3][2][3] then tCount[3][2][3]:=tCount[3][2][3]+1
else begin
last[3][2][3]:=ReceBuf;
tCount[3][2][3]:=0;
end;
end;
if nCount=7 then begin
canshuming:='水表' ;
ListBox1.Items.Add(' ');
ListBox2.Items.Add('C3');
ListBox3.Items.Add(ReceBuf);
if ReceBuf=last[3][3][1] then tCount[3][3][1]:=tCount[3][3][1]+1
else begin
last[3][3][1]:=ReceBuf;
tCount[3][3][1]:=0;
end;
end;
if nCount=8 then begin
canshuming:='电表' ;
ListBox4.Items.Add(ReceBuf);
if ReceBuf=last[3][3][2] then tCount[3][3][2]:=tCount[3][3][2]+1
else begin
last[3][3][2]:=ReceBuf;
tCount[3][3][2]:=0;
end;
end;
if nCount=9 then begin
canshuming:='煤气表' ;
ListBox5.Items.Add(ReceBuf);
if ReceBuf=last[3][3][3] then tCount[3][3][3]:=tCount[3][3][3]+1
else begin
last[3][3][3]:=ReceBuf;
tCount[3][3][3]:=0;
end;
end;
if nCount >=7 then begin
bianhao:='C3' ;
if ((tCount[3][3][1]>=2)and(tCount[3][3][2]>=2)and(tCount[3][3][3]>=2))then
tishi:='异常'
else
tishi:='正常'
end
else if nCount>=4 then begin
bianhao:='C2' ;
if ((tCount[3][2][1]>=2)and(tCount[3][2][2]>=2)and(tCount[3][2][3]>=2))then
tishi:='异常'
else
tishi:='正常'
end
else begin
bianhao:='C1' ;
if ((tCount[3][1][1]>=2)and(tCount[3][1][2]>=2)and(tCount[3][1][3]>=2))then
tishi:='异常'
else
tishi:='正常'
end;
shishu := strtoint(ReceBuf);
strSql:='Insert into 数据信息(编号,表名,示数,记录时间,记录日期,告警提示)';
strSql:=strSql + 'Values(:a,:b,:c,:d,:e,:f)';
self.ADOCommand1.CommandText:=strSql;
self.ADOCommand1.Parameters.ParamByName('a').Value:=bianhao;
self.ADOCommand1.Parameters.ParamByName('b').Value:=canshuming;
self.ADOCommand1.Parameters.ParamByName('c').Value :=shishu;
self.ADOCommand1.Parameters.ParamByName('d').Value:=strTime;
self.ADOCommand1.Parameters.ParamByName('e').Value:=strDate;
self.ADOCommand1.Parameters.ParamByName('f').Value:=tishi;
self.ADOCommand1.Execute;
exit;
end;
end;
procedure Ttongxinji.FormCreate(Sender: TObject);
var
strpath:string; //配置文件路径
strsyspara:Tinifile; //系统特殊数据存放文件
I:Integer;
J:Integer;
k:Integer;
begin
label9.Caption := DateToStr (Date());
ADOTable1.Active := True;
strpath := ExtractFilePath(Application.ExeName);
strsyspara := Tinifile.Create(strpath+'shenchang_CONFIG.INI');
if NOT FileExists(strpath+'shenchang_CONFIG.INI') then
begin
showmessage('警告:系统配置文件不存在!');
Bresult:=False;
Exit;
end;
g_connection:=TADOConnection.Create(nil);
g_connection.ConnectionString:=strsyspara.ReadString('system','connectionstring','');
g_connection.LoginPrompt := False;
g_connection.Open;
self.ADOCommand1.Connection := g_Connection;
self.ADOTable1.Connection := g_Connection;
//self.ADODataSet1.Connection := g_Connection;
if Not MSComm1.PortOpen then
begin
MSComm1.PortOpen:=True;
MSComm1.DTREnable:=True;
MSComm1.RTSEnable:=True;
end;
MSComm1.RThreshold := 1;
for I:=1 to 3 do
begin
for J:=1 to 5 do
begin
for K:=1 to 3 do
begin
last[I][J][K]:='';
end;
end;
end;
for I:=1 to 3 do
begin
for J:=1 to 5 do
begin
for K:=1 to 3 do
begin
tCount[I][J][K]:=0;
end;
end;
end;
end;
procedure Ttongxinji.Button2Click(Sender: TObject);
var
str1:string;
str2 : string;
begin
ADOTable1.Close;
ADOTable1.Open;
str2 := Datetostr (Date());
if ADOTable1.Locate('记录日期',str2,[]) then
begin
Messagedlg('今天的数据已采取,请勿重复.',mtError,[mbok],0);
exit
end;
timer1.Enabled := True;
gostart := true;
if gostart = true then begin
Button2.Enabled := False
end
else
Button2.Enabled := True;
//str1:=inttostr(nCount);
str1:='读A栋';
if MSComm1.PortOpen then begin
MSComm1.Output:=str1;
ListBox1.Items.Add(str1);
end
else
Messagedlg('通信端口1未打开!',mtError,[mbok],0);
TimeDelay(5000);
str1:='读B栋';
if MSComm1.PortOpen then begin
MSComm1.Output:=str1;
ListBox1.Items.Add(str1);
end
else
Messagedlg('通信端口1未打开!',mtError,[mbok],0);
TimeDelay(5000);
str1:='读C栋';
if MSComm1.PortOpen then begin
MSComm1.Output:=str1;
ListBox1.Items.Add(str1);
end
else
Messagedlg('通信端口1未打开!',mtError,[mbok],0);
timer1.Enabled := False;
Button2.Enabled := True;
end;
procedure Ttongxinji.Timer2Timer(Sender: TObject);
begin
label8.Caption := Datetostr (Date());
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -