otsdaq  v2_04_02
ARTDAQTableBase.h
1 #ifndef _ots_ARTDAQTableBase_h_
2 #define _ots_ARTDAQTableBase_h_
3 
4 #include "otsdaq/ConfigurationInterface/ConfigurationManager.h"
5 #include "otsdaq/TableCore/TableBase.h"
6 
7 // helpers
8 #define OUT out << tabStr << commentStr
9 #define PUSHTAB tabStr += "\t"
10 #define POPTAB tabStr.resize(tabStr.size() - 1)
11 #define PUSHCOMMENT commentStr += "# "
12 #define POPCOMMENT commentStr.resize(commentStr.size() - 2)
13 
14 namespace ots
15 {
16 // clang-format off
17 class ARTDAQTableBase : public TableBase
18 {
19  public:
20 
22  ARTDAQTableBase(std::string tableName, std::string* accumulatedExceptions = 0);
23 
24  virtual ~ARTDAQTableBase(void);
25 
26  static const std::string ARTDAQ_SUPERVISOR_TABLE;
27 
28  enum class ARTDAQAppType {
29  BoardReader,
30  EventBuilder,
31  DataLogger,
32  Dispatcher
33  };
34 
35  static struct ProcessTypes
36  {
37  std::string const READER = "reader";
38  std::string const BUILDER = "builder";
39  std::string const LOGGER = "logger";
40  std::string const DISPATCHER = "dispatcher";
41  } processTypes_;
42 
43  enum {
44  DEFAULT_MAX_FRAGMENT_SIZE = 1048576
45  };
46 
48  {
49  int id;
50  std::string label;
51 
52  std::set<int> sources; //by subsystem id
53  int destination; //destination subsystem id, 0 := no destination
54 
55  SubsystemInfo() : sources(),destination(0) {}
56  };
57  static const int NULL_SUBSYSTEM_DESTINATION;
58 
59  struct ProcessInfo
60  {
61  std::string label;
62  std::string hostname;
63  int subsystem;
64 
65  ProcessInfo(std::string l, std::string h, int s)
66  : label(l), hostname(h), subsystem(s) {}
67  };
68 
69 
70  static const std::string& getTypeString (ARTDAQAppType type);
71  static std::string getFHICLFilename (ARTDAQTableBase::ARTDAQAppType type, const std::string& name);
72  static std::string getFlatFHICLFilename (ARTDAQTableBase::ARTDAQAppType type, const std::string& name);
73  static void flattenFHICL (ARTDAQTableBase::ARTDAQAppType type, const std::string& name);
74 
75  static void insertParameters (std::ostream& out, std::string& tabStr, std::string& commentStr, ConfigurationTree parameterLink, const std::string& parameterPreamble, bool onlyInsertAtTableParameters = false, bool includeAtTableParameters =false);
76  static std::string insertModuleType (std::ostream& out, std::string& tabStr, std::string& commentStr, ConfigurationTree moduleTypeNode);
77 
78  static void outputReaderFHICL (
79  const ConfigurationTree& readerNode,
80  const std::string& selfHost,
81  size_t maxFragmentSizeBytes);
82 
83 
84  static void outputDataReceiverFHICL (
85  const ConfigurationTree& receiverNode,
86  //unsigned int selfRank,
87  const std::string& selfHost,
88  //unsigned int selfPort,
89  ARTDAQTableBase::ARTDAQAppType appType,
90  size_t maxFragmentSizeBytes);
91 
92  static void extractArtdaqInfo (
93  ConfigurationTree artdaqSupervisorNode,
94  std::map<int /*subsystem ID*/, ARTDAQTableBase::SubsystemInfo>& subsystems,
95  std::map<ARTDAQTableBase::ARTDAQAppType, std::list<ARTDAQTableBase::ProcessInfo>>& processes,
96  bool doWriteFHiCL = false,
97  size_t maxFragmentSizeBytes = ARTDAQTableBase::DEFAULT_MAX_FRAGMENT_SIZE,
98  ProgressBar* progressBar = 0);
99 
100  private:
101  static int getSubsytemId (ConfigurationTree subsystemNode);
102 
103 };
104 // clang-format on
105 } // namespace ots
106 
107 #endif