This is Unofficial EPICS BASE Doxygen Site
MonitorUser Struct Reference

#include "chancache.h"

+ Inheritance diagram for MonitorUser:
+ Collaboration diagram for MonitorUser:

Public Member Functions

 POINTER_DEFINITIONS (MonitorUser)
 
epicsMutex & mutex () const
 
 MonitorUser (const MonitorCacheEntry::shared_pointer &)
 
virtual ~MonitorUser ()
 
virtual void destroy ()
 
virtual epics::pvData::Status start ()
 
virtual epics::pvData::Status stop ()
 
virtual epics::pvData::MonitorElementPtr poll ()
 
virtual void release (epics::pvData::MonitorElementPtr const &monitorElement)
 
virtual std::string getRequesterName ()
 
- Public Member Functions inherited from epics::pvAccess::Monitor
 POINTER_DEFINITIONS (Monitor)
 
virtual ~Monitor ()
 
virtual void release (MonitorElementPtr const &monitorElement)=0
 
virtual void getStats (Stats &s) const
 
virtual void reportRemoteQueueStatus (epics::pvData::int32 freeElements)
 
- Public Member Functions inherited from epics::pvAccess::Destroyable
 POINTER_DEFINITIONS (Destroyable)
 

Public Attributes

weak_pointer weakref
 
MonitorCacheEntry::shared_pointer entry
 
epics::pvData::MonitorRequester::weak_pointer req
 
std::tr1::weak_ptr< GWChannelsrvchan
 
bool initial
 
bool running
 
bool inoverflow
 
size_t nwakeups
 
size_t nevents
 
size_t ndropped
 
std::deque< epics::pvData::MonitorElementPtr > filled
 
std::deque< epics::pvData::MonitorElementPtr > empty
 
std::set< epics::pvData::MonitorElementPtr > inuse
 
epics::pvData::MonitorElementPtr overflowElement
 

Static Public Attributes

static size_t num_instances
 

Additional Inherited Members

- Public Types inherited from epics::pvAccess::Monitor
typedef MonitorRequester requester_type
 
- Protected Member Functions inherited from epics::pvAccess::Destroyable
virtual ~Destroyable ()
 

Detailed Description

Definition at line 67 of file chancache.h.

Constructor & Destructor Documentation

MonitorUser::MonitorUser ( const MonitorCacheEntry::shared_pointer &  e)

Definition at line 244 of file moncache.cpp.

245  :entry(e)
246  ,initial(true)
247  ,running(false)
248  ,inoverflow(false)
249  ,nevents(0)
250  ,ndropped(0)
251 {
253 }
MonitorCacheEntry::shared_pointer entry
Definition: chancache.h:75
bool running
Definition: chancache.h:81
bool initial
Definition: chancache.h:80
size_t nevents
Definition: chancache.h:84
EPICS_ATOMIC_INLINE size_t epicsAtomicIncrSizeT(size_t *pTarget)
static size_t num_instances
Definition: chancache.h:70
bool inoverflow
Definition: chancache.h:82
size_t ndropped
Definition: chancache.h:85
MonitorUser::~MonitorUser ( )
virtual

Definition at line 255 of file moncache.cpp.

256 {
258 }
EPICS_ATOMIC_INLINE size_t epicsAtomicDecrSizeT(size_t *pTarget)
static size_t num_instances
Definition: chancache.h:70

Member Function Documentation

void MonitorUser::destroy ( )
virtual

Destroy this instance.

Implements epics::pvAccess::Destroyable.

Definition at line 262 of file moncache.cpp.

263 {
264  {
265  Guard G(mutex());
266  running = false;
267  }
268 }
bool running
Definition: chancache.h:81
epicsMutex & mutex() const
Definition: chancache.h:73
std::string MonitorUser::getRequesterName ( )
virtual

Definition at line 378 of file moncache.cpp.

379 {
380  return "MonitorCacheEntry";
381 }
epicsMutex& MonitorUser::mutex ( ) const
inline

Definition at line 73 of file chancache.h.

73 { return entry->mutex(); }
MonitorUser::POINTER_DEFINITIONS ( MonitorUser  )
pva::MonitorElementPtr MonitorUser::poll ( )
virtual

If monitor has occurred return data.

Returns
monitorElement for modified data. Must call get to determine if data is available.

May recursively call MonitorRequester::unlisten()

Implements epics::pvAccess::Monitor.

Definition at line 332 of file moncache.cpp.

333 {
334  Guard G(mutex());
336  if(!filled.empty()) {
337  ret = filled.front();
338  inuse.insert(ret); // track which ones are out for client use
339  filled.pop_front();
340  //TODO: track lost buffers w/ wrapped shared_ptr?
341  }
342  return ret;
343 }
epicsMutex & mutex() const
Definition: chancache.h:73
std::tr1::shared_ptr< MonitorElement > MonitorElementPtr
Definition: monitor.h:40
std::deque< epics::pvData::MonitorElementPtr > filled
Definition: chancache.h:87
std::set< epics::pvData::MonitorElementPtr > inuse
Definition: chancache.h:88
void MonitorUser::release ( epics::pvData::MonitorElementPtr const &  monitorElement)
virtual

Definition at line 346 of file moncache.cpp.

347 {
348  Guard G(mutex());
349  //TODO: ifdef DEBUG? (only track inuse when debugging?)
350  std::set<epics::pvData::MonitorElementPtr>::iterator it = inuse.find(monitorElement);
351  if(it!=inuse.end()) {
352  inuse.erase(it);
353 
354  if(inoverflow) { // leaving overflow condition
355 
356  // to avoid copy, enqueue the current overflowElement
357  // and replace it with the element being release()d
358 
359  filled.push_back(overflowElement);
360  overflowElement = monitorElement;
361  overflowElement->changedBitSet->clear();
362  overflowElement->overrunBitSet->clear();
363 
364  inoverflow = false;
365  } else {
366  // push_back empty element
367  empty.push_back(monitorElement);
368  }
369  } else {
370  // oh no, we've been given an element which we didn't give to downstream
371  //TODO: check empty and filled lists to see if this is one of ours, of from somewhere else
372  throw std::invalid_argument("Can't release MonitorElement not in use");
373  }
374  // TODO: pipeline window update?
375 }
std::deque< epics::pvData::MonitorElementPtr > empty
Definition: chancache.h:87
epics::pvData::MonitorElementPtr overflowElement
Definition: chancache.h:90
epicsMutex & mutex() const
Definition: chancache.h:73
bool inoverflow
Definition: chancache.h:82
std::deque< epics::pvData::MonitorElementPtr > filled
Definition: chancache.h:87
std::set< epics::pvData::MonitorElementPtr > inuse
Definition: chancache.h:88
pvd::Status MonitorUser::start ( )
virtual

Start monitoring.

Returns
completion status.

Implements epics::pvAccess::Monitor.

Definition at line 271 of file moncache.cpp.

272 {
273  pvd::MonitorRequester::shared_pointer req(this->req.lock());
274  if(!req)
275  return pvd::Status(pvd::Status::STATUSTYPE_FATAL, "already dead");
276 
277  bool doEvt = false;
278  {
279  Guard G(entry->mutex()); // MCE and MU have share a lock
280 
281  if(!entry->startresult.isSuccess())
282  return entry->startresult;
283 
284  pvd::PVStructurePtr lval;
285  if(entry->havedata)
286  lval = entry->lastelem->pvStructurePtr;
287  pvd::StructureConstPtr typedesc(entry->typedesc);
288 
289  if(initial) {
290  initial = false;
291 
292  empty.resize(entry->bufferSize);
294  for(unsigned i=0; i<empty.size(); i++) {
295  empty[i].reset(new pvd::MonitorElement(fact->createPVStructure(typedesc)));
296  }
297 
298  // extra element to accumulate updates during overflow
299  overflowElement.reset(new pvd::MonitorElement(fact->createPVStructure(typedesc)));
300  }
301 
302  doEvt = filled.empty();
303 
304  if(lval && !empty.empty()) {
305  //already running, notify of initial element
306 
307  const pva::MonitorElementPtr& elem(empty.front());
308  elem->pvStructurePtr->copy(*lval);
309  elem->changedBitSet->set(0); // indicate all changed
310  elem->overrunBitSet->clear();
311  filled.push_back(elem);
312  empty.pop_front();
313  }
314 
315  doEvt &= !filled.empty();
316  running = true;
317  }
318  if(doEvt)
319  req->monitorEvent(shared_pointer(weakref)); // TODO: worker thread?
320  return pvd::Status();
321 }
epics::pvData::MonitorRequester::weak_pointer req
Definition: chancache.h:76
int i
Definition: scan.c:967
bool running
Definition: chancache.h:81
std::deque< epics::pvData::MonitorElementPtr > empty
Definition: chancache.h:87
std::tr1::shared_ptr< const Structure > StructureConstPtr
Definition: pvIntrospect.h:162
weak_pointer weakref
Definition: chancache.h:71
An element for a monitorQueue.
Definition: monitor.h:54
epics::pvData::MonitorElementPtr overflowElement
Definition: chancache.h:90
std::tr1::shared_ptr< PVDataCreate > PVDataCreatePtr
Definition: pvData.h:124
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
bool initial
Definition: chancache.h:80
std::tr1::shared_ptr< MonitorElement > MonitorElementPtr
Definition: monitor.h:40
FORCE_INLINE const PVDataCreatePtr & getPVDataCreate()
Definition: pvData.h:1648
std::deque< epics::pvData::MonitorElementPtr > filled
Definition: chancache.h:87
pvd::Status MonitorUser::stop ( )
virtual

Stop Monitoring.

Returns
completion status.

Implements epics::pvAccess::Monitor.

Definition at line 324 of file moncache.cpp.

325 {
326  Guard G(mutex());
327  running = false;
328  return pvd::Status::Ok;
329 }
static Status Ok
Definition: status.h:47
bool running
Definition: chancache.h:81
epicsMutex & mutex() const
Definition: chancache.h:73

Member Data Documentation

std::deque<epics::pvData::MonitorElementPtr> MonitorUser::empty

Definition at line 87 of file chancache.h.

MonitorCacheEntry::shared_pointer MonitorUser::entry

Definition at line 75 of file chancache.h.

std::deque<epics::pvData::MonitorElementPtr> MonitorUser::filled

Definition at line 87 of file chancache.h.

bool MonitorUser::initial

Definition at line 80 of file chancache.h.

bool MonitorUser::inoverflow

Definition at line 82 of file chancache.h.

std::set<epics::pvData::MonitorElementPtr> MonitorUser::inuse

Definition at line 88 of file chancache.h.

size_t MonitorUser::ndropped

Definition at line 85 of file chancache.h.

size_t MonitorUser::nevents

Definition at line 84 of file chancache.h.

size_t MonitorUser::num_instances
static

Definition at line 70 of file chancache.h.

size_t MonitorUser::nwakeups

Definition at line 83 of file chancache.h.

epics::pvData::MonitorElementPtr MonitorUser::overflowElement

Definition at line 90 of file chancache.h.

epics::pvData::MonitorRequester::weak_pointer MonitorUser::req

Definition at line 76 of file chancache.h.

bool MonitorUser::running

Definition at line 81 of file chancache.h.

std::tr1::weak_ptr<GWChannel> MonitorUser::srvchan

Definition at line 77 of file chancache.h.

weak_pointer MonitorUser::weakref

Definition at line 71 of file chancache.h.


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