|
lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
|
Base of the DRP trigger result receivers. More...
#include <DrpBase.hh>
Inherits Pds::Eb::EbCtrbInBase.
Inherited by Drp::Gpu::TebReceiver, and Drp::TebReceiver.
Public Member Functions | |
| TebReceiverBase (const Parameters &, DrpBase &) | |
| Construct the EbCtrbInBase from the TEB parameters of the DRP, keep references to the DRP and its pool, and allocate a buffer of para.maxTrSize bytes for the Configure datagram. | |
| virtual | ~TebReceiverBase () |
| Does nothing; empty body. | |
| void | resetCounters (bool all) |
| Reset the EbCtrbInBase counters, the damage count and histogram and the latency; with all true, also reset the expected next buffer index so that index 0 is expected. | |
| int | connect (const std::shared_ptr< Pds::MetricExporter >) |
| Register metrics (if the exporter is non-null), remember the node ID on the timing-system DRP (detType ts), and connect to the TEBs with EbCtrbInBase::connect(). | |
| void | unconfigure () |
| Close the files (in case BeginRun failed), then call EbCtrbInBase::unconfigure(). | |
| std::string | openFiles (const RunInfo &runInfo) |
| If runInfo.runNumber is non-zero, create the directories and open the data file outputDir/instrument/experiment/xtc/RUN.xtc2 and the small-data file RUN.smd.xtc2 in its smalldata subdirectory (RUN is experiment-rNNNN-sNNN-c000), sending a file report message for each. | |
| bool | advanceChunkId () |
| If no chunk change is pending, increment the chunk ID in the file parameters, mark a change pending and return true; otherwise return false. | |
| std::string | reopenFiles () |
| Close the current data file and open the data file for the new chunk (name from FileParameters::runName()), sending a file report message and clearing the pending flag on success. | |
| std::string | closeFiles () |
| If writing, clear the writing flag and close the small-data and data files. | |
| uint64_t | chunkSize () const |
| Return the number of bytes recorded since the current chunk started. | |
| void | chunkRequestSet () |
| Set the chunk-request flag. | |
| void | chunkReset () |
| Clear the chunk offset, the chunk-request flag and the pending flag left from a previous run. | |
| void | offsetReset () |
| Set the recorded byte offset to 0. | |
| void | offsetAppend (size_t size) |
| Add size to the recorded byte offset. | |
| bool | writing () const |
| Return true while files are open for recording (from a successful openFiles() until closeFiles()). | |
| const FileParameters & | fileParameters () const |
| Return the file parameters cached by openFiles(); valid only after a successful openFiles(). | |
| virtual FileWriterBase & | fileWriter ()=0 |
| Pure virtual: return the writer used for the data file. | |
| virtual SmdWriterBase & | smdWriter ()=0 |
| Pure virtual: return the writer used for the small-data file. | |
Public Member Functions inherited from Pds::Eb::EbCtrbInBase | |
| EbCtrbInBase (const TebCtrbParams &) | |
| Keep a reference to the parameters and create the server transport from prms.verbose and prms.kwargs. | |
| virtual | ~EbCtrbInBase () |
| Free the result region. | |
| int | resetCounters () |
| Reset the batch, event, missing, bypass and no-progress counters; returns 0. | |
| int | startConnection (std::string &port) |
| Listen on prms.ifAddr:port for up to MAX_TEBS TEB connections with EbLfServer::listen(); an empty port is replaced by the bound ephemeral port. | |
| int | connect (const std::shared_ptr< MetricExporter >) |
| Register metrics with the exporter (if non-null) and accept one link per builder in prms.builders with linksConnect(). | |
| int | configure (unsigned numBuffers) |
| Forget left-over inputs and deferred results, then for each TEB link receive the result region size, (re)allocate the shared result region if the size changed, and register it and send its description with EbLfSvrLink::setupMr(). | |
| void | unconfigure () |
| Does nothing; empty body. | |
| void | disconnect () |
| Call unconfigure(), then disconnect and drop all links. | |
| void | shutdown () |
| Call disconnect(), then shut down the transport. | |
| void | receiver (TebContributor &, std::atomic< bool > &running) |
| Thread body: pin to prms.core[1], name the thread drp/TEBreceiver and repeatedly wait (100 ms each) for result batches and match them with the pending inputs of ctrb, until running becomes false. | |
Static Public Attributes | |
| static const uint64_t | DefaultChunkThresh = 500ull * 1024ull * 1024ull * 1024ull |
| Chunk threshold of 500 * 1024^3 bytes (500 GB per the comment): process() requests a new chunk when chunkSize() exceeds it, and DrpBase::enable() advances the chunk once chunkSize() exceeds half of it. | |
Protected Member Functions | |
| void | process (const Pds::Eb::ResultDgram &, unsigned index) override |
| Pure virtual: handle the result of one event; index is the buffer index of the matching input datagram. | |
| virtual int | setupMetrics (const std::shared_ptr< Pds::MetricExporter >, std::map< std::string, std::string > &labels)=0 |
| virtual void | complete (unsigned index, const Pds::Eb::ResultDgram &result)=0 |
Protected Attributes | |
| MemPool & | m_pool |
| DrpBase & | m_drp |
| unsigned | m_tsId |
| ZmqSocket & | m_inprocSend |
| bool | m_chunkRequest |
| unsigned | m_configureIndex |
| std::vector< uint8_t > | m_configureBuffer |
| uint64_t | m_evtSize |
| uint64_t | m_latPid |
| int64_t | m_latency |
Base of the DRP trigger result receivers.
process() checks each result against the pebble datagram, transfers the result damage, requests file chunking and calls complete(); the class also opens and closes the data and small-data files. Subclasses provide the writers, metrics and complete().
| Drp::TebReceiverBase::TebReceiverBase | ( | const Parameters & | , |
| DrpBase & | |||
| ) |
Construct the EbCtrbInBase from the TEB parameters of the DRP, keep references to the DRP and its pool, and allocate a buffer of para.maxTrSize bytes for the Configure datagram.
|
inlinevirtual |
Does nothing; empty body.
| bool Drp::TebReceiverBase::advanceChunkId | ( | ) |
If no chunk change is pending, increment the chunk ID in the file parameters, mark a change pending and return true; otherwise return false.
| void Drp::TebReceiverBase::chunkRequestSet | ( | ) |
Set the chunk-request flag.
| void Drp::TebReceiverBase::chunkReset | ( | ) |
Clear the chunk offset, the chunk-request flag and the pending flag left from a previous run.
|
inline |
Return the number of bytes recorded since the current chunk started.
| std::string Drp::TebReceiverBase::closeFiles | ( | ) |
If writing, clear the writing flag and close the small-data and data files.
Always returns an empty string.
|
protectedpure virtual |
Implemented in Drp::CubeTebReceiver, Drp::TebReceiver, and Drp::Gpu::TebReceiver.
| int Drp::TebReceiverBase::connect | ( | const std::shared_ptr< Pds::MetricExporter > | ) |
Register metrics (if the exporter is non-null), remember the node ID on the timing-system DRP (detType ts), and connect to the TEBs with EbCtrbInBase::connect().
Returns 0 or the first error.
|
inline |
Return the file parameters cached by openFiles(); valid only after a successful openFiles().
|
pure virtual |
Pure virtual: return the writer used for the data file.
Implemented in Drp::TebReceiver, and Drp::Gpu::TebReceiver.
|
inline |
Add size to the recorded byte offset.
|
inline |
Set the recorded byte offset to 0.
| std::string Drp::TebReceiverBase::openFiles | ( | const RunInfo & | runInfo | ) |
If runInfo.runNumber is non-zero, create the directories and open the data file outputDir/instrument/experiment/xtc/RUN.xtc2 and the small-data file RUN.smd.xtc2 in its smalldata subdirectory (RUN is experiment-rNNNN-sNNN-c000), sending a file report message for each.
Returns an empty string on success, after which writing() is true, or a message naming the file that failed.
|
overrideprotectedvirtual |
Pure virtual: handle the result of one event; index is the buffer index of the matching input datagram.
Called from the receiver thread for each input matched with a result, and with a locally built persist result for inputs that bypassed the TEBs.
Implements Pds::Eb::EbCtrbInBase.
| std::string Drp::TebReceiverBase::reopenFiles | ( | ) |
Close the current data file and open the data file for the new chunk (name from FileParameters::runName()), sending a file report message and clearing the pending flag on success.
Returns an empty string on success or an error message (also when not writing).
| void Drp::TebReceiverBase::resetCounters | ( | bool | all | ) |
Reset the EbCtrbInBase counters, the damage count and histogram and the latency; with all true, also reset the expected next buffer index so that index 0 is expected.
|
protectedpure virtual |
Implemented in Drp::TebReceiver, and Drp::Gpu::TebReceiver.
|
pure virtual |
Pure virtual: return the writer used for the small-data file.
Implemented in Drp::TebReceiver, and Drp::Gpu::TebReceiver.
| void Drp::TebReceiverBase::unconfigure | ( | ) |
Close the files (in case BeginRun failed), then call EbCtrbInBase::unconfigure().
|
inline |
Return true while files are open for recording (from a successful openFiles() until closeFiles()).
|
static |
Chunk threshold of 500 * 1024^3 bytes (500 GB per the comment): process() requests a new chunk when chunkSize() exceeds it, and DrpBase::enable() advances the chunk once chunkSize() exceeds half of it.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |