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

📄 doorforbiddecript.pas

📁 倉庫下線條碼源碼
💻 PAS
字号:
unit DoorForbidDecript;

interface

uses
   SysUtils, Windows, Classes, Forms, ScktComp, DateUtils, StrUtils,
   WGDoorForbid, CommuFunc, DFOutParaImplBody;

   
function DecryptDeviceTimeGP(var devTimeGPObj: TWG_DeviceTimeGP; nLen: integer;
   const retData: PChar): integer;
function DecryptDFRightData(var rightData: TWG_RightData; nLen: integer;
   const retData: PChar): integer;
function DecryptDeviceStatus(var wgStatus: TWG_DeviceStatus; nLen: integer;
   const retData: PChar): integer;
   
implementation

function DecryptDeviceTimeGP(var devTimeGPObj: TWG_DeviceTimeGP; nLen: integer;
   const retData: PChar): integer;
var
  stp1: string;
  i: integer;
  nDate: Word;   
begin
  Result := -7;
  if (nLen > 0) and (retData <> nil) and (devTimeGPObj <> nil) then
  begin
    stp1 := IntToHex(Byte(retData[6]),2)+IntToHex(Byte(retData[5]),2);
    devTimeGPObj.FSDIndex := HexToInt(stp1,-1);
    devTimeGPObj.FTimeGroup.weekCtl := Byte(retData[7]);
    devTimeGPObj.FMonday := (Byte(retData[7]) and $01) = $01;
    devTimeGPObj.FTuesday := (Byte(retData[7]) and $02) = $02;
    devTimeGPObj.FWednesday := (Byte(retData[7]) and $04) = $04;
    devTimeGPObj.FThursday := (Byte(retData[7]) and $08) = $08;
    devTimeGPObj.FFriday := (Byte(retData[7]) and $10) = $10;
    devTimeGPObj.FSaturday := (Byte(retData[7]) and $20) = $20;
    devTimeGPObj.FSunday := (Byte(retData[7]) and $40) = $40;
    devTimeGPObj.FTimeControl := (Byte(retData[7]) and $80) = $80;
    for i := 0 to 8 do
    begin
      devTimeGPObj.FTimeGroup.TimeGroup[i,0] := 0;
      devTimeGPObj.FTimeGroup.TimeGroup[i,1] := 0;
    end;
    for i := 0 to 2 do
    begin
      stp1 := IntToHex(Byte(retData[i*4+12]),2)+IntToHex(Byte(retData[i*4+11]),2);
      nDate := HexToInt(stp1,-1);
      devTimeGPObj.FTimeGroup.TimeGroup[i,0] := StrToTime(WG_DecryptTime(nDate));
      stp1 := IntToHex(Byte(retData[i*4+14]),2)+IntToHex(Byte(retData[i*4+13]),2);
      nDate := HexToInt(stp1,-1);
      devTimeGPObj.FTimeGroup.TimeGroup[i,1] := StrToTime(WG_DecryptTime(nDate));
    end;
  end;            
end;

function DecryptDFRightData(var rightData: TWG_RightData; nLen: integer;
   const retData: PChar): integer;
var
  stp1: string;
  nData: integer;
begin
  Result := -7;
  if (nLen > 0) and (retData <> nil) and (rightData <> nil) then
  begin
    stp1 := IntToHex(Byte(retData[7]),2)+IntToHex(Byte(retData[6]),2)
           +IntToHex(Byte(retData[5]),2);
    if UpperCase(stp1) <> 'FFFFFF' then
      rightData.CardSerial := IntToStr(HexToInt(stp1,-1))
    else rightData.CardSerial := 'FFFFFF';
    rightData.DoorNo := Byte(retData[8]);
    stp1 := IntToHex(Byte(retData[10]),2)+IntToHex(Byte(retData[9]),2);
    nData := HexToInt(stp1,-1);
    rightData.StartDate := WG_DecryptDate(nData);
    stp1 := IntToHex(Byte(retData[12]),2)+IntToHex(Byte(retData[11]),2);
    nData := HexToInt(stp1,-1);
    rightData.StopDate := WG_DecryptDate(nData);
    rightData.SDIndex := Byte(retData[13]);
    stp1 := IntToHex(Byte(retData[16]),2)+IntToHex(Byte(retData[15]),2)
      +IntToHex(Byte(retData[14]),2);
    if UpperCase(stp1) <> 'FFFFFF' then
      rightData.UserPassword := HexToInt(stp1,-1)
    else rightData.UserPassword := $FFFFFF;
  end;
end;
   
function DecryptDeviceStatus(var wgStatus: TWG_DeviceStatus; nLen: integer;
   const retData: PChar): integer;
var
  stp1: string;
  nDate: integer;
  wY,wM,wD,wH,wMin,wSec: word;
begin
  Result := -7;
  if (nLen > 0) and (retData <> nil) and (wgStatus <> nil) then
  begin
    stp1 := IntToHex(Byte(retData[22]),2)+IntToHex(Byte(retData[21]),2);
    nDate := HexToInt(stp1,-1);
    if nDate <> -1 then
      wgStatus.FCardDate := WG_DecryptDate(nDate)
    else wgStatus.FCardDate := 0.0;
    stp1 := IntToHex(Byte(retData[24]),2)+IntToHex(Byte(retData[23]),2);
    nDate := HexToInt(stp1,-1);
    if nDate <> -1 then
      wgStatus.FCardTime := WG_DecryptTime(nDate)
    else wgStatus.FCardTime := '';
    wY := IntHexToInt(Byte(retData[5]))+2000;
    wM := IntHexToInt(Byte(retData[6]));
    wD := IntHexToInt(Byte(retData[7]));
    wH := IntHexToInt(Byte(retData[9]));
    wMin := IntHexToInt(Byte(retData[10]));
    wSec := IntHexToInt(Byte(retData[11]));
    try
      wgStatus.FCurrentTime := EncodeDateTime(wY,wM,wD,wH,wMin,wSec,0);
    except
      on Ex2: Exception do
        wgStatus.FCurrentTime := Now;
    end;
    wgStatus.FCurrentWeek := IntHexToInt(Byte(retData[8]));
    stp1 := IntToHex(Byte(retData[14]),2)+IntToHex(Byte(retData[13]),2)
           +IntToHex(Byte(retData[12]),2);

    wgStatus.FDataCount := HexToInt(stp1,-1);
    stp1 := IntToHex(Byte(retData[16]),2)+IntToHex(Byte(retData[15]),2);
    wgStatus.FRightCount := HexToInt(stp1,-1);
    stp1 := IntToHex(Byte(retData[19]),2)+IntToHex(Byte(retData[18]),2)
           +IntToHex(Byte(retData[17]),2);
    if UpperCase(stp1) <> 'FFFFFF' then
      wgStatus.FCardSerial := IntToStr(HexToInt(stp1,-1))
    else wgStatus.FCardSerial := 'FFFFFF';
    if (Byte(retData[20]) and $80) = $80 then
      wgStatus.FRightCard := 0
    else
      wgStatus.FRightCard := 1;
    if Byte(retData[20]) < $FF then
      wgStatus.FReadCMNo := Byte(retData[20]) and $0F
    else wgStatus.FReadCMNo := $FF;
    wgStatus.FDoorState := Byte(retData[25]);
    wgStatus.FDoorButtonState := Byte(retData[26]);
    wgStatus.FWarningNo := Byte(retData[27]);
    wgStatus.FTroubleNo := 0;
    if (Byte(retData[28]) and 4) = 4 then
    begin
      if ((Byte(retData[28]) and 1) = 0) and ((Byte(retData[28]) and 2) = 0)
         and ((Byte(retData[28]) and 8) = 0) then
        wgStatus.FTroubleNo := 2
      else
        wgStatus.FTroubleNo := 3;
    end else
    begin
      if ((Byte(retData[28]) and 1) = 1) or ((Byte(retData[28]) and 2) = 1)
         or ((Byte(retData[28]) and 8) = 1) then
        wgStatus.FTroubleNo := 1;
    end;
    Result := nLen;
  end;
end;

end.

⌨️ 快捷键说明

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