⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thread.pas

📁 usb4711A数据采集卡的DI转换通道程序
💻 PAS
字号:
unit Thread;

interface

uses
  Classes, Controls, SysUtils, stdctrls,
  Driver;

type
  PT_ThreadData = Record
    ghDev      : Longint;
    ptxtPMCount  : ^TEdit;  {Position for Pattern match count}
    ptxtSCCount  : ^TEdit;  {Position for Status change count}
    ptxtIntCount : ^TEdit;  {Position for Interrupt count}
  End;


  TWatchThread = class(TThread)
  private
    {Private declarations }
    usPMCount  : Cardinal;
    usSCCount  : Cardinal;
    usIntCount : Cardinal;
  protected
    procedure Execute; override;

  public
    MData        : PT_ThreadData;
    ptCheckEvent : PT_CheckEvent;   { Check event}
    iEventType   : Integer;         { returned event type}
    constructor Create(TData : PT_ThreadData);
  end;

implementation

{ Important: Methods and properties of objects in VCL can only be used in a
  method called using Synchronize, for example,

      Synchronize(UpdateCaption);

  and UpdateCaption could look like,

    procedure TWatchThread.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }

{ TWatchThread }
constructor TWatchThread.Create(TData: PT_ThreadData);
Begin
  inherited Create(False);

  MData := TData;

  {Fill table for furter using}
  ptCheckEvent.EventType := @iEventType;
  ptCheckEvent.Milliseconds := 1000;

  usPMCount  := 0;
  usSCCount  := 0;
  usIntCount := 0;
End;

procedure TWatchThread.Execute;
var
  lErrCde : Longint;
begin
  { Place thread code here }
  while not Terminated do
  Begin
    lErrCde := DRV_CheckEvent(MData.ghDev, ptCheckEvent);
    if lErrCde <> 0 then Exit;

    Case iEventType of
      ADS_EVT_INTERRUPT:
      begin
        usIntCount := usIntCount + 1;       {Increase the event count}
        MData.ptxtIntCount^.Text := IntToStr(usIntCount); {display on screen}
      end; {End of ADS_EVT_INTERRUPT}

      ADS_EVT_PATTERNMATCH:
      begin
        usPMCount := usPMCount + 1;
        MData.ptxtPMCount^.Text := IntToStr(usPMCount);
      end; {End of ADS_EVT_PATTERNMATCH}

      ADS_EVT_STATUSCHANGE:
      begin
        usSCCount := usSCCount + 1;
        MData.ptxtSCCount^.Text := IntToStr(usSCCount);
      end; {end of ADS_EVT_STATUSCHANGE}
    end; {End of case iEventType}
  End; {End of While}
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -