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

MonTracker that copies the payload field of a PV (value by default) into raw buffers: getParams() inspects the field's type and selects the getData function. More...

#include <PvMonitorBase.hh>

Inherits Pds_Epics::MonTracker.

Inherited by Drp::EpicsMonitorPv, and Drp::PvMonitor.

Public Types

enum  { MaxRank = XtcData::MaxRank }
 Rank limit for the getData shape. More...
 

Public Member Functions

 PvMonitorBase (const std::string &pvName, const std::string &provider="pva", const std::string &request="field()", const std::string &fieldName="value")
 Monitor pvName through provider (pva by default) with request; fieldName names the payload field.
 
virtual ~PvMonitorBase ()
 Does nothing; empty virtual destructor.
 
int printStructure () const
 Log the name, offset and type of each top-level field of the latest structure.
 
int getParams (pvd::ScalarType &type, size_t &size, size_t &rank)
 From the latest structure, return the element type, element count and rank of the payload field and set getData for it.
 
bool isPva ()
 Return true if the provider is pva.
 
bool isCa ()
 Return true if the provider is not pva.
 
void getTimestamp (int64_t &seconds, int32_t &nanoseconds)
 Return the seconds and nanoseconds of the timeStamp field of the latest structure.
 
void getTimestampPosix (int64_t &seconds, int32_t &nanoseconds)
 Same as getTimestamp(): the secondsPastEpoch value is returned unchanged.
 
void getTimestampEpics (int64_t &seconds, int32_t &nanoseconds)
 Like getTimestampPosix(), with POSIX_TIME_AT_EPICS_EPOCH subtracted from the seconds.
 
- Public Member Functions inherited from Pds_Epics::MonTracker
 POINTER_DEFINITIONS (MonTracker)
 Expands the pvData POINTER_DEFINITIONS macro for this class; doxygen lists it as a function.
 
 MonTracker (const std::string &name, const std::string &request="field()")
 Connect to name through pva and start a monitor with request (default field()).
 
 MonTracker (const std::string &provider, const std::string &name, const std::string &request="field()")
 Connect to name through ca if provider is ca, otherwise pva, and start a monitor with request.
 
virtual ~MonTracker ()
 Cancel the monitor.
 
const std::string name () const
 Return the channel name.
 
bool connected () const
 Return true from the first data update until a disconnect.
 
virtual void monitorEvent (const pvac::MonitorEvent &evt) OVERRIDE FINAL
 Monitor callback on a pvAccess thread: queue the event on the WorkQueue for process().
 
virtual void process (const pvac::MonitorEvent &evt) OVERRIDE FINAL
 Handle a monitor event on the WorkQueue thread.
 
- Public Member Functions inherited from Pds_Epics::Worker
virtual ~Worker ()
 Does nothing; empty virtual destructor.
 
- 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.
 
virtual void updated ()=0
 Pure virtual: called for each update of the PV.
 

Public Attributes

std::function< size_t(void *data, size_t size, uint32_t shape[MaxRank])> getData
 Copy the payload field into data (size bytes available) and fill shape; returns the bytes used, or the bytes that would have been used if more than size (truncation), per the code comment.
 

Protected Attributes

const bool m_pvaProvider
 
const std::string m_fieldName
 
- Protected Attributes inherited from Pds_Epics::MonTracker
pvd::PVStructure::const_shared_pointer _strct
 
pvd::PVStructure::shared_pointer _request
 
pvac::ClientChannel _channel
 
pvac::Monitor _mon
 
bool _connected
 

Additional Inherited Members

- Static Public Member Functions inherited from Pds_Epics::MonTracker
static void close ()
 Close the shared WorkQueue.
 
- Protected Member Functions inherited from Pds_Epics::MonTracker
void disconnect ()
 
void reconnect ()
 

Detailed Description

MonTracker that copies the payload field of a PV (value by default) into raw buffers: getParams() inspects the field's type and selects the getData function.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Rank limit for the getData shape.

Enumerator
MaxRank 

XtcData::MaxRank.

Constructor & Destructor Documentation

◆ PvMonitorBase()

Pds_Epics::PvMonitorBase::PvMonitorBase ( const std::string &  pvName,
const std::string &  provider = "pva",
const std::string &  request = "field()",
const std::string &  fieldName = "value" 
)
inline

Monitor pvName through provider (pva by default) with request; fieldName names the payload field.

◆ ~PvMonitorBase()

virtual Pds_Epics::PvMonitorBase::~PvMonitorBase ( )
inlinevirtual

Does nothing; empty virtual destructor.

Member Function Documentation

◆ getParams()

int Pds_Epics::PvMonitorBase::getParams ( pvd::ScalarType &  type,
size_t &  size,
size_t &  rank 
)

From the latest structure, return the element type, element count and rank of the payload field and set getData for it.

Strings count MAX_STRING_SIZE bytes each and enum_t structures are treated as strings. Returns 1 if the structure or a needed part of it is missing, else 0; throws a C string for a missing payload or an unsupported type.

◆ getTimestamp()

void Pds_Epics::PvMonitorBase::getTimestamp ( int64_t &  seconds,
int32_t &  nanoseconds 
)
inline

Return the seconds and nanoseconds of the timeStamp field of the latest structure.

◆ getTimestampEpics()

void Pds_Epics::PvMonitorBase::getTimestampEpics ( int64_t &  seconds,
int32_t &  nanoseconds 
)
inline

Like getTimestampPosix(), with POSIX_TIME_AT_EPICS_EPOCH subtracted from the seconds.

◆ getTimestampPosix()

void Pds_Epics::PvMonitorBase::getTimestampPosix ( int64_t &  seconds,
int32_t &  nanoseconds 
)
inline

Same as getTimestamp(): the secondsPastEpoch value is returned unchanged.

◆ isCa()

bool Pds_Epics::PvMonitorBase::isCa ( )
inline

Return true if the provider is not pva.

◆ isPva()

bool Pds_Epics::PvMonitorBase::isPva ( )
inline

Return true if the provider is pva.

◆ printStructure()

int Pds_Epics::PvMonitorBase::printStructure ( ) const

Log the name, offset and type of each top-level field of the latest structure.

Returns 1 if a needed part is missing, else 0.

Member Data Documentation

◆ getData

std::function<size_t(void* data, size_t size, uint32_t shape[MaxRank])> Pds_Epics::PvMonitorBase::getData

Copy the payload field into data (size bytes available) and fill shape; returns the bytes used, or the bytes that would have been used if more than size (truncation), per the code comment.

Set by getParams().

◆ m_fieldName

const std::string Pds_Epics::PvMonitorBase::m_fieldName
protected

◆ m_pvaProvider

const bool Pds_Epics::PvMonitorBase::m_pvaProvider
protected

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