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

XpmDetector that records one or more EPICS PVs (Parameters pvSpecs) through PvMonitor objects, with optional configuration from the Python module psdaq.configdb.pvadetector_config. More...

#include <PvaDetector.hh>

Inherits Drp::XpmDetector.

Public Types

enum  { ConfigNamesIndex = NamesIndex::BASE , RawNamesIndex = unsigned(ConfigNamesIndex) + maxSupportedPVs , InfoNamesIndex = unsigned(RawNamesIndex) + maxSupportedPVs }
 NamesId index bases, one block of maxSupportedPVs indices each. More...
 

Public Member Functions

 PvDetector (PvParameters &, MemPoolCpu &)
 Construct the XpmDetector base with virtual channel 0 and import psdaq.configdb.pvadetector_config (aborting if that fails).
 
 ~PvDetector ()
 Release the Python module.
 
unsigned connect (const nlohmann::json &, const std::string &collectionId, std::string &msg)
 Call XpmDetector::connect() and create one PvMonitor per PV spec, parsing an optional alias=, provider/, ,firstDim, .field, [shape] and (type) from each spec.
 
unsigned disconnect ()
 Call XpmDetector::shutdown() and drop the PV monitors; returns 0.
 
unsigned configure (const std::string &config_alias, XtcData::Xtc &, const void *bufEnd) override
 Run XpmDetector::configure, then for each PV monitor add its raw names (version from the data_vsn kwarg, default 0x010000) and, unless detType is pv, the XTC translation of the JSON returned by Python pvadetector_config (nothing when it returns None).
 
unsigned unconfigure ()
 Clear the names lookup table; returns 0.
 
void enable ()
 Set the running flag that lets PV updates be matched.
 
void disable ()
 Clear the running flag.
 
void event (XtcData::Dgram &evt, const void *bufEnd, PGPEvent *, uint64_t l1count) override
 Does nothing; empty body (marked unused).
 
void event (XtcData::Dgram &evt, const void *bufEnd, const Pds::Eb::ResultDgram &) override
 Does nothing; empty body (marked unused).
 
const std::vector< std::shared_ptr< PvMonitor > > & pvMonitors () const
 Return the PV monitors created by connect().
 
virtual unsigned enable (XtcData::Xtc &xtc, const void *bufEnd, const nlohmann::json &info)
 Return 0 without doing anything unless overridden.
 
virtual unsigned disable (XtcData::Xtc &xtc, const void *bufEnd, const nlohmann::json &info)
 Return 0 without doing anything unless overridden.
 
- Public Member Functions inherited from Drp::Detector
 Detector (Parameters *para, MemPool *pool)
 Set nodeId to -1u and virtChan to 0, keep para and pool, and allocate a transition buffer of para->maxTrSize bytes.
 
virtual ~Detector ()
 Does nothing; empty body.
 
virtual Gpu::Detector * gpuDetector ()
 Return nullptr; Gpu::Detector overrides it to return itself.
 
virtual unsigned beginrun (XtcData::Xtc &xtc, const void *bufEnd, const nlohmann::json &runInfo)
 Return 0 without doing anything unless overridden.
 
virtual unsigned beginstep (XtcData::Xtc &xtc, const void *bufEnd, const nlohmann::json &stepInfo)
 Return 0 without doing anything unless overridden.
 
virtual void slowupdate (XtcData::Xtc &xtc, const void *bufEnd)
 Reset xtc to an empty Parent Xtc whose source is nodeId.
 
virtual XtcData::Shape shapeCube (unsigned rawDefIndex, unsigned valueIndex, XtcData::DescData &rawData)
 Return the shape in rawData of entry valueIndex of raw definition rawDefIndex (from rawDef()).
 
virtual unsigned addToCube (unsigned rawDefIndex, unsigned valueIndex, unsigned subIndex, double *dst, unsigned bin, XtcData::DescData &rawData)
 Generic cube accumulation without calibration: add the value or array entry valueIndex of rawData, converted to double, into bin bin of dst (entries of any XTC numeric type).
 
virtual unsigned subIndices ()
 Return 0 unless overridden.
 
virtual unsigned rawNamesIndex ()
 Return 0 unless overridden.
 
virtual unsigned cubeNamesIndex ()
 Return 0 unless overridden.
 
virtual unsigned cubeBinBytes ()
 Return ten times the pebble buffer size unless overridden.
 
virtual std::vector< XtcData::VarDef > & rawDef ()
 Log an error and abort; detectors used for cube binning must override it.
 
virtual unsigned maxMonBufSize ()
 Return the pebble buffer size, times 10 when Parameters::nCubeWorkers is non-zero.
 
virtual unsigned configureScan (const nlohmann::json &stepInfo, XtcData::Xtc &xtc, const void *bufEnd)
 Return 1 (failure) unless overridden, per the code comment.
 
virtual unsigned stepScan (const nlohmann::json &stepInfo, XtcData::Xtc &xtc, const void *bufEnd)
 Return 1 (failure) unless overridden.
 
virtual Pds::TimingHeader * getTimingHeader (uint32_t index) const
 Return the start of DMA buffer index as a TimingHeader pointer.
 
virtual bool scanEnabled ()
 Return false unless overridden.
 
XtcData::Xtc & transitionXtc ()
 Return the start of the transition buffer as an Xtc reference.
 
const void * trXtcBufEnd ()
 Return the end of the transition buffer.
 
XtcData::NamesLookup & namesLookup ()
 Return the names lookup table of this detector.
 

Static Public Attributes

static const unsigned maxSupportedPVs = 64
 Maximum number of PVs per detector (64); spaces the names indices below.
 

Additional Inherited Members

- Public Attributes inherited from Drp::Detector
unsigned nodeId
 Node ID used as the XTC source; -1u until set.
 
unsigned virtChan
 Virtual channel number; 0 unless a subclass sets it.
 
- Protected Member Functions inherited from Drp::XpmDetector
 XpmDetector (Parameters *para, MemPool *pool, unsigned len=100)
 
nlohmann::json connectionInfo (const nlohmann::json &msg) override
 Return an empty JSON object unless overridden; msg is not used.
 
void connect (const nlohmann::json &, const std::string &collectionId) override
 Does nothing unless overridden.
 
unsigned configure (const std::string &config_alias, XtcData::Xtc &xtc, const void *bufEnd) override
 Pure virtual: add the Configure data for config_alias to xtc; implementations return 0 on success.
 
void shutdown () override
 Does nothing unless overridden.
 
void connectionShutdown () override
 Does nothing unless overridden.
 
- Protected Attributes inherited from Drp::XpmDetector
unsigned m_length
 
- Protected Attributes inherited from Drp::Detector
Parameters * m_para
 
MemPool * m_pool
 
XtcData::NamesLookup m_namesLookup
 
std::vector< char > m_xtcbuf
 

Detailed Description

XpmDetector that records one or more EPICS PVs (Parameters pvSpecs) through PvMonitor objects, with optional configuration from the Python module psdaq.configdb.pvadetector_config.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

NamesId index bases, one block of maxSupportedPVs indices each.

Enumerator
ConfigNamesIndex 

Configuration names, from NamesIndex::BASE (0) plus the PV index.

RawNamesIndex 

Raw PV data names, from 64 plus the PV index.

InfoNamesIndex 

The pvdetinfo names (128).

Constructor & Destructor Documentation

◆ PvDetector()

Drp::PvDetector::PvDetector ( PvParameters &  ,
MemPoolCpu &   
)

Construct the XpmDetector base with virtual channel 0 and import psdaq.configdb.pvadetector_config (aborting if that fails).

◆ ~PvDetector()

Drp::PvDetector::~PvDetector ( )

Release the Python module.

Member Function Documentation

◆ configure()

unsigned Drp::PvDetector::configure ( const std::string &  config_alias,
XtcData::Xtc &  ,
const void *  bufEnd 
)
overridevirtual

Run XpmDetector::configure, then for each PV monitor add its raw names (version from the data_vsn kwarg, default 0x010000) and, unless detType is pv, the XTC translation of the JSON returned by Python pvadetector_config (nothing when it returns None).

Then add the pvdetinfo names and data listing the PV aliases (comma-separated) and PV names (newline-separated). Returns 0; 1 if the base configure or a monitor's getParams fails, -1 (as unsigned) if the JSON translation fails, and aborts if the config XTC exceeds maxTrSize.

Implements Drp::Detector.

◆ connect()

unsigned Drp::PvDetector::connect ( const nlohmann::json &  ,
const std::string &  collectionId,
std::string &  msg 
)

Call XpmDetector::connect() and create one PvMonitor per PV spec, parsing an optional alias=, provider/, ,firstDim, .field, [shape] and (type) from each spec.

Returns 0, or 1 with msg set (and no monitors kept) if a spec has an unrecognized type.

◆ disable() [1/2]

void Drp::PvDetector::disable ( )

Clear the running flag.

◆ disable() [2/2]

virtual unsigned Drp::Detector::disable ( XtcData::Xtc &  xtc,
const void *  bufEnd,
const nlohmann::json &  info 
)
inlinevirtual

Return 0 without doing anything unless overridden.

Reimplemented from Drp::Detector.

◆ disconnect()

unsigned Drp::PvDetector::disconnect ( )

Call XpmDetector::shutdown() and drop the PV monitors; returns 0.

◆ enable() [1/2]

void Drp::PvDetector::enable ( )

Set the running flag that lets PV updates be matched.

◆ enable() [2/2]

virtual unsigned Drp::Detector::enable ( XtcData::Xtc &  xtc,
const void *  bufEnd,
const nlohmann::json &  info 
)
inlinevirtual

Return 0 without doing anything unless overridden.

Reimplemented from Drp::Detector.

◆ event() [1/2]

void Drp::PvDetector::event ( XtcData::Dgram &  evt,
const void *  bufEnd,
const Pds::Eb::ResultDgram &   
)
inlineoverridevirtual

Does nothing; empty body (marked unused).

Reimplemented from Drp::Detector.

◆ event() [2/2]

void Drp::PvDetector::event ( XtcData::Dgram &  evt,
const void *  bufEnd,
PGPEvent *  ,
uint64_t  l1count 
)
inlineoverridevirtual

Does nothing; empty body (marked unused).

Implements Drp::Detector.

◆ pvMonitors()

const std::vector< std::shared_ptr< PvMonitor > > & Drp::PvDetector::pvMonitors ( ) const
inline

Return the PV monitors created by connect().

◆ unconfigure()

unsigned Drp::PvDetector::unconfigure ( )

Clear the names lookup table; returns 0.

Member Data Documentation

◆ maxSupportedPVs

const unsigned Drp::PvDetector::maxSupportedPVs = 64
static

Maximum number of PVs per detector (64); spaces the names indices below.


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