DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::datahandlinglibs::DataHandlingModel< ReadoutType, RequestHandlerType, LatencyBufferType, RawDataProcessorType, InputDataType >::PostprocessScheduleAlgorithm Class Reference

#include <DataHandlingModel.hpp>

Public Member Functions

 PostprocessScheduleAlgorithm (LatencyBufferType &latency_buffer_impl, RawDataProcessorType &raw_processor_impl, uint64_t processing_delay_ticks, uint64_t post_processing_delay_min_wait, uint64_t post_processing_delay_max_wait)
int run (bool timeout)
int do_run (bool timeout)

Private Attributes

LatencyBufferType & m_latency_buffer_impl
RawDataProcessorType & m_raw_processor_impl
const uint64_t m_processing_delay_ticks
const uint64_t m_post_processing_delay_min_wait
const uint64_t m_post_processing_delay_max_wait
bool m_first_cycle
RDT m_processed_up_to
int m_consecutive_timeouts
const timestamp_t m_max_wait_in_ticks
std::chrono::time_point< std::chrono::system_clock > m_last_post_proc_time

Detailed Description

template<class ReadoutType, class RequestHandlerType, class LatencyBufferType, class RawDataProcessorType, class InputDataType = ReadoutType>
class dunedaq::datahandlinglibs::DataHandlingModel< ReadoutType, RequestHandlerType, LatencyBufferType, RawDataProcessorType, InputDataType >::PostprocessScheduleAlgorithm

Definition at line 137 of file DataHandlingModel.hpp.

Constructor & Destructor Documentation

◆ PostprocessScheduleAlgorithm()

template<class ReadoutType, class RequestHandlerType, class LatencyBufferType, class RawDataProcessorType, class InputDataType = ReadoutType>
dunedaq::datahandlinglibs::DataHandlingModel< ReadoutType, RequestHandlerType, LatencyBufferType, RawDataProcessorType, InputDataType >::PostprocessScheduleAlgorithm::PostprocessScheduleAlgorithm ( LatencyBufferType & latency_buffer_impl,
RawDataProcessorType & raw_processor_impl,
uint64_t processing_delay_ticks,
uint64_t post_processing_delay_min_wait,
uint64_t post_processing_delay_max_wait )
inline

Member Function Documentation

◆ do_run()

template<class ReadoutType, class RequestHandlerType, class LatencyBufferType, class RawDataProcessorType, class InputDataType = ReadoutType>
int dunedaq::datahandlinglibs::DataHandlingModel< ReadoutType, RequestHandlerType, LatencyBufferType, RawDataProcessorType, InputDataType >::PostprocessScheduleAlgorithm::do_run ( bool timeout)
inline

Definition at line 175 of file DataHandlingModel.hpp.

176 {
177 if (m_latency_buffer_impl.occupancy() == 0) {
178 TLOG_DEBUG(TLVL_WORK_STEPS) << "Nothing to postprocess (empty buffer)";
179 return 0;
180 }
181
182 if (m_first_cycle) {
183 auto head = m_latency_buffer_impl.front();
184 m_processed_up_to.set_timestamp(head->get_timestamp());
185 m_first_cycle = false;
186 TLOG() << "***** First pass post processing *****";
187 }
188
189 // Get the LB boundaries
190 auto tail = m_latency_buffer_impl.back();
191 auto newest_ts = tail->get_timestamp();
192
195
196 if (timeout) {
197 // Return if the last processed timestamp is greater than the newest timestamp
198 // This condition occurs after a timeout
199 if (m_processed_up_to.get_timestamp() >= newest_ts + 1) {
200 TLOG_DEBUG(TLVL_WORK_STEPS) << "Nothing to postprocess (at or past cap)";
201 return 0;
202 }
203
206
208 end_win_ts = std::min(end_win_ts, newest_ts + 1); // Cap to prevent end_win_ts from becoming unnecessarily large
209 } else {
211
212 if (m_processed_up_to.get_timestamp() >= newest_ts + 1) {
213 TLOG_DEBUG(TLVL_WORK_STEPS) << "Nothing to postprocess (data arrived too late, will be ignored)";
214 return 0;
215 }
216
218
220 if (newest_ts - m_processed_up_to.get_timestamp() > m_processing_delay_ticks) {
222 } else {
223 TLOG_DEBUG(TLVL_WORK_STEPS) << "Not ready to postprocess (m_processing_delay_ticks is greater)";
224 return 0;
225 }
226 } else {
227 TLOG_DEBUG(TLVL_WORK_STEPS) << "Not ready to postprocess (too fast)";
228 return 0;
229 }
230 }
231
232 auto start_iter = m_latency_buffer_impl.lower_bound(m_processed_up_to, false);
233 m_processed_up_to.set_timestamp(end_win_ts);
234 auto end_iter = m_latency_buffer_impl.lower_bound(m_processed_up_to, false);
235
236 // This likely happens when RDT uses a composite key
237 // The current algorithm does not support composite keys
238 // Our search item `m_processed_up_to` will have its other keys set to their defaults
239 // E.g., for TriggerPrimitive, channel = INVALID_TP_CHANNEL
240 // Even if an entry with the same ts exists in the buffer, its channel will be a valid (smaller) value,
241 // so `lower_bound` will not be able to find it
242 // We should verify that this is the only scenario in which we end up here
243 if (!start_iter.good()) {
244 TLOG_DEBUG(TLVL_WORK_STEPS) << "Nothing to postprocess (!start_iter.good())";
245 return 0;
246 }
247
248 if (start_iter == end_iter) {
249 TLOG_DEBUG(TLVL_WORK_STEPS) << "Nothing to postprocess (start_iter == end_iter)";
250 return 0;
251 }
252
253 int processed = 0;
254 for (auto it = start_iter; it != end_iter; ++it) {
255 // Just to be completely safe
256 // We should understand why we end up here
257 if (!it.good()) {
258 TLOG_DEBUG(TLVL_WORK_STEPS) << "Invalid iterator in postprocessing loop";
259 break;
260 }
261 m_raw_processor_impl.postprocess_item(&(*it));
262 ++processed;
263 }
264
266
267 return processed;
268 }

◆ run()

template<class ReadoutType, class RequestHandlerType, class LatencyBufferType, class RawDataProcessorType, class InputDataType = ReadoutType>
int dunedaq::datahandlinglibs::DataHandlingModel< ReadoutType, RequestHandlerType, LatencyBufferType, RawDataProcessorType, InputDataType >::PostprocessScheduleAlgorithm::run ( bool timeout)
inline

Member Data Documentation

◆ m_consecutive_timeouts

template<class ReadoutType, class RequestHandlerType, class LatencyBufferType, class RawDataProcessorType, class InputDataType = ReadoutType>
int dunedaq::datahandlinglibs::DataHandlingModel< ReadoutType, RequestHandlerType, LatencyBufferType, RawDataProcessorType, InputDataType >::PostprocessScheduleAlgorithm::m_consecutive_timeouts
private

Definition at line 278 of file DataHandlingModel.hpp.

◆ m_first_cycle

template<class ReadoutType, class RequestHandlerType, class LatencyBufferType, class RawDataProcessorType, class InputDataType = ReadoutType>
bool dunedaq::datahandlinglibs::DataHandlingModel< ReadoutType, RequestHandlerType, LatencyBufferType, RawDataProcessorType, InputDataType >::PostprocessScheduleAlgorithm::m_first_cycle
private

Definition at line 276 of file DataHandlingModel.hpp.

◆ m_last_post_proc_time

template<class ReadoutType, class RequestHandlerType, class LatencyBufferType, class RawDataProcessorType, class InputDataType = ReadoutType>
std::chrono::time_point<std::chrono::system_clock> dunedaq::datahandlinglibs::DataHandlingModel< ReadoutType, RequestHandlerType, LatencyBufferType, RawDataProcessorType, InputDataType >::PostprocessScheduleAlgorithm::m_last_post_proc_time
private

Definition at line 280 of file DataHandlingModel.hpp.

◆ m_latency_buffer_impl

template<class ReadoutType, class RequestHandlerType, class LatencyBufferType, class RawDataProcessorType, class InputDataType = ReadoutType>
LatencyBufferType& dunedaq::datahandlinglibs::DataHandlingModel< ReadoutType, RequestHandlerType, LatencyBufferType, RawDataProcessorType, InputDataType >::PostprocessScheduleAlgorithm::m_latency_buffer_impl
private

Definition at line 271 of file DataHandlingModel.hpp.

◆ m_max_wait_in_ticks

template<class ReadoutType, class RequestHandlerType, class LatencyBufferType, class RawDataProcessorType, class InputDataType = ReadoutType>
const timestamp_t dunedaq::datahandlinglibs::DataHandlingModel< ReadoutType, RequestHandlerType, LatencyBufferType, RawDataProcessorType, InputDataType >::PostprocessScheduleAlgorithm::m_max_wait_in_ticks
private

Definition at line 279 of file DataHandlingModel.hpp.

◆ m_post_processing_delay_max_wait

template<class ReadoutType, class RequestHandlerType, class LatencyBufferType, class RawDataProcessorType, class InputDataType = ReadoutType>
const uint64_t dunedaq::datahandlinglibs::DataHandlingModel< ReadoutType, RequestHandlerType, LatencyBufferType, RawDataProcessorType, InputDataType >::PostprocessScheduleAlgorithm::m_post_processing_delay_max_wait
private

Definition at line 275 of file DataHandlingModel.hpp.

◆ m_post_processing_delay_min_wait

template<class ReadoutType, class RequestHandlerType, class LatencyBufferType, class RawDataProcessorType, class InputDataType = ReadoutType>
const uint64_t dunedaq::datahandlinglibs::DataHandlingModel< ReadoutType, RequestHandlerType, LatencyBufferType, RawDataProcessorType, InputDataType >::PostprocessScheduleAlgorithm::m_post_processing_delay_min_wait
private

Definition at line 274 of file DataHandlingModel.hpp.

◆ m_processed_up_to

template<class ReadoutType, class RequestHandlerType, class LatencyBufferType, class RawDataProcessorType, class InputDataType = ReadoutType>
RDT dunedaq::datahandlinglibs::DataHandlingModel< ReadoutType, RequestHandlerType, LatencyBufferType, RawDataProcessorType, InputDataType >::PostprocessScheduleAlgorithm::m_processed_up_to
private

Definition at line 277 of file DataHandlingModel.hpp.

◆ m_processing_delay_ticks

template<class ReadoutType, class RequestHandlerType, class LatencyBufferType, class RawDataProcessorType, class InputDataType = ReadoutType>
const uint64_t dunedaq::datahandlinglibs::DataHandlingModel< ReadoutType, RequestHandlerType, LatencyBufferType, RawDataProcessorType, InputDataType >::PostprocessScheduleAlgorithm::m_processing_delay_ticks
private

Definition at line 273 of file DataHandlingModel.hpp.

◆ m_raw_processor_impl

template<class ReadoutType, class RequestHandlerType, class LatencyBufferType, class RawDataProcessorType, class InputDataType = ReadoutType>
RawDataProcessorType& dunedaq::datahandlinglibs::DataHandlingModel< ReadoutType, RequestHandlerType, LatencyBufferType, RawDataProcessorType, InputDataType >::PostprocessScheduleAlgorithm::m_raw_processor_impl
private

Definition at line 272 of file DataHandlingModel.hpp.


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