//Listing K8055D.h
#ifdef __cplusplus
extern "C" {
#endif
#define FUNCTION __decl spec(dllim port)
FUNCTION long __stdcall OpenDevice(l ong CardAddress);
FUNCTION __ stdcall CloseDevice();
FUNCTION long __ stdcall ReadAnalogChannel(lon g Channel);
FUNCTION __stdcall ReadAllAnalog(long *Data1, lo ng *Data2);
FUNCTION __stdca ll OutputAnalogChannel(long Channel, long Data);
FUNCTION __stdc all OutputAllAnalog(lo ng Data1, long Data2);
FUNCTION __stdca ll ClearAnalogChannel(long Channel);
FUNCTION __std call ClearAllAnalog();
FUNCTION __ stdcall SetAnalogChannel(long Channel);
FUNCTION __s tdcall SetAllAnalog();
FUNCTION __stdcall WriteAllDigital(long Data);
FUNCTION __stdc all ClearDigitalChannel(long Channel);
FUNCTION __st dcall ClearAllDigital();
FUNCTI ON __stdc all SetDigitalChannel(long Channel);
FUNCTION __s tdcall SetAllDigital();
FUNCTION bool __st dcall ReadDigitalChannel(long Channel);
FUNCTION l ong __std call ReadAllDigital();
FUNCTION lo ng __stdc all ReadCounter(long CounterNr);
FUNCTION __s tdcall ResetCounter(long CounterNr);
FUNCTION __st dcall SetCounterDebounceTime(long CounterNr, lo ng DebounceTime);
#ifdef __cplusplus
}
# endif
//Listing Unit1.cpp
//------- ------------- ------------ ------------ ------------ ------------ -------
#include <
vcl.h>
#pragma hdrstop
#include "Unit1. h"
#include "K8055D. h"
//-------- ------------ ------------ ------------- ------------ ------------ ------
#pragma
package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//------- ------------- ------------ ------------ ------------ ------------- ------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
/ /----------- ------------ ------------ ------------ ------------- ------------ ---
void __ fastcall TForm1::Connect1Click(TObject *Sender)
{
int CardAddr = 3 - (int (CheckBox1->Checked) + in t(CheckBox2->Checked) * 2);
int h = OpenDevice(CardAddr);
switch (h) {
case 0 :
case 1 :
case 2 :
case 3 :
Label1->Caption = "Card " + IntToStr(h) + " connected";
break;
case -1 :
Label1->Caption = "Card " + IntToStr(CardAddr) + " not found";
}
}
//----- ------------ ------------ ------------- ------------ ------------ ---------
void __fastc all TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
CloseDevice;
}
//---- ------------ ------------ ------------ ------------- ------------ ----------