artdaq
v3_09_01
|
FragmentBuffer is a FragmentGenerator-derived abstract class that defines the interface for a FragmentGenerator designed as a state machine with start, stop, etc., transition commands. More...
#include <artdaq/DAQrate/FragmentBuffer.hh>
Classes | |
struct | Config |
Configuration of the FragmentBuffer. May be used for parameter validation More... | |
Public Types | |
using | Parameters = fhicl::WrappedTable< Config > |
Used for ParameterSet validation (if desired) | |
Public Member Functions | |
FragmentBuffer (const fhicl::ParameterSet &ps) | |
FragmentBuffer Constructor. More... | |
virtual | ~FragmentBuffer () |
FragmentBuffer Destructor. More... | |
void | AddFragmentsToBuffer (FragmentPtrs frags) |
void | Stop () |
void | Reset (bool stop) |
void | applyRequestsIgnoredMode (artdaq::FragmentPtrs &frags) |
Create fragments using data buffer for request mode Ignored. Precondition: dataBufferMutex_ and request_mutex_ are locked More... | |
void | applyRequestsSingleMode (artdaq::FragmentPtrs &frags) |
Create fragments using data buffer for request mode Single. Precondition: dataBufferMutex_ and request_mutex_ are locked More... | |
void | applyRequestsBufferMode (artdaq::FragmentPtrs &frags) |
Create fragments using data buffer for request mode Buffer. Precondition: dataBufferMutex_ and request_mutex_ are locked More... | |
void | applyRequestsWindowMode (artdaq::FragmentPtrs &frags) |
Create fragments using data buffer for request mode Window. Precondition: dataBufferMutex_ and request_mutex_ are locked More... | |
void | applyRequestsSequenceIDMode (artdaq::FragmentPtrs &frags) |
Create fragments using data buffer for request mode SequenceID. Precondition: dataBufferMutex_ and request_mutex_ are locked More... | |
void | applyRequestsWindowMode_CheckAndFillDataBuffer (artdaq::FragmentPtrs &frags, artdaq::Fragment::fragment_id_t id, artdaq::Fragment::sequence_id_t seq, artdaq::Fragment::timestamp_t ts) |
bool | applyRequests (FragmentPtrs &frags) |
See if any requests have been received, and add the corresponding data Fragment objects to the output list. More... | |
bool | sendEmptyFragment (FragmentPtrs &frags, size_t sequenceId, Fragment::fragment_id_t fragmentId, std::string desc) |
Send an EmptyFragmentType Fragment. More... | |
void | sendEmptyFragments (FragmentPtrs &frags, std::map< Fragment::sequence_id_t, Fragment::timestamp_t > &requests) |
This function is for Buffered and Single request modes, as they can only respond to one data request at a time If the request message seqID > ev_counter, simply send empties until they're equal. More... | |
void | checkSentWindows (Fragment::sequence_id_t seq) |
Check the windows_sent_ooo_ map for sequence IDs that may be removed. More... | |
bool | waitForDataBufferReady (Fragment::fragment_id_t id) |
Wait for the data buffer to drain (dataBufferIsTooLarge returns false), periodically reporting status. More... | |
bool | dataBufferIsTooLarge (Fragment::fragment_id_t id) |
Test the configured constraints on the data buffer. More... | |
void | getDataBufferStats (Fragment::fragment_id_t id) |
Calculate the size of the dataBuffer and report appropriate metrics. More... | |
void | getDataBuffersStats () |
Calculate the size of all dataBuffers and report appropriate metrics. | |
void | checkDataBuffer (Fragment::fragment_id_t id) |
Perform data buffer pruning operations for the given buffer. If the RequestMode is Single, removes all but the latest Fragment from the data buffer. More... | |
void | checkDataBuffers () |
Perform data buffer pruning operations for all buffers. | |
std::map < Fragment::sequence_id_t, std::chrono::steady_clock::time_point > | GetSentWindowList (Fragment::fragment_id_t id) |
Get the map of Window-mode requests fulfilled by this Fragment Geneerator for the given Fragment ID. More... | |
std::vector < Fragment::fragment_id_t > | fragmentIDs () |
Get the list of Fragment IDs handled by this FragmentBuffer. More... | |
RequestMode | request_mode () const |
Get the current request mode of the FragmentBuffer More... | |
void | SetRequestBuffer (std::shared_ptr< RequestBuffer > buffer) |
Set the pointer to the RequestBuffer used to retrieve requests. More... | |
artdaq::Fragment::sequence_id_t | GetNextSequenceID () const |
Get the next sequence ID expected by this FragmentBuffer. This is used to track sent windows and missed requests. More... | |
Protected Member Functions | |
artdaq::Fragment::fragment_id_t | fragment_id () const |
Get the Fragment ID of this Fragment generator. More... | |
bool | check_stop () |
Routine used by applyRequests to make sure that all outstanding requests have been fulfilled before returning. More... | |
std::string | printMode_ () |
Return the string representation of the current RequestMode. More... | |
size_t | dataBufferFragmentCount_ () |
Get the total number of Fragments in all data buffers. More... | |
FragmentBuffer is a FragmentGenerator-derived abstract class that defines the interface for a FragmentGenerator designed as a state machine with start, stop, etc., transition commands.
Users of classes derived from FragmentBuffer will call these transitions via the publically defined StartCmd(), StopCmd(), etc.; these public functions contain functionality considered properly universal to all FragmentBuffer-derived classes, including calls to private virtual functions meant to be overridden in derived classes. The same applies to this class's implementation of the FragmentGenerator::getNext() pure virtual function, which is declared final (i.e., non-overridable in derived classes) and which itself calls a pure virtual getNext_() function to be implemented in derived classes.
State-machine related interface functions will be called only from a single thread. getNext() will be called only from a single thread. The thread from which state-machine interfaces functions are called may be a different thread from the one that calls getNext().
John F., 3/24/14
After some discussion with Kurt, FragmentBuffer has been updated such that it now contains a member vector fragment_ids_ ; if "fragment_id" is set in the FHiCL document controlling a class derived from FragmentBuffer, fragment_ids_ will be booked as a length-1 vector, and the value in this vector will be returned by fragment_id(). fragment_id() will throw an exception if the length of the vector isn't 1. If "fragment_ids" is set in the FHiCL document, then fragment_ids_ is filled with the values in the list which "fragment_ids" refers to, otherwise it is set to the empty vector (this is what should happen if the user sets the "fragment_id" variable in the FHiCL document, otherwise exceptions will end up thrown due to the logical conflict). If neither "fragment_id" nor "fragment_ids" is set in the FHiCL document, writers of classes derived from this one will be expected to override the virtual fragmentIDs() function with their own code (the CompositeDriver class is an example of this)
Definition at line 82 of file FragmentBuffer.hh.
|
explicit |
FragmentBuffer Constructor.
ps | ParameterSet used to configure FragmentBuffer. See artdaq::FragmentBuffer::Config. |
Definition at line 46 of file FragmentBuffer.cc.
|
virtual |
FragmentBuffer Destructor.
Joins all threads before returning
Definition at line 115 of file FragmentBuffer.cc.
bool artdaq::FragmentBuffer::applyRequests | ( | FragmentPtrs & | frags | ) |
See if any requests have been received, and add the corresponding data Fragment objects to the output list.
[out] | frags | list of FragmentPtr objects ready for transmission |
Definition at line 758 of file FragmentBuffer.cc.
void artdaq::FragmentBuffer::applyRequestsBufferMode | ( | artdaq::FragmentPtrs & | frags | ) |
Create fragments using data buffer for request mode Buffer. Precondition: dataBufferMutex_ and request_mutex_ are locked
frags | Ouput fragments |
Definition at line 470 of file FragmentBuffer.cc.
void artdaq::FragmentBuffer::applyRequestsIgnoredMode | ( | artdaq::FragmentPtrs & | frags | ) |
Create fragments using data buffer for request mode Ignored. Precondition: dataBufferMutex_ and request_mutex_ are locked
frags | Ouput fragments |
Definition at line 411 of file FragmentBuffer.cc.
void artdaq::FragmentBuffer::applyRequestsSequenceIDMode | ( | artdaq::FragmentPtrs & | frags | ) |
Create fragments using data buffer for request mode SequenceID. Precondition: dataBufferMutex_ and request_mutex_ are locked
frags | Ouput fragments |
Definition at line 700 of file FragmentBuffer.cc.
void artdaq::FragmentBuffer::applyRequestsSingleMode | ( | artdaq::FragmentPtrs & | frags | ) |
Create fragments using data buffer for request mode Single. Precondition: dataBufferMutex_ and request_mutex_ are locked
frags | Ouput fragments |
Definition at line 427 of file FragmentBuffer.cc.
void artdaq::FragmentBuffer::applyRequestsWindowMode | ( | artdaq::FragmentPtrs & | frags | ) |
Create fragments using data buffer for request mode Window. Precondition: dataBufferMutex_ and request_mutex_ are locked
frags | Ouput fragments |
Definition at line 653 of file FragmentBuffer.cc.
void artdaq::FragmentBuffer::applyRequestsWindowMode_CheckAndFillDataBuffer | ( | artdaq::FragmentPtrs & | frags, |
artdaq::Fragment::fragment_id_t | id, | ||
artdaq::Fragment::sequence_id_t | seq, | ||
artdaq::Fragment::timestamp_t | ts | ||
) |
Copy data from the relevant data buffer that matches the given timestamp.
frags | Output Fragments |
id | Fragment ID of buffer to search |
seq | Sequence ID of output Fragment |
ts | Timestamp of output Fragment (used to determine window limits) |
Definition at line 536 of file FragmentBuffer.cc.
|
protected |
Routine used by applyRequests to make sure that all outstanding requests have been fulfilled before returning.
Definition at line 210 of file FragmentBuffer.cc.
void artdaq::FragmentBuffer::checkDataBuffer | ( | Fragment::fragment_id_t | id | ) |
Perform data buffer pruning operations for the given buffer. If the RequestMode is Single, removes all but the latest Fragment from the data buffer.
id | Fragment ID of buffer In Window and Buffer RequestModes, this function discards the oldest Fragment objects until the data buffer is below its size constraints, then also checks for stale Fragments, based on the timestamp of the most recent Fragment. |
Definition at line 361 of file FragmentBuffer.cc.
void artdaq::FragmentBuffer::checkSentWindows | ( | Fragment::sequence_id_t | seq | ) |
Check the windows_sent_ooo_ map for sequence IDs that may be removed.
seq | Sequence ID of current window |
Definition at line 867 of file FragmentBuffer.cc.
|
protected |
Get the total number of Fragments in all data buffers.
Definition at line 245 of file FragmentBuffer.cc.
bool artdaq::FragmentBuffer::dataBufferIsTooLarge | ( | Fragment::fragment_id_t | id | ) |
Test the configured constraints on the data buffer.
id | Fragment ID of data buffer |
Definition at line 322 of file FragmentBuffer.cc.
|
inlineprotected |
Get the Fragment ID of this Fragment generator.
cet::exception("FragmentID") | if there is more that one Fragment ID configured for this Fragment Generator |
Definition at line 361 of file FragmentBuffer.hh.
|
inline |
Get the list of Fragment IDs handled by this FragmentBuffer.
Definition at line 301 of file FragmentBuffer.hh.
void artdaq::FragmentBuffer::getDataBufferStats | ( | Fragment::fragment_id_t | id | ) |
Calculate the size of the dataBuffer and report appropriate metrics.
id | Fragment ID of buffer |
Definition at line 335 of file FragmentBuffer.cc.
|
inline |
Get the next sequence ID expected by this FragmentBuffer. This is used to track sent windows and missed requests.
Definition at line 345 of file FragmentBuffer.hh.
|
inline |
Get the map of Window-mode requests fulfilled by this Fragment Geneerator for the given Fragment ID.
id | Fragment ID of buffer |
This function is used in FragmentBuffer_t to verify correct functioning of Window mode
Definition at line 287 of file FragmentBuffer.hh.
|
protected |
Return the string representation of the current RequestMode.
Definition at line 226 of file FragmentBuffer.cc.
|
inline |
Get the current request mode of the FragmentBuffer
Definition at line 317 of file FragmentBuffer.hh.
bool artdaq::FragmentBuffer::sendEmptyFragment | ( | FragmentPtrs & | frags, |
size_t | sequenceId, | ||
Fragment::fragment_id_t | fragmentId, | ||
std::string | desc | ||
) |
Send an EmptyFragmentType Fragment.
[out] | frags | Output list to append EmptyFragmentType to |
sequenceId | Sequence ID of Empty Fragment | |
fragmentId | Fragment ID of Empty Fragment | |
desc | Message to log with reasoning for sending Empty Fragment |
Definition at line 840 of file FragmentBuffer.cc.
void artdaq::FragmentBuffer::sendEmptyFragments | ( | FragmentPtrs & | frags, |
std::map< Fragment::sequence_id_t, Fragment::timestamp_t > & | requests | ||
) |
This function is for Buffered and Single request modes, as they can only respond to one data request at a time If the request message seqID > ev_counter, simply send empties until they're equal.
[out] | frags | Output list to append EmptyFragmentType to |
requests | List of requests to process |
Definition at line 851 of file FragmentBuffer.cc.
|
inline |
Set the pointer to the RequestBuffer used to retrieve requests.
buffer | Pointer to the RequestBuffer |
Definition at line 339 of file FragmentBuffer.hh.
bool artdaq::FragmentBuffer::waitForDataBufferReady | ( | Fragment::fragment_id_t | id | ) |
Wait for the data buffer to drain (dataBufferIsTooLarge returns false), periodically reporting status.
id | Fragment ID of data buffer |
Definition at line 253 of file FragmentBuffer.cc.