ChimeraTK-DeviceAccess-DoocsBackend  01.09.02
eq_dummy.cc
Go to the documentation of this file.
1 #include "eq_dummy.h"
2 
3 #include <iostream>
4 #include <unistd.h>
5 
6 eq_dummy::eq_dummy(const EqFctParameters& p)
7 : EqFct(p), prop_someInt("SOME_INT Some integer property", this),
8  prop_someReadonlyInt("SOME_RO_INT Some read-only integer property", this), prop_someFloat("SOME_FLOAT", this),
9  prop_someDouble("SOME_DOUBLE", this), prop_someString("SOME_STRING", this), prop_someStatus("SOME_STATUS", this),
10  prop_someBit("SOME_BIT", 0, &prop_someStatus.stat_, this), prop_someIntArray("SOME_INT_ARRAY", 42, this),
11  prop_someShortArray("SOME_SHORT_ARRAY", 5, this), prop_someLongArray("SOME_LONG_ARRAY", 5, this),
12  prop_someFloatArray("SOME_FLOAT_ARRAY", 5, this), prop_someDoubleArray("SOME_DOUBLE_ARRAY", 5, this),
13  prop_someSpectrum("SOME_SPECTRUM", 100, this), prop_someIIII("SOME_IIII", this), prop_someIFFF("SOME_IFFF", this),
14  prop_someImage("SOME_IMAGE", 640 * 460, this), prop_unsupportedDataType("UNSUPPORTED_DATA_TYPE", this),
15  prop_someZMQInt("SOME_ZMQINT", this),
16  // counter well below the 10000 used by testUnifiesBackendTest
17  counter(1234), startTime(1584020594) {
18  prop_someReadonlyInt.set_ro_access();
19 }
20 
22 
24  prop_someInt.set_value(42);
25  prop_someInt.set_mpnum(counter);
26  prop_someInt.set_tmstmp(startTime, 0);
27 
28  prop_someFloat.set_value(3.1415f);
29  prop_someFloat.set_mpnum(counter);
30  prop_someFloat.set_tmstmp(startTime, 0);
31 
32  prop_someDouble.set_value(2.8);
33  prop_someDouble.set_mpnum(counter);
34  prop_someDouble.set_tmstmp(startTime, 0);
35 
36  prop_someString.set_value("The quick brown fox jumps over the lazy dog.");
37  prop_someString.set_mpnum(counter);
38  prop_someString.set_tmstmp(startTime, 0);
39 
40  prop_someStatus.set_value(3);
41  prop_someStatus.set_mpnum(counter);
42  prop_someStatus.set_tmstmp(startTime, 0);
43 
44  prop_someBit.set_mpnum(counter);
45  prop_someBit.set_tmstmp(startTime, 0);
46 
47  for(int i = 0; i < 42; i++) prop_someIntArray.set_value(3 * i + 120, i);
48  prop_someIntArray.set_mpnum(counter);
49  prop_someIntArray.set_tmstmp(startTime, 0);
50 
51  for(int i = 0; i < 5; i++) prop_someShortArray.set_value(10 + i, i);
52  prop_someShortArray.set_mpnum(counter);
53  prop_someShortArray.set_tmstmp(startTime, 0);
54 
55  for(int i = 0; i < 5; i++) prop_someLongArray.set_value(10 + i, i);
56  prop_someLongArray.set_mpnum(counter);
57  prop_someLongArray.set_tmstmp(startTime, 0);
58 
59  for(int i = 0; i < 5; i++) prop_someFloatArray.set_value((float)i / 1000.F, i);
60  prop_someFloatArray.set_mpnum(counter);
61  prop_someFloatArray.set_tmstmp(startTime, 0);
62 
63  for(int i = 0; i < 5; i++) prop_someDoubleArray.set_value((double)i / 333., i);
64  prop_someDoubleArray.set_mpnum(counter);
65  prop_someDoubleArray.set_tmstmp(startTime, 0);
66 
67  for(int i = 0; i < 100; i++) prop_someSpectrum.fill_spectrum(i, (float)i / 42.F);
68  prop_someSpectrum.macro_pulse(counter, 0);
69  prop_someSpectrum.set_tmstmp(startTime, 0, 0);
70 
71  prop_someIIII.set_value(10, 11, 12, 13);
72  prop_someIIII.set_mpnum(counter);
73  prop_someIIII.set_tmstmp(startTime, 0);
74 
75  prop_someIFFF.set_value(10, 2.71828f, 3.14159f, 197.327f);
76  prop_someIFFF.set_mpnum(counter);
77  prop_someIFFF.set_tmstmp(startTime, 0);
78 
79  IMH imh{};
80  imh.image_format = TTF2_IMAGE_FORMAT_GRAY;
81  imh.bpp = 2;
82  imh.width = 200;
83  imh.height = 100;
84  imh.event = counter;
85  imh.frame = counter;
86  prop_someImage.set_img_header(&imh); // copies header
87  prop_someImage.fill_image(1);
88  prop_someImage.set_event_id(doocs::EventId{counter});
89  prop_someImage.set_tmstmp(startTime, 0);
90 
91  prop_someZMQInt.set_value(0);
92 }
93 
95  // enable data messaging for property
96  int res = prop_someZMQInt.set_mode(DMSG_EN);
97  if(res != 0) {
98  std::cout << "Could not enable ZeroMQ messaging for prop_someZMQInt. Code: " << res << std::endl;
99  exit(1);
100  }
101 }
102 
104  set_global_mpnum(counter);
105 
106  // set new value of ZMQINT
107  prop_someZMQInt.set_value(prop_someZMQInt.value() + 1);
108  prop_someZMQInt.set_mpnum(counter);
109  prop_someZMQInt.set_tmstmp(startTime, 0);
110 
111  // Attach new MP number and timestamp
112  prop_someInt.set_mpnum(counter);
113  prop_someInt.set_tmstmp(startTime, 0);
114 
115  prop_someFloat.set_mpnum(counter);
116  prop_someFloat.set_tmstmp(startTime, 0);
117 
118  prop_someDouble.set_mpnum(counter);
119  prop_someDouble.set_tmstmp(startTime, 0);
120 
121  prop_someString.set_mpnum(counter);
122  prop_someString.set_tmstmp(startTime, 0);
123 
124  prop_someStatus.set_mpnum(counter);
125  prop_someStatus.set_tmstmp(startTime, 0);
126 
127  prop_someBit.set_mpnum(counter);
128  prop_someBit.set_tmstmp(startTime, 0);
129 
130  prop_someIntArray.set_mpnum(counter);
131  prop_someIntArray.set_tmstmp(startTime, 0);
132 
133  prop_someShortArray.set_mpnum(counter);
134  prop_someShortArray.set_tmstmp(startTime, 0);
135 
136  prop_someLongArray.set_mpnum(counter);
137  prop_someLongArray.set_tmstmp(startTime, 0);
138 
139  prop_someFloatArray.set_mpnum(counter);
140  prop_someFloatArray.set_tmstmp(startTime, 0);
141 
142  prop_someDoubleArray.set_mpnum(counter);
143  prop_someDoubleArray.set_tmstmp(startTime, 0);
144 
145  prop_someSpectrum.macro_pulse(counter, 0);
146  prop_someSpectrum.set_tmstmp(startTime, 0, 0);
147 
148  prop_someIIII.set_mpnum(counter);
149  prop_someIIII.set_tmstmp(startTime, 0);
150 
151  prop_someIFFF.set_mpnum(counter);
152  prop_someIFFF.set_tmstmp(startTime, 0);
153 
154  prop_someImage.set_mpnum(counter);
155  prop_someImage.set_tmstmp(startTime, 0);
156 
157  // publish new value via ZeroMQ
158  dmsg_info_t db;
159  db.sec = startTime++;
160  db.usec = 0;
161  db.ident = counter++;
162  db.stat = 0;
163  prop_someZMQInt.send(&db);
164 
165  // wait some time to limit the rate
166  usleep(10000);
167 }
eq_dummy::prop_someImage
D_image prop_someImage
Definition: eq_dummy.h:29
eq_dummy::prop_someIIII
D_iiii prop_someIIII
Definition: eq_dummy.h:27
eq_dummy::prop_someString
D_string prop_someString
Definition: eq_dummy.h:16
eq_dummy::prop_someBit
D_bit prop_someBit
Definition: eq_dummy.h:18
eq_dummy::prop_someFloatArray
D_floatarray prop_someFloatArray
Definition: eq_dummy.h:23
eq_dummy::init
void init()
Definition: eq_dummy.cc:23
eq_dummy::startTime
int64_t startTime
Definition: eq_dummy.h:35
eq_dummy::eq_dummy
eq_dummy(const EqFctParameters &p)
Definition: eq_dummy.cc:6
eq_dummy::prop_someLongArray
D_longarray prop_someLongArray
Definition: eq_dummy.h:22
eq_dummy::update
void update()
Definition: eq_dummy.cc:103
eq_dummy::prop_someStatus
D_status prop_someStatus
Definition: eq_dummy.h:17
eq_dummy::prop_someZMQInt
D_int prop_someZMQInt
Definition: eq_dummy.h:32
eq_dummy.h
eq_dummy::prop_someSpectrum
D_spectrum prop_someSpectrum
Definition: eq_dummy.h:26
eq_dummy::post_init
void post_init()
Definition: eq_dummy.cc:94
eq_dummy::prop_someInt
D_int prop_someInt
Definition: eq_dummy.h:12
eq_dummy::prop_someDouble
D_double prop_someDouble
Definition: eq_dummy.h:15
eq_dummy::prop_someShortArray
D_shortarray prop_someShortArray
Definition: eq_dummy.h:21
eq_dummy::prop_someIntArray
D_intarray prop_someIntArray
Definition: eq_dummy.h:20
eq_dummy::counter
int64_t counter
Definition: eq_dummy.h:34
eq_dummy::prop_someReadonlyInt
D_int prop_someReadonlyInt
Definition: eq_dummy.h:13
eq_dummy::prop_someDoubleArray
D_doublearray prop_someDoubleArray
Definition: eq_dummy.h:24
eq_dummy::~eq_dummy
virtual ~eq_dummy()
Definition: eq_dummy.cc:21
eq_dummy::prop_someIFFF
D_ifff prop_someIFFF
Definition: eq_dummy.h:28
eq_dummy::prop_someFloat
D_float prop_someFloat
Definition: eq_dummy.h:14