tdaq-develop-2025-02-12
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  __COUT_TYPE__(TLVL_DEBUG + 20) << __COUT_HDR__ << childPair.first << std::endl;
35  childPair.second.getNode(colNames_.colDataType_).getValue(childType);
36  __COUT_TYPE__(TLVL_DEBUG + 20)
37  << __COUT_HDR__ << "childType=" << childType << std::endl;
38 
39  if(childType[childType.size() - 1] ==
40  'b') // if ends in 'b' then take that many bits
41  {
42  unsigned int sz;
43  sscanf(&childType[0], "%u", &sz);
44  if(sz < 1 || sz > 64)
45  {
46  __SS__ << "Data type '" << childType << "' for UID=" << childPair.first
47  << " is invalid. "
48  << " The bit size given was " << sz
49  << " and it must be between 1 and 64." << std::endl;
50  __COUT_ERR__ << "\n" << ss.str();
51  __SS_THROW__;
52  }
53  }
54  else if(childType != TableViewColumnInfo::DATATYPE_STRING_DEFAULT &&
55  childType != "char" && childType != "unsigned char" &&
56  childType != "short" && childType != "unsigned short" &&
57  childType != "int" && childType != "unsigned int" &&
58  childType != "long long " && childType != "unsigned long long" &&
59  childType != "float" && childType != "double")
60  {
61  __SS__ << "Data type '" << childType << "' for UID=" << childPair.first
62  << " is invalid. "
63  << "Valid data types (w/size in bytes) are as follows: "
64  << "#b (# bits)"
65  << ", char (" << sizeof(char) << "B), unsigned char ("
66  << sizeof(unsigned char) << "B), short (" << sizeof(short)
67  << "B), unsigned short (" << sizeof(unsigned short) << "B), int ("
68  << sizeof(int) << "B), unsigned int (" << sizeof(unsigned int)
69  << "B), long long (" << sizeof(long long) << "B), unsigned long long ("
70  << sizeof(unsigned long long) << "B), float (" << sizeof(float)
71  << "B), double (" << sizeof(double) << "B)." << std::endl;
72  __COUT_ERR__ << "\n" << ss.str();
73  __SS_THROW__;
74  }
75  }
76 } // end init()
77 
78 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.