EPICS ARCHIVER V4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
EngineConfig.h
1 #ifndef ENGINECONFIG_H_
2 #define ENGINECONFIG_H_
3 
4 // Tools
5 #include "tools/ToolsConfig.h"
6 #include "tools/FUX.h"
7 
15 {
16 public:
17  EngineConfig()
18  {
19  write_period = 30.0;
20  buffer_reserve = 3;
21  max_repeat_count = 100;
22  ignored_future = 60.0;
23  get_threshold = 20.0;
24  file_size_limit = 100*1024*1024; // 100MB Default
25  disconnect_on_disable = false;
26 
27  chunk_period = write_period;
28  }
29 
31  double getWritePeriod() const { return write_period; }
32 
34  size_t getBufferReserve() const { return buffer_reserve; }
35 
37  size_t getSuggestedBufferSpace(double scan_period) const
38  {
39  if (scan_period <= 0)
40  return 1;
41  size_t num = (size_t)(write_period * buffer_reserve / scan_period);
42  if (num < 3)
43  return 3;
44  return num;
45  }
46 
50  size_t getMaxRepeatCount() const { return max_repeat_count; }
51 
54  double getIgnoredFutureSecs() const { return ignored_future; }
55 
57  double getGetThreshold() const { return get_threshold; }
58 
60  size_t getFileSizeLimit() const { return file_size_limit; }
61 
63  bool getDisconnectOnDisable() const { return disconnect_on_disable; }
64 
66  double getChunkPeriod() const { return chunk_period; }
67 
69  void addToFUX(class FUX::Element *doc);
70 
71 protected:
72  double write_period;
73  size_t buffer_reserve;
74  size_t max_repeat_count;
75  double ignored_future;
76  double get_threshold;
77  size_t file_size_limit;
78  bool disconnect_on_disable;
79 
80  double chunk_period;
81 
82 };
83 
88 {
89 public:
91  void setWritePeriod(double secs) { write_period = secs; }
92 
94  void setBufferReserve(size_t times) { buffer_reserve = times; }
95 
99  void setMaxRepeatCount(size_t count) { max_repeat_count = count; }
100 
104  void setIgnoredFutureSecs(double secs) { ignored_future = secs; }
105 
107  void setGetThreshold(double secs) { get_threshold = secs; }
108 
110  void setFileSizeLimit(size_t bytes) { file_size_limit = bytes; }
111 
113  void setDisconnectOnDisable(bool yes_no) { disconnect_on_disable = yes_no;}
114 
116  void setChunkPeriod(double secs) { chunk_period = secs; }
117 
118 };
119 
125 
126  public:
127 
128  virtual ~EngineConfigListener();
129 
131  virtual void addChannel(const stdString &group_name,
132  const stdString &channel_name,
133  double scan_period,
134  bool disabling, bool monitor) = 0;
135 };
136 
143 {
144 public:
146 
151  void read(const char *filename, EngineConfigListener *listener);
152 
153 private:
154  EngineConfigListener *listener;
155  void handle_group(FUX::Element *group);
156  void handle_channel(const stdString &group_name,
157  FUX::Element *channel);
158 };
159 
160 #endif /*ENGINECONFIG_H_*/
void setFileSizeLimit(size_t bytes)
Set the file size limit (Bytes).
Definition: EngineConfig.h:110
void setBufferReserve(size_t times)
Set how many times more buffer is reserved.
Definition: EngineConfig.h:94
double getWritePeriod() const
Definition: EngineConfig.h:31
size_t getSuggestedBufferSpace(double scan_period) const
Definition: EngineConfig.h:37
double getChunkPeriod() const
Definition: EngineConfig.h:66
double getIgnoredFutureSecs() const
Definition: EngineConfig.h:54
double getGetThreshold() const
Definition: EngineConfig.h:57
void setIgnoredFutureSecs(double secs)
Set which data gets ignored because time stamp is too far ahead of host clock.
Definition: EngineConfig.h:104
void setChunkPeriod(double secs)
Set the period in seconds between &#39;writes&#39; to Storage.
Definition: EngineConfig.h:116
size_t getFileSizeLimit() const
Definition: EngineConfig.h:60
void setGetThreshold(double secs)
Set threshold between &#39;Get&#39; and &#39;MonitoredGet&#39;.
Definition: EngineConfig.h:107
virtual void addChannel(const stdString &group_name, const stdString &channel_name, double scan_period, bool disabling, bool monitor)=0
Invoked for each channel that the EngineConfigParser found.
Global engine configuration parameters.
Definition: EngineConfig.h:14
void setDisconnectOnDisable(bool yes_no)
Should engine disconnect channels that are disabled?
Definition: EngineConfig.h:113
size_t getMaxRepeatCount() const
Definition: EngineConfig.h:50
bool getDisconnectOnDisable() const
Definition: EngineConfig.h:63
Modifyable global engine configuration parameters.
Definition: EngineConfig.h:87
void addToFUX(class FUX::Element *doc)
Append this config to a FUX document.
Reads the config from an XML file that should conform to engineconfig.dtd.
Definition: EngineConfig.h:142
One element in the FUX tree.
Definition: FUX.h:51
size_t getBufferReserve() const
Definition: EngineConfig.h:34
void setMaxRepeatCount(size_t count)
Set the max.
Definition: EngineConfig.h:99
Listener to EngineConfigParser.
Definition: EngineConfig.h:124
void read(const char *filename, EngineConfigListener *listener)
Reads the config from an XML file.
void setWritePeriod(double secs)
Set the period in seconds between &#39;writes&#39; to Storage.
Definition: EngineConfig.h:91