otsdaq  3.03.00
FESlowControlsTable_table.cc
1 #include "otsdaq/Macros/TablePluginMacros.h"
2 #include "otsdaq/TablePlugins/FESlowControlsTable.h"
3 
4 #include "otsdaq/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 //==============================================================================
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  if(!isFirstAppInContext)
26  return;
27 
28  std::string childType;
29  std::vector<std::pair<std::string, ConfigurationTree>> childrenMap =
30  configManager->__SELF_NODE__.getChildren();
31  for(auto& childPair : childrenMap)
32  {
33  // check each row in table
34  __COUTS__(20) << childPair.first << std::endl;
35  childPair.second.getNode(colNames_.colDataType_).getValue(childType);
36  __COUTS__(20) << "childType=" << childType << std::endl;
37 
38  if(childType[childType.size() - 1] ==
39  'b') // if ends in 'b' then take that many bits
40  {
41  unsigned int sz;
42  sscanf(&childType[0], "%u", &sz);
43  if(sz < 1 || sz > 64)
44  {
45  __SS__ << "Data type '" << childType << "' for UID=" << childPair.first
46  << " is invalid. "
47  << " The bit size given was " << sz
48  << " and it must be between 1 and 64." << std::endl;
49  __COUT_ERR__ << "\n" << ss.str();
50  __SS_THROW__;
51  }
52  }
53  else if(childType != TableViewColumnInfo::DATATYPE_STRING_DEFAULT &&
54  childType != "char" && childType != "unsigned char" &&
55  childType != "short" && childType != "unsigned short" &&
56  childType != "int" && childType != "unsigned int" &&
57  childType != "long long " && childType != "unsigned long long" &&
58  childType != "float" && childType != "double")
59  {
60  __SS__ << "Data type '" << childType << "' for UID=" << childPair.first
61  << " is invalid. "
62  << "Valid data types (w/size in bytes) are as follows: "
63  << "#b (# bits)"
64  << ", char (" << sizeof(char) << "B), unsigned char ("
65  << sizeof(unsigned char) << "B), short (" << sizeof(short)
66  << "B), unsigned short (" << sizeof(unsigned short) << "B), int ("
67  << sizeof(int) << "B), unsigned int (" << sizeof(unsigned int)
68  << "B), long long (" << sizeof(long long) << "B), unsigned long long ("
69  << sizeof(unsigned long long) << "B), float (" << sizeof(float)
70  << "B), double (" << sizeof(double) << "B)." << std::endl;
71  __COUT_ERR__ << "\n" << ss.str();
72  __SS_THROW__;
73  }
74  }
75 } // end init()
76 
77 DEFINE_OTS_TABLE(FESlowControlsTable)
std::vector< std::pair< std::string, ConfigurationTree > > getChildren(std::map< std::string, TableVersion > *memberMap=0, std::string *accumulatedTreeErrors=0) const
void init(ConfigurationManager *configManager)
Methods.