📄 tcommsenddatathread_unit.pas
字号:
unit TCommSendDataThread_Unit;
interface
uses
Classes,Windows,SysUtils, Dialogs ,GlbVar_Unit;
type
TCommSendDataThread = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
public
end;
function AcceptData : Boolean;
function FindBufHead(lpBuf:PByte;nLen:Integer):Integer;
function FindBufHead2A(lpBuf:PByte;nLen:Integer):Integer;
var //缓冲区
TCTLINK : array [1..68] of BYTE; //4路总控器路号加上16字节的配置信息
SYSTIMEDOWN : array [1..4] of BOOLEAN; //系统时间下载
SETUPDOWN : array [1..4] of BOOLEAN; //配置是否下载过
CTStatus : array [1..508] of Byte;
M1ValveStatus : Array [1..508] of byte; //四路总控器没一路的阀门状态
M2ValveStatus : Array [1..508] of byte;
M3ValveStatus : Array [1..508] of byte;
M4ValveStatus : Array [1..508] of byte;
iRate,iSecond ,iRateMid,iTimeMid : Integer;
//结算
BalComm :Byte;
BalPath :Byte;
BalMac :Integer;
BalAcc :Integer;
BalMoney: Integer;
BalTime : String;
BalGroup :Integer;
BalDinner :Integer;
ifPayMac :Integer;
BalOperName :String;
BalOperID :Integer;
datawww :String;
/////////////
CommNo : Integer;
PathNo : Integer;
MacNo : Integer;
SendWater_Sql :String;
/////出纳机应用///////////
//Open_Pay : Boolean; //打开出纳机
In_Pay : Boolean; //在出纳机刷卡
in_ServPay :Boolean; //在伺服机上
CardNo :Cardinal;
IsOperCard : Boolean; //是操作员卡
/////////////////////
problemdate : integer;
PosType : integer; //pos机类型
{门禁使用信息begin}
iOAGroupID : integer;
idegname : String;
idepid : integer;
idepname : String;
ipername : String;
{门禁使用信息end}
implementation
uses TMCommDriverClass_Unit, CRCMAC_Unit, GlbDataModule_Unit,
MAIN_UNIT, TCommFunc_Unit, BleepInt;
procedure TCommSendDataThread.Execute;
var
i : Integer;
iContrl : Integer;
bSendDataBuf : array [1..1024] of Byte;
iCount : Integer;
dwRet : DWORD;
crc16 : Word;
nLen : Integer;
iLength : Integer;
iHead : Integer;
iSecond : Integer;
iRate,iAccountPwd : Integer;
iStatus,iIfOpen,iAMoney,iALMoney,iMFMoney : Integer;
iCount1 : Integer;
CheckSum : Byte;
crc161 : Word;
iChange : integer;
///////
/////////
iMacSumMoney : integer; ///统计当日消费额
/////////
PayCount :integer;
NowPayNo :integer;
////////
OperCount :integer;
NowOper : integer;
////
AccountOpen : Boolean; //判断帐户是否打开
LockCount :integer;
iAccount : Cardinal;
{各种控制选择一种begin}
Controltype :integer;
{各种控制选择一种begin}
/////补助、回绕、统一发放状态////
SendStatus :boolean;
iSendStaMoney :integer;
begin
try
//ZeroMemory(@TCTCounters,4);
ZeroMemory(@TCTLINK,68);
ZeroMemory(@M1ValveStatus,508);
ZeroMemory(@M2ValveStatus,508);
ZeroMemory(@M3ValveStatus,508);
ZeroMemory(@M4ValveStatus,508);
ZeroMemory(@bSendDataBuf,1024);
//ZeroMemory(@OpenAccount,Sizeof(OpenAccount));
//ZeroMemory(@BalAccount,Sizeof(BalAccount));
//////////////////////////
SendWater_sys :=false;
////////////////////////
/////出纳机应用//////////////////
In_Pay :=false;
in_ServPay :=false;
//Open_Pay :=false;
IsOperCard :=false;
ReadCardThreadRun:=true;
/////////////////////
//////
problemdate :=StrToInt(FormatDateTime('yyyymmdd',now));
LockCount :=0 ;
/////////////////////
for i:=1 to 4 do
begin
SYSTIMEDOWN[i]:=false;
SETUPDOWN[i] :=false;
end;
ZeroMemory(@CTStatus,508);
///初始化
CommFunc.InitPosSeting;
////////////////////////////////////////////////////////// /////////////////////////////////
while (Not Terminated) do
begin
begin
iContrl := 1;
While (iContrl<68) do
begin
if (TCTLINK[iContrl]>0) then
begin
if SETUPDOWN[TCTLINK[iContrl]] then
begin
if Not SYSTIMEDOWN[TCTLINK[iContrl]] then
begin
CommNetDriver.m_hSection.Acquire; //加载系统时钟 (每次重新启动总控器时加载)
ZeroMemory(@CommNetDriver.GDataBuf,1024);
CommNetDriver.m_hSection.Release;
ZeroMemory(@bSendDataBuf,1024);
bSendDataBuf[1] := STARSIGN;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -