lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
Pds_Epics::PVBase Class Reference

EpicsPVA that is its own monitor callback; the base for read and write PVs (per the code comment). More...

#include <PVBase.hh>

Inherits Pds_Epics::EpicsPVA, and Pds_Epics::PVMonitorCb.

Inherited by Drp::BldDescriptor.

Public Member Functions

 PVBase (const char *channelName, const int maxElements=1)
 Connect to channelName through pva with this object as the monitor callback; maxElements is passed on but not used by EpicsPVA.
 
 PVBase (const char *provider, const char *channelName, const int maxElements=1)
 Connect to channelName through provider (ca or pva) with this object as the monitor callback.
 
 ~PVBase ()
 Does nothing; empty body.
 
void updated ()
 Does nothing; empty body.
 
bool ready ()
 Wait up to 30 s for the first value (getComplete()); returns true if it has arrived.
 
- Public Member Functions inherited from Pds_Epics::EpicsPVA
 EpicsPVA (const char *channelName, const int maxElements=0)
 Connect to channelName through pva without a monitor callback; maxElements is not used.
 
 EpicsPVA (const char *channelName, PVMonitorCb *, const int maxElements=0)
 Connect to channelName through pva; monitor, if not null, receives updated() calls.
 
 EpicsPVA (const char *provider, const char *channelName, PVMonitorCb *, const int maxElements=0, bool nType=false)
 Connect to channelName through ca if provider is ca, otherwise pva.
 
virtual ~EpicsPVA ()
 Remove the connect listener and cancel the pending get.
 
std::string name () const
 Return the channel name.
 
bool connected () const
 Return the state from the last connect event; the flag is not initialized before the first event.
 
long sec ()
 Return secondsPastEpoch of the PV time stamp, or -1 if no value arrives within 30 s (getComplete()).
 
int nsec ()
 Return the nanoseconds of the PV time stamp, or -1 if no value arrives within 30 s.
 
size_t nelem ()
 Return the length of the value array, or the largest size_t value (from -1) if no value arrives within 30 s.
 
template<typename T >
T getScalarAs (const char *field="value") const
 Return field (default value) of the latest structure converted to T, or 0 if no value has been received.
 
template<typename T >
void getVectorAs (pvd::shared_vector< const T > &vec, const char *field="value") const
 Copy array field (default value) of the latest structure into vec as T; does nothing if no value has been received.
 
template<typename T >
T getVectorElemAt (size_t i, const char *field="value") const
 Return element i of array field converted to T, converting the whole array first (per the code comment); i is not range-checked.
 
template<typename T >
void putFrom (T val)
 Put val to the value field and wait for the put to end; timeouts and runtime errors are caught and printed.
 
template<typename T >
void putFromVector (const pvd::shared_vector< const T > &val)
 Put array val to the value field and wait for the put to end; timeouts are caught and printed.
 
void putFromStructure (const void *val, const unsigned *sizes, bool ldebug=false)
 Put the packed buffer val to the top-level fields of the PV (see StructurePutTracker) and wait for the put to end; timeouts are caught and printed.
 
virtual void getDone (const pvac::GetEvent &evt)
 Get callback: on success, fulfil the value promise and, if a monitor callback was given, start monitoring (only timeStamp and value if nType is set).
 
virtual void connectEvent (const pvac::ConnectEvent &evt)
 Connect callback: store the connection state and, if connected, start a get of the PV.
 
virtual void monitorEvent (const pvac::MonitorEvent &evt)
 Monitor callback: for data, store each queued update as the latest structure and call the monitor callback's updated().
 
- Public Member Functions inherited from Pds_Epics::PVMonitorCb
virtual ~PVMonitorCb ()
 Does nothing; empty virtual destructor.
 
virtual void onConnect ()
 Called by MonTracker on the first data update after connecting; does nothing by default.
 
virtual void onDisconnect ()
 Called by MonTracker on a disconnect; does nothing by default.
 

Additional Inherited Members

- Static Public Member Functions inherited from Pds_Epics::EpicsPVA
static void setProvider (const char *)
 Declared but not defined in EpicsPVA.cc.
 
- Protected Member Functions inherited from Pds_Epics::EpicsPVA
virtual void onConnect ()
 
bool getComplete (unsigned tmo)
 
bool getComplete ()
 
- Protected Attributes inherited from Pds_Epics::EpicsPVA
pvac::ClientChannel _channel
 
pvac::Operation _op
 
pvac::Monitor _pvmon
 
std::promise< pvd::PVStructure::const_shared_pointer > _promise
 
pvd::PVStructure::const_shared_pointer _strct
 
PVMonitorCb * _monitorCB
 
bool _nType
 
bool _connected
 

Detailed Description

EpicsPVA that is its own monitor callback; the base for read and write PVs (per the code comment).

Subclasses override updated() and onConnect().

Constructor & Destructor Documentation

◆ PVBase() [1/2]

Pds_Epics::PVBase::PVBase ( const char *  channelName,
const int  maxElements = 1 
)
inline

Connect to channelName through pva with this object as the monitor callback; maxElements is passed on but not used by EpicsPVA.

◆ PVBase() [2/2]

Pds_Epics::PVBase::PVBase ( const char *  provider,
const char *  channelName,
const int  maxElements = 1 
)
inline

Connect to channelName through provider (ca or pva) with this object as the monitor callback.

◆ ~PVBase()

Pds_Epics::PVBase::~PVBase ( )
inline

Does nothing; empty body.

Member Function Documentation

◆ ready()

bool Pds_Epics::PVBase::ready ( )
inline

Wait up to 30 s for the first value (getComplete()); returns true if it has arrived.

◆ updated()

void Pds_Epics::PVBase::updated ( )
inlinevirtual

Does nothing; empty body.

Implements Pds_Epics::PVMonitorCb.


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