formrun.cpp
来自「16 relay output channels and 16 isolated」· C++ 代码 · 共 86 行
CPP
86 行
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "FORMRUN.h"
#include "FORMSTAR.h"
#include "..\..\..\..\include\driver.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tfrmrun *frmrun;
extern long DeviceHandle;
extern long ErrCde;
extern char szErrMsg[80];
extern PT_CounterEventStart ptCounterEventStart;
extern PT_CounterEventRead ptCounterEventRead;
//---------------------------------------------------------------------------
__fastcall Tfrmrun::Tfrmrun(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall Tfrmrun::CmdExitClick(TObject *Sender)
{
frmrun->Close();
frmstart->Show();
tmrRead->Enabled = False;
}
//---------------------------------------------------------------------------
void __fastcall Tfrmrun::hscrFreqChange(TObject *Sender)
{
if (hscrFreq->Position == 0)
tmrRead->Interval = 0;
else
tmrRead->Interval = 10000 / hscrFreq->Position;
tmrRead->Enabled = True;
}
//---------------------------------------------------------------------------
void __fastcall Tfrmrun::tmrReadTimer(TObject *Sender)
{
USHORT overflow;
ULONG count;
ptCounterEventRead.counter = ptCounterEventStart.counter;
ptCounterEventRead.overflow = &overflow;
ptCounterEventRead.count = &count;
ErrCde = DRV_CounterEventRead(DeviceHandle, &ptCounterEventRead);
if (ErrCde != 0)
{
DRV_GetErrorMessage(ErrCde, szErrMsg);
Application->MessageBox(szErrMsg, "Error!!", MB_OK);
return;
}
txtCountRead->Text = IntToStr(count);
}
//---------------------------------------------------------------------------
void __fastcall Tfrmrun::FormCreate(TObject *Sender)
{
hscrFreq->Position = 10;
tmrRead->Enabled = False;
}
//---------------------------------------------------------------------------
void __fastcall Tfrmrun::CmdReadClick(TObject *Sender)
{
USHORT overflow;
ULONG count;
tmrRead->Enabled = False;
ptCounterEventRead.counter = ptCounterEventStart.counter;
ptCounterEventRead.overflow = &overflow;
ptCounterEventRead.count = &count;
ErrCde = DRV_CounterEventRead(DeviceHandle, &ptCounterEventRead);
if (ErrCde != 0)
{
DRV_GetErrorMessage(ErrCde, szErrMsg);
Application->MessageBox(szErrMsg, "Error!!", MB_OK);
return;
}
txtCountRead->Text = IntToStr(count);
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?