FACT++  1.0
pvss_dim_client.cxx
Go to the documentation of this file.
1 #include <dic.hxx>
2 #include <iostream>
3 #include <stdio.h>
4 using namespace std;
5 
6 typedef struct{
7  int bitset;
8  char boolval;
9  int intval;
10  float floatval;
11  char stringval[128];
13 
14 class SimpleService : public DimInfo
15 {
16  void infoHandler()
17  {
18  cout << "SimpleService : " << getFloat() << "\n" << endl;
19  }
20 public :
21  SimpleService(const char *name) : DimInfo(name, -1.0) {};
22 };
23 
24 double no_link_darray[8] = {-1.0,0,0,0,0,0,0,0};
25 
26 class 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  }
40 public :
41  DimDoubleArray(const char *name) : DimInfo(name, no_link_darray, 8*sizeof(double)) {};
42 };
43 
44 
45 class ComplexService : public DimInfo
46 {
47  void infoHandler()
48  {
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  }
77 public :
78  ComplexService(const char *name) : DimInfo(name, -1.0) {};
79 };
80 
81 class RpcService : public DimRpcInfo
82 {
83 public:
84  void rpcInfoHandler() {
85  int value;
86  value = getInt();
88  cout << "RPC Service received: " << value << "\n" << endl;
89  }
90  RpcService(const char *name, int timeout) : DimRpcInfo(name, timeout, -1) {};
91 };
92 
93 
94 int 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  {
105  value++;
106  cout << "RPC Service sent: " << value << "\n" << endl;
107  rpc.setData(value);
108  value++;
109  sleep(30);
110  }
111  return 0;
112 }
static int sendCommand(const char *name, int data)
Definition: diccpp.cxx:1098
int i
Definition: db_dim_client.c:21
STL namespace.
Definition: dic.hxx:31
RpcService(const char *name, int timeout)
SimpleService(const char *name)
void setData(void *data, int size)
Definition: discpp.cxx:1571
int main()
ComplexService(const char *name)
float data[4 *1440]
DimDoubleArray(const char *name)
void dim_print_date_time()
Definition: utilities.c:134
double no_link_darray[8]
void rpcInfoHandler()
char stringval[128]