DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
FixedRateQueueModel.hxx
Go to the documentation of this file.
1// Declarations for FixedRateQueueModel
2
3namespace dunedaq {
4namespace datahandlinglibs {
5
6template<typename T>
7typename IterableQueueModel<T>::Iterator
8FixedRateQueueModel<T>::lower_bound(T& element, bool with_errors)
9{
10 if (with_errors) {
11 return BinarySearchQueueModel<T>::lower_bound(element, with_errors);
12 }
13 uint64_t timestamp = element.get_timestamp(); // NOLINT(build/unsigned)
14 unsigned int start_index =
15 IterableQueueModel<T>::readIndex_.load(std::memory_order_relaxed); // NOLINT(build/unsigned)
16 size_t occupancy_guess = IterableQueueModel<T>::occupancy();
17 uint64_t last_ts = IterableQueueModel<T>::records_[start_index].get_timestamp(); // NOLINT(build/unsigned)
18 uint64_t newest_ts = // NOLINT(build/unsigned)
19 last_ts +
20 occupancy_guess * T::expected_tick_difference * IterableQueueModel<T>::records_[start_index].get_num_frames();
21 size_t n_frames = IterableQueueModel<T>::records_[start_index].get_num_frames();
22
23 if (last_ts > timestamp || timestamp > newest_ts) {
25 }
26
27 int64_t time_tick_diff = (timestamp - last_ts);
28
29 //if we are aligned on a n_frame boundary,
30 uint32_t num_element_offset = time_tick_diff/T::expected_tick_difference/n_frames; // NOLINT(build/unsigned)
31 uint32_t target_index = start_index + num_element_offset; // NOLINT(build/unsigned)
32
33 //if we aren't perfectly aligned on a n_frames boundary, move us up so we satisfy normal lower_bound rules
34 if(time_tick_diff%(T::expected_tick_difference*n_frames)!=0) ++target_index;
35
36 if (target_index >= IterableQueueModel<T>::size_) {
37 target_index -= IterableQueueModel<T>::size_;
38 }
39
40 return typename IterableQueueModel<T>::Iterator(*this, target_index);
41}
42
43} // namespace datahandlinglibs
44} // namespace dunedaq
IterableQueueModel< T >::Iterator lower_bound(T &element, bool=false)
IterableQueueModel< T >::Iterator lower_bound(T &element, bool with_errors=false)
Including Qt Headers.
std::size_t occupancy() const override
Occupancy of LB.