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

Common machinery of a DRP process: TEB and MEB contributors, the TEB result receiver, the trigger primitive, Prometheus metrics, and the handling of the connect, configure, run and chunking transitions. More...

#include <DrpBase.hh>

Inherited by Drp::BldDrp, Drp::EaDrp, Drp::Gpu::PGPDrp, Drp::PGPDrp, Drp::PvDrp, and Drp::UdpDrp.

Public Member Functions

 DrpBase (Parameters &para, MemPool &pool, Detector &det, ZmqContext &context)
 Create the Prometheus exposer (port offset from the lowest laneMask bit and the numeric suffix of the device name), create the TEB and MEB contributors from para, and connect the inproc://drp PAIR socket.
 
void shutdown ()
 Call disconnect(), then shut down the TEB contributor, the MEB contributor and the TEB receiver.
 
nlohmann::json connectionInfo (const std::string &ip)
 Start listening for TEB results on ip with an ephemeral port (aborting on failure) and return JSON with drp_port, num_buffers, max_ev_size and max_tr_size.
 
std::string connect (const nlohmann::json &msg, size_t id)
 Keep msg and id, parse the connection parameters, (re)create the metric exporter, then connect the TEB contributor, the MEB contributor (only if MEBs are listed) and the TEB receiver.
 
std::string configure (const nlohmann::json &msg)
 Load the trigger primitive, configure the TEB contributor and the MEB contributor (if MEBs are listed), configure the trigger primitive (if this DRP provides trigger input) and the TEB receiver.
 
std::string beginrun (const nlohmann::json &phase1Info, RunInfo &runInfo)
 Fill runInfo from run_info in phase1Info (run number forced to 0 if monitor_info marks this detector monitor-only), open the files if the run number is non-zero, and reset the contributor and receiver counters and the chunk state.
 
std::string endrun (const nlohmann::json &phase1Info)
 Does nothing; returns an empty string.
 
std::string enable (const nlohmann::json &phase1Info, bool &chunkRequest, ChunkInfo &chunkInfo)
 If writing and the current chunk exceeds half of DefaultChunkThresh, advance the chunk ID; if that succeeds, set chunkRequest and fill chunkInfo with the new file name and chunk ID.
 
void unconfigure ()
 Unconfigure the TEB contributor, the MEB contributor (if MEBs are listed) and the TEB receiver.
 
void disconnect ()
 Call unconfigure(), disconnect the TEB contributor, the MEB contributor (if MEBs are listed) and the TEB receiver, and drop the metric exporter.
 
std::string startup (XtcData::Xtc &xtc, const void *bufEnd)
 Print the parameters, let the trigger primitive (if any) add to the Configure data, start the TEB receiver thread and reset the counters.
 
void runInfoSupport (XtcData::Xtc &xtc, const void *bufEnd, XtcData::NamesLookup &namesLookup)
 Add the runinfo Names (RunInfoDef, NamesIndex::RUNINFO) to xtc and register them in namesLookup.
 
void runInfoData (XtcData::Xtc &xtc, const void *bufEnd, XtcData::NamesLookup &namesLookup, const RunInfo &runInfo)
 Add the experiment name and run number of runInfo as runinfo data.
 
void chunkInfoSupport (XtcData::Xtc &xtc, const void *bufEnd, XtcData::NamesLookup &namesLookup)
 Add the chunkinfo Names (ChunkInfoDef, NamesIndex::CHUNKINFO) to xtc and register them in namesLookup.
 
void chunkInfoData (XtcData::Xtc &xtc, const void *bufEnd, XtcData::NamesLookup &namesLookup, const ChunkInfo &chunkInfo)
 Add the file name and chunk ID of chunkInfo as chunkinfo data.
 
Detector & detector () const
 Return the detector given to the constructor.
 
Pds::Eb::TebContributor & tebContributor () const
 Return the TEB contributor created by the constructor.
 
Pds::Eb::MebContributor & mebContributor () const
 Return the MEB contributor created by the constructor.
 
TebReceiverBase & tebReceiver () const
 Return the TEB result receiver set by a subclass with setTebReceiver().
 
Pds::Trg::TriggerPrimitive * triggerPrimitive () const
 Return the trigger primitive created by configure(), or nullptr if this DRP provides no trigger input.
 
prometheus::Exposer * exposer () const
 Return the Prometheus exposer created by the constructor.
 
ZmqSocket & inprocSend ()
 Return the inproc://drp PAIR socket used to send file report and chunk request messages.
 
const nlohmann::json & connectMsg () const
 Return the connect message saved by connect().
 
size_t collectionId () const
 Return the collection ID saved by connect().
 
unsigned nodeId () const
 Return the ID of this DRP (drp_id from the connect message).
 
const Pds::Eb::TebCtrbParams & tebPrms () const
 Return the TEB contributor parameters.
 
bool isSupervisor () const
 Return true if this DRP is the supervisor, chosen while parsing the connect message as the first DRP whose alias contains this detector name.
 
const std::string & supervisorIpPort () const
 Return the IP and port of the supervisor (port 32256 + 8 * xpm_id + partition).
 

Public Attributes

MemPool & pool
 Buffer pools shared with the detector code.
 

Protected Member Functions

void setTebReceiver (std::unique_ptr< TebReceiverBase > tebRecv)
 

Detailed Description

Common machinery of a DRP process: TEB and MEB contributors, the TEB result receiver, the trigger primitive, Prometheus metrics, and the handling of the connect, configure, run and chunking transitions.

Constructor & Destructor Documentation

◆ DrpBase()

Drp::DrpBase::DrpBase ( Parameters &  para,
MemPool &  pool,
Detector &  det,
ZmqContext &  context 
)

Create the Prometheus exposer (port offset from the lowest laneMask bit and the numeric suffix of the device name), create the TEB and MEB contributors from para, and connect the inproc://drp PAIR socket.

Also stat()s the output directory and appends the pva_addr kwarg to EPICS_PVA_ADDR_LIST.

Member Function Documentation

◆ beginrun()

std::string Drp::DrpBase::beginrun ( const nlohmann::json &  phase1Info,
RunInfo &  runInfo 
)

Fill runInfo from run_info in phase1Info (run number forced to 0 if monitor_info marks this detector monitor-only), open the files if the run number is non-zero, and reset the contributor and receiver counters and the chunk state.

Returns an empty string or an error message.

◆ chunkInfoData()

void Drp::DrpBase::chunkInfoData ( XtcData::Xtc &  xtc,
const void *  bufEnd,
XtcData::NamesLookup &  namesLookup,
const ChunkInfo &  chunkInfo 
)

Add the file name and chunk ID of chunkInfo as chunkinfo data.

◆ chunkInfoSupport()

void Drp::DrpBase::chunkInfoSupport ( XtcData::Xtc &  xtc,
const void *  bufEnd,
XtcData::NamesLookup &  namesLookup 
)

Add the chunkinfo Names (ChunkInfoDef, NamesIndex::CHUNKINFO) to xtc and register them in namesLookup.

◆ collectionId()

size_t Drp::DrpBase::collectionId ( ) const
inline

Return the collection ID saved by connect().

◆ configure()

std::string Drp::DrpBase::configure ( const nlohmann::json &  msg)

Load the trigger primitive, configure the TEB contributor and the MEB contributor (if MEBs are listed), configure the trigger primitive (if this DRP provides trigger input) and the TEB receiver.

Returns an empty string or an error message.

◆ connect()

std::string Drp::DrpBase::connect ( const nlohmann::json &  msg,
size_t  id 
)

Keep msg and id, parse the connection parameters, (re)create the metric exporter, then connect the TEB contributor, the MEB contributor (only if MEBs are listed) and the TEB receiver.

Returns an empty string or an error message.

◆ connectionInfo()

nlohmann::json Drp::DrpBase::connectionInfo ( const std::string &  ip)

Start listening for TEB results on ip with an ephemeral port (aborting on failure) and return JSON with drp_port, num_buffers, max_ev_size and max_tr_size.

◆ connectMsg()

const nlohmann::json & Drp::DrpBase::connectMsg ( ) const
inline

Return the connect message saved by connect().

◆ detector()

Detector & Drp::DrpBase::detector ( ) const
inline

Return the detector given to the constructor.

◆ disconnect()

void Drp::DrpBase::disconnect ( )

Call unconfigure(), disconnect the TEB contributor, the MEB contributor (if MEBs are listed) and the TEB receiver, and drop the metric exporter.

◆ enable()

std::string Drp::DrpBase::enable ( const nlohmann::json &  phase1Info,
bool &  chunkRequest,
ChunkInfo &  chunkInfo 
)

If writing and the current chunk exceeds half of DefaultChunkThresh, advance the chunk ID; if that succeeds, set chunkRequest and fill chunkInfo with the new file name and chunk ID.

Always returns an empty string.

◆ endrun()

std::string Drp::DrpBase::endrun ( const nlohmann::json &  phase1Info)

Does nothing; returns an empty string.

◆ exposer()

prometheus::Exposer * Drp::DrpBase::exposer ( ) const
inline

Return the Prometheus exposer created by the constructor.

◆ inprocSend()

ZmqSocket & Drp::DrpBase::inprocSend ( )
inline

Return the inproc://drp PAIR socket used to send file report and chunk request messages.

◆ isSupervisor()

bool Drp::DrpBase::isSupervisor ( ) const
inline

Return true if this DRP is the supervisor, chosen while parsing the connect message as the first DRP whose alias contains this detector name.

◆ mebContributor()

Pds::Eb::MebContributor & Drp::DrpBase::mebContributor ( ) const
inline

Return the MEB contributor created by the constructor.

◆ nodeId()

unsigned Drp::DrpBase::nodeId ( ) const
inline

Return the ID of this DRP (drp_id from the connect message).

◆ runInfoData()

void Drp::DrpBase::runInfoData ( XtcData::Xtc &  xtc,
const void *  bufEnd,
XtcData::NamesLookup &  namesLookup,
const RunInfo &  runInfo 
)

Add the experiment name and run number of runInfo as runinfo data.

◆ runInfoSupport()

void Drp::DrpBase::runInfoSupport ( XtcData::Xtc &  xtc,
const void *  bufEnd,
XtcData::NamesLookup &  namesLookup 
)

Add the runinfo Names (RunInfoDef, NamesIndex::RUNINFO) to xtc and register them in namesLookup.

◆ setTebReceiver()

void Drp::DrpBase::setTebReceiver ( std::unique_ptr< TebReceiverBase >  tebRecv)
inlineprotected

◆ shutdown()

void Drp::DrpBase::shutdown ( )

Call disconnect(), then shut down the TEB contributor, the MEB contributor and the TEB receiver.

◆ startup()

std::string Drp::DrpBase::startup ( XtcData::Xtc &  xtc,
const void *  bufEnd 
)

Print the parameters, let the trigger primitive (if any) add to the Configure data, start the TEB receiver thread and reset the counters.

Returns an empty string.

◆ supervisorIpPort()

const std::string & Drp::DrpBase::supervisorIpPort ( ) const
inline

Return the IP and port of the supervisor (port 32256 + 8 * xpm_id + partition).

◆ tebContributor()

Pds::Eb::TebContributor & Drp::DrpBase::tebContributor ( ) const
inline

Return the TEB contributor created by the constructor.

◆ tebPrms()

const Pds::Eb::TebCtrbParams & Drp::DrpBase::tebPrms ( ) const
inline

Return the TEB contributor parameters.

◆ tebReceiver()

TebReceiverBase & Drp::DrpBase::tebReceiver ( ) const
inline

Return the TEB result receiver set by a subclass with setTebReceiver().

◆ triggerPrimitive()

Pds::Trg::TriggerPrimitive * Drp::DrpBase::triggerPrimitive ( ) const
inline

Return the trigger primitive created by configure(), or nullptr if this DRP provides no trigger input.

◆ unconfigure()

void Drp::DrpBase::unconfigure ( )

Unconfigure the TEB contributor, the MEB contributor (if MEBs are listed) and the TEB receiver.

Member Data Documentation

◆ pool

MemPool& Drp::DrpBase::pool

Buffer pools shared with the detector code.


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