⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recethr.~pas

📁 delphi6.0电子寻更源程序,用来计算保安有无查抄
💻 ~PAS
📖 第 1 页 / 共 4 页
字号:
      postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_SetTimeFale);
  except
    postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_SetTimeFale);
  end;
  result:=1;
end;

function  TwritePenclock.PostComm:integer;
begin
end;

//-----------------------------------------------------------------
constructor TInitPen.create(owner:thandle;Com1:Integer;FStB:TStatusBar;f1:word);
begin
  fcount:=f1 mod 4097;
  inherited Create(OWNER,com1,fstb);
end;

function  TInitpen.DoComm:integer;
var
  i1,i2:integer;
  w1,w2,w3,w4,w5,w6:word;
  s1,s2,s3: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_InitPen);

  i1:=0;
  while true  do     //read count
  begin
    i2:=Read24C01(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 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;
  w1:=s1[1]*256+s1[2];
  w2:=s1[3]*256+s1[4];
  w3:=s1[5]*256+s1[6];
  if ((w1+w2) mod 4096)=w3 then
  begin
    w4:=fcount;
    if fcount>w3 then w5:=4096+w3-fcount
    else w5:=w3-fcount;
    w6:=w3;
  end else
  begin
    w4:=fcount;
    w5:=0;
    w6:=fcount;
  end;
  s2[1]:=w4 div 256;s2[2]:=w4 mod 256;
  s2[3]:=w5 div 256;s2[4]:=w5 mod 256;
  s2[5]:=w6 div 256;s2[6]:=w6 mod 256;

  i1:=0;
  while true  do           //write count
  begin
    i2:=Write24C01(8,6,S2);
    if i2=1 then break;
    postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_Offline);
    sleep(200);
    i2:=WakeupPen;
    if i2<>1 then begin
    postmessage(fowner,WM_MESSAGE1,Msg_Comm,Msg_Comm_DeviceErr);result:=-3;exit;end;
    inc(i1);
    if i1>3 then begin result:=-3;exit;end;
  end;

  i1:=0;
  while true  do
  begin
    i2:=Read24C01(8,6,S3);
    if i2=1 then break;
    postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_Offline);
    sleep(200);
    i2:=WakeupPen;
    if i2<>1 then begin
    postmessage(fowner,WM_MESSAGE1,Msg_Comm,Msg_Comm_DeviceErr);result:=-4;exit;end;
    inc(i1);
    if i1>3 then begin result:=-4;exit;end;
  end;
  for i1:=1 to 6 do
    if s2[i1]<>s3[i1] then
    begin
      postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_InitPenFale);
      result:=-5;
      exit;
    end;
  postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_InitPenSucc);
  result:=1;
end;

function  TInitpen.PostComm:integer;
begin
end;

//=====================================
constructor Twritepencode.create(owner:thandle;Com1:Integer;FStB:TStatusBar;f1:byte);
begin
  fcode:=f1;
  inherited Create(OWNER,com1,fstb);
end;

constructor Tsetpenmod.create(owner:thandle;Com1:Integer;FStB:TStatusBar;f1:boolean);
begin
  fchmodel:=f1;
  inherited Create(OWNER,com1,fstb);
end;

function  Twritepencode.DoComm:integer;
var
  i1,i2:integer;
  s1,s2:array [1..8] of byte;
  ii:integer;
  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_WritePencode);
{  while true do                 //connect pen
  begin
 // ii:=read_reccount;
    i2:=WakeupPen;
    if i2=1 then break;
    if i2=-1 then
      exit;
    sleep(200);
    inc(i1);
    if i1>5 then begin
    result:=-1;exit;end;
  end;

}
  i1:=0;
  //l_pen_code:=read_reccount;
  S1[1]:=FCODE;
  while true  do
  begin
    i2:=Write24C01(0,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;


//  postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_readtime);
  while true  do            //get pen data_counter
  begin
    i2:=Read24C01(0,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
    postmessage(fowner,WM_MESSAGE1,Msg_Comm,Msg_Comm_DeviceErr); result:=-3;exit;end;
  end;
  if S2[1]=FCODE then
    postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_WritePencodeSucc)
  else
    postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_WritePencodeFale);

  result:=1;
end;

function  Tsetpenmod.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_setpenmod);

  i1:=0;
  if fchmodel=true then S1[1]:=$0
  else s1[1]:=$33;
  while true  do
  begin
    i2:=Write24C01(4,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;


//  postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_readtime);
  while true  do            //get pen data_counter
  begin
    i2:=Read24C01(4,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
    postmessage(fowner,WM_MESSAGE1,Msg_Comm,Msg_Comm_DeviceErr);result:=-3;exit;end;
  end;
  if S2[1]= s1[1] then
    postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_setpenmodSucc)
  else
    postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_setpenmodFale);

  result:=1;
end;

function  TwritePencode.PostComm:integer;
begin
end;

function  Tsetpenmod.PostComm:integer;
begin
end;

//=====================================//
constructor TReadPenData.create(owner:thandle;Com1:Integer;FStB:TStatusBar;f1:pe2buff);
begin
  FPe2buff:=f1;
  inherited Create(OWNER,com1,fstb);
end;

constructor TClearPenData.create(owner:thandle;Com1:Integer;FStB:TStatusBar);
begin
  inherited Create(OWNER,com1,FStB);
end;

function  TReadPenData.DoComm:integer;
var
  i1,i2,i3,i4,li,ad1:integer;
  s1,s2:array [1..20] of byte;
  y,m,d,hour,min,sec,msec:word;

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;

//  fstring[0]:='检测到笔';
//  FUpdateItem:=0;
//  SynChronize(UpdateStatusBar);

  i1:=0;
  while true do                 //get pen code
  begin
   i2:=Read24C01(0,4,s1);
   if i2=1 then break;
   postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_Offline);
   sleep(200);

   i2:=WakeupPen;
   if i2<>1 then
   begin
     postmessage(fowner,WM_MESSAGE1,Msg_Comm,Msg_Comm_DeviceErr);
     result:=-2 ;exit;
   end;
   inc(i1);
   if i1>10 then begin result:=-2;exit;end;
  end;
  FPenCode:=s1[1];
  postmessage(fowner,WM_MESSAGE1,Msg_PCode,FPenCode);

  i1:=0;
  while true  do            //get pen data_counter
  begin
    i2:=Read24c01(8,8,s1);
   if i2=1 then break;
   postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_Offline);
   sleep(200);

   i2:=WakeupPen;
   if i2<>1 then
   begin
   postmessage(fowner,WM_MESSAGE1,Msg_Comm,Msg_Comm_DeviceErr);
     result:=-3 ;exit;
   end;
  end;
  FPnDL:=byte(s1[1])*256+byte(s1[2]);
  FPnDB:=byte(s1[3])*256+byte(s1[4]);
  FPnDE:=byte(s1[5])*256+byte(s1[6]);
  postmessage(fowner,WM_MESSAGE1,Msg_PDataCount,FPnDL);

  IF FPnDL<>0 then
  begin
    ad1:=FPnDB;
    postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_DRStart);
    for li:=0 to FPnDL-1  do              //read patrol data in pen
    begin
      i1:=0;
      postmessage(fowner,WM_MESSAGE1,Msg_PDtTryPoint,Li+1);
      while true  do
      begin
      if mainform.stopflag=true then
      begin
        postmessage(fowner,WM_MESSAGE1,Msg_Comm,Msg_Comm_DeviceErr);
        exit;
      end;
        i2:=Read24c256(((ad1+li)*8) mod 32768,8,fpe2buff[li+1]);
        postmessage(fowner,WM_MESSAGE1,Msg_PDataPoint,Li+1);

        if i2=1 then
        begin
           //postmessage(fowner,WM_MESSAGE1,MSG_PEN,MSG_PEN_REVDATA);
           break;
        end;
        postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_Offline);
       // sleep(300);
        while true do
        begin
           i2:=WakeUpPen;
           if i2=1 then break;
           if i2=-1 then begin
           postmessage(fowner,WM_MESSAGE1,Msg_Comm,Msg_Comm_DeviceErr); result:=-4;exit;end;
           inc(i1);
           if i1>10 then begin  result:=-4;exit;end;
        end;
      end;
    end;
    postmessage(fowner,WM_MESSAGE1,Msg_Pen,Msg_Pen_DREnd);
    i1:=0;
    s1[1]:=byte($0);
    s1[2]:=byte($0);
    s1[3]:=byte(FPnDE) div 256;
    S1[4]:=byte(FPnDE) mod 256;
    s1[5]:=S1[3];
    S1[6]:=S1[4];

{  s1[1]:=byte($10);
  s1[2]:=byte($0);
  s1[3]:=byte($0);
  S1[4]:=byte($0);
  s1[5]:=byte($0);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -