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

PgpReader for the PGP-card DRP that forwards broken-event and event-counter-reset notifications to its PGPDrp. More...

#include <EpicsArch.hh>

Inherits Drp::PgpReader, Drp::PgpReader, Drp::PgpReader, Drp::PgpReader, and Drp::PgpReader.

Public Member Functions

 Pgp (Parameters &para, DrpBase &drp, Detector *det)
 Construct the PgpReader on the pool of drp (at most 100 buffers per read, 32 per free batch) and set the driver mask for laneMask on the virtual channel of det, logging an error on failure.
 
const Pds::TimingHeader * next ()
 Return the TimingHeader of the current DMA buffer, reading new buffers when the previous batch is used up and timing out TEB batches while waiting.
 
void worker (std::shared_ptr< Pds::MetricExporter > exporter[], prometheus::Exposer *)
 Thread body: build the BLD sources from Parameters::detType (comma-separated names, or entries with plus signs looked up through PVs), set up their metrics, then match timing headers with BLD events by timestamp.
 
void shutdown ()
 Ask the worker loop to stop and clear the names lookup of the detector.
 
 Pgp (const Parameters &para, MemPool &pool, Detector &det, PGPDrp &m_drp)
 Construct the PgpReader (at most 1000 buffers per read, 32 per free batch) and set the driver mask for laneMask on the virtual channel of det; aborts with a message if that fails.
 
virtual void handleBrokenEvent (const PGPEvent &event) override
 Forward event to PGPDrp::handleBrokenEvent, which counts it in the current batch.
 
virtual void resetEventCounter () override
 Call PgpReader::resetEventCounter (last completed event counter to 0), then PGPDrp::resetEventCounter (batching restarts at event counter 1).
 
 Pgp (const Parameters &para, MemPool &pool, Detector *det)
 Construct the PgpReader (at most 100 buffers per read, 32 per free batch) and set the driver mask for laneMask on the virtual channel of det, logging an error on failure.
 
Pds::EbDgram * next (uint32_t &evtIndex)
 Return the next complete event as an EbDgram built in its pebble buffer (its index is stored in evtIndex), reading more DMA buffers when the previous batch is used up.
 
const uint64_t nDmaRet () const
 Return the number of DMA buffers returned by the most recent read.
 
 Pgp (const UdpParameters &para, MemPool &pool, Detector *det)
 Construct the PgpReader (at most 100 buffers per read, 32 per free batch) and set the driver mask for laneMask on the virtual channel of det, logging an error on failure.
 
Pds::EbDgram * next (uint32_t &evtIndex)
 Return the next complete event as an EbDgram built in its pebble buffer (its index is stored in evtIndex), reading more DMA buffers when the previous batch is used up.
 
const uint64_t nDmaRet ()
 Return the number of DMA buffers returned by the most recent read.
 
 Pgp (const Parameters &para, MemPool &pool, Detector *det)
 
Pds::EbDgram * next (uint32_t &evtIndex)
 
const uint64_t nDmaRet () const
 
- Public Member Functions inherited from Drp::PgpReader
 PgpReader (const Parameters &para, MemPool &pool, unsigned maxRetCnt, unsigned dmaFreeCnt)
 Size the bulk-read arrays for maxRetCnt buffers and the free-index batch for dmaFreeCnt buffers (aborting if the pool has fewer DMA buffers than dmaFreeCnt), set up poll() on the device file descriptor and reset the pool counters.
 
virtual ~PgpReader ()
 Call flush().
 
int32_t read ()
 Read up to maxRetCnt DMA buffers.
 
void flush ()
 Return the DMA indices queued for freeing, return every DMA buffer that can still be read without counting it, and free all pebble buffers in use.
 
const Pds::TimingHeader * handle (Detector *det, unsigned current)
 Process DMA buffer current of the last read() for detector det: record it in the PGPEvent chosen by its event counter and, once all lanes have arrived, check the event (counter jumps, common readout group, readout groups of SlowUpdates) and allocate a transition buffer (non-L1Accept) and a pebble buffer index.
 
void freeDma (PGPEvent *event)
 Queue the DMA buffers of all lanes of event for return to the driver (returned in batches of dmaFreeCnt) and clear the lane mask of the event.
 
uint64_t dmaBytes () const
 Return the total number of DMA bytes handled.
 
uint64_t dmaSize () const
 Return the size of the last DMA buffer handled.
 
int64_t latency () const
 Return the last measured TimingHeader latency in microseconds, updated about every 92857 pulse IDs (10 Hz per the code comment).
 
uint64_t nDmaErrors () const
 Return the number of DMA buffers that reported an error.
 
uint64_t nNoComRoG () const
 Return the number of events dropped because the common readout group was missing.
 
uint64_t nMissingRoGs () const
 Return the number of SlowUpdates dropped because readout groups in Parameters::rogMask were missing.
 
uint64_t nTmgHdrError () const
 Return the number of timing headers with the error bit set.
 
uint64_t nPgpJumps () const
 Return the number of event counter jumps detected.
 
uint64_t nNoTrDgrams () const
 Return the number of events dropped because no transition buffer was available.
 
int64_t nPgpInUser () const
 Return dmaGetRxBuffinUserCount() for the device of the pool.
 
int64_t nPgpInHw () const
 Return dmaGetRxBuffinHwCount() for the device of the pool.
 
int64_t nPgpInPreHw () const
 Return dmaGetRxBuffinPreHwQCount() for the device of the pool.
 
int64_t nPgpInRx () const
 Return dmaGetRxBuffinSwQCount() for the device of the pool.
 
std::chrono::nanoseconds age (const XtcData::TimeStamp &time) const
 Return the latency of timestamp time (Pds::Eb::latency()) in nanoseconds.
 

Additional Inherited Members

- Protected Attributes inherited from Drp::PgpReader
const Parameters & m_para
 
MemPool & m_pool
 
pollfd m_pfd
 
Pds::fast_monotonic_clock::time_point m_t0
 
int m_tmo
 
unsigned m_us
 
std::vector< int32_t > dmaRet
 
std::vector< uint32_t > dmaIndex
 
std::vector< uint32_t > dest
 
std::vector< uint32_t > dmaFlags
 
std::vector< uint32_t > dmaErrors
 
uint32_t m_lastComplete
 
XtcData::TransitionId::Value m_lastTid
 
uint32_t m_lastData [6]
 
std::vector< uint32_t > m_dmaIndices
 
unsigned m_count
 
uint64_t m_dmaBytes
 
uint64_t m_dmaSize
 
uint64_t m_latPid
 
int64_t m_latency
 
uint64_t m_nDmaErrors
 
uint64_t m_nNoComRoG
 
uint64_t m_nMissingRoGs
 
uint64_t m_nTmgHdrError
 
uint64_t m_nPgpJumps
 
uint64_t m_nNoTrDgrams
 
std::mutex m_lock
 
bool m_dmaOverrun
 

Detailed Description

PgpReader for the PGP-card DRP that forwards broken-event and event-counter-reset notifications to its PGPDrp.

PgpReader for the UDP encoder DRP that turns complete PGP events into EbDgrams in the pebble.

PgpReader for the PV DRP that turns complete PGP events into EbDgrams in the pebble.

Constructor & Destructor Documentation

◆ Pgp() [1/5]

Drp::Pgp::Pgp ( Parameters &  para,
DrpBase &  drp,
Detector *  det 
)

Construct the PgpReader on the pool of drp (at most 100 buffers per read, 32 per free batch) and set the driver mask for laneMask on the virtual channel of det, logging an error on failure.

◆ Pgp() [2/5]

Drp::Pgp::Pgp ( const Parameters &  para,
MemPool &  pool,
Detector &  det,
PGPDrp &  m_drp 
)

Construct the PgpReader (at most 1000 buffers per read, 32 per free batch) and set the driver mask for laneMask on the virtual channel of det; aborts with a message if that fails.

◆ Pgp() [3/5]

Drp::Pgp::Pgp ( const Parameters &  para,
MemPool &  pool,
Detector *  det 
)

Construct the PgpReader (at most 100 buffers per read, 32 per free batch) and set the driver mask for laneMask on the virtual channel of det, logging an error on failure.

◆ Pgp() [4/5]

Drp::Pgp::Pgp ( const UdpParameters &  para,
MemPool &  pool,
Detector *  det 
)

Construct the PgpReader (at most 100 buffers per read, 32 per free batch) and set the driver mask for laneMask on the virtual channel of det, logging an error on failure.

◆ Pgp() [5/5]

Drp::Pgp::Pgp ( const Parameters &  para,
MemPool &  pool,
Detector *  det 
)

Member Function Documentation

◆ handleBrokenEvent()

virtual void Drp::Pgp::handleBrokenEvent ( const PGPEvent &  event)
overridevirtual

Forward event to PGPDrp::handleBrokenEvent, which counts it in the current batch.

Reimplemented from Drp::PgpReader.

◆ nDmaRet() [1/3]

const uint64_t Drp::Pgp::nDmaRet ( )
inline

Return the number of DMA buffers returned by the most recent read.

◆ nDmaRet() [2/3]

const uint64_t Drp::Pgp::nDmaRet ( ) const
inline

Return the number of DMA buffers returned by the most recent read.

◆ nDmaRet() [3/3]

const uint64_t Drp::Pgp::nDmaRet ( ) const
inline

◆ next() [1/4]

const Pds::TimingHeader * Drp::Pgp::next ( )

Return the TimingHeader of the current DMA buffer, reading new buffers when the previous batch is used up and timing out TEB batches while waiting.

Returns nullptr if nothing arrives within 20 ms.

◆ next() [2/4]

Pds::EbDgram * Drp::Pgp::next ( uint32_t &  evtIndex)

Return the next complete event as an EbDgram built in its pebble buffer (its index is stored in evtIndex), reading more DMA buffers when the previous batch is used up.

Returns nullptr if the read returned 0 or the buffer did not complete an event.

◆ next() [3/4]

Pds::EbDgram * Drp::Pgp::next ( uint32_t &  evtIndex)

Return the next complete event as an EbDgram built in its pebble buffer (its index is stored in evtIndex), reading more DMA buffers when the previous batch is used up.

Returns nullptr if nothing was read or the buffer did not complete an event.

◆ next() [4/4]

Pds::EbDgram * Drp::Pgp::next ( uint32_t &  evtIndex)

◆ resetEventCounter()

virtual void Drp::Pgp::resetEventCounter ( )
overridevirtual

Call PgpReader::resetEventCounter (last completed event counter to 0), then PGPDrp::resetEventCounter (batching restarts at event counter 1).

Reimplemented from Drp::PgpReader.

◆ shutdown()

void Drp::Pgp::shutdown ( )

Ask the worker loop to stop and clear the names lookup of the detector.

◆ worker()

void Drp::Pgp::worker ( std::shared_ptr< Pds::MetricExporter >  exporter[],
prometheus::Exposer *   
)

Thread body: build the BLD sources from Parameters::detType (comma-separated names, or entries with plus signs looked up through PVs), set up their metrics, then match timing headers with BLD events by timestamp.

Transitions are sent at once (Configure also adds the source names); L1Accepts are sent once older than bld_tmo_ms (default 50 ms), with DroppedContribution damage if a source has no matching event.


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