User manual
Description of the DLL14
© 2003 ... Velleman
Die K8055D.
DLL in Borland C++ Builder verwenden
In diesem Anwendungsbeispiel werden die Arbeitsweisen und die Funktionen der K8055.DLL erklärt.
Auch werden die 2 wichtigsten DLL -Signale:
OpenDevice
and
CloseDevice
verdeutlicht.
//Listing K8055D.h
#ifdef __cplusplus
extern
"C"
{
#endif
#define FUNCTION
__declspec
(dllimport)
FUNCTION
long
__stdcall
OpenDevice(
long
CardAddress);
FUNCTION
__stdcall
CloseDevice();
FUNCTION
long
__stdcall
ReadAnalogChannel(
long
Channel);
FUNCTION
__stdcall
ReadAllAnalog(
long
*Data1,
long
*Data2);
FUNCTION
__stdcall
OutputAnalogChannel(
long
Channel,
long
Data);
FUNCTION
__stdcall
OutputAllAnalog(
long
Data1,
long
Data2);
FUNCTION
__stdcall
ClearAnalogChannel(
long
Channel);
FUNCTION
__stdcall
ClearAllAnalog();
FUNCTION
__stdcall
SetAnalogChannel(
long
Channel);
FUNCTION
__stdcall
SetAllAnalog();
FUNCTION
__stdcall
WriteAllDigital(
long
Data);
FUNCTION
__stdcall
ClearDigitalChannel(
long
Channel);
FUNCTION
__stdcall
ClearAllDigital();
FUNCTION
__stdcall
SetDigitalChannel(
long
Channel);
FUNCTION
__stdcall
SetAllDigital();
FUNCTION
bool
__stdcall
ReadDigitalChannel(
long
Channel);
FUNCTION
long
__stdcall
ReadAllDigital();
FUNCTION
long
__stdcall
ReadCounter(
long
CounterNr);
FUNCTION
__stdcall
ResetCounter(
long
CounterNr);
FUNCTION
__stdcall
SetCounterDebounceTime(
long
CounterNr,
long
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) +
int
(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
: