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

XpmDetector for a UDP encoder: owns the UdpReceiver and records each frame as raw and, when interpolating, interpolated encoder data. More...

#include <UdpEncoder.hh>

Inherits Drp::XpmDetector.

Public Types

enum  { DefaultDataPort = 5006 }
 Default UDP data port. More...
 
enum  { MajorVersion = 3 , MinorVersion = 0 , MicroVersion = 0 }
 Version written into the encoder names and the loopback frames. More...
 

Public Member Functions

 UdpEncoder (UdpParameters &para, MemPoolCpu &pool)
 Construct the XpmDetector base and set virtual channel 0.
 
unsigned connect (const nlohmann::json &msg, const std::string &id, std::string &errorMsg)
 Call XpmDetector::connect() and create the UdpReceiver with one buffer per pebble buffer.
 
unsigned disconnect ()
 Call XpmDetector::shutdown() and release the UdpReceiver; returns 0.
 
unsigned configure (const std::string &config_alias, XtcData::Xtc &xtc, const void *bufEnd) override
 Call XpmDetector::configure() (returning 1 if it fails) and declare the encoder names with addNames(0, ...); returns 0.
 
unsigned unconfigure ()
 Clear the names lookup table; returns 0.
 
void event_ (XtcData::Dgram &dgram, const void *const bufEnd, const encoder_frame_t &frame, uint32_t *rawValue, uint32_t *interpolatedValue)
 Add the frame fields (frame count, timing, scale, scale denominator, mode, error) together with *interpolatedValue as interpolated data and with *rawValue as raw data; each part is skipped when its pointer is null.
 
void event (XtcData::Dgram &dgram, const void *bufEnd, PGPEvent *event, uint64_t l1count) override
 Does nothing (the code comment says unused); events are recorded through event_().
 
void addNames (unsigned segment, XtcData::Xtc &xtc, const void *bufEnd)
 Declare the raw encoder names (algorithm raw, version MajorVersion.MinorVersion.MicroVersion) for segment, plus the interpolated names when interpolation is enabled.
 
const std::shared_ptr< UdpReceiver > & udpReceiver () const
 Return the UdpReceiver; empty before connect() and after disconnect().
 
int reset ()
 Call UdpReceiver::reset() if a receiver exists, otherwise return 0.
 
- 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 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.
 
virtual void slowupdate (XtcData::Xtc &xtc, const void *bufEnd)
 Reset xtc to an empty Parent Xtc whose source is nodeId.
 
virtual void event (XtcData::Dgram &dgram, const void *bufEnd, const Pds::Eb::ResultDgram &result)
 Does nothing unless overridden; called with the trigger result for an event.
 
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.
 

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 for a UDP encoder: owns the UdpReceiver and records each frame as raw and, when interpolating, interpolated encoder data.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Default UDP data port.

Enumerator
DefaultDataPort 

UDP data port used when no loopback port is set (5006).

◆ anonymous enum

anonymous enum

Version written into the encoder names and the loopback frames.

Enumerator
MajorVersion 

Major version (3).

MinorVersion 

Minor version (0).

MicroVersion 

Micro version (0).

Constructor & Destructor Documentation

◆ UdpEncoder()

Drp::UdpEncoder::UdpEncoder ( UdpParameters &  para,
MemPoolCpu &  pool 
)

Construct the XpmDetector base and set virtual channel 0.

Member Function Documentation

◆ addNames()

void Drp::UdpEncoder::addNames ( unsigned  segment,
XtcData::Xtc &  xtc,
const void *  bufEnd 
)

Declare the raw encoder names (algorithm raw, version MajorVersion.MinorVersion.MicroVersion) for segment, plus the interpolated names when interpolation is enabled.

◆ configure()

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

Call XpmDetector::configure() (returning 1 if it fails) and declare the encoder names with addNames(0, ...); returns 0.

Implements Drp::Detector.

◆ connect()

unsigned Drp::UdpEncoder::connect ( const nlohmann::json &  msg,
const std::string &  id,
std::string &  errorMsg 
)

Call XpmDetector::connect() and create the UdpReceiver with one buffer per pebble buffer.

Returns 0, or 1 with errorMsg set if creation threw a std::string.

◆ disconnect()

unsigned Drp::UdpEncoder::disconnect ( )

Call XpmDetector::shutdown() and release the UdpReceiver; returns 0.

◆ event()

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

Does nothing (the code comment says unused); events are recorded through event_().

Implements Drp::Detector.

◆ event_()

void Drp::UdpEncoder::event_ ( XtcData::Dgram &  dgram,
const void *const  bufEnd,
const encoder_frame_t &  frame,
uint32_t *  rawValue,
uint32_t *  interpolatedValue 
)

Add the frame fields (frame count, timing, scale, scale denominator, mode, error) together with *interpolatedValue as interpolated data and with *rawValue as raw data; each part is skipped when its pointer is null.

◆ reset()

int Drp::UdpEncoder::reset ( )
inline

Call UdpReceiver::reset() if a receiver exists, otherwise return 0.

◆ udpReceiver()

const std::shared_ptr< UdpReceiver > & Drp::UdpEncoder::udpReceiver ( ) const
inline

Return the UdpReceiver; empty before connect() and after disconnect().

◆ unconfigure()

unsigned Drp::UdpEncoder::unconfigure ( )

Clear the names lookup table; returns 0.


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