📄 recethr.~pas
字号:
S1[6]:=byte($0);}
{ postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_ClearData);
i1:=0;
while true do
begin
i2:=write24c01(8,6,s1);
if i2=1 then begin result:=1;break;end;
postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_Offline);
sleep(350);
i2:=wakeuppen;
if i2<>1 then begin result:=-5;exit;end;
inc(i1);
if i1>10 then begin result:=-5;exit;end;
end;
postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_ClearDataSucc);}
end;
postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_SaveData);
postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_SetTime);
i1:=0;
while true do
begin
decodedate(date,y,m,d);
decodetime(time, hour,min,sec,msec);
i2:=WritePenClock(y,m,d,hour,min,sec);
if i2=1 then begin result:=1;break;end;
postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_Offline);
sleep(350);
i2:=wakeuppen;
if i2=1 then continue;
sleep(3000);
i2:=wakeuppen;
if i2<>1 then begin
postmessage(fowner,WM_MESSAGE1,Msg_Comm,Msg_Comm_DeviceErr); result:=-5;exit;end;
inc(i1);
if i1>10 then begin result:=-5;exit;end;
end;
postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_SetTimeSucc);
result:=1;
end;
function TReadPenData.PostComm:integer;
begin
end;
function TClearPenData.PostComm:integer;
begin
end;
function TClearPenData.DoComm:integer;
var
i1,i2:integer;
s1:array [1..20] of byte;
begin
FComm.PurgeOut;
FComm.PurgeIn;
i1:=0;
while true do //connect pen
begin
i2:=WakeupPen;
if i2=1 then break;
if i2=-1 then
begin
postmessage(fowner,WM_MESSAGE1,Msg_Comm,Msg_Comm_DeviceErr);
exit;
end;
sleep(200);
inc(i1);
if i1>10 then begin
postmessage(fowner,WM_MESSAGE1,Msg_Comm,Msg_Comm_comerror);
result:=-1;exit;end;
end;
postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_ClearData);
i1:=0;
s1[1]:=0;
while true do
begin
i2:=write24c01(8,6,s1); //数据删除
if i2=1 then begin result:=1;break;end;
postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_Offline);
sleep(350);
i2:=wakeuppen;
if i2<>1 then begin
postmessage(fowner,WM_MESSAGE1,Msg_Comm,Msg_Comm_DeviceErr); result:=-5;exit;end;
inc(i1);
if i1>10 then begin result:=-5;exit;end;
end;
postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_ClearDataSucc);
result:=1;
end;
function Tsetpenmode.DoComm:integer;
var
i1,i2:integer;
s1,s2:array [1..8] of byte;
begin
FComm.PurgeOut;
FComm.PurgeIn;
i1:=0;
while true do //connect pen
begin
i2:=WakeupPen;
if i2=1 then break;
if i2=-1 then
begin
postmessage(fowner,WM_MESSAGE1,Msg_Comm,Msg_Comm_DeviceErr);
exit;
end;
sleep(200);
inc(i1);
if i1>5 then begin
postmessage(fowner,WM_MESSAGE1,Msg_Comm,Msg_Comm_comerror);
result:=-1;exit;end;
end;
postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_WritePenMode);
i1:=0;
if fmode=1 then s1[1]:=$ff
else s1[1]:=$01;
while true do
begin
i2:=Write24C01(5,1,S1); //写入单键、三键方式
if i2=1 then begin result:=1;break;end;
postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_Offline);
sleep(350);
i2:=wakeuppen;
if i2=1 then continue;
sleep(2000);
i2:=wakeuppen;
if i2<>1 then begin
postmessage(fowner,WM_MESSAGE1,Msg_Comm,Msg_Comm_DeviceErr); result:=-2;exit;end;
inc(i1);
if i1>5 then begin result:=-2;exit;end;
end;
i1:=0;
{ while true do //get pen data_counter
begin
i2:=Read24C01(5,1,S2);
if i2=1 then break;
postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_Offline);
sleep(200);
i2:=WakeupPen;
if i2<>1 then begin result:=-3;exit;end;
inc(i1);
if i1>2 then begin result:=-3;exit;end;
end;}
if result=1 then {S2[1]=S1[1] then}
postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_WritePenModeSucc)
else
postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_WritePenModeFale);
// result:=1;
end;
function TSETPenMODE.PostComm:integer;
begin
end;
//=======================================================
constructor TSaveThr.create(owner:thandle;f1:byte;f2:integer;f3:pe2buff);
begin
fowner:=owner;
fpcode:=f1;
fdcnt:=f2;
fpe2buff:=f3;
FreeOnTerminate := True;
inherited Create(False);
end;
constructor TSaveThr1.create(owner:thandle;f1:byte;f2:integer;f3:pe2buff);
begin
fowner:=owner;
fpcode:=f1;
fdcnt:=f2;
fpe2buff:=f3;
FreeOnTerminate := True;
inherited Create(False);
end;
procedure TSaveThr.Execute; //接触式
var
i1,yearnum,num,l_lseq:integer;
s,l_workname,l_node,l_nodename,l_nodeplace,l_linename:string;
l_dd,l_time:tdatetime;
spencode:string;
v_year,v_month,v_day,v_hour,v_min:word;
v_node2,v_workcode,v_node1:string;
id:integer;
filetext:string;
begin
id:=0;
try
spencode:=inttohex(FPCode,2);
datamodule1.q_PATROLREC.open;
//datamodule1.q_WORKER.open;
//datamodule1.q_POINT.IndexName:='';
//datamodule1.q_POINT.IndexFieldNames:='node';
datamodule1.q_POINT.open;
for i1:=1 to FDCnt do
begin
try
V_year:=2000+bytehextoDec(byte(FpE2BUFF[i1][1]));
V_month:=bytehextodec(byte(FpE2BUFF[i1][2]));
V_day:=bytehextodec(byte(FpE2BUFF[i1][3]));
V_hour:=bytehextodec(byte(FpE2BUFF[i1][4]));
V_min:=bytehextodec(byte(FpE2BUFF[i1][5]));
V_node1:=inttohex(byte(FpE2BUFF[i1][6]),2);
V_node2:=inttohex(byte(FpE2BUFF[i1][7]),2);
v_workcode:=inttohex(byte(FpE2BUFF[i1][8]),2);
l_node:=v_node2+v_node1;
if datamodule1.q_point.Locate('node;code',vararrayOf([l_node,v_workcode]),[loCaseInsensitive]) then
begin
l_nodename:=datamodule1.q_point.fieldbyname('nodename').asstring;
l_nodeplace:=datamodule1.q_point.fieldbyname('nodeplace').asstring;
l_linename:=datamodule1.q_point.fieldbyname('linename').asstring;
l_lseq:=datamodule1.q_point.fieldbyname('lseq').asinteger;
l_workname:=datamodule1.q_point.fieldbyname('name').asstring;
end
else
begin
l_nodename:='';
l_nodeplace:='';
l_linename:='';
l_lseq:=0;
l_workname:='';
end;
//v_month:=52;
//v_day:=92;
l_dd:=encodedate(v_year,v_month,v_day);
l_time:=encodetime(v_hour,v_min,0,0);
with datamodule1.q_PATROLREC do
begin //L_2
//datamodule1.q_PATROLREC.open;
append; //增加一条新记录
edit;
fieldbyname('pdate').value:=l_dd;
fieldbyname('ptime').value:=l_time;
fieldbyname('workercode').asstring:=V_workcode;
fieldbyname('node').asstring:=l_node;
fieldbyname('pencode').asstring:=spencode;
fieldbyname('workername').asstring:=l_workname;
fieldbyname('nodename').asstring:=l_nodename;
fieldbyname('nodeplace').asstring:=l_nodeplace;
fieldbyname('linename').asstring:=l_linename;
fieldbyname('lseq').asinteger:=l_lseq;
post;
refresh;
if id=0 then
begin
id:=fieldbyname('dataseq').asinteger;
ReceForm.Label1.Caption:=inttostr(id);
//showmessage(inttostr(id));
end;
postmessage(fowner,WM_MsgSave,i1,1);
end;//L_2
/////////////////////L_1
////////////////////////////////////////////////////////////////////////////////
except
filetext:='保存資料出錯! 資料獲取時間:'+formatdatetime('yyyy-mm-dd hh:mm:ss',ReceForm.recetime);
WriteLog(filetext);
filetext:='棒號:'+spencode;
WriteLog(filetext);
filetext:='人員鈕號:'+V_workcode;
WriteLog(filetext);
filetext:='資訊鈕號:'+l_node;
writelog(filetext) ;
filetext:='时间:'+inttostr(v_year)+'-'+inttostrl(v_month,2)+'-'+inttostrl(v_day,2)+' '+inttostrl(v_hour,2)+':'+inttostrl(v_min,2);
writelog(filetext) ;
{filetext:='保存資料出錯! 資料獲取時間:'+formatdatetime('yyyy-mm-dd hh:mm:ss',ReceForm.recetime)+
char(13)+'棒號:'+spencode+
char(13)+'人員鈕號:'+V_workcode+
char(13)+'資訊鈕號:'+l_node+
char(13)+'時間:'+inttostr(v_year)+'-'+inttostrl(v_month,2)+'-'+inttostrl(v_day,2)+' '+inttostrl(v_hour,2)+':'+inttostrl(v_min,2);
writelog(filetext) ; }
postmessage(fowner,WM_MsgSave,i1,0);
end;
end;
receform.Label2.Caption:=inttostr(datamodule1.q_PATROLREC.fieldbyname('dataseq').asinteger);
//showmessage(receform.label1.caption+'--'+ReceForm.label2.caption)
finally
datamodule1.q_PATROLREC.close;
//datamodule1.q_WORKER.CLOSE; \
datamodule1.q_POINT.close;
end;
end;
procedure TSaveThr1.Execute;//感应式
var
i1,yearnum,num,l_lseq:integer;
s,l_workname,l_node,l_nodename,l_nodeplace,l_linename:string;
spencode:string;
v_statu,v_node1,v_node2,v_workcode:string;
l_dd,l_time:Tdatetime;
ls,ms,rs:string;
unzipdate:array [0..7] of byte;
id:integer;
filetext:string;
v_year,v_month,v_day,v_hour,v_min:word;
begin
getkeyset(ls,ms,rs);
id:=0;
try
spencode:=inttohex(FPCode,2);
datamodule1.q_PATROLREC.open;
datamodule1.q_point.open;
// datamodule1.q_POINT.IndexName:='';
// datamodule1.q_POINT.IndexFieldNames:='node';
//datamodule1.q_POINT.open;
for i1:=1 to FDCnt do
begin
try
unziptime(FpE2Buff[i1],unzipdate);
// v_statu:=inttohex(byte(FpE2BUFF[i1][5]),2);
if FpE2BUFF[i1][5]=6 then v_statu:='正常'
else
if FpE2BUFF[i1][5]=1 then v_statu:=ls
else //左键
if FpE2BUFF[i1][5]=2 then v_statu:=ms
else //中键
if FpE2BUFF[i1][5]=4 then v_statu:=rs; //右键
V_node1:=inttohex(byte(FpE2BUFF[i1][6]),2);
V_node2:=inttohex(byte(FpE2BUFF[i1][7]),2);
v_workcode:=inttohex(byte(FpE2BUFF[i1][8]),2);
l_node:=v_node1+v_node2;
if datamodule1.q_point.Locate('node;code',vararrayOf([l_node,v_workcode]),[loCaseInsensitive]) then
begin
l_nodename:=datamodule1.q_point.fieldbyname('nodename').asstring;
l_nodeplace:=datamodule1.q_point.fieldbyname('nodeplace').asstring;
l_linename:=datamodule1.q_point.fieldbyname('linename').asstring;
l_lseq:=datamodule1.q_point.fieldbyname('lseq').asinteger;
l_workname:=datamodule1.q_point.fieldbyname('name').asstring;
end
else
begin
l_nodename:='';
l_nodeplace:='';
l_linename:='';
l_lseq:=0;
l_workname:='';
end;
v_year:=byte(unzipdate[0]);
v_month:=byte(unzipdate[1]);
v_day:=byte(unzipdate[2]);
v_hour:=byte(unzipdate[3]);
v_min:=byte(unzipdate[4]);
l_dd:=encodedate(2000+v_year,v_month,v_day);
l_time:=encodetime(v_hour,v_min,0,0);
with datamodule1.q_PATROLREC do
begin //L_2
//datamodule1.q_PATROLREC.open;
append; //增加一条新记录
edit;
fieldbyname('pdate').value:=l_dd;
fieldbyname('ptime').value:=l_time;
fieldbyname('workercode').asstring:=V_workcode;
fieldbyname('node').asstring:=l_node;
fieldbyname('pencode').asstring:=spencode;
fieldbyname('workername').asstring:=l_workname;
fieldbyname('nodename').asstring:=l_nodename;
fieldbyname('nodeplace').asstring:=l_nodeplace;
fieldbyname('linename').asstring:=l_linename;
fieldbyname('lseq').asinteger:=l_lseq;
fieldbyname('pstatu').asstring:=v_statu;
post;
//refresh;
if id=0 then
begin
id:=fieldbyname('dataseq').asinteger;
ReceForm.Label1.Caption:=inttostr(id);
//showmessage(inttostr(id));
end;
postmessage(fowner,WM_MsgSave,i1,1);
end;//L_2
/////////////////////L_1
except
filetext:='保存資料出錯! 資料獲取時間:'+formatdatetime('yyyy-mm-dd hh:mm:ss',ReceForm.recetime);
WriteLog(filetext);
filetext:='棒號:'+spencode;
WriteLog(filetext);
filetext:='情況:'+v_statu;
WriteLog(filetext);
filetext:='人員鈕號:'+V_workcode;
WriteLog(filetext);
filetext:='資訊鈕號:'+l_node;
writelog(filetext) ;
filetext:='时间:'+inttostr(2000+v_year)+'-'+inttostrl(v_month,2)+'-'+inttostrl(v_day,2)+' '+inttostrl(v_hour,2)+':'+inttostrl(v_min,2);
writelog(filetext) ;
{filetext:='保存資料出錯! 資料獲取時間:'+formatdatetime('yyyy-mm-dd hh:mm:ss',ReceForm.recetime)+
char(13)+'棒號:'+spencode+
char(13)+'情況:'+v_statu+
char(13)+'人員鈕號:'+V_workcode+
char(13)+'資訊鈕號:'+l_node+
char(13)+'時間:'+inttostr(2000+v_year)+'-'+inttostrl(v_month,2)+'-'+inttostrl(v_day,2)+' '+inttostrl(v_hour,2)+':'+inttostrl(v_min,2);
writelog(filetext) ;}
postmessage(fowner,WM_MsgSave,i1,0);
end;
end;
receform.Label2.Caption:=inttostr(datamodule1.q_PATROLREC.fieldbyname('dataseq').asinteger);
//showmessage(receform.Label1.Caption+'---'+receform.Label2.Caption);
finally
datamodule1.q_PATROLREC.close;
datamodule1.q_WORKER.CLOSE;
datamodule1.q_POINT.close;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -