DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
datahandlinglibs
include
datahandlinglibs
models
detail
FixedRateQueueModel.hxx
Go to the documentation of this file.
1
// Declarations for FixedRateQueueModel
2
3
namespace
dunedaq
{
4
namespace
datahandlinglibs
{
5
6
template
<
typename
T>
7
typename
IterableQueueModel<T>::Iterator
8
FixedRateQueueModel<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) {
24
return
IterableQueueModel<T>::end
();
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
dunedaq::datahandlinglibs::BinarySearchQueueModel::lower_bound
IterableQueueModel< T >::Iterator lower_bound(T &element, bool=false)
Definition
BinarySearchQueueModel.hxx:8
dunedaq::datahandlinglibs::FixedRateQueueModel::lower_bound
IterableQueueModel< T >::Iterator lower_bound(T &element, bool with_errors=false)
Definition
FixedRateQueueModel.hxx:8
dunedaq::datahandlinglibs
Definition
DataHandlingConcept.hpp:16
dunedaq
Including Qt Headers.
Definition
module.cpp:16
dunedaq::datahandlinglibs::IterableQueueModel::Iterator
Definition
IterableQueueModel.hpp:213
dunedaq::datahandlinglibs::IterableQueueModel::size_
uint32_t size_
Definition
IterableQueueModel.hpp:314
dunedaq::datahandlinglibs::IterableQueueModel::end
Iterator end()
Definition
IterableQueueModel.hpp:278
dunedaq::datahandlinglibs::IterableQueueModel::occupancy
std::size_t occupancy() const override
Occupancy of LB.
Definition
IterableQueueModel.hxx:254
dunedaq::datahandlinglibs::IterableQueueModel::readIndex_
std::atomic< unsigned int > readIndex_
Definition
IterableQueueModel.hpp:317
dunedaq::datahandlinglibs::IterableQueueModel::records_
T * records_
Definition
IterableQueueModel.hpp:315
Generated on
for DUNE-DAQ by
1.17.0