ChimeraTK-DeviceAccess-DoocsBackend  01.09.02
RegisterInfo.cc
Go to the documentation of this file.
1 #include "RegisterInfo.h"
2 
3 #include <eq_types.h>
4 
5 #include <boost/shared_ptr.hpp>
6 
7 /*******************************************************************************************************************/
8 
10  const std::string& name, unsigned int length, int doocsType, ChimeraTK::AccessModeFlags flags) {
12 
13  info._name = name;
14  info._length = length;
15  info.doocsTypeId = doocsType;
16  info.accessModeFlags = flags;
17 
18  if(info._length == 0) {
19  // DOOCS reports 0 if not an array
20  info._length = 1;
21  }
22  if(doocsType == DATA_TEXT || doocsType == DATA_STRING || doocsType == DATA_USTR) {
23  // in case of strings, DOOCS reports the length of the string
24  info._length = 1;
25  info.dataDescriptor = ChimeraTK::DataDescriptor(ChimeraTK::DataDescriptor::FundamentalType::string);
26  if(!hasRegister(info.getRegisterName())) addRegister(info);
27  }
28  else if(doocsType == DATA_INT || doocsType == DATA_A_INT || doocsType == DATA_A_SHORT || doocsType == DATA_A_LONG ||
29  doocsType == DATA_A_BYTE || doocsType == DATA_IIII) { // integral data types
30  size_t digits;
31  if(doocsType == DATA_A_SHORT) { // 16 bit signed
32  digits = 6;
33  }
34  else if(doocsType == DATA_A_BYTE) { // 8 bit signed
35  digits = 4;
36  }
37  else if(doocsType == DATA_A_LONG) { // 64 bit signed
38  digits = 20;
39  }
40  else { // 32 bit signed
41  digits = 11;
42  }
43  if(doocsType == DATA_IIII) info._length = 4;
44 
45  info.dataDescriptor =
46  ChimeraTK::DataDescriptor(ChimeraTK::DataDescriptor::FundamentalType::numeric, true, true, digits);
47  if(!hasRegister(info.getRegisterName())) addRegister(info);
48  }
49  else if(doocsType == DATA_IFFF) {
50  info._name = name + "/I";
51  info.dataDescriptor = ChimeraTK::DataDescriptor(
52  ChimeraTK::DataDescriptor::FundamentalType::numeric, true, true, 11); // 32 bit integer
53 
54  DoocsBackendRegisterInfo infoF1(info);
55  infoF1._name = name + "/F1";
56  infoF1.dataDescriptor =
57  ChimeraTK::DataDescriptor(ChimeraTK::DataDescriptor::FundamentalType::numeric, false, true, 320, 300); // float
58 
59  DoocsBackendRegisterInfo infoF2(infoF1);
60  infoF2._name = name + "/F2";
61 
62  DoocsBackendRegisterInfo infoF3(infoF1);
63  infoF3._name = name + "/F3";
64 
65  if(!hasRegister(info.getRegisterName())) addRegister(info);
66  if(!hasRegister(infoF1.getRegisterName())) addRegister(infoF1);
67  if(!hasRegister(infoF2.getRegisterName())) addRegister(infoF2);
68  if(!hasRegister(infoF3.getRegisterName())) addRegister(infoF3);
69  }
70  else if(doocsType == DATA_IMAGE) {
71  // data type for created accessor is uint8
72  info.dataDescriptor = ChimeraTK::DataDescriptor(
73  ChimeraTK::DataDescriptor::FundamentalType::numeric, true, false, 3, 0, ChimeraTK::DataType::uint8);
74  info._writable = false;
75  if(!hasRegister(info.getRegisterName())) addRegister(info);
76  }
77  else { // floating point data types: always treat like double
78  info.dataDescriptor =
79  ChimeraTK::DataDescriptor(ChimeraTK::DataDescriptor::FundamentalType::numeric, false, true, 320, 300);
80  if(!hasRegister(info.getRegisterName())) addRegister(info);
81  }
82 
83  DoocsBackendRegisterInfo infoEventId;
84  infoEventId._name = name + "/eventId";
85  infoEventId._writable = false;
86  infoEventId.doocsTypeId = DATA_LONG;
87  infoEventId._length = 1;
88  infoEventId.dataDescriptor =
89  ChimeraTK::DataDescriptor(ChimeraTK::DataDescriptor::FundamentalType::numeric, true, true, 20);
90  infoEventId.accessModeFlags = flags;
91  if(!hasRegister(infoEventId.getRegisterName())) addRegister(infoEventId);
92 
93  DoocsBackendRegisterInfo infoTimeStamp;
94  infoTimeStamp._name = name + "/timeStamp";
95  infoTimeStamp.doocsTypeId = DATA_LONG;
96  infoTimeStamp._length = 1;
97  infoTimeStamp.dataDescriptor =
98  ChimeraTK::DataDescriptor(ChimeraTK::DataDescriptor::FundamentalType::numeric, true, true, 20);
99  infoTimeStamp._writable = false;
100  infoTimeStamp.accessModeFlags = flags;
101  if(!hasRegister(infoTimeStamp.getRegisterName())) addRegister(infoTimeStamp);
102 }
103 
104 /*******************************************************************************************************************/
105 
106 std::unique_ptr<ChimeraTK::BackendRegisterInfoBase> DoocsBackendRegisterInfo::clone() const {
107  return std::unique_ptr<ChimeraTK::BackendRegisterInfoBase>(new DoocsBackendRegisterInfo(*this));
108 }
109 
110 /*******************************************************************************************************************/
DoocsBackendRegisterCatalogue::addProperty
void addProperty(const std::string &name, unsigned int length, int doocsType, ChimeraTK::AccessModeFlags flags)
Definition: RegisterInfo.cc:9
DoocsBackendRegisterInfo::doocsTypeId
int doocsTypeId
Definition: RegisterInfo.h:43
DoocsBackendRegisterInfo::_length
unsigned int _length
Definition: RegisterInfo.h:40
DoocsBackendRegisterInfo::getRegisterName
ChimeraTK::RegisterPath getRegisterName() const override
Definition: RegisterInfo.h:23
DoocsBackendRegisterInfo::_name
ChimeraTK::RegisterPath _name
Definition: RegisterInfo.h:39
RegisterInfo.h
DoocsBackendRegisterInfo::dataDescriptor
ChimeraTK::DataDescriptor dataDescriptor
Definition: RegisterInfo.h:41
DoocsBackendRegisterInfo::clone
std::unique_ptr< BackendRegisterInfoBase > clone() const override
Definition: RegisterInfo.cc:106
DoocsBackendRegisterInfo::accessModeFlags
ChimeraTK::AccessModeFlags accessModeFlags
Definition: RegisterInfo.h:42
DoocsBackendRegisterInfo
Definition: RegisterInfo.h:21
DoocsBackendRegisterInfo::_writable
bool _writable
Definition: RegisterInfo.h:45