📄 hrunit1.~pas
字号:
end;
end;
end
else
begin
tempstr[9]:='0'; //人工读数
tempstr[10]:='0'; //估收水量
end;
//*********
//停转时间
if (midbstr(temp,1,1)='I') or (midbstr(temp,1,1)='M') then
begin
tempfj:=round((ord(Midbstr(temp, 44, 1)[1])*256*256+ord(Midbstr(temp, 45, 1)[1])*256+ord(Midbstr(temp, 46, 1)[1])));
tempstr[11]:=tempfj div 3600;
tempstr[12]:='0';
tempstr[13]:='0';
end
else if (midbstr(temp,1,1)='A') or (midbstr(temp,1,1)='W') then
begin
if inttostr((ord(Midbstr(temp, 37, 1)[1]) mod 128) div 64)='1' then
tempstr[11]:='48';
tempfj:=round((ord(Midbstr(temp, 47, 1)[1])*256+ord(Midbstr(temp, 48, 1)[1])));
tempstr[12]:=tempfj div 3600; //停转开始时间
tempfj:=round((ord(Midbstr(temp, 49, 1)[1])*256+ord(Midbstr(temp, 50, 1)[1])));
tempstr[13]:=tempfj div 3600; //当前时间
end;
DataModule1.adocommand1.Connection :=datamodule1.ADOConnection1;
DataModule1.adocommand1.commandtext:='insert into 临时数据表(设备ID号,注册号,本期指数,停转时间,电池电压,计数轮,定点时间,设备上传时间,设备当前时钟,设备类型,数据来源,状态,人工读数,估收水量,停转开始时间,当前时间) values('''+trim(tempstr[3])+''','''+trim(tempstr[2])+''','''+trim(tempstr[8])+''','''+trim(tempstr[11])+''','''+trim(tempstr[7])+''','''+trim(tempstr[4])+''',''00:00:00'','''+trim(formatdatetime('yyyy-mm-dd hh:nn:ss',strtodatetime(tempstr[6])))+''','''+trim(formatdatetime('yyyy-mm-dd hh:nn:ss',strtodatetime(tempstr[6])))+''','''+trim(tempstr[1])+''',''HR'','''+trim(tempstr[5])+''','''+trim(tempstr[9])+''','''+trim(tempstr[10])+''','''+trim(tempstr[12])+''','''+trim(tempstr[13])+''')';
DataModule1.adocommand1.Execute;
//end;
until j=FileSize(FromF) div 52;
closefile(FromF);
result:=1;
Screen.Cursors[crMyCursor]:=crdefault;
Screen.Cursor:=crdefault;
except
on e:exception do
begin
result:=0;
closefile(FromF);
Screen.Cursors[crMyCursor]:=crdefault;
Screen.Cursor:=crdefault;
exit;
end;
end;
end;
//******************************************************************************
function ParseTask:integer;stdcall;
var
fnum1:textfile;
tempt,usernos:string;
begin
try
assignfile(fnum1,extractfilepath(application.ExeName) + 'Data\cIM_TA.db');
reset(fnum1);
while not eof(fnum1) do
begin
readln(fnum1,tempt);
application.ProcessMessages;
screen.Cursors[crMyCursor]:=LoadCursorFromFile('bgwork.ani');
screen.Cursor :=crMyCursor;
if trim(midbstr(tempt,5,1))='N' then
begin
{if trim(midbstr(tempt,2,1))='M' then
usernos:=leftbstr(trim(midbstr(tempt,14,16)),length(trim(midbstr(tempt,14,16)))-1)+rightbstr(trim(midbstr(tempt,14,16)),1)
else
usernos:=midbstr(tempt,14,16);}
usernos:=trim(leftbstr(trim(midbstr(tempt,14,16)),length(trim(midbstr(tempt,14,16)))-1))+rightbstr(trim(midbstr(tempt,14,16)),1);
DataModule1.adoquery4.Connection :=datamodule1.ADOConnection1;
DataModule1.adoquery4.SQL.Clear;
DataModule1.ADOQuery4.Filtered:=false;
DataModule1.adoquery4.Close;
DataModule1.adoquery4.SQL.Add('select * from 设备信息表 where 注册号='''+trim(usernos)+'''');
DataModule1.adoquery4.Prepared;
DataModule1.adoquery4.open;
if datamodule1.ADOQuery4.RecordCount <>0 then
begin
DataModule1.adocommand1.Connection :=datamodule1.ADOConnection1;
DataModule1.adocommand1.commandtext:='insert into 临时数据表(设备ID号,注册号,本期指数,停转时间,电池电压,计数轮,定点时间,设备上传时间,设备当前时钟,设备类型,数据来源,状态,人工读数,估收水量,停转开始时间,当前时间) values('''+trim(datamodule1.ADOQuery4.fieldbyname('设备ID号').AsString)+''','''+trim(usernos)+''',''0'',''0'',''未知'',''0'',''00:00:00'','''+trim(formatdatetime('yyyy-mm-dd hh:nn:ss',now))+''','''+trim(formatdatetime('yyyy-mm-dd hh:nn:ss',now))+''','''+trim(datamodule1.ADOQuery4.fieldbyname('设备类型').AsString)+''',''HR'',''999'',''0'',''0'',''0'',''0'')';
DataModule1.adocommand1.Execute;
end;
end;
end;
closefile(fnum1);
Screen.Cursors[crMyCursor]:=crdefault;
Screen.Cursor:=crdefault;
result:=1;
except
on e:exception do
begin
result:=0;
closefile(fnum1);
Screen.Cursors[crMyCursor]:=crdefault;
Screen.Cursor:=crdefault;
exit;
end;
end;
end;
//******************************************************************************
function Parse48DayCurveData:integer;stdcall
var
fnum1:textfile;
tempfj:Variant;
dangl:real;
temp:string;
tempstr:array[1..4] of string;
begin
try
assignfile(fnum1,extractfilepath(application.ExeName) + 'Data\cIM_CUA.db');
reset(fnum1);
while not eof(fnum1) do
begin
application.ProcessMessages;
readln(fnum1,temp);
application.ProcessMessages;
screen.Cursors[crMyCursor]:=LoadCursorFromFile('bgwork.ani');
screen.Cursor :=crMyCursor;
//tempstr[1]:=trim(midbstr(temp,1,16)); //注册号
tempstr[1]:=trim(leftbstr(trim(midbstr(temp,1,16)),length(trim(midbstr(temp,1,16)))-1))+rightbstr(trim(midbstr(temp,1,16)),1);
tempfj:=trim(midbstr(temp,17,1));
if tempfj='D' then
dangl:=0.01
else if tempfj='E' then
dangl:=0.1
else if tempfj='F' then
dangl:=1.0
else if tempfj='0' then
dangl:=10
else if tempfj='1' then
dangl:=100;
tempstr[2]:=floattostr(dangl * 0.1); //计数轮
tempstr[3]:=formatdatetime('yyyy-mm-dd',strtodatetime(midbstr(temp,26,2)+'-'+midbstr(temp,28,2)+'-'+midbstr(temp,30,2)))+'/00';
tempstr[4]:=midbstr(temp,32,192);
DataModule1.adoquery4.Connection :=datamodule1.ADOConnection1;
DataModule1.adoquery4.SQL.Clear;
DataModule1.ADOQuery4.Filtered:=false;
DataModule1.adoquery4.Close;
DataModule1.adoquery4.SQL.Add('select * from 设备信息表 where 注册号='''+tempstr[1]+'''');
DataModule1.adoquery4.Prepared;
DataModule1.adoquery4.open;
if datamodule1.ADOQuery4.RecordCount <>0 then
begin
DataModule1.adocommand1.Connection :=datamodule1.ADOConnection1;
DataModule1.adocommand1.commandtext:='insert into 曲线临时表 (设备ID号,注册号,设备上传时间,曲线开始时间,曲线数据,设备类型) values('''+trim(datamodule1.ADOQuery4.fieldbyname('设备ID号').AsString)+''','''+trim(tempstr[1])+''','''+formatdatetime('yyyy-mm-dd hh:nn:ss',strtodatetime(leftstr(trim(tempstr[3]),10)+stringofchar(char(32),1)+'00:00:01'))+''','''+tempstr[3]+''','''+tempstr[4]+''','''+trim(datamodule1.ADOQuery4.fieldbyname('设备类型').AsString)+''')';
DataModule1.adocommand1.Execute;
end
else
begin
DataModule1.adocommand1.Connection :=datamodule1.ADOConnection1;
DataModule1.adocommand1.commandtext:='insert into 曲线临时表 (设备ID号,注册号,设备上传时间,曲线开始时间,曲线数据,设备类型) values(''未知'','''+trim(tempstr[1])+''','''+formatdatetime('yyyy-mm-dd hh:nn:ss',strtodatetime(leftstr(trim(tempstr[3]),10)+stringofchar(char(32),1)+'00:00:01'))+''','''+tempstr[3]+''','''+tempstr[4]+''',''未知'')';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -