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

📄 eventthread.pas

📁 16 relay output channels and 16 isolated digital input channels LED indicators to show activated
💻 PAS
字号:
unit EventThread;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls,Driver,event;

type
  TEventThread = class(TThread)
  private
    { Private declarations }
  protected
    procedure Execute; override;
  public
    lDriverHandle : Longint;
    constructor Create(lDHandle : Longint);
  end;

implementation

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

      Synchronize(UpdateCaption);

  and UpdateCaption could look like,

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

{ TEventThread }
constructor TEventThread.Create(lDHandle : Longint);
Begin
	lDriverHandle := lDHandle;

	inherited Create(False);

End;

procedure TEventThread.Execute;
var
   usEventType : Smallint;
   ErrCde : Longint;
   ptCheckEvent : PT_CheckEvent;
   szErrMsg      : array[0..80] of Char;

begin
  { Place thread code here }
    usEventType := 0;

    ptCheckEvent.EventType := @usEventType;
    ptCheckEvent.Milliseconds := 5000;
    while(not Terminated)do
    begin
        ErrCde := DRV_CheckEvent(lDriverHandle,ptCheckEvent);
        if(ErrCde <> SUCCESS)then
        begin
          DRV_GetErrorMessage(ErrCde,@szErrMsg);
          Application.MessageBox(szErrMsg,'Driver Message');
          Terminate;
          Exit;
        end;
        case (usEventType)of
            ADS_EVT_TERMINATE_CNT0:
                Application.MessageBox('Counter0 Terminal Event Occured!','Interrupt Message');
            ADS_EVT_TERMINATE_CNT1:
	        Application.MessageBox('Counter1 Terminal Event Occured !','Interrupt Message');
            ADS_EVT_TERMINATE_CNT2:
	        Application.MessageBox('Counter2 Terminal Event Occured !','Interrupt Message');
            ADS_EVT_TERMINATE_CNT3:
               Application.MessageBox('Counter3 Terminal Event Occured !','Interrupt Message');
            ADS_EVT_TERMINATE_CNT4:
		Application.MessageBox('Counter4 Terminal Event Occured !','Interrupt Message');
            ADS_EVT_TERMINATE_CNT5:
		Application.MessageBox('Counter5 Terminal Event Occured !','Interrupt Message');
            ADS_EVT_TERMINATE_CNT6:
		 Application.MessageBox('Counter6 Terminal Event Occured !','Interrupt Message');
            ADS_EVT_TERMINATE_CNT7:
                 Application.MessageBox('Counter7 Terminal Event Occured !','Interrupt Message');
       end;
    end;
end;

end.

⌨️ 快捷键说明

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