pvAccessCPP
7.1.7
|
Utility implementation of Monitor. More...
#include <client/pv/monitor.h>
Classes | |
struct | Source |
Source methods may be called with downstream mutex locked. More... | |
Public Types | |
typedef std::tr1::shared_ptr < MonitorFIFO > | shared_pointer |
typedef std::tr1::shared_ptr < const MonitorFIFO > | const_shared_pointer |
typedef std::tr1::weak_ptr < MonitorFIFO > | weak_pointer |
typedef std::tr1::weak_ptr < const MonitorFIFO > | const_weak_pointer |
typedef MonitorRequester | requester_type |
Public Member Functions | |
MonitorFIFO (const std::tr1::shared_ptr< MonitorRequester > &requester, const pvData::PVStructure::const_shared_pointer &pvRequest, const Source::shared_pointer &source=Source::shared_pointer(), Config *conf=0) | |
const std::tr1::shared_ptr < MonitorRequester > | getRequester () const |
Access to MonitorRequester passed to ctor, or NULL if it has already been destroyed. More... | |
void | show (std::ostream &strm) const |
virtual void | destroy () |
Destroy this instance. | |
void | setFreeHighMark (double level) |
Level, as a percentage of empty buffer slots, at which to call Source::freeHighMark(). More... | |
void | open (const epics::pvData::StructureConstPtr &type) |
Mark subscription as "open" with the associated structure type. | |
void | close () |
Abnormal closure (eg. due to upstream dis-connection) | |
void | finish () |
Successful closure (eg. RDB query done) | |
bool | tryPost (const pvData::PVStructure &value, const epics::pvData::BitSet &changed, const epics::pvData::BitSet &overrun=epics::pvData::BitSet(), bool force=false) |
Consume a free slot if available. More... | |
void | post (const pvData::PVStructure &value, const epics::pvData::BitSet &changed, const epics::pvData::BitSet &overrun=epics::pvData::BitSet()) |
Consume a free slot if available, otherwise squash with most recent. | |
void | notify () |
Call after calling any other upstream interface methods (open()/close()/finish()/post()/...) when no upstream mutexes are locked. More... | |
virtual epics::pvData::Status | start () |
Start monitoring. More... | |
virtual epics::pvData::Status | stop () |
Stop Monitoring. More... | |
virtual MonitorElementPtr | poll () |
If monitor has occurred return data. More... | |
virtual void | release (MonitorElementPtr const &monitorElement) |
Release a MonitorElement that was returned by poll. More... | |
virtual void | getStats (Stats &s) const |
virtual void | reportRemoteQueueStatus (epics::pvData::int32 freeElements) |
Report remote queue status. More... | |
size_t | freeCount () const |
Number of unused FIFO slots at this moment, which may changed in the next. | |
POINTER_DEFINITIONS (Monitor) | |
Friends | |
void | providerRegInit (void *) |
Utility implementation of Monitor.
The Monitor interface defines the downstream (consumer facing) side of a FIFO. This class is a concrete implementation of this FIFO, including the upstream (producer facing) side.
In addition to MonitorRequester, which provides callbacks to the downstream side, The MonitorFIFO::Source class provides callbacks to the upstream side.
The simplest usage is to create (as shown below), then put update into the FIFO using post() and tryPost(). These methods behave the same when the queue is not full, but differ when it is. Additionally, tryPost() has an argument 'force'. Together there are three actions
The intent of tryPost() with force=true is to aid code which is transferring values from some upstream buffer and this FIFO. Such code can be complicated if an item is removed from the upstream buffer, but can't be put into this downstream FIFO. Rather than being forced to effectivly maintain a third FIFO, code can use force=true.
In either case, tryPost()==false indicates the the FIFO is full.
eg. simple usage in a sub-class for Channel named MyChannel.
epics::pvAccess::MonitorFIFO::MonitorFIFO | ( | const std::tr1::shared_ptr< MonitorRequester > & | requester, |
const pvData::PVStructure::const_shared_pointer & | pvRequest, | ||
const Source::shared_pointer & | source = Source::shared_pointer() , |
||
Config * | conf = 0 |
||
) |
requester | Downstream/consumer callbacks |
pvRequest | Downstream provided options |
source | Upstream/producer callbacks |
conf | Upstream provided options. Updated with actual values used. May be NULL to use defaults. |
|
inline |
Access to MonitorRequester passed to ctor, or NULL if it has already been destroyed.
void epics::pvAccess::MonitorFIFO::notify | ( | ) |
Call after calling any other upstream interface methods (open()/close()/finish()/post()/...) when no upstream mutexes are locked.
Do not call from Source::freeHighMark(). This is done automatically. Call any MonitorRequester methods.
|
virtual |
If monitor has occurred return data.
May recursively call MonitorRequester::unlisten()
Implements epics::pvAccess::Monitor.
|
virtual |
Release a MonitorElement that was returned by poll.
A poll() must be called after the release() to check the presence of any modified data.
monitorElement |
Implements epics::pvAccess::Monitor.
|
virtual |
Report remote queue status.
freeElements | number of free elements. |
Reimplemented from epics::pvAccess::Monitor.
void epics::pvAccess::MonitorFIFO::setFreeHighMark | ( | double | level | ) |
Level, as a percentage of empty buffer slots, at which to call Source::freeHighMark().
Trigger condition is when number of free buffer slots goes above this level. In range [0.0, 1.0)
|
virtual |
|
virtual |
bool epics::pvAccess::MonitorFIFO::tryPost | ( | const pvData::PVStructure & | value, |
const epics::pvData::BitSet & | changed, | ||
const epics::pvData::BitSet & | overrun = epics::pvData::BitSet() , |
||
bool | force = false |
||
) |
Consume a free slot if available.
otherwise ... if !force take no action and return false. if force then attempt to allocate and fill a new slot, then return false. The extra slot will be free'd after it is consumed.