1#ifdef _WIN32
2 #include <windows.h>
3 #define usleep(us) Sleep(us / 1000)
4#else
5 #include <unistd.h>
6#endif
7#include <stdio.h>
8#include <stdexcept>
9#include <vector>
10
12
13
14
15
16
18void TestRes(bool result)
19{
20 char ErrText[512];
21
22
23 if (result)
24 return;
25
26
28
29 throw std::runtime_error(ErrText);
30}
32
33
34int main()
35{
39
40 try
41 {
42
44
45
46
47
48 std::vector<char>pstText(4096);
50 printf("Version numbers ==>\n%s\n", &pstText[0]);
52
53
55
58
59
60 char serialnumber[32];
62 printf("\nSerial number: '%s'\n", serialnumber);
63
64
66
68 if (digitalOutput.
Open(0))
69 {
70 printf("\nFound Digital Output device\n");
72
74 printf(" Setting output signals...\n");
75
76
77 TestRes(digitalOutput.
Set(0xffff));
78
79
80 unsigned int outputSignals;
82 for (unsigned int signal = 0; signal < outputSignals; signal++)
83 {
84 usleep(100*1000);
85 TestRes(digitalOutput.
SetBit(signal,
false));
86 }
88 }
89
91
92 }
94 catch (std::runtime_error &err)
95 {
96 printf("\n==============================================\n");
97 printf("Error:\n %s\n", err.what());
98 printf("\n==============================================\n");
99 }
100 catch (...)
101 {
102 printf("\n==============================================\n");
103 printf("Error: ???\n");
104 printf("\n==============================================\n");
105 }
106
107
109 if (pVIBSystem != NULL)
110 {
111 printf("\nClosing devices...\n");
112
113 if (pService != NULL)
115
117 }
119
120 printf("\nPress ENTER to exit.\n");
121 getchar();
122
123 return 0;
124}
Header file for this library.
This class controls a group of digital output signals.
Definition VIB_Interface.h:473
bool Set(unsigned int Val)
Sets the state of the digital output signals.
Definition DigitalOutput.cpp:122
bool GetNumberOfOutputs(unsigned int &NumberOfOutputs)
Returns number of output channels.
Definition DigitalOutput.cpp:93
bool SetBit(unsigned int BitIndex, bool OnOff)
Sets the state of the specified digital output.
Definition DigitalOutput.cpp:135
This class contains functions associated with the hardware component (serial number,...
Definition VIB_Interface.h:583
bool GetSerialNumber(char pSerialnumber[32])
Returns the serial number for the hardware component.
Definition Service.cpp:525
The factory for devices.
Definition VIB_Interface.h:223
bool OpenDevice(eDeviceType Type, int Index, iDevice **ppNewDevice)
Opens a device and returns a new device object.
Definition VIBSystem.cpp:455
bool GetVersionString(char *pText, unsigned int MaxStringSize)
Returns a string with version data from all components. (DLL, driver, FPGA, ...)
Definition VIBSystem.cpp:937
static bool DeleteInstance(VIBSystem *pObj)
Releases the device object.
Definition VIBSystem.cpp:199
bool CloseDevice(iDevice *pDevice)
Closes a device.
Definition VIBSystem.cpp:856
static bool CreateInstance(VIBSystem **ppVIBSystem)
Creates a factory instance for the mainboard.
Definition VIBSystem.cpp:105
static void GetLastErrorString(char &pText, unsigned int MaxStringSize)
Returns the last error message.
Definition VIBSystem.cpp:233
bool Open(unsigned int Index=0)
Opens a device.
Definition iDevice.cpp:109