otsdaq  v2_04_01
FESlowControlsTable_table.cc
1 #include "otsdaq-core/Macros/TablePluginMacros.h"
2 #include "otsdaq-core/TablePlugins/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 //==============================================================================
14 FESlowControlsTable::~FESlowControlsTable(void) {}
15 
16 //==============================================================================
17 // init
18 // Validates user inputs for data type.
19 void FESlowControlsTable::init(ConfigurationManager* configManager)
20 {
21  // use isFirstAppInContext to only run once per context, for example to avoie
22  // generating files on local disk multiple times.
23  bool isFirstAppInContext = configManager->isOwnerFirstAppInContext();
24 
25  __COUTV__(isFirstAppInContext);
26  if(!isFirstAppInContext)
27  return;
28 
29  // check for valid data types
30  __COUT__ << "*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*" << std::endl;
31  __COUT__ << configManager->__SELF_NODE__ << std::endl;
32 
33  // __COUT__ << configManager->getNode(this->getTableName()).getValueAsString()
34  // << std::endl;
35 
36  std::string childType;
37  std::vector<std::pair<std::string, ConfigurationTree>> childrenMap =
38  configManager->__SELF_NODE__.getChildren();
39  for(auto& childPair : childrenMap)
40  {
41  // check each row in table
42  __COUT__ << childPair.first << std::endl;
43  childPair.second.getNode(colNames_.colDataType_).getValue(childType);
44  __COUT__ << "childType=" << childType << std::endl;
45 
46  if(childType[childType.size() - 1] ==
47  'b') // if ends in 'b' then take that many bits
48  {
49  unsigned int sz;
50  sscanf(&childType[0], "%u", &sz);
51  if(sz < 1 || sz > 64)
52  {
53  __SS__ << "Data type '" << childType << "' for UID=" << childPair.first
54  << " is invalid. "
55  << " The bit size given was " << sz
56  << " and it must be between 1 and 64." << std::endl;
57  __COUT_ERR__ << "\n" << ss.str();
58  __SS_THROW__;
59  }
60  }
61  else if(childType != TableViewColumnInfo::DATATYPE_STRING_DEFAULT &&
62  childType != "char" && childType != "unsigned char" &&
63  childType != "short" && childType != "unsigned short" &&
64  childType != "int" && childType != "unsigned int" &&
65  childType != "long long " && childType != "unsigned long long" &&
66  childType != "float" && childType != "double")
67  {
68  __SS__ << "Data type '" << childType << "' for UID=" << childPair.first
69  << " is invalid. "
70  << "Valid data types (w/size in bytes) are as follows: "
71  << "#b (# bits)"
72  << ", char (" << sizeof(char) << "B), unsigned char ("
73  << sizeof(unsigned char) << "B), short (" << sizeof(short)
74  << "B), unsigned short (" << sizeof(unsigned short) << "B), int ("
75  << sizeof(int) << "B), unsigned int (" << sizeof(unsigned int)
76  << "B), long long (" << sizeof(long long) << "B), unsigned long long ("
77  << sizeof(unsigned long long) << "B), float (" << sizeof(float)
78  << "B), double (" << sizeof(double) << "B)." << std::endl;
79  __COUT_ERR__ << "\n" << ss.str();
80  __SS_THROW__;
81  }
82  }
83 } // end init()
84 
85 DEFINE_OTS_TABLE(FESlowControlsTable)