📄 sendthread.~pas
字号:
unit SendThread;
interface
uses
Classes {$IFDEF MSWINDOWS} , Windows {$ENDIF},StdCtrls,SyncObjs,SysUtils,Goalvar;
type
TSendThread = class(TThread)
private
{ Private declarations }
m_SdTotalCount_Edit :TEdit;
m_SdOKCount_Edit :TEdit;
m_SdFaileCount_Edit : TEdit;
protected
procedure Execute; override;
public
procedure Init(SdTotalCount_Edit: TEdit;SdOKCount_Edit: TEdit;SdFaileCount_Edit: TEdit);
end;
implementation
{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example,
Synchronize(UpdateCaption);
and UpdateCaption could look like,
procedure TSendThread.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }
{ TSendThread }
procedure TSendThread.Init(SdTotalCount_Edit: TEdit;SdOKCount_Edit: TEdit;SdFaileCount_Edit: TEdit);
begin
m_SdTotalCount_Edit := SdTotalCount_Edit;
m_SdOKCount_Edit := SdOKCount_Edit;
m_SdFaileCount_Edit := SdFaileCount_Edit;
end;
procedure TSendThread.Execute;
var
i : integer;
Status : integer;
begin
{ Place thread code here }
Status :=-1;
while g_SendThreadFlag = TRUE do
begin
if(g_hStartSendEvent.WaitFor( INFINITE )= wrSignaled) then
begin
//非循环发送时复位发送事件
if(g_blCycleSend = FALSE) then
g_hStartSendEvent.ResetEvent();
for i:=0 to g_TryCount do
begin
Status := HKCanSendFrame(@g_mDevHandle,@g_SendFrame);
if(Status=0) then
break
else
HKCanAbortSend(@g_mDevHandle,g_SendFrame.Port);
end;
g_SendTotalCount := g_SendTotalCount+1;
if(Status <> 0) then
g_SendFailCount := g_SendFailCount + 1
else
g_SendOKCount := g_SendOKCount +1;
if(g_ShowProcess = TRUE) then
begin
m_SdTotalCount_Edit.Text := inttostr(g_SendTotalCount);
m_SdOKCount_Edit.Text := inttostr(g_SendOKCount);
m_SdFaileCount_Edit.Text := inttostr(g_SendFailCount);
end;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -