上面是把ICDM.DLL封装成类的,下面一个是直接调用的
unit CExample;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ExtCtrls, ComCtrls;
/////////////////////////////////////////////////////////////////////////
//结构定义
/////////////////////////////////////////////////////////////////////////
//枚举变量定义
type
TCardID = 0..99999;
TYear = 1999..2100;
TMonth = 1..12;
TDay = 1..31;
THour = 0..23;
TMinute = 0..59;
/////////////////////////////////////////////////////////////////////////
//卡存储信息结构
type CARDINFO = record
nCardID : Integer;
nInfoID : Integer;
nRegion, nPart, nGrade : Integer;
end;
/////////////////////////////////////////////////////////////////////////
//鸣叫
type BEEPTIME = record
nBeepTime : Integer;
nBeepTimes : Integer;
nBeepInterval : Integer;
end;
/////////////////////////////////////////////////////////////////////////
//打卡记录结构
type CARDRECORD = record
nInfoID : Integer;
nYear,nMonth, nDay : Integer;
nHour, nMinute : Integer;
end;
/////////////////////////////////////////////////////////////////////////
//机具状态结构
type DMSTATUS = record
nAddress : Integer;
nGrade,nSort : Integer;
nBeginPointer, nPresentPointer : Integer;
nRecordLength : Integer;
end;
type TKey = array[1..12] of Char;
/////////////////////////////////////////////////////////////////////////
//机具状态结构
type MFKEY = record
nAorBKey : Integer;
nSectorNum : Integer;
strOldKey : TKey;
strNewKey : TKey;
end;
/////////////////////////////////////////////////////////////////////////
//黑名单结构
type INVAIDCARDID = record
nCardID : Integer;
end;
type
TFormTestSys = class(TForm)
BitBtnInitSeriPort: TBitBtn;
BitBtnExitPort: TBitBtn;
EditTagAddress: TEdit;
Label1: TLabel;
Label2: TLabel;
GroupBox1: TGroupBox;
CheckBoxSetTime: TCheckBox;
CheckBoxDelInvaidcard: TCheckBox;
CheckBoxTest: TCheckBox;
CheckBoxSetDMGrade: TCheckBox;
CheckBoxReadLastResult: TCheckBox;
CheckBoxReadCardINFO: TCheckBox;
CheckBoxMFReadCardData: TCheckBox;
CheckBoxTMReadCardData: TCheckBox;
CheckBoxInitCardData: TCheckBox;
CheckBoxMFSeardhCard: TCheckBox;
CheckBoxMFModifyKey: TCheckBox;
CheckBoxTMModifyKEY: TCheckBox;
CheckBoxWriteUserPassword: TCheckBox;
CheckBoxDMBeep: TCheckBox;
CheckBoxAddInvaidCard: TCheckBox;
CheckBoxInItPointer: TCheckBox;
CheckBoxSetDMSort: TCheckBox;
CheckBoxDMStatus: TCheckBox;
CheckBoxRecord: TCheckBox;
CheckBoxWriteCardInfo: TCheckBox;
CheckBoxMFWriteCardData: TCheckBox;
CheckBoxTMWriteCardData: TCheckBox;
CheckBoxAddCardData: TCheckBox;
CheckBoxReduceCardData: TCheckBox;
CheckBoxMFVerifyKEY: TCheckBox;
CheckBoxTMVerifyKEY: TCheckBox;
CheckBoxVerifyUserPassord: TCheckBox;
CheckBoxModifyUserPassword: TCheckBox;
CheckBoxActiveTime: TCheckBox;
LabelSetTime: TLabel;
LabelDelInvaidCard: TLabel;
LabelTest: TLabel;
LabelDMGrade: TLabel;
LabelLastResult: TLabel;
LabelReadCardINFO: TLabel;
LabelMFReadCardData: TLabel;
LabelTMReadCardData: TLabel;
LabelInitCardData: TLabel;
LabelMFSearchCard: TLabel;
LabelMFModifyKey: TLabel;
LabelTMModifyKEY: TLabel;
LabelWriteUserPassword: TLabel;
LabelDMBeep: TLabel;
LabelAddInvaiDcard: TLabel;
LabelInitPointer: TLabel;
LabelSetDMSort: TLabel;
LabelDMStatus: TLabel;
LabelRecord: TLabel;
LabelWriteCardInfo: TLabel;
LabelMFWriteCardData: TLabel;
LabelTMWriteCardData: TLabel;
LabelAddCardData: TLabel;
LabelReduceCardData: TLabel;
LabelMFVerifyKEY: TLabel;
LabelTMVerifyKEY: TLabel;
LabelVerifyUserPassword: TLabel;
LabelModifyUserPassword: TLabel;
LabelActiveTime: TLabel;
Bevel1: TBevel;
Label32: TLabel;
StatusBarDM: TStatusBar;
BitBtnTest: TBitBtn;
BitBtnClose: TBitBtn;
Label3: TLabel;
ComboBoxDMSort: TComboBox;
CheckBoxSetVoiceHint: TCheckBox;
LabelSetVoiceHint: TLabel;
ComboBox_cominfo: TComboBox;
procedure BitBtnInitSeriPortClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure BitBtnExitPortClick(Sender: TObject);
procedure BitBtnTestClick(Sender: TObject);
procedure ComboBox_cominfoExit(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
nTagAddress:Integer;
m_pDevice: Pointer;
m_pCommand: Pointer;
m_nMyAddress: Integer;
m_strCommDef: string;
bLink :Boolean;
bDisLink :Boolean;
procedure FormInit();
public
{ Public declarations }
end;
var
FormTestSys: TFormTestSys;
const
//---------------------------命令字定义-------------------------//
nSETTIME :Integer = 2; // 广播校时
nRECORD :Integer = 16; // 取下位机定长打卡记录
nRECORDRLT :Integer = 18; // 取下位机定长打卡记录确认帧
nLASTSTATUS :Integer = 20; // 取前次操作结果
nDMSTATUS :Integer = 22; // 取机具状态
nSETDMNUM :Integer = 24; // 设置机具号
nSETDMGRADE :Integer = 26; // 设置机具级别
nSETDMSORT :Integer = 28; // 设置机具类别
nSETSTORAGESORT :Integer = 30; // 设置记录存储满后的处理方式
nREADCARDINFO :Integer = 64; // 读卡信息
nWRITECARDINFO :Integer = 66; // 发卡
nMFSEARCHCARD :Integer = 68; // 寻卡(mifare卡)
nMFREADCARDDATA :Integer = 70; // 读数据块(mifare卡)
nMFWRITECARDDATA :Integer = 72; // 写数据块(mifare卡)
nTMREADCARDDATA :Integer = 74; // 读数据块(temic卡)
nTMWRITECARDDATA :Integer = 76; // 写数据块(temic卡)
nINITCARDDATA :Integer = 78; // 初始化块值
nADDCARDDATA :Integer = 80; // 块增值操作
nREDUCECARDDATA :Integer = 82; // 块减值操作
nTEST :Integer = 112; // 通讯测试
nINITPOINTER :Integer = 114; // 初始化数据区
nMFMODIFYKEY :Integer = 144; // mifare卡修改某一扇区密码
nMFVERIFYKEY :Integer = 146; // mifare卡验证某一扇区密码
nTMMODIFYKEY :Integer = 148; // temic卡修改密码
nTMVERIFYKE :Integer = 150; // temic卡验证密码
nWRITEUSERPASSWORD :Integer = 152; // 设置用户口令
nVERIFYUSERPASSWORD :Integer = 154; // 验证用户口令
nMODIFYUSERPASSWORD :Integer = 156; // 修改用户口令
nADDINVAIDCARD :Integer = 158; // 下载黑名单
nDELINVAIDCARD :Integer = 160; // 删除黑名单
nSETRELAYTIME :Integer = 192; // 设置继电器吸合时间
nBEEP :Integer = 194; // 设置蜂鸣时间
nSETSYSSORT :Integer = 196; // 设置系统类别
nSETVOICEHINT :Integer = 198; // 语音提示设置
/////////////////////////////////////////////////////////////////////////
//返回信息代码
nSENDSUCCESS :Integer = 0; // 发送成功
nCOMMERROR :Integer = 1; // 通讯错误
nFLAGERROR :Integer = 2; // 帧标志错误
nCHECKERROR :Integer = 3; // 检验错误
nNOTSEND :Integer = 4; // 未发送错误
nOVERTIME :Integer = 5; // 超时错误
nNOTRECVFRM :Integer = 6; // 未收到返回帧
nRECVFRM :Integer = 7; // 收到返回帧
nSUCCESS :Integer = 8; // 命令执行成功
nFAIL :Integer = 9; // 命令执行失败
nADRERROR :Integer = 10; // 返回地址错误
nCMDERROR :Integer = 11; // 返回命令字错误
nDATAERROR :Integer = 12; // 返回数据错误
nRECVEMPTY :Integer = 13; // 下位机记录取完
nRECVSUCCESS :Integer = 14; // 成功取记录
//-------------------------------------------------------------------------
//函数与过程定义
function OpenDevice(nMyAddress: Integer; hWnd: HWND): Pointer; stdcall; external 'icdm.dll' name 'OpenDevice';
procedure CloseDevice(pDevice: Pointer); stdcall; external 'icdm.dll' name 'CloseDevice';
function Connect(pDevice: Pointer; lpCommDef: pChar): Boolean stdcall; external 'icdm.dll' name 'Connect';
function IsConnect(pDevice: Pointer): Boolean stdcall; external 'icdm.dll' name 'IsConnect';
procedure SetAddLog(pDevice: Pointer; bAddLog: Boolean); stdcall; external 'icdm.dll' name 'SetAddLog';
function DisConnect(pDevice: Pointer): Boolean stdcall; external 'icdm.dll' name 'DisConnect';
function StartICDMCommand(pDevice: Pointer; nAddress: Integer; ICDMCmd: Integer; pPara: Pointer; nSize: Integer): Pointer; stdcall; external 'icdm.dll' name 'StartICDMCommand';
function GetSizeOfData(pCommand: Pointer): Integer; stdcall; external 'icdm.dll' name 'GetSizeOfData';
function GetData(pCommand: Pointer; pDataBuffer: Pointer; nSize: Integer): Boolean; stdcall; external 'icdm.dll' name 'GetData';
function GetCmdResult(pCommand: Pointer): Integer; stdcall; external 'icdm.dll' name 'GetCmdResult';
procedure EndICDMCommand(pCommand: Pointer); stdcall; external 'icdm.dll' name 'EndICDMCommand';
implementation
{$R *.DFM}
procedure TFormTestSys.FormCreate(Sender: TObject);
begin
m_nMyAddress := $64;
m_pCommand := nil;
m_pDevice := nil;
ComboBoxDMSort.ItemIndex := 0;
m_pDevice := OpenDevice(m_nMyAddress, Handle);
end;
procedure TFormTestSys.FormDestroy(Sender: TObject);
begin
DisConnect(m_pDevice);
CloseDevice(m_pDevice);
end;
procedure TFormTestSys.BitBtnInitSeriPortClick(Sender: TObject);
begin
m_strCommDef :='com' + ComboBox_cominfo.Text + ':baud=9600,parity=e,data=8,stop=1';
if m_pDevice <> nil then
begin
bLink := Connect(m_pDevice, PChar(m_strCommDef));
if bLink = TRUE then
begin
SetAddLog(m_pDevice, True);
StatusBarDM.SimpleText := '串口连接成功,添加日志! 请开始测试!';
end
else
StatusBarDM.SimpleText := '串口连接失败! 请重新连接!';
end
else
begin
bLink := FALSE;
StatusBarDM.SimpleText := '串口连接失败! 请重新启动程序!';
end;
end;
procedure TFormTestSys.BitBtnExitPortClick(Sender: TObject);
begin
if m_pDevice <> nil then
begin
bDisLink := DisConnect(m_pDevice);
if bDisLink = TRUE then
StatusBarDM.SimpleText :='断开连接成功!'
Else
StatusBarDM.SimpleText :='断开连接失败!';
end
else
begin
bDisLink := FALSE;
StatusBarDM.SimpleText := '串口关闭失败!';
end;
end;
procedure TFormTestSys.BitBtnTestClick(Sender: TObject);
Var
bSetOK :Boolean; //
nInfoCode :Integer; // 返回信息代码
nLoop :Integer; // 循环变量
nInvaidCard :Integer; // 黑名单
nTestLength :Integer; // 测试时的数据长度;
nDMGrade :Integer; // 机具级别
nDMSort :Integer; // 机具类别
nRecordLeng :Integer; // 定长记录长度
nSize :Integer; // 取得数据的字节数
nCount :Integer; // 取得记录条数
pDataBuffer
ointer; // 存储信息缓冲区
pCardRecordBuffer :^CARDRECORD; // 打卡记录
rCardRecord :CardRecord;
pCardInfoBuffer :^CARDINFO; // 卡存储信息
rCardInfo :CardInfo;
pDMStatusBuffer :^DMSTATUS; // 机具状态
rDMStatus
MStatus;
rBeepTest :BEEPTIME ; // 机具鸣叫
nVoiceHintNum :Integer; // 语音提示
rMFKey :MFKEY; // 修改密码
begin
nTestLength := 16;
nDMGrade := 1;
nDMSort := 0;
nRecordLeng := 4;
nVoiceHintNum := 1;
nInvaidCard := 12345;
bSetOK := FALSE;
StatusBarDM.SimpleText := '';
FormInit();//初始化界面
nTagAddress := StrToInt(EditTagAddress.Text);//获得机具地址
BitBtnTest.Enabled := FALSE;
BitBtnClose.Enabled := FALSE;
//-----------------------------广播较时---------------------------------//
If CheckBoxSetTime.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxSetTime.Caption;
CheckBoxSetTime.Font.Color := clYellow;
if blink then
Begin
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nSETTIME, nil, 0);
if m_pCommand <> nil then
Begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSENDSUCCESS then
Begin
LabelSetTIME.Caption := '发送成功!';
CheckBoxSetTime.Font.Color := clGreen;
End
Else
Begin
LabelSetTIME.Caption := '未发送!';
CheckBoxSetTime.Font.Color := clRed;
End;
End
Else
Begin
LabelSetTime.Caption := '命令失败!';
CheckBoxSetTime.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
End
Else
Begin
LabelSetTime.Caption := '串口未连接!';
CheckBoxSetTime.Font.Color := clRed;
End;
End;
//---------------------------------通讯测试-----------------------------//
If CheckBoxTest.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxTest.Caption;
CheckBoxTest.Font.Color := clYellow;
If bLink then
Begin
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nTEST, @nTestLength, SizeOf(Integer));
if m_pCommand <> nil then
begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
Begin
labelTest.Caption := '测试成功!';
CheckBoxTest.Font.Color := clGreen;
End
else
Begin
labelTest.Caption := '测试失败!';
CheckBoxTest.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
End
Else
Begin
labelTest.Caption := '命令失败!';
CheckBoxTest.Font.Color := clRed;
End;
End
Else
Begin
labelTest.Caption := '串口未连接!';
CheckBoxTest.Font.Color := clRed;
End;
End;
//-------------------------------设置机具类别----------------------------//
if CheckBoxSetDMSort.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxSetDMSort.Caption;
CheckBoxSetDMSort.Font.Color := clYellow;
If bLink then
Begin
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nSETDMSORT, @nDMSort, SizeOf(Integer));
if m_pCommand <> nil then
begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
Begin
labelSetDMSort.Caption := '类别设置成功!';
CheckBoxSetDMSort.Font.Color := clGreen;
End
else
Begin
labelSetDMSort.Caption := '类别设置失败!';
CheckBoxSetDMSort.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
end
Else
Begin
labelSetDMSort.Caption := '命令失败!';
CheckBoxSetDMSort.Font.Color := clRed;
End;
end
Else
Begin
labelSetDMSort.Caption := '串口未连接!';
CheckBoxSetDMSort.Font.Color := clRed;
End;
End;
//-------------------------------设置机具级别---------------------------//
If CheckBoxSetDMGrade.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxSetDMGrade.Caption;
CheckBoxSetDMGrade.Font.Color := clYellow;
If bLink then
Begin
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nSETDMGRADE, @nDMGrade, SizeOf(Integer));
if m_pCommand <> nil then
begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
Begin
labelDMGrade.Caption := '级别设置成功!';
CheckBoxSetDMGrade.Font.Color := clGreen;
End
else
Begin
labelDMGrade.Caption := '级别设置失败!';
CheckBoxSetDMGrade.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
end
else
begin
labelDMGrade.Caption := '命令失败!';
CheckBoxSetDMGrade.Font.Color := clRed;
end;
end
Else
Begin
labelDMGrade.Caption := '串口未连接!';
CheckBoxSetDMGrade.Font.Color := clRed;
End;
End;
//--------------------------------取所有记录----------------------------//
If CheckBoxRecord.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxRecord.Caption;
CheckBoxRecord.Font.Color := clYellow;
nInfoCode := nCOMMERROR;
If bLink then
Begin
Repeat
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nRECORD, @nRecordLeng, SizeOf(Integer));
if m_pCommand <> nil then
Begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nRECVSUCCESS then
begin
nSize := GetSizeOfData(m_pCommand);
nCount := nSize div SizeOf(CARDRECORD);
if nCount > 0 then
begin
GetMem(pDataBuffer, nSize);
GetData(m_pCommand, pDataBuffer, nSize);
pCardRecordBuffer := pDataBuffer;
for nLoop := 1 to nCount do
begin
rCardRecord := pCardRecordBuffer^;
Inc(pCardRecordBuffer);
// UpdateDB(rCardRecord);//写入数据库
end;
FreeMem(pDataBuffer);
End;
end;
EndICDMCommand(m_pCommand);
if nInfoCode = nRECVSUCCESS then
begin
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nRECORDRLT, nil, 0);
EndICDMCommand(m_pCommand);
End
End;
Until nInfoCode <> nRECVSUCCESS;
if nInfoCode = nRECVEMPTY then
begin
LabelRecord.Caption := '记录取完!';
CheckBoxRecord.Font.Color := clGreen;
end
else if nInfoCode = nRECVSUCCESS then
begin
LabelRecord.Caption := '取到记录!';
CheckBoxRecord.Font.Color := clRed;
End
else
begin
LabelRecord.Caption := '取记录失败!';
CheckBoxRecord.Font.Color := clRed;
End;
end
else
begin
LabelRecord.Caption := '串口未连接!';
CheckBoxRecord.Font.Color := clRed;
end;
End;
//----------------------------------写卡信息----------------------------//
If CheckBoxWriteCardInfo.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxWriteCardInfo.Caption;
CheckBoxWriteCardInfo.Font.Color := clYellow;
//-----------先设为发卡器---------------//
Begin
nDMSort := 2;
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nSETDMSORT, @nDMSort, SizeOf(Integer));
if m_pCommand <> nil then
Begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
bSetOK := TRUE
Else
bSetOK := FALSE;
EndICDMCommand(m_pCommand);
End;
End;
If bSetOK then
Begin
rCardInfo.nCardID := 10;
rCardInfo.nRegion := 10;
rCardInfo.nPart := 0;
rCardInfo.nInfoID := 10;
rCardInfo.nGrade := 1;
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nWRITECARDINFO, @rCardInfo, SizeOf(rCardInfo));
if m_pCommand <> nil then
Begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
Begin
LabelWriteCardINFO.Caption := '写卡成功!';
CheckBoxWriteCardInfo.Font.Color := clGreen;
End
else
Begin
LabelWriteCardINFO.Caption := '写卡失败!';
CheckBoxWriteCardInfo.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
End
Else
Begin
LabelWriteCardINFO.Caption := '命令失败!';
CheckBoxWriteCardInfo.Font.Color := clRed;
End;
End
Else
Begin
LabelWriteCardINFO.Caption := '串口未连接!';
CheckBoxWriteCardInfo.Font.Color := clRed;
End;
End;
//-----------------------------------读卡信息----------------------------//
If CheckBoxReadCardINFO.Checked=True Then
Begin
StatusBarDM.SimpleText := CheckBoxReadCardINFO.Caption;
CheckBoxReadCardINFO.Font.Color := clYellow;
If bLINK then
Begin
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nReadCardInfo, nil, 0);// 发送读卡信息命令
if m_pCommand <> nil then
begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nRECVSUCCESS then
begin
//-----------取出卡中信息-----------//
nSize := GetSizeOfData(m_pCommand);
GetMem(pDataBuffer, nSize);
GetData(m_pCommand, pDataBuffer, nSize);
pCardInfoBuffer := pDataBuffer;
rCardInfo := pCardInfoBuffer^;
FreeMem(pDataBuffer);
LabelReadCardINFO.Caption := '读卡成功!';
CheckBoxReadCardINFO.Font.Color := clGreen;
End
else
Begin
LabelReadCardINFO.Caption := '读卡失败!';
CheckBoxReadCardINFO.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
End
Else
Begin
LabelReadCardINFO.Caption := '命令失败!';
CheckBoxReadCardINFO.Font.Color := clRed;
End;
end
Else
Begin
LabelReadCardINFO.Caption := '串口未连接!';
CheckBoxReadCardINFO.Font.Color := clRed;
End;
End;
//--------------------------------取机具状态----------------------------//
If CheckBoxDMStatus.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxDMStatus.Caption;
CheckBoxDMStatus.Font.Color := clYellow;
If bLink then
Begin
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nDMStatus, nil, 0);
if m_pCommand <> nil then
begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nRECVSUCCESS then
Begin
//-----------取出机具状态---------------//
nSize := GetSizeOfData(m_pCommand);
GetMem(pDataBuffer, nSize);
GetData(m_pCommand, pDataBuffer, nSize);
pDMStatusBuffer := pDataBuffer;
rDMStatus := pDMStatusBuffer^;
FreeMem(pDataBuffer);
LabelDMStatus.Caption := '取机具状态成功!';
CheckBoxDMStatus.Font.Color := clGreen;
End
else
Begin
LabelDMStatus.Caption := '取机具状态失败!';
CheckBoxDMStatus.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
end
else
begin
LabelDMStatus.Caption := '命令失败!';
CheckBoxDMStatus.Font.Color := clRed;
end;
end
Else
begin
LabelDMStatus.Caption := '串口未连接!';
CheckBoxDMStatus.Font.Color := clRed;
end;
end;
//-----------------------------下载黑名单--------------------------------//
If CheckBoxAddInvaidCard.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxAddInvaidCard.Caption;
CheckBoxAddInvaidCard.Font.Color := clYellow;
if blink then
Begin
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nADDINVAIDCARD, @nInvaidCard, Sizeof(Integer));
if m_pCommand <> nil then
Begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
Begin
LabelAddInvaiDcard.Caption := '下载成功!';
CheckBoxAddInvaidCard.Font.Color := clGreen;
End
Else
Begin
LabelAddInvaiDcard.Caption := '下载失败!';
CheckBoxAddInvaidCard.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
End
Else
Begin
LabelAddInvaiDcard.Caption := '命令失败!';
CheckBoxAddInvaidCard.Font.Color := clRed;
End;
End
Else
Begin
LabelAddInvaiDcard.Caption := '串口未连接!';
CheckBoxAddInvaidCard.Font.Color := clRed;
End;
End;
//-----------------------------删除黑名单--------------------------------//
If CheckBoxDelInvaidCard.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxDelInvaidCard.Caption;
CheckBoxDelInvaidCard.Font.Color := clYellow;
if blink then
Begin
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nDELINVAIDCARD, @nInvaidCard, Sizeof(Integer));
if m_pCommand <> nil then
Begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
Begin
LabelDelInvaiDcard.Caption := '删除成功!';
CheckBoxDelInvaidCard.Font.Color := clGreen;
End
Else
Begin
LabelDelInvaiDcard.Caption := '删除失败!';
CheckBoxDelInvaidCard.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
End
Else
Begin
LabelDelInvaiDcard.Caption := '命令失败!';
CheckBoxDelInvaidCard.Font.Color := clRed;
End;
End
Else
Begin
LabelDelInvaiDcard.Caption := '串口未连接!';
CheckBoxDelInvaidCard.Font.Color := clRed;
End;
End;
//-----------------------------修改密码--------------------------------//
If CheckBoxMFModifyKey.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxMFModifyKey.Caption;
CheckBoxMFModifyKey.Font.Color := clYellow;
if blink then
Begin
rMFKey.nAorBKey := 0;
rMFKey.nSectorNum := 0;
rMFKey.strOldKey := 'FFFFFFFFFFFF';
rMFKey.strNewKey := 'FFFFFFFFFFFF';
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nMFMODIFYKEY, @rMFKey, Sizeof(rMFKey));
if m_pCommand <> nil then
Begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
Begin
LabelMFModifyKey.Caption := '修改成功!';
CheckBoxMFModifyKey.Font.Color := clGreen;
End
Else
Begin
LabelMFModifyKey.Caption := '修改失败!';
CheckBoxMFModifyKey.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
End
Else
Begin
LabelMFModifyKey.Caption := '命令失败!';
CheckBoxMFModifyKey.Font.Color := clRed;
End;
End
Else
Begin
LabelMFModifyKey.Caption := '串口未连接!';
CheckBoxMFModifyKey.Font.Color := clRed;
End;
End;
//---------------------------------取前次结果----------------------------//
If CheckBoxReadLastResult.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxReadLastResult.Caption;
CheckBoxReadLastResult.Font.Color := clYellow;
If bLink then
Begin
m_pCommand := StartICDMCommand(m_pDevice, nTagAddress, nLastStatus, nil, 0);
if m_pCommand <> nil then
begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
Begin
LabelLastResult.Caption := '取前次结果成功!';
CheckBoxReadLastResult.Font.Color := clGreen;
End
else
Begin
LabelLastResult.Caption := '取前次结果失败!';
CheckBoxReadLastResult.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
End
Else
Begin
LabelLastResult.Caption := '命令失败!';
CheckBoxReadLastResult.Font.Color := clRed;
End;
end
Else
Begin
LabelLastResult.Caption := '串口未连接!';
CheckBoxReadLastResult.Font.Color := clRed;
End;
End;
//------------------------------初始化指针------------------------------//
If CheckBoxInitPointer.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxInitPointer.Caption;
CheckBoxInitPointer.Font.Color := clYellow;
If bLink then
Begin
m_pCommand := StartICDMCommand(m_pDevice,nTagAddress, nInitPointer, nil, 0);
if m_pCommand <> nil then
begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
Begin
LabelInitPointer.Caption := '初始化指针成功!';
CheckBoxInitPointer.Font.Color := clGreen;
End
else
Begin
LabelInitPointer.Caption := '初始化指针失败!';
CheckBoxInitPointer.Font.Color := clRed;
End;
EndICDMCommand(m_pCommand);
End
Else
Begin
LabelInitPointer.Caption := '命令失败!';
CheckBoxInitPointer.Font.Color:=clRed;
End;
end
Else
Begin
LabelInitPointer.Caption := '串口未连接!';
CheckBoxInitPointer.Font.Color:=clRed;
End;
End;
//------------------------------机具鸣叫测试-----------------------------//
if CheckBoxDMBeep.Checked = True then
begin
StatusBarDM.SimpleText := CheckBoxDMBeep.Caption;
CheckBoxDMBeep.Font.Color := clYellow;
if bLink then
begin
rBeepTest.nBeepTime := 0;
rBeepTest.nBeepTimes := 0;
rBeepTest.nBeepInterval := 0;
m_pCommand := StartICDMCommand(m_pDevice, nTagAddress, nBEEP, @rBeepTest, SizeOf(rBeepTest));
if m_pCommand <> nil then
begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
begin
LabelDMBeep.Caption := '鸣叫测试成功!';
CheckBoxDMBeep.Font.Color := clGreen;
end
else
begin
LabelDMBeep.Caption := '鸣叫测试失败!';
CheckBoxDMBeep.Font.Color := clRed;
end;
EndICDMCommand(m_pCommand);
end
else
begin
LabelDMBeep.Caption := '命令失败!';
CheckBoxDMBeep.Font.Color := clRed;
end;
end
Else
begin
LabelDMBeep.Caption := '串口未连接!';
CheckBoxDMBeep.Font.Color := clRed;
end;
end;
//-----------------------------语音提示-------------------------------//
If CheckBoxSetVoiceHint.Checked = True Then
Begin
StatusBarDM.SimpleText := CheckBoxSetVoiceHint.Caption;
CheckBoxSetVoiceHint.Font.Color := clRed;
If bLink then
Begin
m_pCommand := StartICDMCommand(m_pDevice, nTagAddress, nSETVOICEHINT, @nVoiceHintNum, SizeOf(Integer));
if m_pCommand <> nil then
begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
Begin
LabelSetVoiceHint.Caption := '语音提示成功';
CheckBoxSetVoiceHint.Font.Color := clGreen;
End
else
Begin
LabelSetVoiceHint.Caption := '语音提示失败';
CheckBoxSetVoiceHint.Font.Color := clYellow;
End;
EndICDMCommand(m_pCommand);
End
Else
Begin
LabelSetVoiceHint.Caption := '命令失败!';
CheckBoxSetVoiceHint.Font.Color := clYellow;
End;
End
Else
Begin
LabelSetVoiceHint.Caption := '串口未连接!';
CheckBoxSetVoiceHint.Font.Color := clYellow;
End;
End;
//----------------------------测试完后设置机具类别-----------------------//
Begin
nDMSort := ComboBoxDMSort.ItemIndex;
If bLink then
Begin
m_pCommand := StartICDMCommand(m_pDevice, nTagAddress, nSETDMSORT, @nDMSort, SizeOf(Integer));
if m_pCommand <> nil then
begin
nInfoCode := GetCmdResult(m_pCommand);
if nInfoCode = nSUCCESS then
Begin
StatusBarDM.SimpleText := '类别设置成功!';
End
else
Begin
StatusBarDM.SimpleText := '类别设置失败!';
End;
end
Else
Begin
StatusBarDM.SimpleText := '命令失败!';
End;
EndICDMCommand(m_pCommand);
end
Else
Begin
StatusBarDM.SimpleText := '串口未连接!';
End;
End;
StatusBarDM.SimpleText := '测试完成';
BitBtnTest.Enabled := TRUE;
BitBtnClose.Enabled := TRUE;
end;
procedure TFormTestSys.ComboBox_cominfoExit(Sender: TObject);
begin
m_strCommDef :='com' + ComboBox_cominfo.Text + ':baud=9600,parity=e,data=8,stop=1';
end;
procedure TFormTestSys.FormShow(Sender: TObject);
begin
FormInit();
end;
procedure TFormTestSys.FormInit();
Begin
CheckBoxSetTime.Font.Color :=clBlack;
LabelSetTime.Caption :='';
CheckBoxTest.Font.Color :=clBlack;
LabelTest.Caption :='';
CheckBoxSetDMGrade.Font.Color :=clBlack;
LabelDMGrade.Caption :='';
CheckBoxReadLastResult.Font.Color :=clBlack;
LabelLastResult.Caption :='';
CheckBoxReadCardINFO.Font.Color :=clBlack;
LabelReadCardINFO.Caption :='';
CheckBoxSetDMSort.Font.Color :=clBlack;
LabelSetDMSort.Caption :='';
CheckBoxWriteCardInfo.Font.Color :=clBlack;
LabelWriteCardINFO.Caption :='';
CheckBoxRecord.Font.Color :=clBlack;
LabelRecord.Caption :='';
CheckBoxDMStatus.Font.Color :=clBlack;
LabelDMStatus.Caption :='';
CheckBoxInItPointer.Font.Color :=clBlack;
LabelinItPointer.Caption :='';
CheckBoxMFSeardhCard.Font.Color :=clBlack;
LabelMFSearchCard.Caption :='';
CheckBoxMFWriteCardData.Font.Color :=clBlack;
LabelMFWriteCardData.Caption :='';
CheckBoxMFReadCardData.Font.Color :=clBlack;
LabelMFReadCardData.Caption :='';
CheckBoxTMWriteCardData.Font.Color :=clBlack;
LabelTMWriteCardData.Caption :='';
CheckBoxTMReadCardData.Font.Color :=clBlack;
LabelTMReadCardData.Caption :='';
CheckBoxAddCardData.Font.Color :=clBlack;
LabelAddCardData.Caption :='';
CheckBoxReduceCardData.Font.Color :=clBlack;
LabelReduceCardData.Caption :='';
CheckBoxAddInvaidCard.Font.Color :=clBlack;
LabelAddInvaidCard.Caption :='';
CheckBoxDelInvaidcard.Font.Color :=clBlack;
LabelDelInvaidcard.Caption :='';
CheckBoxMFModifyKey.Font.Color :=clBlack;
LabelMFModifyKey.Caption :='';
CheckBoxTMModifyKEY.Font.Color :=clBlack;
LabelTMModifyKEY.Caption :='';
CheckBoxMFVerifyKEY.Font.Color :=clBlack;
LabelMFVerifyKEY.Caption :='';
CheckBoxTMVerifyKEY.Font.Color :=clBlack;
LabelTMVerifyKEY.Caption :='';
CheckBoxWriteUserPassword.Font.Color :=clBlack;
LabelWriteUserPassword.Caption :='';
CheckBoxVerifyUserPassord.Font.Color :=clBlack;
LabelVerifyUserPassword.Caption :='';
CheckBoxModifyUserPassword.Font.Color :=clBlack;
LabelModifyUserPassword.Caption :='';
CheckBoxInitCardData.Font.Color :=clBlack;
LabelInitCardData.Caption :='';
CheckBoxDMBeep.Font.Color :=clBlack;
LabelDMBeep.Caption :='';
CheckBoxActiveTime.Font.Color :=clBlack;
LabelActiveTime.Caption :='';
CheckBoxSetVoiceHint.Font.Color :=clBlack;
LabelSetVoiceHint.Caption :='';
end;
end.