DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
RecorderModel.hxx
Go to the documentation of this file.
1// Declarations for RecorderModel
2
3namespace dunedaq {
4namespace datahandlinglibs {
5
6template<class ReadoutType>
7void
9{
10 for (auto input : conf->get_inputs()) {
11 try {
12 m_data_receiver = get_iom_receiver<ReadoutType>(input->UID());
13 } catch (const ers::Issue& excpt) {
14 throw ResourceQueueError(ERS_HERE, "raw_recording", "RecorderModel");
15 }
16 }
21}
22
23template<class ReadoutType>
24void
26{
28 info.set_recording_status("Y");
29 info.set_packets_recorded(m_packets_processed.exchange(0));
30 info.set_bytes_recorded(m_bytes_processed.exchange(0));
31}
32
33template<class ReadoutType>
34void
35RecorderModel<ReadoutType>::do_conf(const appfwk::DAQModule::CommandData_t& /* args */)
36{
37
38 if (remove(m_output_file.c_str()) == 0) {
39 TLOG(TLVL_WORK_STEPS) << "Removed existing output file from previous run" << std::endl;
40 }
41
43 m_work_thread.set_name(m_name, 0);
44}
45
46template<class ReadoutType>
47void
48RecorderModel<ReadoutType>::do_start(const appfwk::DAQModule::CommandData_t& /* args */)
49{
52
53 m_run_marker.store(true);
55}
56
57template<class ReadoutType>
58void
59RecorderModel<ReadoutType>::do_stop(const appfwk::DAQModule::CommandData_t& /* args */)
60{
61 m_run_marker.store(false);
62 while (!m_work_thread.get_readiness()) {
63 std::this_thread::sleep_for(std::chrono::milliseconds(100));
64 }
65}
66
67template<class ReadoutType>
68void
70{
71 m_time_point_last_info = std::chrono::steady_clock::now();
72
73 ReadoutType element;
74 while (m_run_marker) {
75 try {
76 element = m_data_receiver->receive(std::chrono::milliseconds(100)); // RS -> Use confed timeout?
77 if (!m_buffered_writer.write(reinterpret_cast<char*>(&element), sizeof(element))) { // NOLINT
78 ers::warning(CannotWriteToFile(ERS_HERE, m_output_file));
79 break;
80 }
82 m_bytes_processed += sizeof(element);
83 } catch (const dunedaq::iomanager::TimeoutExpired& excpt) {
84 continue;
85 }
86 }
87 m_buffered_writer.flush();
88}
89
90} // namespace datahandlinglibs
91} // namespace dunedaq
#define ERS_HERE
const std::string & get_output_file() const
Get "output_file" attribute value.
bool get_use_o_direct() const
Get "use_o_direct" attribute value. Whether to use O_DIRECT flag when opening files.
uint32_t get_streaming_buffer_size() const
Get "streaming_buffer_size" attribute value.
const std::string & get_compression_algorithm() const
Get "compression_algorithm" attribute value.
const dunedaq::appmodel::DataRecorderConf * get_configuration() const
Get "configuration" relationship value.
const std::vector< const dunedaq::confmodel::Connection * > & get_inputs() const
Get "inputs" relationship value. List of connections to/from this module.
void init(const appmodel::DataRecorderModule *conf) override
void do_start(const appfwk::DAQModule::CommandData_t &) override
std::shared_ptr< source_t > m_data_receiver
virtual void generate_opmon_data() override
void do_stop(const appfwk::DAQModule::CommandData_t &) override
void do_conf(const appfwk::DAQModule::CommandData_t &) override
std::chrono::steady_clock::time_point m_time_point_last_info
utilities::ReusableThread m_work_thread
Base class for any user define issue.
Definition Issue.hpp:76
#define TLOG(...)
Definition macro.hpp:21
The DUNE-DAQ namespace.
void warning(const Issue &issue)
Definition ers.hpp:150