tdaq-develop-2025-02-12
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 
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
18 {
19  public:
21  SlowControlsTableBase(std::string tableName, std::string* accumulatedExceptions = 0);
22 
23  virtual ~SlowControlsTableBase(void);
24 
26  virtual bool slowControlsChannelListHasChanged (void) const;
27  virtual void getSlowControlsChannelList (std::vector<std::pair<std::string /*channelName*/, std::vector<std::string>>>& channelList) const;
28 
37 
39 
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 
61  struct ColChannel
62  {
63  std::string const colMetricName_ = "MetricName";
64  std::string const colStatus_ = TableViewColumnInfo::COL_NAME_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;
74  bool channelListHasChanged_ = false;
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
<virtual so future plugins can inherit from multiple table base classes
virtual bool outputEpicsPVFile(ConfigurationManager *configManager, std::vector< std::pair< std::string, std::vector< std::string >>> *channelList=0) const
use table name to have different file names! (instead of DEFINES like in DTC)
bool channelListHasChanged_
for managing if PV list has changed
bool isFirstAppInContext_
for managing if PV list has changed
virtual bool slowControlsChannelListHasChanged(void) const
Getters.