📄 common.pas
字号:
{ 公用模块 }
unit common;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, jpeg, ExtCtrls, Menus, ComCtrls, ImgList, FileCtrl, Db;
// ACCESS.DLL
function COM_OPEN(ComPort:string; BaudRate:Word): Longint; stdcall; external 'ACCESS.DLL';
function COM_CLOSE(hComDev:Longint): Smallint; stdcall; external 'ACCESS.DLL';
function ecGetDevType(hComDev:Longint; waitime,devid:Byte; devicetype:string): Smallint; stdcall; external 'ACCESS.DLL';
function ecGetVersion(hComDev:Longint; waitime,devid:Byte; version:String): Smallint; stdcall; external 'ACCESS.DLL';
function ascInitial(hComDev:Longint; waitime,devid,rid:Byte): Smallint; stdcall; external 'ACCESS.DLL';
function ascSetID(hComDev:Longint; waittime,devidold,devidnew:Byte): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetID(hComDev:Longint; waitime,devid:Byte; curdevid:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascSetUserID(hComDev:Longint; waittime,devid:Byte; userid:LongWord): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetUserID(hComDev:Longint; waitime,devid:Byte; userid:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetStatus(hComDev:Longint; waitime,devid:Byte; status:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascSetDateTime(hComDev:Longint; waitime,devid:Byte; datetime:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetDateTime(hComDev:Longint; waitime,devid:Byte; datetime:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascClrHolidayCount(hComDev:Longint; waitime,devid:Byte): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetHolidayCount(hComDev:Longint; waitime,devid:Byte; count:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascAddHoliday(hComDev:Longint; waitime,devid:Byte; holiday:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetHoliday(hComDev:Longint; waitime,devid,ptr:Byte; holiday:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascClrTimeCodeCount(hComDev:Longint; waitime,devid:Byte): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetTimeCodeCount(hComDev:Longint; waitime,devid:Byte; count:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascAddTimeCode(hComDev:Longint; waitime,devid:Byte; tsen:Byte; time1,time2,time3,time4,time5,time6,time7,time8:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetTimeCode(hComDev:Longint; waitime,devid,ptr:Byte; tsen,time1,time2,time3,time4,time5,time6,time7,time8:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascActiveReader(hComDev:Longint; waitime,devid,rid,active:Byte): Smallint; stdcall; external 'ACCESS.DLL';
function ascSetAlarmCode(hComDev:Longint; waitime,devid,alarm1,alarm2,alarm3,alarm4:Byte): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetAlarmCode(hComDev:Longint; waitime,devid:Byte; alarm1,alarm2,alarm3,alarm4:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascClrCardCount(hComDev:Longint; waitime,devid:Byte): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetCardCount(hComDev:Longint; waitime,devid:Byte; count:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascAddCard(hComDev:Longint; waitime,devid,enacs:Byte; cardid:string; cardidx: Word; properties:Byte; expdate:string; timecode:Byte; password:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascUpdateCard(hComDev:Longint; waitime,devid,enacs:Byte; cardid:string; cardidx:Word; properties:Byte; expdate:string; timecode:Byte; password:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetCard(hComDev:Longint; waitime,devid:Byte; ptr:Word; enacs,cardid,cardidx,properties,expdate,timecode,password:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascClrRecordCount(hComDev:Longint; waitime,devid:Byte; count:Word): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetRecordCount(hComDev:Longint; waitime,devid:Byte; count:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetRecord(hComDev:Longint; waitime,devid:Byte; ptr:Word; eventtype,rid,cardid,datetime:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetRecordForce(hComDev:Longint; waitime,devid:Byte; ptr:Word; eventtype,rid,cardid,datetime:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascClrBlackListCount(hComDev:Longint; waitime,devid:Byte): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetBlackListCount(hComDev:Longint; waitime,devid:Byte; count:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascAddBlackList(hComDev:Longint; waitime,devid:Byte; cardno:LongWord; ser:Byte): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetBlackList(hComDev:Longint; waitime,devid,ptr:Byte; cardno,ser:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascSetReaderProp(hComDev:Longint; waitime,devid,rid:Byte; control:Word; password:string; activetime:Byte; event:Word; alarms: Byte; alarm:Pointer): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetReaderProp(hComDev:Longint; waitime,devid,rid:Byte; control,password,activetime,event:string; almcnt:string; alarm:Pointer): Smallint; stdcall; external 'ACCESS.DLL';
function ascSetSaveTime(hComDev:Longint; waitime,devid,rid:Byte; time:Byte): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetEvent(hComDev:Longint; waitime,devid,rid:Byte; eventbuf:pointer): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetCardEvent(hComDev:Longint; waitime,devid,rid:Byte; cardid:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetPINEvent(hComDev:Longint; waitime,devid,rid:Byte; pinstr:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetCardAndPINEvent(hComDev:Longint; waitime,devid,rid:Byte; cardid,pinstr:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetInput(hComDev:Longint; waitime,devid,rid:Byte; input:string): Smallint; stdcall; external 'ACCESS.DLL';
function ascActiveRelay(hComDev:Longint; waitime,devid,rid:Byte; lamp,relay,ontime1,ontime2,ontime3:Byte): Smallint; stdcall; external 'ACCESS.DLL';
function ascDeActiveRelay(hComDev:Longint; waitime,devid,rid:Byte; relay:Byte): Smallint; stdcall; external 'ACCESS.DLL';
function ascActiveAlarm(hComDev:Longint; waitime,devid,rid:Byte; times,ontime,offtime:Byte): Smallint; stdcall; external 'ACCESS.DLL';
function ascDeActiveAlarm(hComDev:Longint; waitime,devid,rid:Byte): Smallint; stdcall; external 'ACCESS.DLL';
function ascActiveLamp(hComDev:Longint; waitime,devid,rid:Byte; mode,ontime:Byte): Smallint; stdcall; external 'ACCESS.DLL';
function ascDeActiveLamp(hComDev:Longint; waitime,devid,rid:Byte): Smallint; stdcall; external 'ACCESS.DLL';
function ascGetValidCard(hComDev:Longint; waitime,devid:Byte; cardid:string): Smallint; stdcall; external 'ACCESS.DLL';
procedure SetLamp(LampIdx: Byte);
function CheckParam(param: string; maxvalue:Longint): Boolean;
function IsDate(datestring: string): Boolean;
function IsXchgDate(datestring: string): Boolean;
Function IsTime(timestring: string): Boolean;
function IsFloat(digitstring: string): Boolean;
function IsDigit(digitstring: string): Boolean;
function IsBcd(bcdstring: string): Boolean;
function GetDaysOfMonth(year,month: Smallint): Smallint;
var
hComDev: Longint;
stop: Boolean;
const
BaudRate=9600;
DaysOfMonth: array[1..12] of Smallint
= ( 31,28,31,30,31,30,31,31,30,31,30,31 );
implementation
procedure SetLamp(LampIdx: Byte);
begin
//
end;
function CheckParam(param: string; maxvalue:Longint): Boolean;
begin
if IsDigit(param) then
begin
if StrToInt(param)>maxvalue then
Result := False
else
Result := True;
end else
Result := False;
end;
function IsFloat(digitstring: string): Boolean;
var
i,j,k,l: Smallint;
C: String;
begin
i := 1;
j := 0;
k := 0;
C := '';
l := Length(Trim(digitstring));
while ( i<=l ) do
begin
if ( Copy(digitstring,i,1)>='0' ) and ( Copy(digitstring,i,1)<='9' ) then
Inc(j)
else begin
C := C+Copy(digitstring,i,1);
Break;
end;
Inc(i);
end;
Inc(i);
while ( i<=l ) do
begin
if ( Copy(digitstring,i,1)>='0' ) and ( Copy(digitstring,i,1)<='9' ) then
Inc(k)
else begin
C := C+Copy(digitstring,i,1);
Break;
end;
Inc(i);
end;
if ( digitstring<>'' ) and ( ( C='' ) or ( C='.' ) ) and ( j>0 ) and
( k>0 ) and ( k<=2 ) then
Result := True
else
Result := False;
end;
function IsDigit(digitstring: string): Boolean;
var
i,l: Smallint;
ItIsDigit: Boolean;
begin
ItIsDigit:=not (digitstring='');
i:=1;
l := Length(Trim(digitstring));
while ( i<=l ) and ItIsDigit do
begin
if ( Copy(digitstring,i,1)<'0' ) or ( Copy(digitstring,i,1)>'9' ) then
ItIsDigit:=False;
Inc(i);
end;
Result:=ItIsDigit;
end;
function IsBcd(bcdstring: string): Boolean;
var
i,l: Smallint;
ItIsBcd: Boolean;
begin
l := Length(Trim(bcdstring));
ItIsBcd:=(l=2);
i:=1;
while ( i<=l ) and ItIsBcd do
begin
ItIsBcd := ( ( ( Copy(bcdstring,i,1)>='0' ) and ( Copy(bcdstring,i,1)<='9' ) ) or
( ( Copy(bcdstring,i,1)>='A' ) and ( Copy(bcdstring,i,1)<='F' ) ) );
Inc(i);
end;
Result:=ItIsBcd;
end;
function IsDate(datestring: string): Boolean;
var
year,month,day,l: Smallint;
check: Boolean;
begin
l := Length(Trim(datestring));
if ( l=6 ) and IsDigit(datestring) then
begin
year:=StrToInt(Copy(datestring,1,2));
month:=StrToInt(Copy(datestring,3,2));
day:=StrToInt(Copy(datestring,5,2));
check:=( year<=15 );
check:=check and ( month>=1 ) and ( month<=12 );
check:=check and ( day>=1 ) and ( day<=GetDaysOfMonth(year,month) );
Result:=check;
end else
Result:=False;
end;
function IsXchgDate(datestring: string): Boolean;
var
year,month,day,no,l: Smallint;
check: Boolean;
begin
l := Length(Trim(datestring));
if ( l=8 ) and IsDigit(datestring) then
begin
year:=StrToInt(Copy(datestring,1,2));
month:=StrToInt(Copy(datestring,3,2));
day:=StrToInt(Copy(datestring,5,2));
no:=StrToInt(Copy(datestring,7,2));
check:=( year<=15 );
check:=check and ( month>=1 ) and ( month<=12 );
check:=check and ( day>=1 ) and ( day<=GetDaysOfMonth(year,month) );
check:=check and ( no<=4 );
Result:=check;
end else
Result:=False;
end;
Function IsTime(timestring: string): Boolean;
var
hour,minute,l: Smallint;
begin
l := Length(Trim(timestring));
if ( l=5 ) and IsDigit(Copy(timestring,1,2)) and
IsDigit(Copy(timestring,4,2)) then
begin
hour:=StrToInt(Copy(timestring,1,2));
minute:=StrToInt(Copy(timestring,4,2));
if ( hour>24 ) or ( minute>60 ) then
Result:=False
else
Result:=True;
end else
Result:=False;
end;
function GetDaysOfMonth(year,month: Smallint): Smallint;
begin
if month=2 then
begin
if IsLeapYear(year) then
Result:=DaysOfMonth[month]+1
else
Result:=DaysOfMonth[month];
end else
Result:=DaysOfMonth[month];
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -