7 #define BOOST_TEST_MODULE testDoocsBackend
10 #include <doocs-server-test-helper/doocsServerTestHelper.h>
11 #include <doocs-server-test-helper/ThreadedDoocsServer.h>
12 #include <doocs/EqCall.h>
14 #include <ChimeraTK/Device.h>
15 #include <ChimeraTK/MappedImage.h>
16 #include <ChimeraTK/TransferGroup.h>
18 #include <boost/filesystem.hpp>
19 #include <boost/test/included/unit_test.hpp>
28 using namespace boost::unit_test_framework;
33 static bool file_exists(
const std::string& name);
34 static void createCacheFileFromCdd(
const std::string& cdd);
35 static void deleteFile(
const std::string& filename);
40 : ThreadedDoocsServer(
"testDoocsBackend.conf", boost::unit_test::framework::master_test_suite().argc,
41 boost::unit_test::framework::master_test_suite().argv,
eq_dummy::createServer()) {
45 cacheFile1 =
"cache1_" + rpc_no +
".xml";
46 cacheFile2 =
"cache2_" + rpc_no +
".xml";
49 DoocsServer1 =
"(doocs:doocs://localhost:" + rpcNo() +
"/F/D)";
50 DoocsServer1_cached =
"(doocs:doocs://localhost:" + rpcNo() +
"/F/D?cacheFile=" + cacheFile1 +
"&updateCache=1)";
51 DoocsServer2 =
"(doocs:doocs://localhost:" + rpcNo() +
"/F/D/MYDUMMY)";
53 "(doocs:doocs://localhost:" + rpcNo() +
"/F/D/MYDUMMY?cacheFile=" + cacheFile2 +
"&updateCache=1)";
58 doocs::EqData src, dst;
59 ea.adr(
"doocs://localhost:" + rpcNo() +
"/F/D/MYDUMMY/SOME_ZMQINT");
60 while(eq.get(&ea, &src, &dst)) usleep(100000);
64 boost::filesystem::remove(cacheFile1);
65 boost::filesystem::remove(cacheFile2);
91 ChimeraTK::Device device;
93 BOOST_TEST(device.isOpened() ==
false);
95 BOOST_TEST(device.isOpened() ==
true);
97 TwoDRegisterAccessor<int32_t> acc_someInt_as_int(device.getTwoDRegisterAccessor<int32_t>(
"MYDUMMY/SOME_INT"));
98 BOOST_TEST(acc_someInt_as_int.getVersionNumber() == VersionNumber{nullptr});
100 BOOST_TEST(acc_someInt_as_int.getNChannels() == 1);
101 BOOST_TEST(acc_someInt_as_int.getNElementsPerChannel() == 1);
102 acc_someInt_as_int.read();
103 BOOST_TEST(acc_someInt_as_int[0][0] == 42);
105 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_INT", 120);
107 BOOST_TEST(acc_someInt_as_int[0][0] == 42);
109 acc_someInt_as_int.read();
110 BOOST_TEST(acc_someInt_as_int[0][0] == 120);
114 acc_someInt_as_int[0][0] = 1234;
115 BOOST_TEST(DoocsServerTestHelper::doocsGet<int>(
"//MYDUMMY/SOME_INT") == 120);
116 VersionNumber nextVersion;
117 acc_someInt_as_int.write(nextVersion);
118 BOOST_TEST(DoocsServerTestHelper::doocsGet<int>(
"//MYDUMMY/SOME_INT") == 1234);
119 BOOST_TEST(acc_someInt_as_int.getVersionNumber() == nextVersion);
121 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_INT", 42);
123 TwoDRegisterAccessor<double> acc_someInt_as_double(device.getTwoDRegisterAccessor<
double>(
"MYDUMMY/SOME_INT"));
124 BOOST_TEST(acc_someInt_as_double.getNChannels() == 1);
125 BOOST_TEST(acc_someInt_as_double.getNElementsPerChannel() == 1);
126 acc_someInt_as_double.read();
127 BOOST_CHECK_CLOSE(acc_someInt_as_double[0][0], 42, 0.001);
129 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_INT", 120);
131 BOOST_CHECK_CLOSE(acc_someInt_as_double[0][0], 42, 0.001);
132 acc_someInt_as_double.read();
133 BOOST_CHECK_CLOSE(acc_someInt_as_double[0][0], 120, 0.001);
135 acc_someInt_as_double[0][0] = 1234.3;
136 BOOST_TEST(DoocsServerTestHelper::doocsGet<int>(
"//MYDUMMY/SOME_INT") == 120);
137 acc_someInt_as_double.write();
138 BOOST_TEST(DoocsServerTestHelper::doocsGet<int>(
"//MYDUMMY/SOME_INT") == 1234);
140 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_INT", 42);
142 TwoDRegisterAccessor<float> acc_someInt_as_float(device.getTwoDRegisterAccessor<
float>(
"MYDUMMY/SOME_INT"));
143 BOOST_TEST(acc_someInt_as_float.getNChannels() == 1);
144 BOOST_TEST(acc_someInt_as_float.getNElementsPerChannel() == 1);
145 acc_someInt_as_float.read();
146 BOOST_CHECK_CLOSE(acc_someInt_as_float[0][0], 42, 0.001);
148 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_INT", 120);
150 BOOST_CHECK_CLOSE(acc_someInt_as_float[0][0], 42, 0.001);
151 acc_someInt_as_float.read();
152 BOOST_CHECK_CLOSE(acc_someInt_as_float[0][0], 120, 0.001);
154 acc_someInt_as_float[0][0] = 1233.9;
155 BOOST_TEST(DoocsServerTestHelper::doocsGet<int>(
"//MYDUMMY/SOME_INT") == 120);
156 acc_someInt_as_float.write();
157 BOOST_TEST(DoocsServerTestHelper::doocsGet<int>(
"//MYDUMMY/SOME_INT") == 1234);
159 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_INT", 42);
161 TwoDRegisterAccessor<std::string> acc_someInt_as_string(
162 device.getTwoDRegisterAccessor<std::string>(
"MYDUMMY/SOME_INT"));
163 BOOST_TEST(acc_someInt_as_string.getNChannels() == 1);
164 BOOST_TEST(acc_someInt_as_string.getNElementsPerChannel() == 1);
165 acc_someInt_as_string.read();
166 BOOST_TEST(acc_someInt_as_string[0][0] ==
"42");
168 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_INT", 120);
170 BOOST_TEST(acc_someInt_as_string[0][0] ==
"42");
171 acc_someInt_as_string.read();
172 BOOST_TEST(acc_someInt_as_string[0][0] ==
"120");
174 acc_someInt_as_string[0][0] =
"1234";
175 BOOST_TEST(DoocsServerTestHelper::doocsGet<int>(
"//MYDUMMY/SOME_INT") == 120);
176 acc_someInt_as_string.write();
177 BOOST_TEST(DoocsServerTestHelper::doocsGet<int>(
"//MYDUMMY/SOME_INT") == 1234);
180 BOOST_TEST(device.isOpened() ==
false);
186 ChimeraTK::Device device;
189 TwoDRegisterAccessor<float> acc_someFloat_as_float(device.getTwoDRegisterAccessor<
float>(
"MYDUMMY/SOME_FLOAT"));
190 BOOST_TEST(acc_someFloat_as_float.getNChannels() == 1);
191 BOOST_TEST(acc_someFloat_as_float.getNElementsPerChannel() == 1);
192 acc_someFloat_as_float.read();
193 BOOST_CHECK_CLOSE(acc_someFloat_as_float[0][0], 3.1415, 0.00001);
195 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_FLOAT", 123.456);
197 BOOST_CHECK_CLOSE(acc_someFloat_as_float[0][0], 3.1415, 0.00001);
199 acc_someFloat_as_float.read();
200 BOOST_CHECK_CLOSE(acc_someFloat_as_float[0][0], 123.456, 0.00001);
204 acc_someFloat_as_float[0][0] = 666.333;
205 BOOST_CHECK_CLOSE(DoocsServerTestHelper::doocsGet<float>(
"//MYDUMMY/SOME_FLOAT"), 123.456, 0.00001);
206 VersionNumber nextVersion;
207 acc_someFloat_as_float.write(nextVersion);
208 BOOST_CHECK_CLOSE(DoocsServerTestHelper::doocsGet<float>(
"//MYDUMMY/SOME_FLOAT"), 666.333, 0.00001);
209 BOOST_TEST(acc_someFloat_as_float.getVersionNumber() == nextVersion);
211 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_FLOAT", 3.1415);
213 TwoDRegisterAccessor<double> acc_someFloat_as_double(device.getTwoDRegisterAccessor<
double>(
"MYDUMMY/SOME_FLOAT"));
214 BOOST_TEST(acc_someFloat_as_double.getNChannels() == 1);
215 BOOST_TEST(acc_someFloat_as_double.getNElementsPerChannel() == 1);
216 acc_someFloat_as_double.read();
217 BOOST_CHECK_CLOSE(acc_someFloat_as_double[0][0], 3.1415, 0.00001);
219 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_FLOAT", 123.456);
221 BOOST_CHECK_CLOSE(acc_someFloat_as_double[0][0], 3.1415, 0.00001);
222 acc_someFloat_as_double.read();
223 BOOST_CHECK_CLOSE(acc_someFloat_as_double[0][0], 123.456, 0.00001);
225 acc_someFloat_as_double[0][0] = 1234.3;
226 BOOST_CHECK_CLOSE(DoocsServerTestHelper::doocsGet<float>(
"//MYDUMMY/SOME_FLOAT"), 123.456, 0.00001);
227 acc_someFloat_as_double.write();
228 BOOST_CHECK_CLOSE(DoocsServerTestHelper::doocsGet<float>(
"//MYDUMMY/SOME_FLOAT"), 1234.3, 0.00001);
230 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_FLOAT", 3.1415);
232 TwoDRegisterAccessor<int> acc_someFloat_as_int(device.getTwoDRegisterAccessor<
int>(
"MYDUMMY/SOME_FLOAT"));
233 BOOST_TEST(acc_someFloat_as_int.getNChannels() == 1);
234 BOOST_TEST(acc_someFloat_as_int.getNElementsPerChannel() == 1);
235 acc_someFloat_as_int.read();
236 BOOST_TEST(acc_someFloat_as_int[0][0] == 3);
238 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_FLOAT", 119.9);
240 BOOST_TEST(acc_someFloat_as_int[0][0] == 3);
241 acc_someFloat_as_int.read();
242 BOOST_TEST(acc_someFloat_as_int[0][0] == 120);
244 acc_someFloat_as_int[0][0] = 1234;
245 BOOST_CHECK_CLOSE(DoocsServerTestHelper::doocsGet<float>(
"//MYDUMMY/SOME_FLOAT"), 119.9, 0.00001);
246 acc_someFloat_as_int.write();
247 BOOST_CHECK_CLOSE(DoocsServerTestHelper::doocsGet<float>(
"//MYDUMMY/SOME_FLOAT"), 1234.0, 0.00001);
249 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_FLOAT", 3.1415);
251 TwoDRegisterAccessor<std::string> acc_someFloat_as_string(
252 device.getTwoDRegisterAccessor<std::string>(
"MYDUMMY/SOME_FLOAT"));
253 BOOST_TEST(acc_someFloat_as_string.getNChannels() == 1);
254 BOOST_TEST(acc_someFloat_as_string.getNElementsPerChannel() == 1);
255 acc_someFloat_as_string.read();
256 BOOST_CHECK_CLOSE(std::stod(acc_someFloat_as_string[0][0]), 3.1415, 0.00001);
258 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_FLOAT", 120);
260 BOOST_CHECK_CLOSE(std::stod(acc_someFloat_as_string[0][0]), 3.1415, 0.00001);
261 acc_someFloat_as_string.read();
262 BOOST_TEST(acc_someFloat_as_string[0][0] ==
"120.000000");
264 acc_someFloat_as_string[0][0] =
"1234.5678";
265 BOOST_CHECK_CLOSE(DoocsServerTestHelper::doocsGet<float>(
"//MYDUMMY/SOME_FLOAT"), 120, 0.00001);
266 acc_someFloat_as_string.write();
267 BOOST_CHECK_CLOSE(DoocsServerTestHelper::doocsGet<float>(
"//MYDUMMY/SOME_FLOAT"), 1234.5678, 0.00001);
275 ChimeraTK::Device device;
278 TwoDRegisterAccessor<float> acc_someDouble_as_float(device.getTwoDRegisterAccessor<
float>(
"MYDUMMY/SOME_DOUBLE"));
279 BOOST_TEST(acc_someDouble_as_float.getNChannels() == 1);
280 BOOST_TEST(acc_someDouble_as_float.getNElementsPerChannel() == 1);
281 acc_someDouble_as_float.read();
282 BOOST_CHECK_CLOSE(acc_someDouble_as_float[0][0], 2.8, 0.00001);
284 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_DOUBLE", 123.456);
286 BOOST_CHECK_CLOSE(acc_someDouble_as_float[0][0], 2.8, 0.00001);
288 acc_someDouble_as_float.read();
289 BOOST_CHECK_CLOSE(acc_someDouble_as_float[0][0], 123.456, 0.00001);
293 acc_someDouble_as_float[0][0] = 666.333;
294 BOOST_CHECK_CLOSE(DoocsServerTestHelper::doocsGet<float>(
"//MYDUMMY/SOME_DOUBLE"), 123.456, 0.00001);
295 VersionNumber nextVersion;
296 acc_someDouble_as_float.write(nextVersion);
297 BOOST_CHECK_CLOSE(DoocsServerTestHelper::doocsGet<float>(
"//MYDUMMY/SOME_DOUBLE"), 666.333, 0.00001);
298 BOOST_TEST(acc_someDouble_as_float.getVersionNumber() == nextVersion);
300 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_DOUBLE", 3.1415);
302 TwoDRegisterAccessor<double> acc_someDouble_as_double(device.getTwoDRegisterAccessor<
double>(
"MYDUMMY/SOME_DOUBLE"));
303 BOOST_TEST(acc_someDouble_as_double.getNChannels() == 1);
304 BOOST_TEST(acc_someDouble_as_double.getNElementsPerChannel() == 1);
305 acc_someDouble_as_double.read();
306 BOOST_CHECK_CLOSE(acc_someDouble_as_double[0][0], 3.1415, 0.00001);
308 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_DOUBLE", 123.456);
310 BOOST_CHECK_CLOSE(acc_someDouble_as_double[0][0], 3.1415, 0.00001);
311 acc_someDouble_as_double.read();
312 BOOST_CHECK_CLOSE(acc_someDouble_as_double[0][0], 123.456, 0.00001);
314 acc_someDouble_as_double[0][0] = 1234.3;
315 BOOST_CHECK_CLOSE(DoocsServerTestHelper::doocsGet<float>(
"//MYDUMMY/SOME_DOUBLE"), 123.456, 0.00001);
316 acc_someDouble_as_double.write();
317 BOOST_CHECK_CLOSE(DoocsServerTestHelper::doocsGet<float>(
"//MYDUMMY/SOME_DOUBLE"), 1234.3, 0.00001);
319 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_FLOAT", 3.1415);
321 TwoDRegisterAccessor<int> acc_someDouble_as_int(device.getTwoDRegisterAccessor<
int>(
"MYDUMMY/SOME_FLOAT"));
322 BOOST_TEST(acc_someDouble_as_int.getNChannels() == 1);
323 BOOST_TEST(acc_someDouble_as_int.getNElementsPerChannel() == 1);
324 acc_someDouble_as_int.read();
325 BOOST_TEST(acc_someDouble_as_int[0][0] == 3);
327 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_FLOAT", 119.9);
329 BOOST_TEST(acc_someDouble_as_int[0][0] == 3);
330 acc_someDouble_as_int.read();
331 BOOST_TEST(acc_someDouble_as_int[0][0] == 120);
333 acc_someDouble_as_int[0][0] = 1234;
334 BOOST_CHECK_CLOSE(DoocsServerTestHelper::doocsGet<float>(
"//MYDUMMY/SOME_FLOAT"), 119.9, 0.00001);
335 acc_someDouble_as_int.write();
336 BOOST_CHECK_CLOSE(DoocsServerTestHelper::doocsGet<float>(
"//MYDUMMY/SOME_FLOAT"), 1234.0, 0.00001);
338 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_FLOAT", 3.1415);
340 TwoDRegisterAccessor<std::string> acc_someDouble_as_string(
341 device.getTwoDRegisterAccessor<std::string>(
"MYDUMMY/SOME_FLOAT"));
342 BOOST_TEST(acc_someDouble_as_string.getNChannels() == 1);
343 BOOST_TEST(acc_someDouble_as_string.getNElementsPerChannel() == 1);
344 acc_someDouble_as_string.read();
345 BOOST_CHECK_CLOSE(std::stod(acc_someDouble_as_string[0][0]), 3.1415, 0.00001);
347 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_FLOAT", 120);
349 BOOST_CHECK_CLOSE(std::stod(acc_someDouble_as_string[0][0]), 3.1415, 0.00001);
350 acc_someDouble_as_string.read();
351 BOOST_TEST(acc_someDouble_as_string[0][0] ==
"120.000000");
353 acc_someDouble_as_string[0][0] =
"1234.5678";
354 BOOST_CHECK_CLOSE(DoocsServerTestHelper::doocsGet<float>(
"//MYDUMMY/SOME_FLOAT"), 120, 0.00001);
355 acc_someDouble_as_string.write();
356 BOOST_CHECK_CLOSE(DoocsServerTestHelper::doocsGet<float>(
"//MYDUMMY/SOME_FLOAT"), 1234.5678, 0.00001);
364 ChimeraTK::Device device;
367 TwoDRegisterAccessor<std::string> acc_someString(device.getTwoDRegisterAccessor<std::string>(
"MYDUMMY/SOME_STRING"));
368 BOOST_TEST(acc_someString.getNChannels() == 1);
369 BOOST_TEST(acc_someString.getNElementsPerChannel() == 1);
370 auto oldVersion = acc_someString.getVersionNumber();
371 acc_someString.read();
372 BOOST_TEST(acc_someString[0][0] ==
"The quick brown fox jumps over the lazy dog.");
373 BOOST_TEST(acc_someString.getVersionNumber() != oldVersion);
375 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_STRING",
"Something else.");
377 BOOST_TEST(acc_someString[0][0] ==
"The quick brown fox jumps over the lazy dog.");
378 acc_someString.read();
379 BOOST_TEST(acc_someString[0][0] ==
"Something else.");
381 acc_someString[0][0] =
"Even different!";
382 BOOST_TEST(DoocsServerTestHelper::doocsGet<std::string>(
"//MYDUMMY/SOME_STRING") ==
"Something else.");
383 VersionNumber nextVersion;
384 acc_someString.write(nextVersion);
385 BOOST_TEST(DoocsServerTestHelper::doocsGet<std::string>(
"//MYDUMMY/SOME_STRING") ==
"Even different!");
386 BOOST_TEST(acc_someString.getVersionNumber() == nextVersion);
394 ChimeraTK::Device device;
397 TwoDRegisterAccessor<int> acc_someArray(device.getTwoDRegisterAccessor<
int>(
"MYDUMMY/SOME_INT_ARRAY"));
398 BOOST_TEST(acc_someArray.getNChannels() == 1);
399 BOOST_TEST(acc_someArray.getNElementsPerChannel() == 42);
400 acc_someArray.read();
401 for(
int i = 0; i < 42; i++) BOOST_TEST(acc_someArray[0][i] == 3 * i + 120);
403 std::vector<int> vals(42);
404 for(
int i = 0; i < 42; i++) vals[i] = -55 * i;
405 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_INT_ARRAY", vals);
407 for(
int i = 0; i < 42; i++) BOOST_TEST(acc_someArray[0][i] == 3 * i + 120);
409 acc_someArray.read();
410 for(
int i = 0; i < 42; i++) BOOST_TEST(acc_someArray[0][i] == -55 * i);
414 for(
int i = 0; i < 42; i++) acc_someArray[0][i] = i - 21;
415 vals = DoocsServerTestHelper::doocsGetArray<int>(
"//MYDUMMY/SOME_INT_ARRAY");
416 for(
int i = 0; i < 42; i++) BOOST_TEST(vals[i] == -55 * i);
417 VersionNumber nextVersion;
418 acc_someArray.write(nextVersion);
419 vals = DoocsServerTestHelper::doocsGetArray<int>(
"//MYDUMMY/SOME_INT_ARRAY");
420 for(
int i = 0; i < 42; i++) BOOST_TEST(vals[i] == i - 21);
421 BOOST_TEST(acc_someArray.getVersionNumber() == nextVersion);
424 TwoDRegisterAccessor<double> acc_someArrayAsDouble(device.getTwoDRegisterAccessor<
double>(
"MYDUMMY/SOME_INT_ARRAY"));
425 acc_someArrayAsDouble.read();
426 for(
int i = 0; i < 5; i++) BOOST_CHECK_CLOSE(acc_someArrayAsDouble[0][i], i - 21, 0.00001);
427 for(
int i = 0; i < 5; i++) acc_someArrayAsDouble[0][i] = 2.4 * i;
428 acc_someArrayAsDouble.write();
429 vals = DoocsServerTestHelper::doocsGetArray<int>(
"//MYDUMMY/SOME_INT_ARRAY");
430 for(
int i = 0; i < 5; i++) BOOST_CHECK_CLOSE(vals[i], round(2.4 * i), 0.00001);
433 TwoDRegisterAccessor<std::string> acc_someArrayAsString(
434 device.getTwoDRegisterAccessor<std::string>(
"MYDUMMY/SOME_INT_ARRAY"));
435 acc_someArrayAsString.read();
436 for(
int i = 0; i < 5; i++) BOOST_CHECK_CLOSE(std::stod(acc_someArrayAsString[0][i]), round(2.4 * i), 0.00001);
437 for(
int i = 0; i < 5; i++) acc_someArrayAsString[0][i] = std::to_string(3 * i);
438 acc_someArrayAsString.write();
439 vals = DoocsServerTestHelper::doocsGetArray<int>(
"//MYDUMMY/SOME_INT_ARRAY");
440 for(
int i = 0; i < 5; i++) BOOST_TEST(vals[i] == 3 * i);
448 ChimeraTK::Device device;
451 TwoDRegisterAccessor<int> acc_someArray(device.getTwoDRegisterAccessor<
int>(
"MYDUMMY/SOME_SHORT_ARRAY"));
452 BOOST_TEST(acc_someArray.getNChannels() == 1);
453 BOOST_TEST(acc_someArray.getNElementsPerChannel() == 5);
454 acc_someArray.read();
455 for(
int i = 0; i < 5; i++) BOOST_TEST(acc_someArray[0][i] == 10 + i);
457 std::vector<short> vals(5);
458 for(
int i = 0; i < 5; i++) vals[i] = -55 * i;
459 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_SHORT_ARRAY", vals);
461 for(
int i = 0; i < 5; i++) BOOST_TEST(acc_someArray[0][i] == 10 + i);
463 acc_someArray.read();
464 for(
int i = 0; i < 5; i++) BOOST_TEST(acc_someArray[0][i] == -55 * i);
468 std::vector<int> vals2(5);
469 for(
int i = 0; i < 5; i++) acc_someArray[0][i] = i - 21;
470 vals2 = DoocsServerTestHelper::doocsGetArray<int>(
"//MYDUMMY/SOME_SHORT_ARRAY");
471 for(
int i = 0; i < 5; i++) BOOST_TEST(vals2[i] == -55 * i);
472 VersionNumber nextVersion;
473 acc_someArray.write(nextVersion);
474 vals2 = DoocsServerTestHelper::doocsGetArray<int>(
"//MYDUMMY/SOME_SHORT_ARRAY");
475 for(
int i = 0; i < 5; i++) BOOST_TEST(vals2[i] == i - 21);
476 BOOST_TEST(acc_someArray.getVersionNumber() == nextVersion);
484 ChimeraTK::Device device;
487 TwoDRegisterAccessor<int> acc_someArray(device.getTwoDRegisterAccessor<
int>(
"MYDUMMY/SOME_LONG_ARRAY"));
488 BOOST_TEST(acc_someArray.getNChannels() == 1);
489 BOOST_TEST(acc_someArray.getNElementsPerChannel() == 5);
490 acc_someArray.read();
491 for(
int i = 0; i < 5; i++) BOOST_TEST(acc_someArray[0][i] == 10 + i);
493 std::vector<int64_t> vals(5);
494 for(
int i = 0; i < 5; i++) vals[i] = -55 * i;
495 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_LONG_ARRAY", vals);
497 for(
int i = 0; i < 5; i++) BOOST_TEST(acc_someArray[0][i] == 10 + i);
499 acc_someArray.read();
500 for(
int i = 0; i < 5; i++) BOOST_TEST(acc_someArray[0][i] == -55 * i);
504 std::vector<int> vals2(5);
505 for(
int i = 0; i < 5; i++) acc_someArray[0][i] = i - 21;
506 vals2 = DoocsServerTestHelper::doocsGetArray<int>(
"//MYDUMMY/SOME_LONG_ARRAY");
507 for(
int i = 0; i < 5; i++) BOOST_TEST(vals2[i] == -55 * i);
508 VersionNumber nextVersion;
509 acc_someArray.write(nextVersion);
510 vals2 = DoocsServerTestHelper::doocsGetArray<int>(
"//MYDUMMY/SOME_LONG_ARRAY");
511 for(
int i = 0; i < 5; i++) BOOST_TEST(vals2[i] == i - 21);
512 BOOST_TEST(acc_someArray.getVersionNumber() == nextVersion);
520 ChimeraTK::Device device;
523 TwoDRegisterAccessor<float> acc_someArray(device.getTwoDRegisterAccessor<
float>(
"MYDUMMY/SOME_FLOAT_ARRAY"));
524 BOOST_TEST(acc_someArray.getNChannels() == 1);
525 BOOST_TEST(acc_someArray.getNElementsPerChannel() == 5);
526 auto oldVersion = acc_someArray.getVersionNumber();
527 acc_someArray.read();
528 for(
int i = 0; i < 5; i++) BOOST_CHECK_CLOSE(acc_someArray[0][i], i / 1000., 0.00001);
529 BOOST_TEST(acc_someArray.getVersionNumber() != oldVersion);
531 std::vector<float> vals(5);
532 for(
int i = 0; i < 5; i++) vals[i] = -3.14159265 * i;
533 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_FLOAT_ARRAY", vals);
535 for(
int i = 0; i < 5; i++) BOOST_CHECK_CLOSE(acc_someArray[0][i], i / 1000., 0.00001);
536 acc_someArray.read();
537 for(
int i = 0; i < 5; i++) BOOST_CHECK_CLOSE(acc_someArray[0][i], -3.14159265 * i, 0.00001);
539 for(
int i = 0; i < 5; i++) acc_someArray[0][i] = 2. / (i + 0.01);
540 vals = DoocsServerTestHelper::doocsGetArray<float>(
"//MYDUMMY/SOME_FLOAT_ARRAY");
541 for(
int i = 0; i < 5; i++) BOOST_CHECK_CLOSE(vals[i], -3.14159265 * i, 0.00001);
542 VersionNumber nextVersion;
543 acc_someArray.write(nextVersion);
544 vals = DoocsServerTestHelper::doocsGetArray<float>(
"//MYDUMMY/SOME_FLOAT_ARRAY");
545 for(
int i = 0; i < 5; i++) BOOST_CHECK_CLOSE(vals[i], 2. / (i + 0.01), 0.00001);
546 BOOST_TEST(acc_someArray.getVersionNumber() == nextVersion);
554 ChimeraTK::Device device;
557 TwoDRegisterAccessor<double> acc_someArray(device.getTwoDRegisterAccessor<
double>(
"MYDUMMY/SOME_DOUBLE_ARRAY"));
558 BOOST_TEST(acc_someArray.getNChannels() == 1);
559 BOOST_TEST(acc_someArray.getNElementsPerChannel() == 5);
560 auto oldVersion = acc_someArray.getVersionNumber();
561 acc_someArray.read();
562 for(
int i = 0; i < 5; i++) BOOST_CHECK_CLOSE(acc_someArray[0][i], i / 333., 0.00001);
563 BOOST_TEST(acc_someArray.getVersionNumber() != oldVersion);
565 std::vector<double> vals(5);
566 for(
int i = 0; i < 5; i++) vals[i] = -3.14159265 * i;
567 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_DOUBLE_ARRAY", vals);
569 for(
int i = 0; i < 5; i++) BOOST_CHECK_CLOSE(acc_someArray[0][i], i / 333., 0.00001);
570 acc_someArray.read();
571 for(
int i = 0; i < 5; i++) BOOST_CHECK_CLOSE(acc_someArray[0][i], -3.14159265 * i, 0.00001);
573 for(
int i = 0; i < 5; i++) acc_someArray[0][i] = 2. / (i + 0.01);
574 vals = DoocsServerTestHelper::doocsGetArray<double>(
"//MYDUMMY/SOME_DOUBLE_ARRAY");
575 for(
int i = 0; i < 5; i++) BOOST_CHECK_CLOSE(vals[i], -3.14159265 * i, 0.00001);
576 VersionNumber nextVersion;
577 acc_someArray.write(nextVersion);
578 vals = DoocsServerTestHelper::doocsGetArray<double>(
"//MYDUMMY/SOME_DOUBLE_ARRAY");
579 for(
int i = 0; i < 5; i++) BOOST_CHECK_CLOSE(vals[i], 2. / (i + 0.01), 0.00001);
580 BOOST_TEST(acc_someArray.getVersionNumber() == nextVersion);
583 TwoDRegisterAccessor<int> acc_someArrayAsInt(device.getTwoDRegisterAccessor<
int>(
"MYDUMMY/SOME_DOUBLE_ARRAY"));
584 acc_someArrayAsInt.read();
585 for(
int i = 0; i < 5; i++) BOOST_TEST(acc_someArrayAsInt[0][i] == round(2. / (i + 0.01)));
586 for(
int i = 0; i < 5; i++) acc_someArrayAsInt[0][i] = 2 * i;
587 acc_someArrayAsInt.write();
588 vals = DoocsServerTestHelper::doocsGetArray<double>(
"//MYDUMMY/SOME_DOUBLE_ARRAY");
589 for(
int i = 0; i < 5; i++) BOOST_CHECK_CLOSE(vals[i], 2 * i, 0.00001);
592 TwoDRegisterAccessor<std::string> acc_someArrayAsString(
593 device.getTwoDRegisterAccessor<std::string>(
"MYDUMMY/SOME_DOUBLE_ARRAY"));
594 acc_someArrayAsString.read();
595 for(
int i = 0; i < 5; i++) BOOST_CHECK_CLOSE(std::stod(acc_someArrayAsString[0][i]), 2 * i, 0.00001);
596 for(
int i = 0; i < 5; i++) acc_someArrayAsString[0][i] = std::to_string(2.1 * i);
597 acc_someArrayAsString.write();
598 vals = DoocsServerTestHelper::doocsGetArray<double>(
"//MYDUMMY/SOME_DOUBLE_ARRAY");
599 for(
int i = 0; i < 5; i++) BOOST_CHECK_CLOSE(vals[i], 2.1 * i, 0.00001);
607 ChimeraTK::Device device;
610 TwoDRegisterAccessor<float> acc_someArray(device.getTwoDRegisterAccessor<
float>(
"MYDUMMY/SOME_SPECTRUM"));
611 BOOST_TEST(acc_someArray.getNChannels() == 1);
612 BOOST_TEST(acc_someArray.getNElementsPerChannel() == 100);
613 auto oldVersion = acc_someArray.getVersionNumber();
614 acc_someArray.read();
615 for(
int i = 0; i < 100; i++) BOOST_CHECK_CLOSE(acc_someArray[0][i], i / 42., 0.00001);
616 BOOST_TEST(acc_someArray.getVersionNumber() != oldVersion);
624 ChimeraTK::Device device;
627 TwoDRegisterAccessor<int> acc_someArray(device.getTwoDRegisterAccessor<
int>(
"MYDUMMY/SOME_IIII"));
628 BOOST_TEST(acc_someArray.getNChannels() == 1);
629 BOOST_TEST(acc_someArray.getNElementsPerChannel() == 4);
630 acc_someArray.read();
631 for(
int i = 0; i < 4; i++) BOOST_TEST(acc_someArray[0][i] == 10 + i);
633 std::vector<int> vals(4);
634 for(
int i = 0; i < 4; i++) vals[i] = -55 * i;
635 DoocsServerTestHelper::doocsSetIIII(
"//MYDUMMY/SOME_IIII", vals);
637 for(
int i = 0; i < 4; i++) BOOST_TEST(acc_someArray[0][i] == 10 + i);
639 acc_someArray.read();
640 for(
int i = 0; i < 4; i++) BOOST_TEST(acc_someArray[0][i] == -55 * i);
644 for(
int i = 0; i < 4; i++) acc_someArray[0][i] = i - 21;
645 vals = DoocsServerTestHelper::doocsGetArray<int>(
"//MYDUMMY/SOME_IIII");
646 for(
int i = 0; i < 4; i++) BOOST_TEST(vals[i] == -55 * i);
647 VersionNumber nextVersion;
648 acc_someArray.write(nextVersion);
649 vals = DoocsServerTestHelper::doocsGetArray<int>(
"//MYDUMMY/SOME_IIII");
650 for(
int i = 0; i < 4; i++) BOOST_TEST(vals[i] == i - 21);
651 BOOST_TEST(acc_someArray.getVersionNumber() == nextVersion);
654 TwoDRegisterAccessor<double> acc_someArrayAsDouble(device.getTwoDRegisterAccessor<
double>(
"MYDUMMY/SOME_IIII"));
655 acc_someArrayAsDouble.read();
656 for(
int i = 0; i < 4; i++) BOOST_CHECK_CLOSE(acc_someArrayAsDouble[0][i], i - 21, 0.00001);
657 for(
int i = 0; i < 4; i++) acc_someArrayAsDouble[0][i] = 2.4 * i;
658 acc_someArrayAsDouble.write();
659 vals = DoocsServerTestHelper::doocsGetArray<int>(
"//MYDUMMY/SOME_IIII");
660 for(
int i = 0; i < 4; i++) BOOST_CHECK_CLOSE(vals[i], round(2.4 * i), 0.00001);
663 TwoDRegisterAccessor<std::string> acc_someArrayAsString(
664 device.getTwoDRegisterAccessor<std::string>(
"MYDUMMY/SOME_IIII"));
665 acc_someArrayAsString.read();
666 for(
int i = 0; i < 4; i++) BOOST_CHECK_CLOSE(std::stod(acc_someArrayAsString[0][i]), round(2.4 * i), 0.00001);
667 for(
int i = 0; i < 4; i++) acc_someArrayAsString[0][i] = std::to_string(3 * i);
668 acc_someArrayAsString.write();
669 vals = DoocsServerTestHelper::doocsGetArray<int>(
"//MYDUMMY/SOME_IIII");
670 for(
int i = 0; i < 4; i++) BOOST_TEST(vals[i] == 3 * i);
678 ChimeraTK::Device device;
682 auto catalogue = device.getRegisterCatalogue();
683 auto regI = catalogue.getRegister(
"MYDUMMY/SOME_IFFF/I");
684 auto regF1 = catalogue.getRegister(
"MYDUMMY/SOME_IFFF/F1");
685 auto regF2 = catalogue.getRegister(
"MYDUMMY/SOME_IFFF/F2");
686 auto regF3 = catalogue.getRegister(
"MYDUMMY/SOME_IFFF/F3");
687 BOOST_TEST(regI.getDataDescriptor().isIntegral());
688 BOOST_TEST(regI.getDataDescriptor().isSigned());
689 BOOST_TEST(regI.getDataDescriptor().nDigits() == 11);
690 BOOST_TEST(!regF1.getDataDescriptor().isIntegral());
691 BOOST_TEST(regF1.getDataDescriptor().isSigned());
692 BOOST_TEST(!regF2.getDataDescriptor().isIntegral());
693 BOOST_TEST(regF2.getDataDescriptor().isSigned());
694 BOOST_TEST(!regF3.getDataDescriptor().isIntegral());
695 BOOST_TEST(regF3.getDataDescriptor().isSigned());
699 auto acc_I = device.getScalarRegisterAccessor<
int>(
"MYDUMMY/SOME_IFFF/I");
700 auto acc_F1 = device.getScalarRegisterAccessor<
float>(
"MYDUMMY/SOME_IFFF/F1");
701 auto acc_F2 = device.getScalarRegisterAccessor<
float>(
"MYDUMMY/SOME_IFFF/F2");
702 auto acc_F3 = device.getScalarRegisterAccessor<
float>(
"MYDUMMY/SOME_IFFF/F3");
705 BOOST_CHECK_EQUAL(
int(acc_I), 10);
707 BOOST_CHECK_CLOSE(
float(acc_F1), 2.71828, 0.00001);
709 BOOST_CHECK_CLOSE(
float(acc_F2), 3.14159, 0.00001);
711 BOOST_CHECK_CLOSE(
float(acc_F3), 197.327, 0.00001);
716 auto acc_I = device.getScalarRegisterAccessor<std::string>(
"MYDUMMY/SOME_IFFF/I");
717 auto acc_F1 = device.getScalarRegisterAccessor<std::string>(
"MYDUMMY/SOME_IFFF/F1");
718 auto acc_F2 = device.getScalarRegisterAccessor<std::string>(
"MYDUMMY/SOME_IFFF/F2");
719 auto acc_F3 = device.getScalarRegisterAccessor<std::string>(
"MYDUMMY/SOME_IFFF/F3");
722 BOOST_CHECK_EQUAL(std::string(acc_I),
"10");
724 BOOST_CHECK_CLOSE(std::stod(acc_F1), 2.71828, 0.00001);
726 BOOST_CHECK_CLOSE(std::stod(acc_F2), 3.14159, 0.00001);
728 BOOST_CHECK_CLOSE(std::stod(acc_F3), 197.327, 0.00001);
733 auto acc_I = device.getScalarRegisterAccessor<
int>(
"MYDUMMY/SOME_IFFF/I");
734 auto acc_F1 = device.getScalarRegisterAccessor<
float>(
"MYDUMMY/SOME_IFFF/F1");
735 auto acc_F2 = device.getScalarRegisterAccessor<
float>(
"MYDUMMY/SOME_IFFF/F2");
736 auto acc_F3 = device.getScalarRegisterAccessor<
float>(
"MYDUMMY/SOME_IFFF/F3");
742 BOOST_CHECK_EQUAL(
int(acc_I), 42);
744 BOOST_CHECK_CLOSE(
float(acc_F1), 2.71828, 0.00001);
746 BOOST_CHECK_CLOSE(
float(acc_F2), 3.14159, 0.00001);
748 BOOST_CHECK_CLOSE(
float(acc_F3), 197.327, 0.00001);
757 BOOST_CHECK_EQUAL(
int(acc_I), 42);
759 BOOST_CHECK_CLOSE(
float(acc_F1), 2.71828, 0.00001);
761 BOOST_CHECK_CLOSE(
float(acc_F2), 123.456, 0.00001);
763 BOOST_CHECK_CLOSE(
float(acc_F3), -666.666, 0.00001);
772 ChimeraTK::Device device;
776 OneDRegisterAccessor<std::uint8_t> acc_someImage(device.getOneDRegisterAccessor<std::uint8_t>(
"MYDUMMY/SOME_IMAGE"));
777 BOOST_TEST(acc_someImage.getNElements() == 640 * 460 +
sizeof(ChimeraTK::ImgHeader));
779 acc_someImage.read();
780 ChimeraTK::MappedImage im(acc_someImage);
781 BOOST_TEST(im.header()->width == 200);
782 BOOST_TEST(im.header()->height == 100);
783 BOOST_CHECK(im.header()->image_format == ChimeraTK::ImgFormat::Gray16);
784 auto imv = im.interpretedView<std::uint16_t>();
785 BOOST_TEST(imv(0, 0) == 0x101);
788 OneDRegisterAccessor<std::uint8_t> acc_someImage_padded(
789 device.getOneDRegisterAccessor<std::uint8_t>(
"MYDUMMY/SOME_IMAGE", 200 * 1000));
790 BOOST_TEST(acc_someImage_padded.getNElements() == 200 * 1000);
791 acc_someImage_padded.read();
793 for(
unsigned i = 0; i < im.header()->totalLength; i++) {
794 BOOST_TEST(acc_someImage[i] == acc_someImage_padded[i]);
797 OneDRegisterAccessor<std::uint8_t> acc_someImage_truncated(
798 device.getOneDRegisterAccessor<std::uint8_t>(
"MYDUMMY/SOME_IMAGE", 200 * 51 * 2));
799 acc_someImage_truncated.read();
800 ChimeraTK::MappedImage im1(acc_someImage_truncated);
801 BOOST_TEST(im1.header()->width == 200);
802 BOOST_TEST(im1.header()->height == 50);
803 BOOST_CHECK(im1.header()->image_format == ChimeraTK::ImgFormat::Gray16);
811 ChimeraTK::Device device;
814 TwoDRegisterAccessor<int> acc_someBit(device.getTwoDRegisterAccessor<
int>(
"MYDUMMY/SOME_BIT"));
815 TwoDRegisterAccessor<int> acc_someStatus(device.getTwoDRegisterAccessor<
int>(
"MYDUMMY/SOME_STATUS"));
816 TwoDRegisterAccessor<uint16_t> acc_someStatusU16(device.getTwoDRegisterAccessor<uint16_t>(
"MYDUMMY/SOME_STATUS"));
818 BOOST_TEST(acc_someBit.getNChannels() == 1);
819 BOOST_TEST(acc_someStatus.getNChannels() == 1);
820 BOOST_TEST(acc_someBit.getNElementsPerChannel() == 1);
821 BOOST_TEST(acc_someStatus.getNElementsPerChannel() == 1);
823 auto oldVersion = acc_someBit.getVersionNumber();
825 BOOST_TEST(acc_someBit[0][0] == 1);
826 BOOST_TEST(acc_someBit.getVersionNumber() != oldVersion);
827 oldVersion = acc_someStatus.getVersionNumber();
828 acc_someStatus.read();
829 BOOST_TEST(acc_someStatus[0][0] == 3);
830 BOOST_TEST(acc_someStatus.getVersionNumber() != oldVersion);
832 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_BIT", 0);
834 BOOST_TEST(acc_someBit[0][0] == 1);
836 BOOST_TEST(acc_someBit[0][0] == 0);
837 BOOST_TEST(acc_someStatus[0][0] == 3);
838 acc_someStatus.read();
839 BOOST_TEST(acc_someStatus[0][0] == 2);
841 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_STATUS", 0xFFFF);
843 BOOST_TEST(acc_someBit[0][0] == 0);
845 BOOST_TEST(acc_someBit[0][0] == 1);
846 BOOST_TEST(acc_someStatus[0][0] == 2);
847 acc_someStatus.read();
848 BOOST_TEST(acc_someStatus[0][0] == 0xFFFF);
850 acc_someStatusU16.read();
851 BOOST_TEST(acc_someStatusU16[0][0] == 0xFFFF);
853 acc_someBit[0][0] = 0;
854 BOOST_TEST(DoocsServerTestHelper::doocsGet<int>(
"//MYDUMMY/SOME_STATUS") == 0xFFFF);
855 VersionNumber nextVersion;
856 acc_someBit.write(nextVersion);
857 BOOST_TEST(DoocsServerTestHelper::doocsGet<int>(
"//MYDUMMY/SOME_STATUS") == 0xFFFE);
858 BOOST_TEST(acc_someBit.getVersionNumber() == nextVersion);
860 acc_someStatus[0][0] = 123;
861 BOOST_TEST(DoocsServerTestHelper::doocsGet<int>(
"//MYDUMMY/SOME_STATUS") == 0xFFFE);
863 acc_someStatus.write(nextVersion);
864 BOOST_TEST(DoocsServerTestHelper::doocsGet<int>(
"//MYDUMMY/SOME_STATUS") == 123);
865 BOOST_TEST(acc_someStatus.getVersionNumber() == nextVersion);
872 ChimeraTK::Device device;
877 OneDRegisterAccessor<int> acc_someArray(device.getOneDRegisterAccessor<
int>(
"MYDUMMY/SOME_INT_ARRAY", 20, 1));
878 BOOST_TEST(acc_someArray.getNElements() == 20);
880 std::vector<int> vals(42);
881 for(
int i = 0; i < 42; i++) vals[i] = -55 * i;
882 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_INT_ARRAY", vals);
884 acc_someArray.read();
885 for(
int i = 0; i < 20; i++) BOOST_TEST(acc_someArray[i] == -55 * (i + 1));
887 for(
int i = 0; i < 20; i++) acc_someArray[i] = i;
888 acc_someArray.write();
889 vals = DoocsServerTestHelper::doocsGetArray<int>(
"//MYDUMMY/SOME_INT_ARRAY");
890 for(
int i = 0; i < 42; i++) {
891 if(i == 0 || i > 20) {
892 BOOST_TEST(vals[i] == -55 * i);
895 BOOST_TEST(vals[i] == i - 1);
902 OneDRegisterAccessor<int> acc_someArray(device.getOneDRegisterAccessor<
int>(
"MYDUMMY/SOME_INT_ARRAY", 1, 10));
903 BOOST_TEST(acc_someArray.getNElements() == 1);
905 std::vector<int> vals(42);
906 for(
int i = 0; i < 42; i++) vals[i] = 33 * i;
907 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_INT_ARRAY", vals);
909 acc_someArray.read();
910 BOOST_TEST(acc_someArray[0] == 33 * 10);
912 acc_someArray[0] = 42;
913 acc_someArray.write();
914 vals = DoocsServerTestHelper::doocsGetArray<int>(
"//MYDUMMY/SOME_INT_ARRAY");
915 for(
int i = 0; i < 42; i++) {
917 BOOST_TEST(vals[i] == 42);
920 BOOST_TEST(vals[i] == 33 * i);
927 OneDRegisterAccessor<float> acc_someArray(device.getOneDRegisterAccessor<
float>(
"MYDUMMY/SOME_DOUBLE_ARRAY", 3, 2));
928 BOOST_TEST(acc_someArray.getNElements() == 3);
930 std::vector<double> vals(5);
931 for(
int i = 0; i < 5; i++) vals[i] = 3.14 * i;
932 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_DOUBLE_ARRAY", vals);
934 acc_someArray.read();
935 for(
int i = 0; i < 3; i++) BOOST_CHECK_CLOSE(acc_someArray[i], 3.14 * (i + 2), 0.00001);
937 for(
int i = 0; i < 3; i++) acc_someArray[i] = 1.2 - i;
938 acc_someArray.write();
939 vals = DoocsServerTestHelper::doocsGetArray<double>(
"//MYDUMMY/SOME_DOUBLE_ARRAY");
940 for(
int i = 0; i < 5; i++) {
942 BOOST_CHECK_CLOSE(vals[i], 1.2 - (i - 2), 0.00001);
945 BOOST_CHECK_CLOSE(vals[i], 3.14 * i, 0.00001);
952 ScalarRegisterAccessor<std::string> acc_someArray(
953 device.getScalarRegisterAccessor<std::string>(
"MYDUMMY/SOME_FLOAT_ARRAY", 0));
955 std::vector<float> vals(5);
956 for(
int i = 0; i < 5; i++) vals[i] = 2.82 * (i + 1);
957 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_FLOAT_ARRAY", vals);
959 acc_someArray.read();
960 BOOST_CHECK_CLOSE(std::stod(acc_someArray), 2.82, 0.00001);
962 acc_someArray =
"-11.111";
963 acc_someArray.write();
964 vals = DoocsServerTestHelper::doocsGetArray<float>(
"//MYDUMMY/SOME_FLOAT_ARRAY");
965 for(
int i = 0; i < 5; i++) {
967 BOOST_CHECK_CLOSE(vals[i], -11.111, 0.00001);
970 BOOST_CHECK_CLOSE(vals[i], 2.82 * (i + 1), 0.00001);
981 ChimeraTK::Device device;
985 BOOST_CHECK_THROW(device.getTwoDRegisterAccessor<
int>(
"MYDUMMY/UNSUPPORTED_DATA_TYPE"),
986 ChimeraTK::logic_error);
989 BOOST_CHECK_THROW(device.getTwoDRegisterAccessor<
int>(
"MYDUMMY/NOT_EXISTING"), ChimeraTK::logic_error);
992 BOOST_CHECK_THROW(device.getTwoDRegisterAccessor<
int>(
"MYDUMMY/SOME_STRING"), ChimeraTK::logic_error);
995 BOOST_CHECK_THROW(device.getOneDRegisterAccessor<
float>(
"MYDUMMY/SOME_DOUBLE_ARRAY", 10, 1), ChimeraTK::logic_error);
998 BOOST_CHECK_THROW(device.getOneDRegisterAccessor<
float>(
"MYDUMMY/SOME_INT_ARRAY", 100, 1), ChimeraTK::logic_error);
1005 void createCacheFileFromCdd(
const std::string& cdd) {
1007 auto d = ctk::Device(cdd);
1009 auto discardedCatalogue = d.getRegisterCatalogue();
1012 void deleteFile(
const std::string& filename) {
1014 if(unlink(filename.c_str()) < 0)
throw std::system_error(std::make_error_code(
static_cast<std::errc
>(errno)));
1024 ChimeraTK::Device device;
1027 ChimeraTK::Device device_cached;
1030 std::vector<ChimeraTK::RegisterCatalogue> catalogueList2;
1031 catalogueList2.push_back(device.getRegisterCatalogue());
1032 catalogueList2.push_back(device_cached.getRegisterCatalogue());
1034 for(
auto& catalogue : catalogueList2) {
1036 BOOST_TEST(catalogue.getNumberOfRegisters() > 13);
1039 BOOST_TEST(catalogue.hasRegister(
"SOME_INT"));
1040 BOOST_TEST(catalogue.hasRegister(
"SOME_FLOAT"));
1041 BOOST_TEST(catalogue.hasRegister(
"SOME_DOUBLE"));
1042 BOOST_TEST(catalogue.hasRegister(
"SOME_STRING"));
1043 BOOST_TEST(catalogue.hasRegister(
"SOME_STATUS"));
1044 BOOST_TEST(catalogue.hasRegister(
"SOME_BIT"));
1045 BOOST_TEST(catalogue.hasRegister(
"SOME_INT_ARRAY"));
1046 BOOST_TEST(catalogue.hasRegister(
"SOME_SHORT_ARRAY"));
1047 BOOST_TEST(catalogue.hasRegister(
"SOME_LONG_ARRAY"));
1048 BOOST_TEST(catalogue.hasRegister(
"SOME_FLOAT_ARRAY"));
1049 BOOST_TEST(catalogue.hasRegister(
"SOME_DOUBLE_ARRAY"));
1050 BOOST_TEST(catalogue.hasRegister(
"SOME_SPECTRUM"));
1051 BOOST_TEST(catalogue.hasRegister(
"SOME_IFFF/I"));
1052 BOOST_TEST(catalogue.hasRegister(
"SOME_IFFF/F1"));
1053 BOOST_TEST(catalogue.hasRegister(
"SOME_IFFF/F2"));
1054 BOOST_TEST(catalogue.hasRegister(
"SOME_IFFF/F3"));
1057 auto r1 = catalogue.getRegister(
"SOME_INT");
1058 BOOST_TEST(r1.getRegisterName() ==
"SOME_INT");
1059 BOOST_TEST(r1.getNumberOfElements() == 1);
1060 BOOST_TEST(r1.getNumberOfChannels() == 1);
1061 BOOST_TEST(r1.getNumberOfDimensions() == 0);
1062 BOOST_TEST(not r1.getSupportedAccessModes().has(ChimeraTK::AccessMode::wait_for_new_data));
1064 auto r2 = catalogue.getRegister(
"SOME_STRING");
1065 BOOST_TEST(r2.getRegisterName() ==
"SOME_STRING");
1066 BOOST_TEST(r2.getNumberOfElements() == 1);
1067 BOOST_TEST(r2.getNumberOfChannels() == 1);
1068 BOOST_TEST(r2.getNumberOfDimensions() == 0);
1069 BOOST_TEST(not r2.getSupportedAccessModes().has(ChimeraTK::AccessMode::wait_for_new_data));
1071 auto r3 = catalogue.getRegister(
"SOME_INT_ARRAY");
1072 BOOST_TEST(r3.getRegisterName() ==
"SOME_INT_ARRAY");
1073 BOOST_TEST(r3.getNumberOfElements() == 42);
1074 BOOST_TEST(r3.getNumberOfChannels() == 1);
1075 BOOST_TEST(r3.getNumberOfDimensions() == 1);
1076 BOOST_TEST(not r3.getSupportedAccessModes().has(ChimeraTK::AccessMode::wait_for_new_data));
1078 auto r4 = catalogue.getRegister(
"SOME_FLOAT_ARRAY");
1079 BOOST_TEST(r4.getRegisterName() ==
"SOME_FLOAT_ARRAY");
1080 BOOST_TEST(r4.getNumberOfElements() == 5);
1081 BOOST_TEST(r4.getNumberOfChannels() == 1);
1082 BOOST_TEST(r4.getNumberOfDimensions() == 1);
1083 BOOST_TEST(not r4.getSupportedAccessModes().has(ChimeraTK::AccessMode::wait_for_new_data));
1085 auto r5 = catalogue.getRegister(
"SOME_SPECTRUM");
1086 BOOST_TEST(r5.getRegisterName() ==
"SOME_SPECTRUM");
1087 BOOST_TEST(r5.getNumberOfElements() == 100);
1088 BOOST_TEST(r5.getNumberOfChannels() == 1);
1089 BOOST_TEST(r5.getNumberOfDimensions() == 1);
1090 BOOST_TEST(not r5.getSupportedAccessModes().has(ChimeraTK::AccessMode::wait_for_new_data));
1092 auto r6 = catalogue.getRegister(
"SOME_ZMQINT");
1093 BOOST_TEST(r6.getRegisterName() ==
"SOME_ZMQINT");
1094 BOOST_TEST(r6.getNumberOfElements() == 1);
1095 BOOST_TEST(r6.getNumberOfChannels() == 1);
1096 BOOST_TEST(r6.getNumberOfDimensions() == 0);
1097 BOOST_TEST(r6.getSupportedAccessModes().has(ChimeraTK::AccessMode::wait_for_new_data));
1099 auto r7 = catalogue.getRegister(
"SOME_IIII");
1100 BOOST_TEST(r7.getRegisterName() ==
"SOME_IIII");
1101 BOOST_TEST(r7.getNumberOfElements() == 4);
1102 BOOST_TEST(r7.getNumberOfChannels() == 1);
1103 BOOST_TEST(r7.getNumberOfDimensions() == 1);
1104 BOOST_TEST(not r7.getSupportedAccessModes().has(ChimeraTK::AccessMode::wait_for_new_data));
1106 auto regI = catalogue.getRegister(
"SOME_IFFF/I");
1107 auto regF1 = catalogue.getRegister(
"SOME_IFFF/F1");
1108 auto regF2 = catalogue.getRegister(
"SOME_IFFF/F2");
1109 auto regF3 = catalogue.getRegister(
"SOME_IFFF/F3");
1110 BOOST_TEST(regI.getDataDescriptor().isIntegral());
1111 BOOST_TEST(regI.getDataDescriptor().isSigned());
1112 BOOST_TEST(regI.getDataDescriptor().nDigits() == 11);
1113 BOOST_TEST(!regF1.getDataDescriptor().isIntegral());
1114 BOOST_TEST(regF1.getDataDescriptor().isSigned());
1115 BOOST_TEST(!regF2.getDataDescriptor().isIntegral());
1116 BOOST_TEST(regF2.getDataDescriptor().isSigned());
1117 BOOST_TEST(!regF3.getDataDescriptor().isIntegral());
1118 BOOST_TEST(regF3.getDataDescriptor().isSigned());
1121 device_cached.close();
1127 std::vector<ChimeraTK::RegisterCatalogue> catalogueList1;
1128 catalogueList1.push_back(device.getRegisterCatalogue());
1129 catalogueList1.push_back(device_cached.getRegisterCatalogue());
1131 for(
auto& catalogue : catalogueList1) {
1133 BOOST_TEST(catalogue.getNumberOfRegisters() > 13);
1136 BOOST_TEST(catalogue.hasRegister(
"MYDUMMY/SOME_INT"));
1137 BOOST_TEST(catalogue.hasRegister(
"MYDUMMY/SOME_ZMQINT"));
1138 BOOST_TEST(catalogue.hasRegister(
"DUMMY._SVR/SVR.BPN"));
1139 BOOST_TEST(catalogue.hasRegister(
"MYDUMMY/SOME_IFFF/I"));
1140 BOOST_TEST(catalogue.hasRegister(
"MYDUMMY/SOME_IFFF/F1"));
1141 BOOST_TEST(catalogue.hasRegister(
"MYDUMMY/SOME_IFFF/F2"));
1142 BOOST_TEST(catalogue.hasRegister(
"MYDUMMY/SOME_IFFF/F3"));
1145 auto r8 = catalogue.getRegister(
"MYDUMMY/SOME_INT");
1146 BOOST_TEST(r8.getRegisterName() ==
"MYDUMMY/SOME_INT");
1147 BOOST_TEST(r8.getNumberOfElements() == 1);
1148 BOOST_TEST(r8.getNumberOfChannels() == 1);
1149 BOOST_TEST(r8.getNumberOfDimensions() == 0);
1150 BOOST_TEST(not r8.getSupportedAccessModes().has(ChimeraTK::AccessMode::wait_for_new_data));
1152 auto r9 = catalogue.getRegister(
"DUMMY._SVR/SVR.BPN");
1153 BOOST_TEST(r9.getRegisterName() ==
"DUMMY._SVR/SVR.BPN");
1154 BOOST_TEST(r9.getNumberOfElements() == 1);
1155 BOOST_TEST(r9.getNumberOfChannels() == 1);
1156 BOOST_TEST(r9.getNumberOfDimensions() == 0);
1157 BOOST_TEST(not r9.getSupportedAccessModes().has(ChimeraTK::AccessMode::wait_for_new_data));
1159 auto r10 = catalogue.getRegister(
"MYDUMMY/SOME_ZMQINT");
1160 BOOST_TEST(r10.getRegisterName() ==
"MYDUMMY/SOME_ZMQINT");
1161 BOOST_TEST(r10.getNumberOfElements() == 1);
1162 BOOST_TEST(r10.getNumberOfChannels() == 1);
1163 BOOST_TEST(r10.getNumberOfDimensions() == 0);
1164 BOOST_TEST(r10.getSupportedAccessModes().has(ChimeraTK::AccessMode::wait_for_new_data));
1166 auto regI = catalogue.getRegister(
"MYDUMMY/SOME_IFFF/I");
1167 auto regF1 = catalogue.getRegister(
"MYDUMMY/SOME_IFFF/F1");
1168 auto regF2 = catalogue.getRegister(
"MYDUMMY/SOME_IFFF/F2");
1169 auto regF3 = catalogue.getRegister(
"MYDUMMY/SOME_IFFF/F3");
1170 BOOST_TEST(regI.getDataDescriptor().isIntegral());
1171 BOOST_TEST(regI.getDataDescriptor().isSigned());
1172 BOOST_TEST(regI.getDataDescriptor().nDigits() == 11);
1173 BOOST_TEST(!regF1.getDataDescriptor().isIntegral());
1174 BOOST_TEST(regF1.getDataDescriptor().isSigned());
1175 BOOST_TEST(!regF2.getDataDescriptor().isIntegral());
1176 BOOST_TEST(regF2.getDataDescriptor().isSigned());
1177 BOOST_TEST(!regF3.getDataDescriptor().isIntegral());
1178 BOOST_TEST(regF3.getDataDescriptor().isSigned());
1181 device_cached.close();
1191 ChimeraTK::Device device;
1195 BOOST_TEST(device.readDeviceInfo() ==
"DOOCS server address: doocs://localhost:" +
DoocsLauncher::rpc_no +
"/F/D");
1198 TwoDRegisterAccessor<int32_t> acc1(device.getTwoDRegisterAccessor<int32_t>(
"MYDUMMY/SOME_INT"));
1199 TwoDRegisterAccessor<int32_t> acc2(device.getTwoDRegisterAccessor<int32_t>(
"MYDUMMY/SOME_INT"));
1200 TransferGroup group;
1201 group.addAccessor(acc1);
1202 group.addAccessor(acc2);
1204 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_INT", 123);
1206 BOOST_CHECK_EQUAL(acc1[0][0], 123);
1207 BOOST_CHECK_EQUAL(acc2[0][0], 123);
1213 device.open(
"sdm://./doocs=TEST.DOOCS,NOT_EXISTING,SOME_LOCATION");
1214 BOOST_TEST(device.readDeviceInfo() ==
"DOOCS server address: TEST.DOOCS/NOT_EXISTING/SOME_LOCATION");
1221 auto server = find_device(
"MYDUMMY");
1234 bool file_exists(
const std::string& name) {
1235 std::ifstream f(name.c_str());
1247 auto discardedCatalogue = d1.getRegisterCatalogue();
1248 discardedCatalogue = d2.getRegisterCatalogue();
1260 std::string xml =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
1261 "<catalogue version=\"1.0\">"
1263 " <name>/DUMMY</name>\n"
1264 " <length>1</length>\n"
1265 " <access_mode></access_mode>\n"
1266 " <doocs_type_id>1</doocs_type_id>\n"
1267 " <!--doocs id: INT-->\n"
1270 std::ofstream o(filename);
1278 std::this_thread::sleep_for(std::chrono::seconds(1));
1279 return creation_time;
1289 std::atomic<bool> cancelTimeOutTask{
false};
1291 std::future<void> timeoutTask = std::async(std::launch::async, [&]() {
1292 unsigned int count = 60;
1293 while(count > 0 && not cancelTimeOutTask) {
1294 std::this_thread::sleep_for(std::chrono::seconds(1));
1299 auto hasTimedOut = [&]() {
return timeoutTask.wait_for(std::chrono::seconds(0)) == std::future_status::ready; };
1301 auto modification_time = creation_time;
1302 while((modification_time <= creation_time) && not hasTimedOut()) {
1304 std::this_thread::sleep_for(std::chrono::seconds(2));
1307 cancelTimeOutTask =
true;
1308 BOOST_TEST(modification_time > creation_time);
1320 auto server = find_device(
"MYDUMMY");
1325 BOOST_TEST(creation_time == modification_time);
1335 DoocsServerTestHelper::doocsSet(
"//MYDUMMY/SOME_INT", 120);
1336 TwoDRegisterAccessor<int32_t> acc_someInt_as_int(d.getTwoDRegisterAccessor<int32_t>(
"MYDUMMY/SOME_INT"));
1337 BOOST_TEST(acc_someInt_as_int.getNChannels() == 1);
1338 BOOST_TEST(acc_someInt_as_int.getNElementsPerChannel() == 1);
1342 acc_someInt_as_int.read();
1343 BOOST_TEST(acc_someInt_as_int[0][0] == 120);
1345 acc_someInt_as_int[0][0] = 50;
1346 acc_someInt_as_int.write();
1347 BOOST_TEST(DoocsServerTestHelper::doocsGet<int>(
"//MYDUMMY/SOME_INT") == 50);
1354 std::string xml =
"";
1366 ChimeraTK::Device device;
1368 auto catalogue = device.getRegisterCatalogue();
1371 DoocsServerTestHelper::runUpdate();
1374 auto eqfct =
reinterpret_cast<eq_dummy*
>(find_device(
"MYDUMMY"));
1377 BOOST_TEST(device.readDeviceInfo() ==
"DOOCS server address: doocs://localhost:" +
DoocsLauncher::rpc_no +
"/F/D");
1379 for(std::string param : {
"SOME_INT",
"SOME_FLOAT",
"SOME_BIT",
"SOME_INT_ARRAY",
"SOME_SHORT_ARRAY",
1380 "SOME_LONG_ARRAY",
"SOME_FLOAT_ARRAY",
"SOME_DOUBLE_ARRAY",
"SOME_SPECTRUM",
"SOME_IIII",
"SOME_IFFF"}) {
1381 auto path = RegisterPath(
"MYDUMMY/" + param +
"/eventId");
1382 BOOST_TEST(catalogue.hasRegister(path));
1384 auto regInfo = catalogue.getRegister(path);
1385 BOOST_TEST(regInfo.isReadable());
1386 BOOST_TEST(!regInfo.isWriteable());
1387 BOOST_CHECK_EQUAL(regInfo.getNumberOfElements(), 1);
1388 BOOST_CHECK_EQUAL(regInfo.getNumberOfChannels(), 1);
1389 BOOST_CHECK_EQUAL(regInfo.getNumberOfDimensions(), 0);
1390 auto descriptor = regInfo.getDataDescriptor();
1391 BOOST_TEST(descriptor.fundamentalType() == ChimeraTK::DataDescriptor::FundamentalType::numeric);
1392 BOOST_CHECK_EQUAL(descriptor.nDigits(), 20);
1393 BOOST_TEST(descriptor.isSigned());
1394 BOOST_TEST(descriptor.isIntegral());
1396 auto acc1 = device.getScalarRegisterAccessor<int64_t>(path);
1398 BOOST_CHECK_EQUAL(
static_cast<int64_t
>(acc1), eqfct->counter - 1);
1399 BOOST_CHECK_EQUAL(acc1.isReadOnly(),
true);
1400 BOOST_CHECK_EQUAL(acc1.isWriteable(),
false);
1401 BOOST_CHECK_EQUAL(acc1.isReadable(),
true);
1402 BOOST_CHECK_THROW(acc1.write(), ChimeraTK::logic_error);
1404 auto acc2 = device.getScalarRegisterAccessor<std::string>(path);
1406 BOOST_CHECK_EQUAL(
static_cast<std::string
>(acc2), std::to_string(eqfct->counter - 1));
1407 BOOST_CHECK_EQUAL(acc2.isReadOnly(),
true);
1408 BOOST_CHECK_EQUAL(acc2.isWriteable(),
false);
1409 BOOST_CHECK_EQUAL(acc2.isReadable(),
true);
1410 BOOST_CHECK_THROW(acc2.write(), ChimeraTK::logic_error);
1418 auto acc1 = device.getScalarRegisterAccessor<int64_t>(
"MYDUMMY/UNSUPPORTED_DATA_TYPE/eventId");
1419 BOOST_TEST(acc1.isInitialised());
1422 DoocsServerTestHelper::runUpdate();
1424 auto path = RegisterPath(
"MYDUMMY/SOME_ZMQINT/eventId");
1425 BOOST_TEST(catalogue.hasRegister(path));
1426 auto acc2 = device.getScalarRegisterAccessor<int64_t>(path);
1428 BOOST_CHECK_EQUAL(
static_cast<int64_t
>(acc2), eqfct->counter - 1);
1429 BOOST_CHECK_EQUAL(acc2.isReadOnly(),
true);
1430 BOOST_CHECK_EQUAL(acc2.isWriteable(),
false);
1431 BOOST_CHECK_EQUAL(acc2.isReadable(),
true);
1432 BOOST_CHECK_THROW(acc2.write(), ChimeraTK::logic_error);
1440 ChimeraTK::Device device;
1442 auto catalogue = device.getRegisterCatalogue();
1445 DoocsServerTestHelper::runUpdate();
1448 auto eqfct =
reinterpret_cast<eq_dummy*
>(find_device(
"MYDUMMY"));
1451 BOOST_TEST(device.readDeviceInfo() ==
"DOOCS server address: doocs://localhost:" +
DoocsLauncher::rpc_no +
"/F/D");
1453 for(std::string param : {
"SOME_INT",
"SOME_FLOAT",
"SOME_BIT",
"SOME_INT_ARRAY",
"SOME_SHORT_ARRAY",
1454 "SOME_LONG_ARRAY",
"SOME_FLOAT_ARRAY",
"SOME_DOUBLE_ARRAY",
"SOME_SPECTRUM",
"SOME_IIII",
"SOME_IFFF"}) {
1455 auto path = RegisterPath(
"MYDUMMY/" + param +
"/timeStamp");
1456 BOOST_TEST(catalogue.hasRegister(path));
1458 auto regInfo = catalogue.getRegister(path);
1459 BOOST_TEST(regInfo.isReadable());
1460 BOOST_TEST(!regInfo.isWriteable());
1461 BOOST_CHECK_EQUAL(regInfo.getNumberOfElements(), 1);
1462 BOOST_CHECK_EQUAL(regInfo.getNumberOfChannels(), 1);
1463 BOOST_CHECK_EQUAL(regInfo.getNumberOfDimensions(), 0);
1464 auto descriptor = regInfo.getDataDescriptor();
1465 BOOST_TEST(descriptor.fundamentalType() == ChimeraTK::DataDescriptor::FundamentalType::numeric);
1466 BOOST_CHECK_EQUAL(descriptor.nDigits(), 20);
1467 BOOST_TEST(descriptor.isSigned());
1468 BOOST_TEST(descriptor.isIntegral());
1470 auto acc1 = device.getScalarRegisterAccessor<int64_t>(path);
1472 BOOST_CHECK_EQUAL(
static_cast<int64_t
>(acc1), eqfct->startTime - 1);
1473 BOOST_CHECK_EQUAL(acc1.isReadOnly(),
true);
1474 BOOST_CHECK_EQUAL(acc1.isWriteable(),
false);
1475 BOOST_CHECK_EQUAL(acc1.isReadable(),
true);
1476 BOOST_CHECK_THROW(acc1.write(), ChimeraTK::logic_error);
1478 auto acc2 = device.getScalarRegisterAccessor<std::string>(path);
1480 BOOST_CHECK_EQUAL(
static_cast<std::string
>(acc2), std::to_string(eqfct->startTime - 1));
1481 BOOST_CHECK_EQUAL(acc2.isReadOnly(),
true);
1482 BOOST_CHECK_EQUAL(acc2.isWriteable(),
false);
1483 BOOST_CHECK_EQUAL(acc2.isReadable(),
true);
1484 BOOST_CHECK_THROW(acc2.write(), ChimeraTK::logic_error);
1492 auto acc1 = device.getScalarRegisterAccessor<int64_t>(
"MYDUMMY/UNSUPPORTED_DATA_TYPE/timeStamp");
1493 BOOST_TEST(acc1.isInitialised());
1496 DoocsServerTestHelper::runUpdate();
1498 auto path = RegisterPath(
"MYDUMMY/SOME_ZMQINT/timeStamp");
1499 BOOST_TEST(catalogue.hasRegister(path));
1500 auto acc2 = device.getScalarRegisterAccessor<int64_t>(path);
1502 BOOST_CHECK_EQUAL(
static_cast<int64_t
>(acc2), eqfct->startTime - 1);
1503 BOOST_CHECK_EQUAL(acc2.isReadOnly(),
true);
1504 BOOST_CHECK_EQUAL(acc2.isWriteable(),
false);
1505 BOOST_CHECK_EQUAL(acc2.isReadable(),
true);
1506 BOOST_CHECK_THROW(acc2.write(), ChimeraTK::logic_error);
1514 ChimeraTK::Device device;
1516 auto catalogue = device.getRegisterCatalogue();
1517 auto eqfct =
reinterpret_cast<eq_dummy*
>(find_device(
"MYDUMMY"));
1519 auto acc1 = device.getScalarRegisterAccessor<
int>(
"MYDUMMY/SOME_INT");
1520 auto acc2 = device.getScalarRegisterAccessor<
float>(
"MYDUMMY/SOME_FLOAT");
1521 auto acc1_id = device.getScalarRegisterAccessor<int64_t>(
"MYDUMMY/SOME_INT/eventId");
1522 auto acc2_id = device.getScalarRegisterAccessor<int64_t>(
"MYDUMMY/SOME_FLOAT/eventId");
1530 DoocsServerTestHelper::runUpdate();
1537 BOOST_TEST(acc1.getVersionNumber() != ChimeraTK::VersionNumber{nullptr});
1538 BOOST_TEST(acc2.getVersionNumber() != ChimeraTK::VersionNumber{nullptr});
1541 BOOST_TEST(acc1_id == 0);
1542 BOOST_TEST(acc2_id == 0);
1544 eqfct->counter = id;
1549 DoocsServerTestHelper::runUpdate();
1556 BOOST_CHECK_MESSAGE(acc1.getVersionNumber() == acc2.getVersionNumber(),
1557 static_cast<std::string
>(acc1.getVersionNumber()) +
" should be equal to " +
1558 static_cast<std::string
>(acc2.getVersionNumber()));
1559 BOOST_CHECK_MESSAGE(acc1.getVersionNumber() == acc1_id.getVersionNumber(),
1560 static_cast<std::string
>(acc1.getVersionNumber()) +
" should be equal to " +
1561 static_cast<std::string
>(acc1_id.getVersionNumber()));
1562 BOOST_CHECK_MESSAGE(acc2.getVersionNumber() == acc2_id.getVersionNumber(),
1563 static_cast<std::string
>(acc2.getVersionNumber()) +
" should be equal to " +
1564 static_cast<std::string
>(acc2_id.getVersionNumber()));
1565 BOOST_CHECK_EQUAL(acc1_id,
id);
1566 BOOST_CHECK_EQUAL(acc2_id,
id);
1569 DoocsServerTestHelper::runUpdate();
1573 BOOST_CHECK_MESSAGE(acc1.getVersionNumber() != acc2.getVersionNumber(),
1574 static_cast<std::string
>(acc1.getVersionNumber()) +
" should not be equal to " +
1575 static_cast<std::string
>(acc2.getVersionNumber()));
1579 BOOST_CHECK_MESSAGE(acc1.getVersionNumber() == acc2.getVersionNumber(),
1580 static_cast<std::string
>(acc1.getVersionNumber()) +
" should be equal to " +
1581 static_cast<std::string
>(acc2.getVersionNumber()));
1585 VersionNumber someVersionBeforeOpeningSecondDevice;
1586 ChimeraTK::Device device2;
1588 auto acc3 = device2.getScalarRegisterAccessor<
int>(
"SOME_INT");
1590 BOOST_CHECK_MESSAGE(acc3.getVersionNumber() > someVersionBeforeOpeningSecondDevice,
1591 static_cast<std::string
>(acc3.getVersionNumber()) +
" should be greater than " +
1592 static_cast<std::string
>(someVersionBeforeOpeningSecondDevice));
1596 VersionNumber lastVersion = acc3.getVersionNumber();
1597 for(
size_t i = 0; i < 3; ++i) {
1598 DoocsServerTestHelper::runUpdate();
1601 BOOST_CHECK_MESSAGE(acc3.getVersionNumber() > lastVersion,
1602 static_cast<std::string
>(acc3.getVersionNumber()) +
" should be greater than " +
1603 static_cast<std::string
>(lastVersion));
1604 BOOST_CHECK_MESSAGE(acc3.getVersionNumber() == acc2.getVersionNumber(),
1605 static_cast<std::string
>(acc3.getVersionNumber()) +
" should be equal to " +
1606 static_cast<std::string
>(acc2.getVersionNumber()));
1607 lastVersion = acc3.getVersionNumber();
1611 device2.setException(
"Test Exception");
1614 DoocsServerTestHelper::runUpdate();
1616 BOOST_CHECK_MESSAGE(acc2.getVersionNumber() > lastVersion,
1617 static_cast<std::string
>(acc2.getVersionNumber()) +
" should be greater than " +
1618 static_cast<std::string
>(lastVersion));
1619 lastVersion = acc2.getVersionNumber();
1622 someVersionBeforeOpeningSecondDevice = {};
1625 BOOST_CHECK_MESSAGE(acc3.getVersionNumber() > someVersionBeforeOpeningSecondDevice,
1626 static_cast<std::string
>(acc3.getVersionNumber()) +
" should be greater than " +
1627 static_cast<std::string
>(someVersionBeforeOpeningSecondDevice));
1630 DoocsServerTestHelper::runUpdate();
1633 BOOST_CHECK_MESSAGE(acc3.getVersionNumber() > lastVersion,
1634 static_cast<std::string
>(acc3.getVersionNumber()) +
" should be greater than " +
1635 static_cast<std::string
>(lastVersion));
1636 BOOST_CHECK_MESSAGE(acc3.getVersionNumber() == acc2.getVersionNumber(),
1637 static_cast<std::string
>(acc3.getVersionNumber()) +
" should be equal to " +
1638 static_cast<std::string
>(acc2.getVersionNumber()));
1639 lastVersion = acc3.getVersionNumber();
1646 auto id1 = eqfct->counter;
1647 DoocsServerTestHelper::runUpdate();
1649 auto ver1 = acc3.getVersionNumber();
1650 DoocsServerTestHelper::runUpdate();
1652 auto ver2 = acc3.getVersionNumber();
1655 BOOST_CHECK_MESSAGE(acc1.getVersionNumber() == ver2,
1656 static_cast<std::string
>(acc1.getVersionNumber()) +
" should be equal to " +
static_cast<std::string
>(ver2));
1657 BOOST_TEST(acc1.dataValidity() == DataValidity::ok);
1659 eqfct->counter = id1;
1660 DoocsServerTestHelper::runUpdate();
1663 BOOST_CHECK_MESSAGE(acc2.getVersionNumber() == ver1,
1664 static_cast<std::string
>(acc2.getVersionNumber()) +
" should be equal to " +
static_cast<std::string
>(ver1));
1665 BOOST_TEST(acc2.dataValidity() == DataValidity::ok);
1669 BOOST_CHECK_MESSAGE(acc1.getVersionNumber() == ver2,
1670 static_cast<std::string
>(acc1.getVersionNumber()) +
" should be equal to " +
static_cast<std::string
>(ver2));
1671 BOOST_TEST(acc1.dataValidity() == DataValidity::ok);
1677 DoocsServerTestHelper::
1679 DoocsServerTestHelper::runUpdate();
1682 auto lastRegularAcc1Version = acc1.getVersionNumber();
1684 int64_t lastRegularEventId = acc1_id;
1685 BOOST_CHECK_MESSAGE(acc1.getVersionNumber() == acc1_id.getVersionNumber(),
1686 static_cast<std::string
>(acc1.getVersionNumber()) +
" should be equal to " +
1687 static_cast<std::string
>(acc1_id.getVersionNumber()));
1690 auto idAfterZero = eqfct->counter;
1692 DoocsServerTestHelper::runUpdate();
1697 auto acc1VersionForId0 = acc1.getVersionNumber();
1698 auto acc1_idVersionForId0 = acc1_id.getVersionNumber();
1699 BOOST_TEST(acc1.getVersionNumber() > lastRegularAcc1Version);
1700 BOOST_TEST(acc1_id.getVersionNumber() > lastRegularAcc1Version);
1701 BOOST_CHECK_EQUAL(acc1_id, 0);
1705 eqfct->counter = lastRegularEventId;
1706 DoocsServerTestHelper::runUpdate();
1710 BOOST_CHECK_MESSAGE(acc1.getVersionNumber() == acc1VersionForId0,
1711 static_cast<std::string
>(acc1.getVersionNumber()) +
" should be equal to " +
1712 static_cast<std::string
>(acc1VersionForId0));
1713 BOOST_CHECK_MESSAGE(acc1_id.getVersionNumber() == acc1_idVersionForId0,
1714 static_cast<std::string
>(acc1_id.getVersionNumber()) +
" should be equal to " +
1715 static_cast<std::string
>(acc1_idVersionForId0));
1716 BOOST_CHECK_EQUAL(acc1_id, lastRegularEventId);
1721 BOOST_CHECK_MESSAGE(acc2.getVersionNumber() == lastRegularAcc1Version,
1722 static_cast<std::string
>(acc2.getVersionNumber()) +
" should be equal to " +
1723 static_cast<std::string
>(lastRegularAcc1Version));
1724 BOOST_CHECK_MESSAGE(acc2_id.getVersionNumber() == lastRegularAcc1Version,
1725 static_cast<std::string
>(acc2_id.getVersionNumber()) +
" should be equal to " +
1726 static_cast<std::string
>(lastRegularAcc1Version));
1727 BOOST_CHECK_EQUAL(acc2_id, lastRegularEventId);
1730 DoocsServerTestHelper::runUpdate();
1734 BOOST_TEST(acc1.getVersionNumber() > acc1VersionForId0);
1736 BOOST_CHECK_MESSAGE(acc1.getVersionNumber() == acc1_id.getVersionNumber(),
1737 static_cast<std::string
>(acc1.getVersionNumber()) +
" should be equal to " +
1738 static_cast<std::string
>(acc1_id.getVersionNumber()));
1739 BOOST_CHECK_EQUAL(acc1_id, idAfterZero);