5,388
社区成员
发帖
与我相关
我的任务
分享
unit Thread_Read;
interface
uses
Classes ,SPComm,Forms,MP_P_BaseForm,MP_P_DMMain,Controls,SysUtils,Buttons,ComCtrls;
type
Thread_Rd = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
public
Spcomm_RW:TComm;
constructor Create(str_ComName1: string; spcomm_RW1: TComm);
procedure GetOutString;
procedure ExcuteGetOutStr();
procedure FreeControlByIndex();
procedure ExcuteFreeControlByIndex();
procedure SetInputString();
procedure ExcuteSetInputStr();
procedure ExcuteCOM1;
procedure ExcuteCOM3;
end;
implementation
{ Thread_Read }
uses
MP_62056_RW;
constructor Thread_Rd.Create(str_ComName1: string; spcomm_RW1: TComm);
begin
Str_ComName:=str_ComName1;
Spcomm_RW:= spcomm_RW1;
inherited Create(False);
end;
procedure Thread_Rd.Execute;
{ Place thread code here }
begin
if Str_ComName='COM1' then
Frm_62056_RW.ReadOperateCOM1 //为主窗口的过程
else if Str_ComName='COM2' then
Frm_62056_RW.ReadOperateCOM2
else if Str_ComName='COM3' then
Frm_62056_RW.ReadOperateCOM3
end;
procedure TFrm_62056_RW.bbtn_ReadClick(Sender: TObject);
begin
Thread_ReadCOM1:= Thread_Rd.Create('COM1',spcomm_RW1);
Thread_ReadCOM2:= Thread_Rd.Create('COM2',spcomm_RW2);
end;
procedure TFrm_62056_RW.ReadOperateCOM1;
var
Str_Error:string;
begin
try
if ReadDataProcess(Gl_Str_MTypeNo,Gl_Str_MeterNo,'COM1',Str_Error,Memo_Debug1,spcomm_RW)<0 then//此处出现如题错误
begin
ShowWarningWithMsg(Str_Error);
end else
begin
ShowInformation(sb_Object.Panels[con_PnlNo_ObjectCount].Text+','+
sb_Object.Panels[con_PnlNo_SucceedCount].Text+','+
sb_Object.Panels[con_PnlNo_FailedCount].Text);
end;
finally
if bbtn_Read.CanFocus then bbtn_Read.SetFocus;
end;
end;
procedure TFrm_62056_RW.ReadOperateCOM2;
var
Str_Error:string;
begin
try
if ReadDataProcess(Gl_Str_MTypeNo,Gl_Str_MeterNo,'COM2',Str_Error,memo_Debug2,spcomm_RW2)<0 then
begin
ShowWarningWithMsg(Str_Error);
end else
begin
ShowInformation(sb_Object.Panels[con_PnlNo_ObjectCount].Text+','+
sb_Object.Panels[con_PnlNo_SucceedCount].Text+','+
sb_Object.Panels[con_PnlNo_FailedCount].Text);
end;
finally
Class_GVar.Str_ExecLockSys:=con_ExecLockSys_Yes;
if bbtn_Read.CanFocus then bbtn_Read.SetFocus;
end;
end;