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

Monitors one EPICS PV and copies its value into the L1Accept whose timestamp equals the timestamp of the PV update. More...

#include <PvaDetector.hh>

Inherits Pds_Epics::PvMonitorBase.

Public Member Functions

 PvMonitor (const PvParameters &para, const std::string &alias, const std::string &pvName, const std::string &provider, const std::string &request, const std::string &field, unsigned id, size_t nBuffers, size_t bufferSize, unsigned type, size_t nelem, size_t rank, uint32_t firstDim, const std::atomic< bool > &running, PvDetector &pvDetector)
 Set up the PV monitor (pvName via provider with request and field) and the queues of nBuffers entries, keep the expected type, element count, rank and first-dimension override (-1 values mean take them from the PV), and connect the error PUSH socket to the collection server.
 
void onConnect () override
 On the first connection, take the type, element count and rank from the PV for any that were not given and mark the monitor ready; aborts if given and PV values differ.
 
void onDisconnect () override
 Mark the monitor not ready and send a warning that the PV disconnected.
 
void updated () override
 When ready and running, compare the update timestamp with queued L1Accepts: on equal timestamps copy the value into that event and pass it on; older L1Accepts are damaged with MissingData and passed on; a younger L1Accept stays queued for the next update.
 
void timeout (Pds::EbDgram *)
 Remove dgram from l1Queue if it is the oldest entry.
 
void startup ()
 Start both queues.
 
void shutdown ()
 Shut down both queues and reset the counters.
 
int getParams (std::string &fieldName, XtcData::Name::DataType &xtcType, int &rank)
 Wait up to 3 s for the PV to connect, then return its field name, XTC type and rank (rank 2 when a first-dimension override is set).
 
unsigned id () const
 Return the index of this PV within the detector.
 
const std::string & alias () const
 Return the alias under which the PV is recorded.
 
uint64_t nUpdates () const
 Return the number of PV updates received.
 
uint64_t nMatch () const
 Return the number of L1Accepts that got PV data.
 
uint64_t nEmpty () const
 Return the number of L1Accepts passed on without PV data (older than the update).
 
uint64_t nTooOld () const
 Return the number of updates older than the oldest queued L1Accept.
 
int64_t timeDiff () const
 Return the last L1Accept minus PV timestamp difference in nanoseconds.
 
int64_t latency () const
 Return the latency of the last PV update in microseconds.
 
- Public Member Functions inherited from Pds_Epics::PvMonitorBase
 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.
 

Public Attributes

SPSCQueue< Pds::EbDgram * > pvQueue
 Events with PV data added (or damaged with MissingData), consumed by the PvDrp collector.
 
SPSCQueue< Pds::EbDgram * > l1Queue
 L1Accept events waiting for a PV update with a matching timestamp.
 
- Public Attributes inherited from Pds_Epics::PvMonitorBase
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.
 

Additional Inherited Members

- Public Types inherited from Pds_Epics::PvMonitorBase
enum  { MaxRank = XtcData::MaxRank }
 Rank limit for the getData shape. More...
 
- 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 ()
 
- Protected Attributes inherited from Pds_Epics::PvMonitorBase
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
 

Detailed Description

Monitors one EPICS PV and copies its value into the L1Accept whose timestamp equals the timestamp of the PV update.

L1Accepts wait in l1Queue; matched (or MissingData-damaged) ones are passed on through pvQueue.

Constructor & Destructor Documentation

◆ PvMonitor()

Drp::PvMonitor::PvMonitor ( const PvParameters &  para,
const std::string &  alias,
const std::string &  pvName,
const std::string &  provider,
const std::string &  request,
const std::string &  field,
unsigned  id,
size_t  nBuffers,
size_t  bufferSize,
unsigned  type,
size_t  nelem,
size_t  rank,
uint32_t  firstDim,
const std::atomic< bool > &  running,
PvDetector &  pvDetector 
)

Set up the PV monitor (pvName via provider with request and field) and the queues of nBuffers entries, keep the expected type, element count, rank and first-dimension override (-1 values mean take them from the PV), and connect the error PUSH socket to the collection server.

Member Function Documentation

◆ alias()

const std::string & Drp::PvMonitor::alias ( ) const
inline

Return the alias under which the PV is recorded.

◆ getParams()

int Drp::PvMonitor::getParams ( std::string &  fieldName,
XtcData::Name::DataType &  xtcType,
int &  rank 
)

Wait up to 3 s for the PV to connect, then return its field name, XTC type and rank (rank 2 when a first-dimension override is set).

Returns 1 if the parameters are unknown or the payload would not fit in a buffer (a message is sent), else 0.

◆ id()

unsigned Drp::PvMonitor::id ( ) const
inline

Return the index of this PV within the detector.

◆ latency()

int64_t Drp::PvMonitor::latency ( ) const
inline

Return the latency of the last PV update in microseconds.

◆ nEmpty()

uint64_t Drp::PvMonitor::nEmpty ( ) const
inline

Return the number of L1Accepts passed on without PV data (older than the update).

◆ nMatch()

uint64_t Drp::PvMonitor::nMatch ( ) const
inline

Return the number of L1Accepts that got PV data.

◆ nTooOld()

uint64_t Drp::PvMonitor::nTooOld ( ) const
inline

Return the number of updates older than the oldest queued L1Accept.

◆ nUpdates()

uint64_t Drp::PvMonitor::nUpdates ( ) const
inline

Return the number of PV updates received.

◆ onConnect()

void Drp::PvMonitor::onConnect ( )
overridevirtual

On the first connection, take the type, element count and rank from the PV for any that were not given and mark the monitor ready; aborts if given and PV values differ.

With verbose above 1, print the PV structure.

Reimplemented from Pds_Epics::PVMonitorCb.

◆ onDisconnect()

void Drp::PvMonitor::onDisconnect ( )
overridevirtual

Mark the monitor not ready and send a warning that the PV disconnected.

Reimplemented from Pds_Epics::PVMonitorCb.

◆ shutdown()

void Drp::PvMonitor::shutdown ( )

Shut down both queues and reset the counters.

◆ startup()

void Drp::PvMonitor::startup ( )

Start both queues.

◆ timeDiff()

int64_t Drp::PvMonitor::timeDiff ( ) const
inline

Return the last L1Accept minus PV timestamp difference in nanoseconds.

◆ timeout()

void Drp::PvMonitor::timeout ( Pds::EbDgram *  )

Remove dgram from l1Queue if it is the oldest entry.

◆ updated()

void Drp::PvMonitor::updated ( )
overridevirtual

When ready and running, compare the update timestamp with queued L1Accepts: on equal timestamps copy the value into that event and pass it on; older L1Accepts are damaged with MissingData and passed on; a younger L1Accept stays queued for the next update.

Implements Pds_Epics::PVMonitorCb.

Member Data Documentation

◆ l1Queue

SPSCQueue<Pds::EbDgram*> Drp::PvMonitor::l1Queue

L1Accept events waiting for a PV update with a matching timestamp.

◆ pvQueue

SPSCQueue<Pds::EbDgram*> Drp::PvMonitor::pvQueue

Events with PV data added (or damaged with MissingData), consumed by the PvDrp collector.


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