otsdaq  v2_04_00
FESlowControlsTable_table.cc
1 #include "otsdaq-core/Macros/TablePluginMacros.h"
2 #include "otsdaq-core/TablePluginDataFormats/FESlowControlsTable.h"
3 
4 #include "otsdaq-core/ConfigurationInterface/ConfigurationManager.h"
5 
6 #include <iostream>
7 
8 using namespace ots;
9 
10 //==============================================================================
11 FESlowControlsTable::FESlowControlsTable(void) : TableBase("FESlowControlsTable")
12 {
13  // <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
14  // <ROOT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
15  // xsi:noNamespaceSchemaLocation="TableInfo.xsd"> <TABLE
16  // Name="FESlowControlsTable"> <VIEW
17  // Name="SLOW_CONTROLS_OTS_FE_CHANNELS_TABLE"
18  // Type="File,Database,DatabaseTest"> <COLUMN
19  // Type="GroupID-SlowControls" Name="FEGroupID" StorageName="FE_GROUP_ID"
20  // DataType="VARCHAR2"/> <COLUMN Type="UID" Name="ChannelName"
21  // StorageName="CHANNEL_NAME" DataType="VARCHAR2"/> <COLUMN
22  // Type="Data" Name="ChannelDataType" StorageName="CHANNEL_DATA_TYPE"
23  // DataType="VARCHAR2"/> <COLUMN Type="Data"
24  // Name="UniversalInterfaceAddress" StorageName="UNIVERSAL_INTERFACE_ADDRESS"
25  // DataType="VARCHAR2"/> <COLUMN Type="YesNo"
26  // Name="ReadAccess" StorageName="READ_ACCESS" DataType="VARCHAR2"/>
27  // <COLUMN Type="YesNo" Name="WriteAccess"
28  // StorageName="WRITE_ACCESS" DataType="VARCHAR2"/> <COLUMN
29  // Type="YesNo" Name="MonitoringEnabled" StorageName="MONITORING_ENABLED"
30  // DataType="VARCHAR2"/> <COLUMN Type="TrueFalse"
31  // Name="TransmitChangesOnly" StorageName="TRANSMIT_CHANGES_ONLY"
32  // DataType="VARCHAR2"/> <COLUMN Type="Data"
33  // Name="DelayBetweenSamples" StorageName="DELAY_BETWEEN_SAMPLES"
34  // DataType="NUMBER"/> <COLUMN Type="YesNo" Name="AlarmsEnabled"
35  // StorageName="ALARMS_ENABLED" DataType="VARCHAR2"/> <COLUMN
36  // Type="Data" Name="LowThreshold" StorageName="LOW_THRESHOLD"
37  // DataType="VARCHAR2"/> <COLUMN Type="Data"
38  // Name="LowLowThreshold" StorageName="LOW_LOW_THRESHOLD"
39  // DataType="VARCHAR2"/> <COLUMN Type="Data"
40  // Name="HighThreshold" StorageName="HIGH_THRESHOLD" DataType="VARCHAR2"/>
41  // <COLUMN Type="Data" Name="HighHighThreshold"
42  // StorageName="HIGH_HIGH_THRESHOLD" DataType="VARCHAR2"/>
43  // <COLUMN Type="Comment" Name="CommentDescription"
44  // StorageName="COMMENT_DESCRIPTION" DataType="VARCHAR2"/>
45  // <COLUMN Type="Author" Name="Author" StorageName="AUTHOR"
46  // DataType="VARCHAR2"/> <COLUMN Type="Timestamp"
47  // Name="RecordInsertionTime" StorageName="RECORD_INSERTION_TIME"
48  // DataType="TIMESTAMP WITH TIMEZONE"/>
49  // </VIEW>
50  // </TABLE>
51  // </ROOT>
52 }
53 
54 //==============================================================================
55 FESlowControlsTable::~FESlowControlsTable(void) {}
56 
57 //==============================================================================
58 // init
59 // Validates user inputs for data type.
60 //
61 void FESlowControlsTable::init(ConfigurationManager* configManager)
62 {
63  // check for valid data types
64  __COUT__ << "*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*" << std::endl;
65  __COUT__ << configManager->__SELF_NODE__ << std::endl;
66 
67  // __COUT__ << configManager->getNode(this->getTableName()).getValueAsString()
68  // << std::endl;
69 
70  std::string childType;
71  auto childrenMap = configManager->__SELF_NODE__.getChildren();
72  for(auto& childPair : childrenMap)
73  {
74  // check each row in table
75  __COUT__ << childPair.first << std::endl;
76  childPair.second.getNode(colNames_.colDataType_).getValue(childType);
77  __COUT__ << "childType=" << childType << std::endl;
78 
79  if(childType[childType.size() - 1] ==
80  'b') // if ends in 'b' then take that many bits
81  {
82  unsigned int sz;
83  sscanf(&childType[0], "%u", &sz);
84  if(sz < 1 || sz > 64)
85  {
86  __SS__ << "Data type '" << childType << "' for UID=" << childPair.first
87  << " is invalid. "
88  << " The bit size given was " << sz
89  << " and it must be between 1 and 64." << std::endl;
90  __COUT_ERR__ << "\n" << ss.str();
91  __SS_THROW__;
92  }
93  }
94  else if(childType != "char" && childType != "short" && childType != "int" &&
95  childType != "unsigned int" && childType != "long long " &&
96  childType != "unsigned long long" && childType != "float" &&
97  childType != "double")
98  {
99  __SS__ << "Data type '" << childType << "' for UID=" << childPair.first
100  << " is invalid. "
101  << "Valid data types (w/size in bytes) are as follows: "
102  << "#b (# bits)"
103  << ", char (" << sizeof(char) << "B), unsigned char ("
104  << sizeof(unsigned char) << "B), short (" << sizeof(short)
105  << "B), unsigned short (" << sizeof(unsigned short) << "B), int ("
106  << sizeof(int) << "B), unsigned int (" << sizeof(unsigned int)
107  << "B), long long (" << sizeof(long long) << "B), unsigned long long ("
108  << sizeof(unsigned long long) << "B), float (" << sizeof(float)
109  << "B), double (" << sizeof(double) << "B)." << std::endl;
110  __COUT_ERR__ << "\n" << ss.str();
111  __SS_THROW__;
112  }
113  }
114 } // end init()
115 
116 DEFINE_OTS_TABLE(FESlowControlsTable)