source: trunk/FACT++/dim/src/examples/pvss_dim_client.cxx@ 14575

Last change on this file since 14575 was 11071, checked in by tbretz, 13 years ago
Replaced v19r21 by a version extracted with 'unzip -a' to get proper unix text format.
File size: 2.2 KB
Line 
1#include <dic.hxx>
2#include <iostream>
3#include <stdio.h>
4using namespace std;
5
6typedef struct{
7 int bitset;
8 char boolval;
9 int intval;
10 float floatval;
11 char stringval[128];
12}COMPLEXDATA;
13
14class SimpleService : public DimInfo
15{
16 void infoHandler()
17 {
18 cout << "SimpleService : " << getFloat() << "\n" << endl;
19 }
20public :
21 SimpleService(char *name) : DimInfo(name, -1.0) {};
22};
23
24double no_link_darray[8] = {-1.0,0,0,0,0,0,0,0};
25
26class DimDoubleArray : public DimInfo
27{
28 void infoHandler()
29 {
30 double *data;
31 int i, len;
32
33 data = (double *)getData();
34 len = getSize()/sizeof(double);
35 for(i = 0; i < len; i++)
36 {
37 cout << data[i] << endl;
38 }
39 }
40public :
41 DimDoubleArray(char *name) : DimInfo(name, no_link_darray, 8*sizeof(double)) {};
42};
43
44
45class ComplexService : public DimInfo
46{
47 void infoHandler()
48 {
49 COMPLEXDATA *data;
50 int i;
51 unsigned mask = 0x80000000;
52
53 data = (COMPLEXDATA *)getData();
54
55 cout << "ComplexService : \n";
56 cout << "\tbitset : ";
57 for(i = 0; i < 32; i++)
58 {
59 if (data->bitset & mask)
60 cout << "1";
61 else
62 cout << "0";
63 mask >>= 1;
64 }
65 cout << "\n";
66 cout << "\tboolval : ";
67 if(data->boolval)
68 cout << "TRUE\n";
69 else
70 cout << "FALSE\n";
71 cout << "\tintval : "<< data->intval << "\n";
72 cout << "\tfloatval : " << data->floatval << "\n";
73 cout << "\tstringval : "<< data->stringval << "\n\n";
74 cout << "Sending PVSS_SIMPLE_COMMAND : " << data->stringval << "\n" << endl;
75 DimClient::sendCommand("PVSS_SIMPLE_COMMAND",data->stringval);
76 }
77public :
78 ComplexService(char *name) : DimInfo(name, -1.0) {};
79};
80
81class RpcService : public DimRpcInfo
82{
83public:
84 void rpcInfoHandler() {
85 int value;
86 value = getInt();
87 dim_print_date_time();
88 cout << "RPC Service received: " << value << "\n" << endl;
89 }
90 RpcService(char *name, int timeout) : DimRpcInfo(name, timeout, -1) {};
91};
92
93
94int main()
95{
96 int value = 0;
97 SimpleService simple("PVSS_SIMPLE_SERVICE");
98 ComplexService complex("PVSS_COMPLEX_SERVICE");
99 RpcService rpc("TESTRPC/INT", 25);
100 DimDoubleArray dda("TEST_SRVC");
101
102 while(1)
103 {
104 dim_print_date_time();
105 value++;
106 cout << "RPC Service sent: " << value << "\n" << endl;
107 rpc.setData(value);
108 value++;
109 sleep(30);
110 }
111 return 0;
112}
Note: See TracBrowser for help on using the repository browser.