pva2pva 1.4.2
Loading...
Searching...
No Matches
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 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)
const epics::pvData::PVStructurePtr & getValue ()
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
bool post (guard_t &guard)
 post update of pending changes. eg. call from requestUpdate()
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)
bool post (guard_t &guard, const epics::pvData::BitSet &updated)
 post update with changed
virtual void onStart ()
virtual void onStop ()
virtual void requestUpdate ()
virtual void destroy ()
virtual void getStats (Stats &s) const

Public Attributes

weak_pointer weakself
epicsMutex & lock

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

◆ guard_t

typedef epicsGuard<epicsMutex> BaseMonitor::guard_t

Definition at line 78 of file pvahelper.h.

◆ requester_t

typedef epics::pvAccess::MonitorRequester BaseMonitor::requester_t

Definition at line 75 of file pvahelper.h.

◆ unguard_t

typedef epicsGuardRelease<epicsMutex> BaseMonitor::unguard_t

Definition at line 79 of file pvahelper.h.

Constructor & Destructor Documentation

◆ BaseMonitor()

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)
98 ,requester(requester)
99 ,inoverflow(false)
100 ,running(false)
101 ,nbuffers(2)
102 {}

◆ ~BaseMonitor()

virtual BaseMonitor::~BaseMonitor ( )
inlinevirtual

Definition at line 104 of file pvahelper.h.

104{destroy();}

Member Function Documentation

◆ connect()

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());
114 epics::pvData::PVDataCreatePtr create(epics::pvData::getPVDataCreate());
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);
128 epics::pvData::Status sts;
129 req->monitorConnect(sts, self, dtype);
130 }
131 }

◆ destroy()

virtual void BaseMonitor::destroy ( )
inlinevirtual

Definition at line 273 of file pvahelper.h.

274 {
275 stop();
276 }

◆ getStats()

virtual void BaseMonitor::getStats ( Stats & s) const
inlinevirtual

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 }

◆ getValue()

const epics::pvData::PVStructurePtr & BaseMonitor::getValue ( )
inline

Definition at line 106 of file pvahelper.h.

106{ return complete; }

◆ onStart()

virtual void BaseMonitor::onStart ( )
inlinevirtual

Definition at line 267 of file pvahelper.h.

267{}

◆ onStop()

virtual void BaseMonitor::onStop ( )
inlinevirtual

Definition at line 268 of file pvahelper.h.

268{}

◆ post() [1/4]

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 }

◆ post() [2/4]

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 }

◆ post() [3/4]

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 }

◆ post() [4/4]

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 }

◆ requestUpdate()

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);}
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

◆ shared_from_this()

shared_pointer BaseMonitor::shared_from_this ( )
inline

Definition at line 73 of file pvahelper.h.

73{ return shared_pointer(weakself); }

Member Data Documentation

◆ lock

epicsMutex& BaseMonitor::lock

Definition at line 77 of file pvahelper.h.

◆ weakself

weak_pointer BaseMonitor::weakself

Definition at line 72 of file pvahelper.h.


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