EPICS ARCHIVER V4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
Public Member Functions | List of all members
SampleMechanism Class Referenceabstract

Sample Mechanism base, has a ProcessVariable and filters its values. More...

#include <SampleMechanism.h>

Inheritance diagram for SampleMechanism:
ProcessVariableListener Guardable Named ProcessVariableStateListener ProcessVariableValueListener SampleMechanismEA3 SampleMechanismGetEA3 SampleMechanismMonitoredEA3 SampleMechanismMonitoredGetEA3

Public Member Functions

 SampleMechanism (const EngineConfig &config, ProcessVariableContext &ctx, const char *name, double period, ProcessVariableListener *disable_filt_listener)
 Construct mechanism for given period. More...
 
virtual unsigned long write (Guard &guard, Index &index)=0
 Write current buffer to index. More...
 
virtual std::string getInfo (Guard &guard)
 
virtual void start (Guard &guard)
 Start the sample mechanism. More...
 
virtual void stop (Guard &guard)
 Stop sampling. More...
 
virtual void addToFUX (Guard &guard, FUX::Element *doc)
 Append this sample mechanism to a FUX document. More...
 
virtual void pvConnected (ProcessVariable &pv, const epicsTime &when)=0
 ProcessVariableStateListener. More...
 
void pvDisconnected (ProcessVariable &pv, const epicsTime &when)
 ProcessVariableStateListener. More...
 
virtual void pvValue (ProcessVariable &pv, const RawValue::Data *data)=0
 ProcessVariableValueListener. More...
 
virtual OrderedMutexgetMutex ()
 
virtual const std::string & getName () const
 Gets the ProcessVariable name. More...
 
bool isRunning (Guard &guard)
 
ProcessVariable::State getPVState ()
 
void disable (const epicsTime &when)
 Temporarily disable sampling. More...
 
void enable (const epicsTime &when)
 Re-enable sampling. More...
 
void addStateListener (ProcessVariableStateListener *listener)
 Add a listener to the underlying PV. More...
 
void removeStateListener (ProcessVariableStateListener *listener)
 Remove a listener from the underlying PV. More...
 
void addValueListener (ProcessVariableValueListener *listener)
 Add a listener to the underlying PV. More...
 
void removeValueListener (ProcessVariableValueListener *listener)
 Remove a listener from the underlying PV. More...
 
- Public Member Functions inherited from ProcessVariableStateListener
virtual ~ProcessVariableStateListener ()
 Constructor.
 

Detailed Description

Sample Mechanism base, has a ProcessVariable and filters its values.

This base class for all sample mechanisms maintains the ProcessVariable start/stop, and also has a DisableFilter.

Data from the PV goes to the DisableFilter, via which the enable/disable is implemented. Derived sample mechanisms will probably add more filters, until finally invoking the ProcessVariableListener interface of the base SampleMechanism.

The ProcessVariableListener implementation in the base SampleMechanism logs "Disconnected" on pvDisconnected(), and otherwise adds every pvValue to the CircularBuffer.

Uses 'virtual Named' so we can implement other 'Named' interfaces in derived SampleMechanisms and still only get one 'Named' base.

Constructor & Destructor Documentation

SampleMechanism::SampleMechanism ( const EngineConfig config,
ProcessVariableContext ctx,
const char *  name,
double  period,
ProcessVariableListener disable_filt_listener 
)

Construct mechanism for given period.

Parameters
configThe global configuration.
ctxThe ProcessVariableContext to use for the pv.
nameThe pv name to connect to.
periodThe sample period. Use differs with derived class.
disable_filt_listenerThe next listener after the DisableFilter.

The disable_filt_listener would typically be another ProcessVariableFilter, linking to yet another one, and the final filter then sends PV events to the SampleMechanism. The derived SampleMechanisms provide those intermediate PV filters and point the last one to the basic SampleMechanism, so the derived mechanisms don't need a PV listener in the constructor.

Member Function Documentation

void SampleMechanism::addStateListener ( ProcessVariableStateListener listener)
inline

Add a listener to the underlying PV.

virtual void SampleMechanism::addToFUX ( Guard guard,
FUX::Element doc 
)
virtual

Append this sample mechanism to a FUX document.

Reimplemented in SampleMechanismMonitoredGetEA3, SampleMechanismGetEA3, and SampleMechanismMonitoredEA3.

void SampleMechanism::addValueListener ( ProcessVariableValueListener listener)
inline

Add a listener to the underlying PV.

void SampleMechanism::disable ( const epicsTime &  when)

Temporarily disable sampling.

See Also
enable()
void SampleMechanism::enable ( const epicsTime &  when)

Re-enable sampling.

See Also
disable()
virtual std::string SampleMechanism::getInfo ( Guard guard)
virtual
Returns
Returns a description of mechanism and current state.

Reimplemented in SampleMechanismMonitoredGetEA3, SampleMechanismGetEA3, and SampleMechanismMonitoredEA3.

virtual OrderedMutex& SampleMechanism::getMutex ( )
virtual
Returns
Returns the mutex for the SampleMechanism.
See Also
Guardable

Implements Guardable.

virtual const std::string& SampleMechanism::getName ( ) const
virtual

Gets the ProcessVariable name.

See Also
NamedAbstractBase

Implements Named.

ProcessVariable::State SampleMechanism::getPVState ( )
Returns
Returns the state of the ProcessVariable.
bool SampleMechanism::isRunning ( Guard guard)
Returns
Returns true if start has been invoked until stop().
virtual void SampleMechanism::pvConnected ( ProcessVariable pv,
const epicsTime &  when 
)
pure virtual
void SampleMechanism::pvDisconnected ( ProcessVariable pv,
const epicsTime &  when 
)
virtual

ProcessVariableStateListener.

Base implementation adds a "DISCONNECTED" marker.

Implements ProcessVariableStateListener.

virtual void SampleMechanism::pvValue ( ProcessVariable pv,
const RawValue::Data data 
)
pure virtual

ProcessVariableValueListener.

Base implementation adds data to buffer. In addition, the initial value after a new connection is also logged with the host time stamp. For PVs that never change, this helps because the original time stamp might be before the last 'disconnect', so this gives us an idea of when the PV connected.

Implements ProcessVariableValueListener.

Implemented in SampleMechanismEA3.

void SampleMechanism::removeStateListener ( ProcessVariableStateListener listener)
inline

Remove a listener from the underlying PV.

void SampleMechanism::removeValueListener ( ProcessVariableValueListener listener)
inline

Remove a listener from the underlying PV.

virtual void SampleMechanism::start ( Guard guard)
virtual

Start the sample mechanism.

Base implementation starts the PV.

Reimplemented in SampleMechanismMonitoredGetEA3, and SampleMechanismGetEA3.

virtual void SampleMechanism::stop ( Guard guard)
virtual

Stop sampling.

See Also
start()

Base implementation stops the PV and adds a 'STOPPED (OFF)' event.

Reimplemented in SampleMechanismMonitoredGetEA3, and SampleMechanismGetEA3.

virtual unsigned long SampleMechanism::write ( Guard guard,
Index index 
)
pure virtual

Write current buffer to index.

Returns
Returns number of samples written.

Implemented in SampleMechanismEA3.


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