DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TPRequestHandler.cpp
Go to the documentation of this file.
4
5#include "rcif/cmd/Nljs.hpp"
6
7namespace dunedaq {
8namespace trigger {
9
10void
12
13 for (auto output : conf->get_outputs()) {
14 if (output->get_data_type() == "TPSet") {
15 try {
17 } catch (const ers::Issue& excpt) {
18 throw datahandlinglibs::ResourceQueueError(ERS_HERE, "tp queue", "DefaultRequestHandlerModel", excpt);
19 }
20 }
21 }
23}
24
25void
26TPRequestHandler::scrap(const nlohmann::json& args) {
27 m_tpset_sink.reset();
29}
30
31void
32TPRequestHandler::start(const nlohmann::json& args) {
33
38 m_first_cycle = true;
39
41 rcif::cmd::StartParams start_params = args.get<rcif::cmd::StartParams>();
42 m_run_number = start_params.run;
43
44}
45
46void
48
49 if (m_tpset_sink == nullptr) return;
50
52
53 {
54 std::unique_lock<std::mutex> lock(m_cv_mutex);
55 m_cv.wait(lock, [&] { return !m_cleanup_requested; });
57 }
58 m_cv.notify_all();
59 if(m_latency_buffer->occupancy() != 0) {
60 // Prepare response
61 RequestResult rres(ResultCode::kUnknown, dr);
62 std::vector<std::pair<void*, size_t>> frag_pieces;
63
64 // Get the newest TP
65 SkipListAcc acc(inherited2::m_latency_buffer->get_skip_list());
66 auto tail = acc.last();
67 auto head = acc.first();
68 m_newest_ts = (*tail).get_timestamp();
69 m_oldest_ts = (*head).get_timestamp();
70
71 if (m_first_cycle) {
73 m_first_cycle = false;
74 }
78 auto num_tps = frag_pieces.size();
79 trigger::TPSet tpset;
82 tpset.origin = m_sourceid;
83 tpset.start_time = m_start_win_ts; // provisory timestamp, will be filled with first TP
84 tpset.end_time = m_end_win_ts; // provisory timestamp, will be filled with last TP
85 tpset.seqno = m_next_tpset_seqno++; // NOLINT(runtime/increment_decrement)
86 // reserve the space for efficiency
87 if (num_tps > 0) {
88 tpset.objects.reserve(frag_pieces.size());
89 bool first_tp = true;
90 for( auto f : frag_pieces) {
92
93 if(first_tp) {
94 tpset.start_time = tp.time_start;
95 first_tp = false;
96 }
97 tpset.end_time = tp.time_start;
98 tpset.objects.emplace_back(std::move(tp));
99 }
100 }
101 if(!m_tpset_sink->try_send(std::move(tpset), iomanager::Sender::s_no_block)) {
104 }
106
107 //remember what we sent for the next loop
109 }
110 }
111 {
112 std::lock_guard<std::mutex> lock(m_cv_mutex);
114 }
115 m_cv.notify_all();
116 return;
117}
118
119} // namespace fdreadoutlibs
120} // namespace dunedaq
#define ERS_HERE
typename folly::ConcurrentSkipList< TriggerPrimitiveTypeAdapter >::Accessor SkipListAcc
static std::shared_ptr< IOManager > get()
Definition IOManager.hpp:40
static constexpr timeout_t s_no_block
Definition Sender.hpp:26
A set of TPs or TAs in a given time window, defined by its start and end times.
Definition Set.hpp:26
std::vector< T > objects
Definition Set.hpp:61
daqdataformats::run_number_t run_number
Definition Set.hpp:45
timestamp_t start_time
Definition Set.hpp:55
origin_t origin
Definition Set.hpp:48
timestamp_t end_time
Definition Set.hpp:58
void start(const nlohmann::json &args) override
std::shared_ptr< iomanager::SenderConcept< dunedaq::trigger::TPSet > > m_tpset_sink
void conf(const appmodel::DataHandlerModule *conf) override
void periodic_data_transmission() override
Periodic data transmission - relevant for trigger in particular.
void scrap(const nlohmann::json &args) override
Base class for any user define issue.
Definition Issue.hpp:69
Including Qt Headers.
void warning(const Issue &issue)
Definition ers.hpp:115
This message represents a request for data sent to a single component of the DAQ.
A single energy deposition on a TPC or PDS channel.