otsdaq  v2_05_02_indev
SlowControlsTableBase.h
1 #ifndef _ots_SlowControlsTableBase_h_
2 #define _ots_SlowControlsTableBase_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 SlowControlsTableBase : virtual public TableBase //virtual so future plugins can inherit from multiple table base classes
18 {
19  public:
21  SlowControlsTableBase(std::string tableName, std::string* accumulatedExceptions = 0);
22 
23  virtual ~SlowControlsTableBase(void);
24 
25  // Getters
26  virtual bool slowControlsChannelListHasChanged (void) const;
27  virtual void getSlowControlsChannelList (std::vector<std::pair<std::string /*channelName*/, std::vector<std::string>>>& channelList) const;
28 
29  //boardReader{
30  // build vector .. based on table 1,2,3,4,5..
31  // pass vector outputPV()
32  //}
33  //DTC {
34  // build vector from config Tree
35  // pass vector to outputPV()
36  //}
37 
38  //use table name to have different file names! (instead of DEFINES like in DTC)
39 
40  //is channel binary or not?.. then can handle all the same
41  virtual bool outputEpicsPVFile (ConfigurationManager* configManager, std::vector<std::pair<std::string /*channelName*/, std::vector<std::string>>>* channelList = 0) const;
42 
43  virtual unsigned int slowControlsHandlerConfig (
44  std::stringstream& out
45  , ConfigurationManager* configManager
46  , std::vector<std::pair<std::string /*channelName*/, std::vector<std::string>>>* channelList /*= 0*/
47  ) const = 0;
48 
49  virtual unsigned int slowControlsHandler (
50  std::stringstream& out
51  , std::string& tabStr
52  , std::string& commentStr
53  , std::string& subsystem
54  , std::string& location
55  , ConfigurationTree slowControlsLink
56  , std::vector<std::pair<std::string /*channelName*/, std::vector<std::string>>>* channelList /*= 0*/
57  ) const;
58  virtual std::string setFilePath () const = 0;
59 
60  // Column names
61  struct ColChannel
62  {
63  std::string const colMetricName_ = "MetricName";
64  std::string const colStatus_ = "Status";
65  std::string const colUnits_ = "Units";
66  std::string const colChannelDataType_ = "ChannelDataType";
67  std::string const colLowLowThreshold_ = "LowLowThreshold";
68  std::string const colLowThreshold_ = "LowThreshold";
69  std::string const colHighThreshold_ = "HighThreshold";
70  std::string const colHighHighThreshold_ = "HighHighThreshold";
71  } channelColNames_;
72 
73  bool isFirstAppInContext_ = false; //for managing if PV list has changed
74  bool channelListHasChanged_ = false; //for managing if PV list has changed
75  ConfigurationManager* lastConfigManager_ = nullptr;
76 
77 private:
78 
79  #define EPICS_CONFIG_PATH (std::string(__ENV__("USER_DATA")) + "/" + "EPICSConfigurations/")
80  #define EPICS_DIRTY_FILE_PATH \
81  std::string( \
82  getenv("OTSDAQ_EPICS_DATA")? \
83  (std::string(getenv("OTSDAQ_EPICS_DATA")) + "/" + "dirtyFlag.txt"): \
84  (EPICS_CONFIG_PATH + "/dirtyFlag.txt") )
85 };
86 } // namespace ots
87 
88 #endif