EPICS ARCHIVER V4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
ArchiveChannel.h
1 #ifndef ARCHIVECHANNEL_H_
2 #define ARCHIVECHANNEL_H_
3 
4 // tools
5 #include "tools/AutoPtr.h"
6 
7 // storage
8 #include "storage/Index.h"
9 
10 // engine
11 #include "engine/Named.h"
12 #include "engine/SampleMechanism.h"
13 #include "engine/EngineConfig.h"
14 #include "engine/ScanList.h"
15 
19 class ArchiveChannel : public NamedBase,
20  public Guardable,
22 
23 public:
24 
28  ScanList& scan_list,
29  const char* channel_name,
30  double scan_period,
31  bool monitor);
32 
34  virtual ~ArchiveChannel();
35 
36  protected:
37 
38  virtual SampleMechanism*
39  createSampleMechanism(EngineConfig& config,
41  ScanList& scan_list) = 0;
42 
43  public:
44 
45  // Guardable API
46 
48  virtual OrderedMutex& getMutex();
49 
50  public:
51 
52  // ProcessVariableListener API
53 
57  virtual void pvConnected(ProcessVariable& pv, const epicsTime& when);
58 
62  virtual void pvDisconnected(ProcessVariable& pv, const epicsTime& when);
63 
65  virtual void pvValue(ProcessVariable& pv, const RawValue::Data* data);
66 
67  public:
68 
78  ScanList& scan_list,
79  double scan_period,
80  bool monitor);
81 
82  public:
83 
85  void addToGroup(Guard& group_guard,
86  class GroupInfo* group,
87  Guard& channel_guard,
88  bool disabling);
89 
91  inline const stdList<class GroupInfo *> getGroups(Guard &guard) const;
92 
94  inline const stdList<class GroupInfo *> getGroupsToDisable(Guard& guard) const;
95 
96  public:
97 
99  void start(Guard& guard);
100 
103  bool isRunning(Guard& guard);
104 
106  bool isConnected(Guard& guard) const;
107 
110  void disable(Guard& guard, const epicsTime& when);
111 
114  void enable(Guard& guard, const epicsTime& when);
115 
119  inline bool isDisabling(Guard& guard) const;
120 
122  inline bool isDisabled(Guard &guard) const;
123 
126  std::string getSampleInfo(Guard& guard);
127 
129  void stop(Guard& guard);
130 
134  unsigned long write(Guard& guard, Index& index);
135 
136  public:
137 
139  void addToFUX(Guard &guard, class FUX::Element *doc);
140 
141  protected:
142 
143  EngineConfig& config;
144 
145  OrderedMutex mutex;
146  double scan_period;
147  bool monitor;
148 
149  // See comments in implementation of waitWhileSampleMechanismBusy().
150  bool sample_mechanism_busy;
151 
152  AutoPtr<SampleMechanism> sample_mechanism;
153  void waitWhileSampleMechanismBusy(Guard &guard);
154 
155  // TODO: Use ConcurrentList types for the next 2.
156  // Groups that this channel disables (might be empty)
157  stdList<class GroupInfo *> disable_groups;
158 
159  // Groups to which this channel belongs (at least one)
160  stdList<class GroupInfo *> groups;
161 
166  inline bool canDisable(Guard &guard) const;
167 
169  bool currently_disabling;
170 
172  size_t disable_count;
173 
174 };
175 
176 inline const stdList<class GroupInfo *>
178  return groups;
179 }
180 
181 inline const stdList<class GroupInfo *>
183  return disable_groups;
184 }
185 
186 inline bool ArchiveChannel::isDisabled(Guard& guard) const {
187  // Disabled when disabled by all its groups.
188  // As long as one group didn't disable the channel,
189  // it has to stay enabled.
190  return disable_count == groups.size();
191 }
192 
193 inline bool ArchiveChannel::canDisable(Guard& guard) const {
194  return !disable_groups.empty();
195 }
196 
197 inline bool ArchiveChannel::isDisabling(Guard& guard) const {
198  return currently_disabling;
199 }
200 
201 #endif /*ARCHIVECHANNEL_H_*/
std::string getSampleInfo(Guard &guard)
const stdList< class GroupInfo * > getGroupsToDisable(Guard &guard) const
Definition: ArchiveChannel.h:182
A mutex with informational name and lock order.
Definition: OrderedMutex.h:34
bool isDisabling(Guard &guard) const
Definition: ArchiveChannel.h:197
void start(Guard &guard)
Start the sample mechanism.
bool isRunning(Guard &guard)
A named thingy.
Definition: Named.h:28
bool isConnected(Guard &guard) const
void disable(Guard &guard, const epicsTime &when)
Temporarily disable sampling.
virtual ~ArchiveChannel()
Destructor.
One process variable.
Definition: ProcessVariable.h:39
Global engine configuration parameters.
Definition: EngineConfig.h:14
void configure(ProcessVariableContext &ctx, ScanList &scan_list, double scan_period, bool monitor)
Configure or re-configure channel.
Automatically takes and releases an epicsMutex.
Definition: Guard.h:63
Sample Mechanism base, has a ProcessVariable and filters its values.
Definition: SampleMechanism.h:33
Listener for ProcessVariable info.
Definition: ProcessVariableListener.h:47
virtual OrderedMutex & getMutex()
void stop(Guard &guard)
Stop sampling.
bool isDisabled(Guard &guard) const
Definition: ArchiveChannel.h:186
virtual void pvDisconnected(ProcessVariable &pv, const epicsTime &when)
Implements ProcessVariableStateListener by forwrding connect/disconnect info to ArchiveChannelStateLi...
Interface for something that can be protected by a Guard.
Definition: Guard.h:49
Context for ProcessVariable instances.
Definition: ProcessVariableContext.h:18
unsigned long write(Guard &guard, Index &index)
Write samples to index.
virtual void pvConnected(ProcessVariable &pv, const epicsTime &when)
Implements ProcessVariableStateListener by forwrding connect/disconnect info to ArchiveChannelStateLi...
One archived channel.
Definition: ArchiveChannel.h:19
ArchiveChannel(EngineConfig &config, ProcessVariableContext &ctx, ScanList &scan_list, const char *channel_name, double scan_period, bool monitor)
Create channel with given name.
virtual void pvValue(ProcessVariable &pv, const RawValue::Data *data)
Implements ProcessVariableValueListener for handling enable/disable.
Base interface for the archiver&#39;s indices.
Definition: Index.h:16
void addToGroup(Guard &group_guard, class GroupInfo *group, Guard &channel_guard, bool disabling)
Add channel to a group.
A ScanList keeps track of Scannable items.
Definition: ScanList.h:43
void enable(Guard &guard, const epicsTime &when)
Re-enable sampling.
One element in the FUX tree.
Definition: FUX.h:51
A Group of channels.
Definition: GroupInfo.h:42
dbr_time_double Data
Type for accessing the raw data and its common fields.
Definition: RawValue.h:55
void addToFUX(Guard &guard, class FUX::Element *doc)
Append this channel to a FUX document.
const stdList< class GroupInfo * > getGroups(Guard &guard) const
Definition: ArchiveChannel.h:177