eventthread.cpp
来自「16 relay output channels and 16 isolated」· C++ 代码 · 共 70 行
CPP
70 行
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "EventThread.h"
#include "..\..\..\include\driver.h"
#include "DiginExForm.h"
#pragma package(smart_init)
extern PT_CheckEvent ptCheckEvent;
extern LONG lDriverHandle;
extern LRESULT ErrCde;
extern char szErrMsg[80];
extern BOOL bThreadRun;
//---------------------------------------------------------------------------
// Important: Methods and properties of objects in VCL can only be
// used in a method called using Synchronize, for example:
//
// Synchronize(UpdateCaption);
//
// where UpdateCaption could look like:
//
// void __fastcall EventThread::UpdateCaption()
// {
// Form1->Caption = "Updated in a thread";
// }
//---------------------------------------------------------------------------
__fastcall EventThread::EventThread(bool CreateSuspended)
: TThread(CreateSuspended)
{
}
//---------------------------------------------------------------------------
void __fastcall EventThread::Execute()
{
//---- Place thread code here ----
USHORT usEventType;
ptCheckEvent.EventType = &usEventType;
ptCheckEvent.Milliseconds = 5000;
while(!Terminated){
if ((ErrCde = DRV_CheckEvent(lDriverHandle,(LPT_CheckEvent)&ptCheckEvent)) != SUCCESS)
{
Application->MessageBoxA("Check Event Error !","Thread Message");
//EventTimer->Enabled = False;
Terminate();
return ;
}
if (usEventType == ADS_EVT_PATTERNMATCH)
frmMain->adPatternMatchEvent();
// Process counter match event
if (usEventType == ADS_EVT_COUNTERMATCH)
frmMain->adCounterMatchEvent();
// Process counter overflow event
if (usEventType == ADS_EVT_COUNTEROVERFLOW)
frmMain->adCounterOverflowEvent();
// Process status change event
if (usEventType == ADS_EVT_STATUSCHANGE)
frmMain->adStatusChangeEvent();
}
bThreadRun = False;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?