ChimeraTK-DeviceAccess  03.18.00
testNumericAddressedBackendUnified.cpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2 // SPDX-License-Identifier: LGPL-3.0-or-later
3 
4 #define BOOST_TEST_DYN_LINK
5 // Define a name for the test module.
6 #define BOOST_TEST_MODULE NumericAddressedBackendUnified
7 // Only after defining the name include the unit test header.
8 #include <boost/test/unit_test.hpp>
9 using namespace boost::unit_test_framework;
10 
11 #include "BackendFactory.h"
12 #include "Device.h"
13 #include "DummyBackend.h"
14 #include "DummyRegisterAccessor.h"
15 #include "ExceptionDummyBackend.h"
16 #include "TransferGroup.h"
17 #include "UnifiedBackendTest.h"
18 
19 namespace ChimeraTK {
20  using namespace ChimeraTK;
21 }
22 using namespace ChimeraTK;
23 
24 /* ===============================================================================================
25  * Despite its name, this test also qualifies as an unified test for the (Exception)DummyBackend.
26  * They are thinish implementations of the NumericAddressedBackend's internal interface.
27  * ==============================================================================================*/
28 
29 // Create a test suite which holds all your tests.
30 BOOST_AUTO_TEST_SUITE(NumericAddressedBackendUnifiedTestSuite)
31 
32 /**********************************************************************************************************************/
33 
34 static std::string cdd("(ExceptionDummy:1?map=test3.map)");
35 static auto exceptionDummy =
36  boost::dynamic_pointer_cast<ExceptionDummy>(BackendFactory::getInstance().createBackend(cdd));
37 
38 static std::string cddMuxed("(ExceptionDummy:1?map=muxedDataAcessor.map)");
39 static auto exceptionDummyMuxed =
40  boost::dynamic_pointer_cast<ExceptionDummy>(BackendFactory::getInstance().createBackend(cddMuxed));
41 
42 /**********************************************************************************************************************/
43 
45  std::string path() { return "/Integers/signed32"; }
46  bool isWriteable() { return true; }
47  bool isReadable() { return true; }
49  size_t nChannels() { return 1; }
50  size_t nElementsPerChannel() { return 1; }
51  size_t writeQueueLength() { return std::numeric_limits<size_t>::max(); }
52  size_t nRuntimeErrorCases() { return 1; }
53  typedef int32_t minimumUserType;
55 
56  static constexpr auto capabilities = TestCapabilities<>()
58  .disableAsyncReadInconsistency()
59  .disableSwitchReadOnly()
60  .disableSwitchWriteOnly()
61  .disableTestWriteNeverLosesData()
62  .enableTestRawTransfer();
63 
65 
66  template<typename Type>
67  std::vector<std::vector<Type>> generateValue([[maybe_unused]] bool raw = false) {
68  return {{acc + 3}};
69  }
70 
71  template<typename UserType>
72  std::vector<std::vector<UserType>> getRemoteValue([[maybe_unused]] bool raw = false) {
73  return {{acc}};
74  }
75 
76  void setRemoteValue() { acc = generateValue<minimumUserType>()[0][0]; }
77 
78  void setForceRuntimeError(bool enable, size_t) {
79  exceptionDummy->throwExceptionRead = enable;
80  exceptionDummy->throwExceptionWrite = enable;
81  exceptionDummy->throwExceptionOpen = enable;
82  }
83 };
84 
86  std::string path() { return "/Integers/signed32_async"; }
87  bool isWriteable() { return false; }
88  bool isReadable() { return true; }
91  }
92  size_t nChannels() { return 1; }
93  size_t nElementsPerChannel() { return 1; }
94  size_t writeQueueLength() { return std::numeric_limits<size_t>::max(); }
95  size_t nRuntimeErrorCases() { return 1; }
96  typedef int32_t minimumUserType;
98 
99  static constexpr auto capabilities = TestCapabilities<>()
101  .disableAsyncReadInconsistency()
102  .disableSwitchReadOnly()
103  .disableSwitchWriteOnly()
104  .disableTestWriteNeverLosesData()
105  .enableTestRawTransfer();
106 
108 
109  template<typename Type>
110  std::vector<std::vector<Type>> generateValue([[maybe_unused]] bool raw = false) {
111  return {{acc + 3}};
112  }
113 
114  template<typename UserType>
115  std::vector<std::vector<UserType>> getRemoteValue([[maybe_unused]] bool raw = false) {
116  return {{acc}};
117  }
118 
119  void setRemoteValue() {
120  acc = generateValue<minimumUserType>()[0][0];
121  if(exceptionDummy->isOpen()) exceptionDummy->triggerInterrupt(6);
122  }
123 
124  void forceAsyncReadInconsistency() { acc = generateValue<minimumUserType>()[0][0]; }
125 
126  void setForceRuntimeError(bool enable, size_t) {
127  exceptionDummy->throwExceptionRead = enable;
128  exceptionDummy->throwExceptionWrite = enable;
129  exceptionDummy->throwExceptionOpen = enable;
130  if(exceptionDummy->isOpen()) exceptionDummy->triggerInterrupt(6);
131  }
132 };
134  // Using the DUMMY_WRITEABLE register here since usually an async register is r/o implicitly
135  std::string path() { return "/Integers/signed32_async/DUMMY_WRITEABLE"; }
136  bool isWriteable() { return true; }
137  bool isReadable() { return true; }
140  }
141  size_t nChannels() { return 1; }
142  size_t nElementsPerChannel() { return 1; }
143  size_t writeQueueLength() { return std::numeric_limits<size_t>::max(); }
144  size_t nRuntimeErrorCases() { return 1; }
145  typedef int32_t minimumUserType;
147 
148  static constexpr auto capabilities = TestCapabilities<>()
150  .disableAsyncReadInconsistency()
151  .disableSwitchReadOnly()
152  .disableSwitchWriteOnly()
153  .disableTestWriteNeverLosesData()
154  .enableTestRawTransfer();
155 
156  DummyRegisterAccessor<int32_t> acc{exceptionDummy.get(), "", "/Integers/signed32_async"};
157 
158  template<typename Type>
159  std::vector<std::vector<Type>> generateValue([[maybe_unused]] bool raw = false) {
160  return {{acc + 3}};
161  }
162 
163  template<typename UserType>
164  std::vector<std::vector<UserType>> getRemoteValue([[maybe_unused]] bool raw = false) {
165  return {{acc}};
166  }
167 
168  void setRemoteValue() {
169  acc = generateValue<minimumUserType>()[0][0];
170  if(exceptionDummy->isOpen()) exceptionDummy->triggerInterrupt(6);
171  }
172 
173  void forceAsyncReadInconsistency() { acc = generateValue<minimumUserType>()[0][0]; }
174 
175  void setForceRuntimeError(bool enable, size_t) {
176  exceptionDummy->throwExceptionRead = enable;
177  exceptionDummy->throwExceptionWrite = enable;
178  exceptionDummy->throwExceptionOpen = enable;
179  if(exceptionDummy->isOpen()) exceptionDummy->triggerInterrupt(6);
180  }
181 };
182 
183 /**********************************************************************************************************************/
184 
185 template<typename Derived, typename rawUserType>
187  Derived* derived{static_cast<Derived*>(this)};
188 
189  bool isWriteable() { return true; }
190  bool isReadable() { return true; }
192  size_t nChannels() { return 1; }
193  size_t nElementsPerChannel() { return 1; }
194  size_t writeQueueLength() { return std::numeric_limits<size_t>::max(); }
195  size_t nRuntimeErrorCases() { return 1; }
196 
197  // The padding (i.e. the bits of the 32 bit word which are not part of the register under test but of the neighbouring
198  // registers) needs to be checked to be unchanged in write operations. This test assumes that in between the calls to
199  // generateValue() and getRemoteValue() the padding bits are not *intentionally* changed (e.g. by testing another
200  // register in between). This is true for the UnifiedBackendTest right now.
201  // TODO: In future it may be better to foresee a "no-side-effect" test in the UnifiedBackendTest, which tests that
202  // other registers stay unchanged (caveat: need to specify which registers to look at! We have intentionally
203  // overlapping registers in this test which of course will change!)
204  int32_t lastPadding{0};
205  bool printPaddingChangedMessage{true};
206 
207  static constexpr auto capabilities = TestCapabilities<>()
209  .disableAsyncReadInconsistency()
210  .disableSwitchReadOnly()
211  .disableSwitchWriteOnly()
212  .disableTestWriteNeverLosesData()
213  .enableTestRawTransfer();
214 
215  // This register shares the address space with all our test registers. It gives us direct access to the 4 byte
216  // address range, so we can test the correct placement of the unaligned values.
217  DummyRegisterRawAccessor acc{exceptionDummy, "", "/Integers/unsigned32"};
218 
219  rawUserType get() { return (acc & derived->bitmask) >> derived->bitshift; }
220 
221  void set(rawUserType val) {
222  acc &= ~derived->bitmask;
223  lastPadding = acc;
224  printPaddingChangedMessage = true;
225  acc |= (val << derived->bitshift) & derived->bitmask;
226  }
227 
228  // Type can be user type or raw type, depeding of the raw flag
229  template<typename Type>
230  std::vector<std::vector<Type>> generateValue(bool raw = false) {
231  rawUserType newRawValue = static_cast<rawUserType>(get() + derived->rawIncrement);
232  Type v = (raw ? newRawValue : (newRawValue * derived->rawToCooked));
233  /* std::cout << "generateValue " << derived->path() << " " << float(rawUserType(get() + derived->rawIncrement))
234  << " -> " << float(v) << std::endl; */
235  lastPadding = acc & ~derived->bitmask;
236  printPaddingChangedMessage = true;
237  return {{v}};
238  }
239 
240  // We use the same function to implement raw and cooked reading.
241  // Do the calculation on the target type, then decide on the padding error.
242  // rawToCooked might undo the ++ effect in case
243  // of rounding. When getting cooked, the ++ must happen on the UserType.
244  // Type can be UserType or RawType.
245  template<typename Type>
246  std::vector<std::vector<Type>> getRemoteValue(bool raw = false) {
247  Type v = get() * (raw ? 1 : derived->rawToCooked);
248  if((acc & ~derived->bitmask) != lastPadding) {
249  if(printPaddingChangedMessage) {
250  std::cerr << "getRemoteValue(): Padding data has changed. Test will be failed by returing a false remote value "
251  << "(off by one)." << std::endl;
252  printPaddingChangedMessage = false;
253  }
254  v++;
255  return {{v}};
256  }
257  /* std::cout << "getRemoteValue " << derived->path() << " " << float(get()) << " -> " << float(v) << std::endl; */
258  return {{v}};
259  }
260 
261  void setRemoteValue() {
262  set(get() + derived->rawIncrement);
263  /* std::cout << "setRemoteValue " << derived->path() << " " << float(get()) << " -> " <<
264  getRemoteValue<float>()[0][0]
265  << std::endl; */
266  }
267 
268  void setForceRuntimeError(bool enable, size_t) {
269  exceptionDummy->throwExceptionRead = enable;
270  exceptionDummy->throwExceptionWrite = enable;
271  exceptionDummy->throwExceptionOpen = enable;
272  }
273 };
274 
275 /**********************************************************************************************************************/
276 
277 struct ShortRaw_signed16 : ShortRaw_base<ShortRaw_signed16, int16_t> {
278  std::string path() { return "/ShortRaw/signed16"; }
279  typedef int16_t minimumUserType;
281 
282  int16_t rawToCooked = 1;
283  // The rawIncrements are chosen such that we generate different values for different variables, and to cover the
284  // specific value range with very few values (to check signed vs. unsigned). Uncomment the above couts in the base
285  // class to check the generated values.
286  int16_t rawIncrement = 17117;
287  int bitshift = 0;
288  int32_t bitmask = 0x0000FFFF;
289 };
290 
291 /**********************************************************************************************************************/
292 
293 struct ShortRaw_unsigned16 : ShortRaw_base<ShortRaw_unsigned16, uint16_t> {
294  std::string path() { return "/ShortRaw/unsigned16"; }
295  typedef uint16_t minimumUserType;
296  typedef int16_t rawUserType;
297 
298  int16_t rawToCooked = 1;
299  int16_t rawIncrement = 17119;
300  int bitshift = 16;
301  int32_t bitmask = 0xFFFF0000;
302 };
303 
304 /**********************************************************************************************************************/
305 
306 struct ShortRaw_fixedPoint16_8u : ShortRaw_base<ShortRaw_fixedPoint16_8u, uint16_t> {
307  std::string path() { return "/ShortRaw/fixedPoint16_8u"; }
308  typedef float minimumUserType;
309  typedef int16_t rawUserType;
310 
311  float rawToCooked = 1. / 256.;
312  int16_t rawIncrement = 17121;
313  int bitshift = 0;
314  int32_t bitmask = 0x0000FFFF;
315 };
316 
317 /**********************************************************************************************************************/
318 
319 struct ShortRaw_fixedPoint16_8s : ShortRaw_base<ShortRaw_fixedPoint16_8s, int16_t> {
320  std::string path() { return "/ShortRaw/fixedPoint16_8s"; }
321  typedef float minimumUserType;
322  typedef int16_t rawUserType;
323 
324  float rawToCooked = 1. / 256.;
325  int16_t rawIncrement = 17123;
326  int bitshift = 16;
327  int32_t bitmask = 0xFFFF0000;
328 };
329 
330 /**********************************************************************************************************************/
331 
332 struct ByteRaw_signed8 : ShortRaw_base<ByteRaw_signed8, int8_t> {
333  std::string path() { return "/ByteRaw/signed8"; }
334  typedef int8_t minimumUserType;
335  typedef int8_t rawUserType;
336 
337  int8_t rawToCooked = 1;
338  int8_t rawIncrement = 119;
339  int bitshift = 0;
340  int32_t bitmask = 0x000000FF;
341 };
342 
343 /**********************************************************************************************************************/
344 
345 struct ByteRaw_unsigned8 : ShortRaw_base<ByteRaw_unsigned8, uint8_t> {
346  std::string path() { return "/ByteRaw/unsigned8"; }
347  typedef uint8_t minimumUserType;
348  typedef int8_t rawUserType;
349 
350  uint8_t rawToCooked = 1;
351  int8_t rawIncrement = 121;
352  int bitshift = 8;
353  int32_t bitmask = 0x0000FF00;
354 };
355 
356 /**********************************************************************************************************************/
357 
358 struct ByteRaw_fixedPoint8_4u : ShortRaw_base<ByteRaw_fixedPoint8_4u, uint8_t> {
359  std::string path() { return "/ByteRaw/fixedPoint8_4u"; }
360  typedef float minimumUserType;
361  typedef int8_t rawUserType;
362 
363  float rawToCooked = 1. / 16.;
364  int8_t rawIncrement = 123;
365  int bitshift = 16;
366  int32_t bitmask = 0x00FF0000;
367 };
368 
369 /**********************************************************************************************************************/
370 
371 struct ByteRaw_fixedPoint8_4s : ShortRaw_base<ByteRaw_fixedPoint8_4s, int8_t> {
372  std::string path() { return "/ByteRaw/fixedPoint8_4s"; }
373  typedef float minimumUserType;
374  typedef int8_t rawUserType;
375 
376  float rawToCooked = 1. / 16.;
377  int8_t rawIncrement = 125;
378  int bitshift = 24;
379  int32_t bitmask = 0xFF000000;
380 };
381 
382 /**********************************************************************************************************************/
383 
384 struct AsciiData {
385  static std::string path() { return "/Text/someAsciiData"; }
386  static bool isWriteable() { return true; }
387  static bool isReadable() { return true; }
388  using minimumUserType = std::string;
390 
391  static size_t nChannels() { return 1; }
392  static size_t nElementsPerChannel() { return 1; }
393  static size_t writeQueueLength() { return std::numeric_limits<size_t>::max(); }
394  static size_t nRuntimeErrorCases() { return 1; }
395 
396  static constexpr auto capabilities = TestCapabilities<>()
398  .disableAsyncReadInconsistency()
399  .disableSwitchReadOnly()
400  .disableSwitchWriteOnly()
401  .disableTestWriteNeverLosesData()
402  .disableTestRawTransfer();
403 
404  // Note: The DummyRegisterAccessor does not yet work properly with none 32-bit word sizes.
405  DummyRegisterAccessor<uint32_t> acc{exceptionDummy.get(), "Text", "someAsciiData_as_i32"};
406 
407  std::string textBase{"Some $%#@! characters "};
408  size_t counter{0};
409  const size_t asciiLength{35};
410 
411  template<typename UserType>
412  std::vector<std::vector<UserType>> generateValue() {
413  return {{textBase + std::to_string(counter++)}};
414  }
415 
416  template<typename UserType>
417  std::vector<std::vector<UserType>> getRemoteValue() {
418  std::vector<std::vector<UserType>> v{{""}};
419  for(size_t i = 0; i < asciiLength; ++i) {
420  size_t word = i / 4;
421  size_t byteInWord = i % 4;
422  char ch = char((acc[word] >> (byteInWord * 8U)) & 0xFF);
423  if(ch == 0) break;
424  v[0][0] += ch;
425  }
426  std::cout << "getRemoteValue: " << v[0][0] << std::endl;
427  return v;
428  }
429 
430  void setRemoteValue() {
431  auto v = generateValue<minimumUserType>();
432  for(size_t i = 0; i < acc.getNumberOfElements(); ++i) {
433  acc[i] = 0;
434  }
435  for(size_t i = 0; i < std::min(asciiLength, v[0][0].length()); ++i) {
436  char ch = v[0][0][i];
437  size_t word = i / 4;
438  size_t byteInWord = i % 4;
439  acc[word] = acc[word] | uint32_t(ch) << (byteInWord * 8U);
440  }
441  std::cout << "setRemoteValue: " << v[0][0] << std::endl;
442  }
443 
444  static void setForceRuntimeError(bool enable, size_t) {
445  exceptionDummy->throwExceptionRead = enable;
446  exceptionDummy->throwExceptionWrite = enable;
447  exceptionDummy->throwExceptionOpen = enable;
448  }
449 };
450 
451 /**********************************************************************************************************************/
452 
453 struct MuxedNodma {
454  std::string path() { return "/TEST/NODMA"; }
455  bool isWriteable() { return true; }
456  bool isReadable() { return true; }
458 
459  size_t nChannels() { return 16; }
460  size_t nElementsPerChannel() { return 4; }
461  size_t writeQueueLength() { return std::numeric_limits<size_t>::max(); }
462  size_t nRuntimeErrorCases() { return 1; }
463  typedef uint16_t minimumUserType;
465 
466  static constexpr auto capabilities = TestCapabilities<>()
468  .disableAsyncReadInconsistency()
469  .disableSwitchReadOnly()
470  .disableSwitchWriteOnly()
471  .disableTestWriteNeverLosesData()
472  .disableTestRawTransfer();
473 
474  DummyMultiplexedRegisterAccessor<uint16_t> acc{exceptionDummyMuxed.get(), "TEST", "NODMA"};
475 
476  template<typename UserType>
477  std::vector<std::vector<UserType>> generateValue() {
478  std::vector<std::vector<UserType>> v;
479  v.resize(nChannels());
480  for(size_t c = 0; c < nChannels(); ++c) {
481  for(size_t e = 0; e < nElementsPerChannel(); ++e) {
482  v[c].push_back(uint16_t(acc[c][e] + 7 * c + 3 * e));
483  }
484  }
485  return v;
486  }
487 
488  template<typename UserType>
489  std::vector<std::vector<UserType>> getRemoteValue() {
490  std::vector<std::vector<UserType>> v;
491  v.resize(nChannels());
492  for(size_t c = 0; c < nChannels(); ++c) {
493  for(size_t e = 0; e < nElementsPerChannel(); ++e) {
494  v[c].push_back(acc[c][e]);
495  }
496  }
497  return v;
498  }
499 
500  void setRemoteValue() {
501  auto v = generateValue<minimumUserType>();
502  for(size_t c = 0; c < nChannels(); ++c) {
503  for(size_t e = 0; e < nElementsPerChannel(); ++e) {
504  acc[c][e] = v[c][e];
505  }
506  }
507  }
508 
509  void setForceRuntimeError(bool enable, size_t) {
510  exceptionDummyMuxed->throwExceptionRead = enable;
511  exceptionDummyMuxed->throwExceptionWrite = enable;
512  exceptionDummyMuxed->throwExceptionOpen = enable;
513  }
514 };
515 
517  std::string path() { return "/TEST/NODMAASYNC"; }
518  bool isWriteable() { return false; }
519  bool isReadable() { return true; }
521 
522  size_t nChannels() { return 16; }
523  size_t nElementsPerChannel() { return 4; }
524  size_t writeQueueLength() { return std::numeric_limits<size_t>::max(); }
525  size_t nRuntimeErrorCases() { return 1; }
526  typedef uint16_t minimumUserType;
528 
529  static constexpr auto capabilities = TestCapabilities<>()
531  .disableAsyncReadInconsistency()
532  .disableSwitchReadOnly()
533  .disableSwitchWriteOnly()
534  .disableTestWriteNeverLosesData()
535  .disableTestRawTransfer();
536 
537  DummyMultiplexedRegisterAccessor<uint16_t> acc{exceptionDummyMuxed.get(), "TEST", "NODMAASYNC"};
538 
539  template<typename UserType>
540  std::vector<std::vector<UserType>> generateValue() {
541  std::vector<std::vector<UserType>> v;
542  v.resize(nChannels());
543  for(size_t c = 0; c < nChannels(); ++c) {
544  for(size_t e = 0; e < nElementsPerChannel(); ++e) {
545  v[c].push_back(uint16_t(acc[c][e] + 7 * c + 3 * e));
546  }
547  }
548  return v;
549  }
550 
551  template<typename UserType>
552  std::vector<std::vector<UserType>> getRemoteValue() {
553  std::vector<std::vector<UserType>> v;
554  v.resize(nChannels());
555  for(size_t c = 0; c < nChannels(); ++c) {
556  for(size_t e = 0; e < nElementsPerChannel(); ++e) {
557  v[c].push_back(acc[c][e]);
558  }
559  }
560  return v;
561  }
562 
563  void setRemoteValue() {
564  auto v = generateValue<minimumUserType>();
565  for(size_t c = 0; c < nChannels(); ++c) {
566  for(size_t e = 0; e < nElementsPerChannel(); ++e) {
567  acc[c][e] = v[c][e];
568  }
569  }
570  if(exceptionDummyMuxed->isOpen()) exceptionDummyMuxed->triggerInterrupt(6);
571  }
572 
573  void setForceRuntimeError(bool enable, size_t) {
574  exceptionDummyMuxed->throwExceptionRead = enable;
575  exceptionDummyMuxed->throwExceptionWrite = enable;
576  exceptionDummyMuxed->throwExceptionOpen = enable;
577  if(exceptionDummyMuxed->isOpen()) exceptionDummyMuxed->triggerInterrupt(6);
578  }
579 };
580 
581 /**********************************************************************************************************************/
582 
583 struct MuxedFloat {
584  std::string path() { return "/TEST/FLOAT"; }
585  bool isWriteable() { return true; }
586  bool isReadable() { return true; }
588 
589  size_t nChannels() { return 4; }
590  size_t nElementsPerChannel() { return 8; }
591  size_t nRuntimeErrorCases() { return 1; }
592  typedef float minimumUserType;
593  // typedef int32_t rawUserType;
594 
595  static constexpr auto capabilities = TestCapabilities<>()
597  .disableAsyncReadInconsistency()
598  .disableSwitchReadOnly()
599  .disableSwitchWriteOnly()
600  .disableTestWriteNeverLosesData()
601  .disableTestRawTransfer();
602 
603  DummyMultiplexedRegisterAccessor<int32_t> rawAcc{exceptionDummyMuxed.get(), "TEST", "FLOAT"};
604 
605  template<typename UserType>
606  std::vector<std::vector<UserType>> generateValue() {
607  std::vector<std::vector<UserType>> v;
608  v.resize(nChannels());
609  for(uint32_t c = 0; c < nChannels(); ++c) {
610  for(uint32_t e = 0; e < nElementsPerChannel(); ++e) {
611  int32_t rawValue = rawAcc[c][e];
612  float* cookedValue = reinterpret_cast<float*>(&rawValue);
613  v[c].push_back(*cookedValue + 0.7f * c + 3 * e);
614  }
615  }
616  return v;
617  }
618 
619  template<typename UserType>
620  std::vector<std::vector<UserType>> getRemoteValue() {
621  std::vector<std::vector<UserType>> v;
622  v.resize(nChannels());
623  for(uint32_t c = 0; c < nChannels(); ++c) {
624  for(uint32_t e = 0; e < nElementsPerChannel(); ++e) {
625  int32_t rawValue = rawAcc[c][e];
626  float* cookedValue = reinterpret_cast<float*>(&rawValue);
627  v[c].push_back(*cookedValue);
628  }
629  }
630  return v;
631  }
632 
633  void setRemoteValue() {
634  auto v = generateValue<minimumUserType>();
635  for(uint32_t c = 0; c < nChannels(); ++c) {
636  for(uint32_t e = 0; e < nElementsPerChannel(); ++e) {
637  int32_t rawValue;
638  float* cookedValue = reinterpret_cast<float*>(&rawValue);
639  *cookedValue = v[c][e];
640  std::cout << "raw value is " << rawValue << "; cookedValue is " << *cookedValue << std::endl;
641  rawAcc[c][e] = rawValue;
642  }
643  }
644  }
645 
646  void setForceRuntimeError(bool enable, size_t) {
647  exceptionDummyMuxed->throwExceptionRead = enable;
648  exceptionDummyMuxed->throwExceptionWrite = enable;
649  exceptionDummyMuxed->throwExceptionOpen = enable;
650  }
651 };
652 
653 /**********************************************************************************************************************/
654 
655 BOOST_AUTO_TEST_CASE(testRegisterAccessor) {
656  std::cout << "*** testRegisterAccessor *** " << std::endl;
659  .addRegister<Integers_signed32_async>()
660  /* .addRegister<Integers_signed32_async_rw>() // disabled for now as .DUMMY_WRITABLE no longer supports
661  wait_for_new_data */
662  .addRegister<ShortRaw_signed16>()
663  .addRegister<ShortRaw_unsigned16>()
664  .addRegister<ShortRaw_fixedPoint16_8u>()
665  .addRegister<ShortRaw_fixedPoint16_8s>()
666  .addRegister<ByteRaw_signed8>()
667  .addRegister<ByteRaw_unsigned8>()
668  .addRegister<ByteRaw_fixedPoint8_4s>()
669  .addRegister<ByteRaw_fixedPoint8_4u>()
670  .addRegister<AsciiData>()
671  .runTests(cdd);
672 }
673 
674 /**********************************************************************************************************************/
675 
676 BOOST_AUTO_TEST_CASE(testMultiplexedRegisterAccessor) {
677  std::cout << "*** testMultiplexedRegisterAccessor *** " << std::endl;
680  .addRegister<MuxedNodmaAsync>()
681  .addRegister<MuxedFloat>()
682  .runTests(cddMuxed);
683 }
684 
685 /**********************************************************************************************************************/
686 
687 BOOST_AUTO_TEST_SUITE_END()
MuxedNodma::path
std::string path()
Definition: testNumericAddressedBackendUnified.cpp:454
ExceptionDummyBackend.h
Integers_signed32::supportedFlags
ChimeraTK::AccessModeFlags supportedFlags()
Definition: testNumericAddressedBackendUnified.cpp:48
AsciiData::nRuntimeErrorCases
static size_t nRuntimeErrorCases()
Definition: testNumericAddressedBackendUnified.cpp:394
Integers_signed32::minimumUserType
int32_t minimumUserType
Definition: testNumericAddressedBackendUnified.cpp:53
MuxedFloat::nRuntimeErrorCases
size_t nRuntimeErrorCases()
Definition: testNumericAddressedBackendUnified.cpp:591
Integers_signed32_async::supportedFlags
ChimeraTK::AccessModeFlags supportedFlags()
Definition: testNumericAddressedBackendUnified.cpp:89
Integers_signed32_async_rw::isReadable
bool isReadable()
Definition: testNumericAddressedBackendUnified.cpp:137
MuxedNodmaAsync::nElementsPerChannel
size_t nElementsPerChannel()
Definition: testNumericAddressedBackendUnified.cpp:523
ShortRaw_base::getRemoteValue
std::vector< std::vector< Type > > getRemoteValue(bool raw=false)
Definition: testNumericAddressedBackendUnified.cpp:246
ShortRaw_fixedPoint16_8s::path
std::string path()
Definition: testNumericAddressedBackendUnified.cpp:320
MuxedNodmaAsync::nRuntimeErrorCases
size_t nRuntimeErrorCases()
Definition: testNumericAddressedBackendUnified.cpp:525
Integers_signed32::nRuntimeErrorCases
size_t nRuntimeErrorCases()
Definition: testNumericAddressedBackendUnified.cpp:52
TransferGroup.h
ChimeraTK::AccessMode::raw
@ raw
Raw access: disable any possible conversion from the original hardware data type into the given UserT...
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(testRegisterAccessor)
Definition: testNumericAddressedBackendUnified.cpp:655
ByteRaw_unsigned8::minimumUserType
uint8_t minimumUserType
Definition: testNumericAddressedBackendUnified.cpp:347
ShortRaw_unsigned16
Definition: testNumericAddressedBackendUnified.cpp:293
ByteRaw_fixedPoint8_4s
Definition: testNumericAddressedBackendUnified.cpp:371
Integers_signed32_async_rw::forceAsyncReadInconsistency
void forceAsyncReadInconsistency()
Definition: testNumericAddressedBackendUnified.cpp:173
ChimeraTK::DummyRegisterAccessor< int32_t >
ShortRaw_base::isReadable
bool isReadable()
Definition: testNumericAddressedBackendUnified.cpp:190
ShortRaw_fixedPoint16_8u
Definition: testNumericAddressedBackendUnified.cpp:306
MuxedNodma::supportedFlags
ChimeraTK::AccessModeFlags supportedFlags()
Definition: testNumericAddressedBackendUnified.cpp:457
MuxedNodmaAsync::generateValue
std::vector< std::vector< UserType > > generateValue()
Definition: testNumericAddressedBackendUnified.cpp:540
MuxedFloat::nChannels
size_t nChannels()
Definition: testNumericAddressedBackendUnified.cpp:589
MuxedFloat
Definition: testNumericAddressedBackendUnified.cpp:583
ChimeraTK::DummyMultiplexedRegisterAccessor< uint16_t >
AsciiData::setRemoteValue
void setRemoteValue()
Definition: testNumericAddressedBackendUnified.cpp:430
AsciiData::nChannels
static size_t nChannels()
Definition: testNumericAddressedBackendUnified.cpp:391
DummyBackend.h
MuxedNodmaAsync::rawUserType
minimumUserType rawUserType
Definition: testNumericAddressedBackendUnified.cpp:527
ShortRaw_base::setRemoteValue
void setRemoteValue()
Definition: testNumericAddressedBackendUnified.cpp:261
Integers_signed32_async_rw::rawUserType
minimumUserType rawUserType
Definition: testNumericAddressedBackendUnified.cpp:146
ByteRaw_signed8::path
std::string path()
Definition: testNumericAddressedBackendUnified.cpp:333
ShortRaw_unsigned16::rawUserType
int16_t rawUserType
Definition: testNumericAddressedBackendUnified.cpp:296
Integers_signed32
Definition: testNumericAddressedBackendUnified.cpp:44
MuxedNodmaAsync::nChannels
size_t nChannels()
Definition: testNumericAddressedBackendUnified.cpp:522
ShortRaw_base::generateValue
std::vector< std::vector< Type > > generateValue(bool raw=false)
Definition: testNumericAddressedBackendUnified.cpp:230
AsciiData::minimumUserType
std::string minimumUserType
Definition: testNumericAddressedBackendUnified.cpp:388
MuxedNodma::setForceRuntimeError
void setForceRuntimeError(bool enable, size_t)
Definition: testNumericAddressedBackendUnified.cpp:509
AsciiData::generateValue
std::vector< std::vector< UserType > > generateValue()
Definition: testNumericAddressedBackendUnified.cpp:412
ByteRaw_fixedPoint8_4s::path
std::string path()
Definition: testNumericAddressedBackendUnified.cpp:372
Integers_signed32::isWriteable
bool isWriteable()
Definition: testNumericAddressedBackendUnified.cpp:46
Integers_signed32::setRemoteValue
void setRemoteValue()
Definition: testNumericAddressedBackendUnified.cpp:76
AsciiData::path
static std::string path()
Definition: testNumericAddressedBackendUnified.cpp:385
Integers_signed32_async::forceAsyncReadInconsistency
void forceAsyncReadInconsistency()
Definition: testNumericAddressedBackendUnified.cpp:124
MuxedFloat::path
std::string path()
Definition: testNumericAddressedBackendUnified.cpp:584
Integers_signed32::nChannels
size_t nChannels()
Definition: testNumericAddressedBackendUnified.cpp:49
ShortRaw_unsigned16::path
std::string path()
Definition: testNumericAddressedBackendUnified.cpp:294
Integers_signed32::nElementsPerChannel
size_t nElementsPerChannel()
Definition: testNumericAddressedBackendUnified.cpp:50
AsciiData::nElementsPerChannel
static size_t nElementsPerChannel()
Definition: testNumericAddressedBackendUnified.cpp:392
MuxedFloat::generateValue
std::vector< std::vector< UserType > > generateValue()
Definition: testNumericAddressedBackendUnified.cpp:606
MuxedNodma::isWriteable
bool isWriteable()
Definition: testNumericAddressedBackendUnified.cpp:455
MuxedNodmaAsync::setForceRuntimeError
void setForceRuntimeError(bool enable, size_t)
Definition: testNumericAddressedBackendUnified.cpp:573
cdd
std::string cdd
Definition: testAsyncRead.cpp:25
ChimeraTK::TestCapabilities
Descriptor for the test capabilities for each register.
Definition: UnifiedBackendTest.h:54
Integers_signed32_async_rw::path
std::string path()
Definition: testNumericAddressedBackendUnified.cpp:135
Integers_signed32_async::rawUserType
minimumUserType rawUserType
Definition: testNumericAddressedBackendUnified.cpp:97
Integers_signed32_async_rw::nElementsPerChannel
size_t nElementsPerChannel()
Definition: testNumericAddressedBackendUnified.cpp:142
MuxedNodmaAsync::supportedFlags
ChimeraTK::AccessModeFlags supportedFlags()
Definition: testNumericAddressedBackendUnified.cpp:520
MuxedNodma
Definition: testNumericAddressedBackendUnified.cpp:453
Integers_signed32_async::isReadable
bool isReadable()
Definition: testNumericAddressedBackendUnified.cpp:88
MuxedNodma::generateValue
std::vector< std::vector< UserType > > generateValue()
Definition: testNumericAddressedBackendUnified.cpp:477
MuxedFloat::supportedFlags
ChimeraTK::AccessModeFlags supportedFlags()
Definition: testNumericAddressedBackendUnified.cpp:587
Integers_signed32_async_rw::minimumUserType
int32_t minimumUserType
Definition: testNumericAddressedBackendUnified.cpp:145
MuxedFloat::isReadable
bool isReadable()
Definition: testNumericAddressedBackendUnified.cpp:586
ShortRaw_base::isWriteable
bool isWriteable()
Definition: testNumericAddressedBackendUnified.cpp:189
Integers_signed32::setForceRuntimeError
void setForceRuntimeError(bool enable, size_t)
Definition: testNumericAddressedBackendUnified.cpp:78
MuxedNodma::nChannels
size_t nChannels()
Definition: testNumericAddressedBackendUnified.cpp:459
Integers_signed32_async_rw
Definition: testNumericAddressedBackendUnified.cpp:133
Integers_signed32_async::nChannels
size_t nChannels()
Definition: testNumericAddressedBackendUnified.cpp:92
Integers_signed32_async_rw::setRemoteValue
void setRemoteValue()
Definition: testNumericAddressedBackendUnified.cpp:168
MuxedNodmaAsync::path
std::string path()
Definition: testNumericAddressedBackendUnified.cpp:517
ShortRaw_signed16
Definition: testNumericAddressedBackendUnified.cpp:277
ByteRaw_unsigned8
Definition: testNumericAddressedBackendUnified.cpp:345
MuxedNodma::nElementsPerChannel
size_t nElementsPerChannel()
Definition: testNumericAddressedBackendUnified.cpp:460
MuxedFloat::isWriteable
bool isWriteable()
Definition: testNumericAddressedBackendUnified.cpp:585
MuxedNodmaAsync::writeQueueLength
size_t writeQueueLength()
Definition: testNumericAddressedBackendUnified.cpp:524
AsciiData::setForceRuntimeError
static void setForceRuntimeError(bool enable, size_t)
Definition: testNumericAddressedBackendUnified.cpp:444
ByteRaw_fixedPoint8_4s::rawUserType
int8_t rawUserType
Definition: testNumericAddressedBackendUnified.cpp:374
MuxedNodmaAsync
Definition: testNumericAddressedBackendUnified.cpp:516
ShortRaw_signed16::minimumUserType
int16_t minimumUserType
Definition: testNumericAddressedBackendUnified.cpp:279
ShortRaw_base::nChannels
size_t nChannels()
Definition: testNumericAddressedBackendUnified.cpp:192
ByteRaw_fixedPoint8_4u::rawUserType
int8_t rawUserType
Definition: testNumericAddressedBackendUnified.cpp:361
ShortRaw_base
Definition: testNumericAddressedBackendUnified.cpp:186
ShortRaw_fixedPoint16_8u::rawUserType
int16_t rawUserType
Definition: testNumericAddressedBackendUnified.cpp:309
ChimeraTK::AccessMode::wait_for_new_data
@ wait_for_new_data
Make any read blocking until new data has arrived since the last read.
Integers_signed32::isReadable
bool isReadable()
Definition: testNumericAddressedBackendUnified.cpp:47
ByteRaw_fixedPoint8_4u
Definition: testNumericAddressedBackendUnified.cpp:358
Integers_signed32::rawUserType
minimumUserType rawUserType
Definition: testNumericAddressedBackendUnified.cpp:54
Device.h
ByteRaw_fixedPoint8_4u::minimumUserType
float minimumUserType
Definition: testNumericAddressedBackendUnified.cpp:360
ShortRaw_signed16::rawUserType
minimumUserType rawUserType
Definition: testNumericAddressedBackendUnified.cpp:280
ShortRaw_fixedPoint16_8s::minimumUserType
float minimumUserType
Definition: testNumericAddressedBackendUnified.cpp:321
Integers_signed32_async::getRemoteValue
std::vector< std::vector< UserType > > getRemoteValue([[maybe_unused]] bool raw=false)
Definition: testNumericAddressedBackendUnified.cpp:115
MuxedFloat::getRemoteValue
std::vector< std::vector< UserType > > getRemoteValue()
Definition: testNumericAddressedBackendUnified.cpp:620
ShortRaw_fixedPoint16_8u::minimumUserType
float minimumUserType
Definition: testNumericAddressedBackendUnified.cpp:308
MuxedNodma::setRemoteValue
void setRemoteValue()
Definition: testNumericAddressedBackendUnified.cpp:500
Integers_signed32_async_rw::getRemoteValue
std::vector< std::vector< UserType > > getRemoteValue([[maybe_unused]] bool raw=false)
Definition: testNumericAddressedBackendUnified.cpp:164
Integers_signed32::path
std::string path()
Definition: testNumericAddressedBackendUnified.cpp:45
MuxedNodmaAsync::getRemoteValue
std::vector< std::vector< UserType > > getRemoteValue()
Definition: testNumericAddressedBackendUnified.cpp:552
Integers_signed32_async_rw::nRuntimeErrorCases
size_t nRuntimeErrorCases()
Definition: testNumericAddressedBackendUnified.cpp:144
ShortRaw_base::writeQueueLength
size_t writeQueueLength()
Definition: testNumericAddressedBackendUnified.cpp:194
Integers_signed32::writeQueueLength
size_t writeQueueLength()
Definition: testNumericAddressedBackendUnified.cpp:51
ShortRaw_signed16::path
std::string path()
Definition: testNumericAddressedBackendUnified.cpp:278
ChimeraTK::UnifiedBackendTest
Class to test any backend for correct behaviour.
Definition: UnifiedBackendTest.h:259
ShortRaw_base::setForceRuntimeError
void setForceRuntimeError(bool enable, size_t)
Definition: testNumericAddressedBackendUnified.cpp:268
ChimeraTK::DummyRegisterRawAccessor
Accessor for raw 32 bit integer access to the underlying memory space.
Definition: DummyRegisterAccessor.h:324
MuxedFloat::minimumUserType
float minimumUserType
Definition: testNumericAddressedBackendUnified.cpp:592
AsciiData
Definition: testNumericAddressedBackendUnified.cpp:384
Integers_signed32_async::writeQueueLength
size_t writeQueueLength()
Definition: testNumericAddressedBackendUnified.cpp:94
ShortRaw_unsigned16::minimumUserType
uint16_t minimumUserType
Definition: testNumericAddressedBackendUnified.cpp:295
ChimeraTK::TestCapabilities::disableForceDataLossWrite
constexpr TestCapabilities< _syncRead, TestCapability::disabled, _asyncReadInconsistency, _switchReadOnly, _switchWriteOnly, _writeNeverLosesData, _testWriteOnly, _testReadOnly, _testRawTransfer, _testCatalogue, _setRemoteValueIncrementsVersion > disableForceDataLossWrite() const
Definition: UnifiedBackendTest.h:81
AsciiData::isReadable
static bool isReadable()
Definition: testNumericAddressedBackendUnified.cpp:387
MuxedNodmaAsync::isReadable
bool isReadable()
Definition: testNumericAddressedBackendUnified.cpp:519
ShortRaw_fixedPoint16_8s
Definition: testNumericAddressedBackendUnified.cpp:319
AsciiData::writeQueueLength
static size_t writeQueueLength()
Definition: testNumericAddressedBackendUnified.cpp:393
MuxedNodma::isReadable
bool isReadable()
Definition: testNumericAddressedBackendUnified.cpp:456
MuxedFloat::setForceRuntimeError
void setForceRuntimeError(bool enable, size_t)
Definition: testNumericAddressedBackendUnified.cpp:646
Integers_signed32_async::isWriteable
bool isWriteable()
Definition: testNumericAddressedBackendUnified.cpp:87
MuxedNodmaAsync::setRemoteValue
void setRemoteValue()
Definition: testNumericAddressedBackendUnified.cpp:563
ByteRaw_signed8
Definition: testNumericAddressedBackendUnified.cpp:332
Integers_signed32_async::minimumUserType
int32_t minimumUserType
Definition: testNumericAddressedBackendUnified.cpp:96
Integers_signed32_async_rw::supportedFlags
ChimeraTK::AccessModeFlags supportedFlags()
Definition: testNumericAddressedBackendUnified.cpp:138
MuxedNodmaAsync::minimumUserType
uint16_t minimumUserType
Definition: testNumericAddressedBackendUnified.cpp:526
MuxedNodma::minimumUserType
uint16_t minimumUserType
Definition: testNumericAddressedBackendUnified.cpp:463
Integers_signed32_async::generateValue
std::vector< std::vector< Type > > generateValue([[maybe_unused]] bool raw=false)
Definition: testNumericAddressedBackendUnified.cpp:110
AsciiData::supportedFlags
static ChimeraTK::AccessModeFlags supportedFlags()
Definition: testNumericAddressedBackendUnified.cpp:389
Integers_signed32_async::nElementsPerChannel
size_t nElementsPerChannel()
Definition: testNumericAddressedBackendUnified.cpp:93
DummyRegisterAccessor.h
ShortRaw_fixedPoint16_8s::rawUserType
int16_t rawUserType
Definition: testNumericAddressedBackendUnified.cpp:322
Integers_signed32_async
Definition: testNumericAddressedBackendUnified.cpp:85
MuxedFloat::nElementsPerChannel
size_t nElementsPerChannel()
Definition: testNumericAddressedBackendUnified.cpp:590
BackendFactory.h
MuxedNodma::getRemoteValue
std::vector< std::vector< UserType > > getRemoteValue()
Definition: testNumericAddressedBackendUnified.cpp:489
MuxedNodma::writeQueueLength
size_t writeQueueLength()
Definition: testNumericAddressedBackendUnified.cpp:461
Integers_signed32_async::nRuntimeErrorCases
size_t nRuntimeErrorCases()
Definition: testNumericAddressedBackendUnified.cpp:95
Integers_signed32::generateValue
std::vector< std::vector< Type > > generateValue([[maybe_unused]] bool raw=false)
Definition: testNumericAddressedBackendUnified.cpp:67
Integers_signed32_async_rw::writeQueueLength
size_t writeQueueLength()
Definition: testNumericAddressedBackendUnified.cpp:143
ShortRaw_base::set
void set(rawUserType val)
Definition: testNumericAddressedBackendUnified.cpp:221
Integers_signed32_async::setRemoteValue
void setRemoteValue()
Definition: testNumericAddressedBackendUnified.cpp:119
ShortRaw_base::nRuntimeErrorCases
size_t nRuntimeErrorCases()
Definition: testNumericAddressedBackendUnified.cpp:195
ByteRaw_signed8::minimumUserType
int8_t minimumUserType
Definition: testNumericAddressedBackendUnified.cpp:334
Integers_signed32_async::setForceRuntimeError
void setForceRuntimeError(bool enable, size_t)
Definition: testNumericAddressedBackendUnified.cpp:126
AsciiData::getRemoteValue
std::vector< std::vector< UserType > > getRemoteValue()
Definition: testNumericAddressedBackendUnified.cpp:417
ChimeraTK::AccessModeFlags
Set of AccessMode flags with additional functionality for an easier handling.
Definition: AccessMode.h:48
MuxedNodmaAsync::isWriteable
bool isWriteable()
Definition: testNumericAddressedBackendUnified.cpp:518
ByteRaw_unsigned8::rawUserType
int8_t rawUserType
Definition: testNumericAddressedBackendUnified.cpp:348
ShortRaw_base::supportedFlags
ChimeraTK::AccessModeFlags supportedFlags()
Definition: testNumericAddressedBackendUnified.cpp:191
AsciiData::isWriteable
static bool isWriteable()
Definition: testNumericAddressedBackendUnified.cpp:386
ByteRaw_signed8::rawUserType
int8_t rawUserType
Definition: testNumericAddressedBackendUnified.cpp:335
ChimeraTK
Definition: DummyBackend.h:16
Integers_signed32::getRemoteValue
std::vector< std::vector< UserType > > getRemoteValue([[maybe_unused]] bool raw=false)
Definition: testNumericAddressedBackendUnified.cpp:72
UnifiedBackendTest.h
ChimeraTK::to_string
std::string to_string(Boolean &value)
Definition: SupportedUserTypes.h:59
Integers_signed32_async::path
std::string path()
Definition: testNumericAddressedBackendUnified.cpp:86
exceptionDummy
auto exceptionDummy
Definition: testExceptionDummyDevice.cc:16
MuxedFloat::setRemoteValue
void setRemoteValue()
Definition: testNumericAddressedBackendUnified.cpp:633
Integers_signed32_async_rw::nChannels
size_t nChannels()
Definition: testNumericAddressedBackendUnified.cpp:141
ChimeraTK::UnifiedBackendTest::addRegister
UnifiedBackendTest< typename boost::mpl::push_back< VECTOR_OF_REGISTERS_T, REG_T >::type > addRegister()
Add a register to be used by the test.
Definition: UnifiedBackendTest.h:352
ByteRaw_unsigned8::path
std::string path()
Definition: testNumericAddressedBackendUnified.cpp:346
ShortRaw_base::nElementsPerChannel
size_t nElementsPerChannel()
Definition: testNumericAddressedBackendUnified.cpp:193
Integers_signed32_async_rw::setForceRuntimeError
void setForceRuntimeError(bool enable, size_t)
Definition: testNumericAddressedBackendUnified.cpp:175
MuxedNodma::nRuntimeErrorCases
size_t nRuntimeErrorCases()
Definition: testNumericAddressedBackendUnified.cpp:462
ShortRaw_fixedPoint16_8u::path
std::string path()
Definition: testNumericAddressedBackendUnified.cpp:307
Integers_signed32_async_rw::generateValue
std::vector< std::vector< Type > > generateValue([[maybe_unused]] bool raw=false)
Definition: testNumericAddressedBackendUnified.cpp:159
ByteRaw_fixedPoint8_4u::path
std::string path()
Definition: testNumericAddressedBackendUnified.cpp:359
ByteRaw_fixedPoint8_4s::minimumUserType
float minimumUserType
Definition: testNumericAddressedBackendUnified.cpp:373
ShortRaw_base::get
rawUserType get()
Definition: testNumericAddressedBackendUnified.cpp:219
Integers_signed32_async_rw::isWriteable
bool isWriteable()
Definition: testNumericAddressedBackendUnified.cpp:136
MuxedNodma::rawUserType
minimumUserType rawUserType
Definition: testNumericAddressedBackendUnified.cpp:464