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

📄 formrun.cpp

📁 16 relay output channels and 16 isolated digital input channels LED indicators to show activated
💻 CPP
字号:
//---------------------------------------------------------------------------

#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -