This is Unofficial EPICS BASE Doxygen Site
BaseMonitor Struct Reference

#include "pvahelper.h"

+ Inheritance diagram for BaseMonitor:
+ Collaboration diagram for BaseMonitor:

Classes

struct  no_overflow
 

Public Types

typedef epics::pvAccess::MonitorRequester requester_t
 
typedef epicsGuard< epicsMutex > guard_t
 
typedef epicsGuardRelease< epicsMutex > unguard_t
 
- Public Types inherited from epics::pvAccess::Monitor
typedef MonitorRequester requester_type
 

Public Member Functions

 POINTER_DEFINITIONS (BaseMonitor)
 
shared_pointer shared_from_this ()
 
 BaseMonitor (epicsMutex &lock, const requester_t::weak_pointer &requester, const epics::pvData::PVStructure::shared_pointer &pvReq)
 
virtual ~BaseMonitor ()
 
const epics::pvData::PVStructurePtrgetValue ()
 
void connect (guard_t &guard, const epics::pvData::PVStructurePtr &value)
 
bool post (guard_t &guard, const epics::pvData::BitSet &updated, no_overflow)
 post update if queue not full, if full return false w/o overflow More...
 
bool post (guard_t &guard)
 post update of pending changes. eg. call from requestUpdate() More...
 
bool post (guard_t &guard, const epics::pvData::BitSet &updated, const epics::pvData::BitSet &overflowed)
 post update with changed and overflowed masks (eg. when updates were lost in some upstream queue) More...
 
bool post (guard_t &guard, const epics::pvData::BitSet &updated)
 post update with changed More...
 
virtual void onStart ()
 
virtual void onStop ()
 
virtual void requestUpdate ()
 
virtual void destroy ()
 
virtual void getStats (Stats &s) const
 
- Public Member Functions inherited from epics::pvAccess::Monitor
 POINTER_DEFINITIONS (Monitor)
 
virtual ~Monitor ()
 
virtual void reportRemoteQueueStatus (epics::pvData::int32 freeElements)
 
- Public Member Functions inherited from epics::pvAccess::Destroyable
 POINTER_DEFINITIONS (Destroyable)
 

Public Attributes

weak_pointer weakself
 
epicsMutex & lock
 

Additional Inherited Members

- Protected Member Functions inherited from epics::pvAccess::Destroyable
virtual ~Destroyable ()
 

Detailed Description

Helper which implements a Monitor queue. connect()s to a complete copy of a PVStructure. When this struct has changed, post(BitSet) should be called.

Derived class may use onStart(), onStop(), and requestUpdate() to react to subscriber events.

Definition at line 69 of file pvahelper.h.

Member Typedef Documentation

typedef epicsGuard<epicsMutex> BaseMonitor::guard_t

Definition at line 78 of file pvahelper.h.

Definition at line 79 of file pvahelper.h.

Constructor & Destructor Documentation

BaseMonitor::BaseMonitor ( epicsMutex &  lock,
const requester_t::weak_pointer &  requester,
const epics::pvData::PVStructure::shared_pointer &  pvReq 
)
inline

Definition at line 94 of file pvahelper.h.

97  :lock(lock)
99  ,inoverflow(false)
100  ,running(false)
101  ,nbuffers(2)
102  {}
const ChannelProcessRequester::weak_pointer requester
Definition: pvAccess.cpp:68
epicsMutex & lock
Definition: pvahelper.h:77
virtual BaseMonitor::~BaseMonitor ( )
inlinevirtual

Definition at line 104 of file pvahelper.h.

104 {destroy();}
virtual void destroy()
Definition: pvahelper.h:273

Member Function Documentation

void BaseMonitor::connect ( guard_t guard,
const epics::pvData::PVStructurePtr value 
)
inline

Must call before first post(). Sets .complete and calls monitorConnect()

Note
that value will never by accessed except by post() and requestUpdate()

Definition at line 110 of file pvahelper.h.

111  {
112  guard.assertIdenticalMutex(lock);
113  epics::pvData::StructureConstPtr dtype(value->getStructure());
115  BaseMonitor::shared_pointer self(shared_from_this());
116  requester_t::shared_pointer req(requester.lock());
117 
118  assert(!complete); // can't call twice
119 
120  complete = value;
121  empty.resize(nbuffers);
122  for(size_t i=0; i<empty.size(); i++) {
123  empty[i].reset(new epics::pvAccess::MonitorElement(create->createPVStructure(dtype)));
124  }
125 
126  if(req) {
127  unguard_t U(guard);
129  req->monitorConnect(sts, self, dtype);
130  }
131  }
epics::pvData::BitSetPtr empty
Definition: pvAccess.cpp:135
Definition: link.h:174
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
int i
Definition: scan.c:967
std::tr1::shared_ptr< const Structure > StructureConstPtr
Definition: pvIntrospect.h:162
epicsGuardRelease< epicsMutex > unguard_t
Definition: pvahelper.h:79
An element for a monitorQueue.
Definition: monitor.h:54
std::tr1::shared_ptr< PVDataCreate > PVDataCreatePtr
Definition: pvData.h:124
shared_pointer shared_from_this()
Definition: pvahelper.h:73
const ChannelProcessRequester::weak_pointer requester
Definition: pvAccess.cpp:68
epicsMutex & lock
Definition: pvahelper.h:77
FORCE_INLINE const PVDataCreatePtr & getPVDataCreate()
Definition: pvData.h:1648
virtual void BaseMonitor::destroy ( )
inlinevirtual

Destroy this instance.

Implements epics::pvAccess::Destroyable.

Reimplemented in PDBGroupMonitor, and PDBSingleMonitor.

Definition at line 273 of file pvahelper.h.

274  {
275  stop();
276  }
virtual void BaseMonitor::getStats ( Stats s) const
inlinevirtual

Reimplemented from epics::pvAccess::Monitor.

Definition at line 341 of file pvahelper.h.

342  {
343  guard_t G(lock);
344  s.nempty = empty.size();
345  s.nfilled = inuse.size();
346  s.noutstanding = nbuffers - s.nempty - s.nfilled;
347  }
epics::pvData::BitSetPtr empty
Definition: pvAccess.cpp:135
epicsGuard< epicsMutex > guard_t
Definition: pvahelper.h:78
epicsMutex & lock
Definition: pvahelper.h:77
const epics::pvData::PVStructurePtr& BaseMonitor::getValue ( )
inline

Definition at line 106 of file pvahelper.h.

106 { return complete; }
virtual void BaseMonitor::onStart ( )
inlinevirtual

Reimplemented in PDBGroupMonitor, and PDBSingleMonitor.

Definition at line 267 of file pvahelper.h.

267 {}
virtual void BaseMonitor::onStop ( )
inlinevirtual

Reimplemented in PDBGroupMonitor, and PDBSingleMonitor.

Definition at line 268 of file pvahelper.h.

268 {}
BaseMonitor::POINTER_DEFINITIONS ( BaseMonitor  )
bool BaseMonitor::post ( guard_t guard,
const epics::pvData::BitSet updated,
no_overflow   
)
inline

post update if queue not full, if full return false w/o overflow

Definition at line 136 of file pvahelper.h.

137  {
138  guard.assertIdenticalMutex(lock);
139  requester_t::shared_pointer req;
140 
141  if(!complete || !running) return false;
142 
143  changed |= updated;
144 
145  if(empty.empty()) return false;
146 
147  if(p_postone())
148  req = requester.lock();
149  inoverflow = false;
150 
151  if(req) {
152  unguard_t U(guard);
153  req->monitorEvent(shared_from_this());
154  }
155  return true;
156  }
epics::pvData::BitSetPtr empty
Definition: pvAccess.cpp:135
epicsGuardRelease< epicsMutex > unguard_t
Definition: pvahelper.h:79
shared_pointer shared_from_this()
Definition: pvahelper.h:73
const ChannelProcessRequester::weak_pointer requester
Definition: pvAccess.cpp:68
epicsMutex & lock
Definition: pvahelper.h:77
bool BaseMonitor::post ( guard_t guard)
inline

post update of pending changes. eg. call from requestUpdate()

Definition at line 159 of file pvahelper.h.

160  {
161  guard.assertIdenticalMutex(lock);
162  bool oflow;
163  requester_t::shared_pointer req;
164 
165  if(!complete || !running) return false;
166 
167  if(empty.empty()) {
168  oflow = inoverflow = true;
169 
170  } else {
171 
172  if(p_postone())
173  req = requester.lock();
174  oflow = inoverflow = false;
175  }
176 
177  if(req) {
178  unguard_t U(guard);
179  req->monitorEvent(shared_from_this());
180  }
181  return !oflow;
182  }
epics::pvData::BitSetPtr empty
Definition: pvAccess.cpp:135
epicsGuardRelease< epicsMutex > unguard_t
Definition: pvahelper.h:79
shared_pointer shared_from_this()
Definition: pvahelper.h:73
const ChannelProcessRequester::weak_pointer requester
Definition: pvAccess.cpp:68
epicsMutex & lock
Definition: pvahelper.h:77
bool BaseMonitor::post ( guard_t guard,
const epics::pvData::BitSet updated,
const epics::pvData::BitSet overflowed 
)
inline

post update with changed and overflowed masks (eg. when updates were lost in some upstream queue)

Definition at line 185 of file pvahelper.h.

188  {
189  guard.assertIdenticalMutex(lock);
190  bool oflow;
191  requester_t::shared_pointer req;
192 
193  if(!complete || !running) return false;
194 
195  if(empty.empty()) {
196  oflow = inoverflow = true;
197  overflow |= overflowed;
198  overflow.or_and(updated, changed);
199  changed |= updated;
200 
201  } else {
202 
203  changed |= updated;
204  if(p_postone())
205  req = requester.lock();
206  oflow = inoverflow = false;
207  }
208 
209  if(req) {
210  unguard_t U(guard);
211  req->monitorEvent(shared_from_this());
212  }
213  return !oflow;
214  }
epics::pvData::BitSetPtr empty
Definition: pvAccess.cpp:135
epicsGuardRelease< epicsMutex > unguard_t
Definition: pvahelper.h:79
shared_pointer shared_from_this()
Definition: pvahelper.h:73
const ChannelProcessRequester::weak_pointer requester
Definition: pvAccess.cpp:68
void or_and(const BitSet &set1, const BitSet &set2)
Definition: bitSet.cpp:282
epicsMutex & lock
Definition: pvahelper.h:77
bool BaseMonitor::post ( guard_t guard,
const epics::pvData::BitSet updated 
)
inline

post update with changed

Definition at line 217 of file pvahelper.h.

217  {
218  bool oflow;
219  requester_t::shared_pointer req;
220 
221  if(!complete || !running) return false;
222 
223  if(empty.empty()) {
224  oflow = inoverflow = true;
225  overflow.or_and(updated, changed);
226  changed |= updated;
227 
228  } else {
229 
230  changed |= updated;
231  if(p_postone())
232  req = requester.lock();
233  oflow = inoverflow = false;
234  }
235 
236  if(req) {
237  unguard_t U(guard);
238  req->monitorEvent(shared_from_this());
239  }
240  return !oflow;
241  }
epics::pvData::BitSetPtr empty
Definition: pvAccess.cpp:135
epicsGuardRelease< epicsMutex > unguard_t
Definition: pvahelper.h:79
shared_pointer shared_from_this()
Definition: pvahelper.h:73
const ChannelProcessRequester::weak_pointer requester
Definition: pvAccess.cpp:68
void or_and(const BitSet &set1, const BitSet &set2)
Definition: bitSet.cpp:282
virtual void BaseMonitor::requestUpdate ( )
inlinevirtual

called when within release() when the opportunity exists to end the overflow condition May do nothing, or lock and call post()

Reimplemented in PDBGroupMonitor, and PDBSingleMonitor.

Definition at line 271 of file pvahelper.h.

271 {guard_t G(lock); post(G);}
epicsGuard< epicsMutex > guard_t
Definition: pvahelper.h:78
bool post(guard_t &guard, const epics::pvData::BitSet &updated, no_overflow)
post update if queue not full, if full return false w/o overflow
Definition: pvahelper.h:136
epicsMutex & lock
Definition: pvahelper.h:77
shared_pointer BaseMonitor::shared_from_this ( )
inline

Definition at line 73 of file pvahelper.h.

73 { return shared_pointer(weakself); }
weak_pointer weakself
Definition: pvahelper.h:72

Member Data Documentation

epicsMutex& BaseMonitor::lock

Definition at line 77 of file pvahelper.h.

weak_pointer BaseMonitor::weakself

Definition at line 72 of file pvahelper.h.


The documentation for this struct was generated from the following file: