DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
datahandlinglibs
include
datahandlinglibs
models
detail
RecorderModel.hxx
Go to the documentation of this file.
1
// Declarations for RecorderModel
2
3
namespace
dunedaq
{
4
namespace
datahandlinglibs
{
5
6
template
<
class
ReadoutType>
7
void
8
RecorderModel<ReadoutType>::init
(
const
appmodel::DataRecorderModule
* conf)
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
}
17
m_output_file
= conf->
get_configuration
()->
get_output_file
();
18
m_stream_buffer_size
= conf->
get_configuration
()->
get_streaming_buffer_size
();
19
m_compression_algorithm
= conf->
get_configuration
()->
get_compression_algorithm
();
20
m_use_o_direct
= conf->
get_configuration
()->
get_use_o_direct
();
21
}
22
23
template
<
class
ReadoutType>
24
void
25
RecorderModel<ReadoutType>::generate_opmon_data
()
26
{
27
opmon::RecordingInfo
info;
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
33
template
<
class
ReadoutType>
34
void
35
RecorderModel<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
42
m_buffered_writer
.open(
43
m_output_file
,
m_stream_buffer_size
,
m_compression_algorithm
,
m_use_o_direct
);
44
m_work_thread
.set_name(
m_name
, 0);
45
}
46
47
template
<
class
ReadoutType>
48
void
49
RecorderModel<ReadoutType>::do_start
(
const
appfwk::DAQModule::CommandData_t&
/* args */
)
50
{
51
m_packets_processed
= 0;
52
m_bytes_processed
= 0;
53
54
m_run_marker
.store(
true
);
55
m_work_thread
.set_work(&
RecorderModel<ReadoutType>::do_work
,
this
);
56
}
57
58
template
<
class
ReadoutType>
59
void
60
RecorderModel<ReadoutType>::do_stop
(
const
appfwk::DAQModule::CommandData_t&
/* args */
)
61
{
62
m_run_marker
.store(
false
);
63
while
(!
m_work_thread
.get_readiness()) {
64
std::this_thread::sleep_for(std::chrono::milliseconds(100));
65
}
66
}
67
68
template
<
class
ReadoutType>
69
void
70
RecorderModel<ReadoutType>::do_work
()
71
{
72
m_time_point_last_info
= std::chrono::steady_clock::now();
73
74
ReadoutType element;
75
while
(
m_run_marker
) {
76
try
{
77
element =
m_data_receiver
->receive(std::chrono::milliseconds(100));
// RS -> Use confed timeout?
78
if
(!
m_buffered_writer
.write(
reinterpret_cast<
char
*
>
(&element),
sizeof
(element))) {
// NOLINT
79
ers::warning
(CannotWriteToFile(
ERS_HERE
,
m_output_file
));
80
break
;
81
}
82
m_packets_processed
++;
83
m_bytes_processed
+=
sizeof
(element);
84
}
catch
(
const
dunedaq::iomanager::TimeoutExpired& excpt) {
85
continue
;
86
}
87
}
88
m_buffered_writer
.flush();
89
}
90
91
}
// namespace datahandlinglibs
92
}
// namespace dunedaq
TLVL_WORK_STEPS
@ TLVL_WORK_STEPS
Definition
IfaceWrapper.cpp:52
ERS_HERE
#define ERS_HERE
Definition
LocalContext.hpp:141
dunedaq::appmodel::DataRecorderConf::get_output_file
const std::string & get_output_file() const
Get "output_file" attribute value.
Definition
DataRecorderConf.hpp:99
dunedaq::appmodel::DataRecorderConf::get_use_o_direct
bool get_use_o_direct() const
Get "use_o_direct" attribute value. Whether to use O_DIRECT flag when opening files.
Definition
DataRecorderConf.hpp:193
dunedaq::appmodel::DataRecorderConf::get_streaming_buffer_size
uint32_t get_streaming_buffer_size() const
Get "streaming_buffer_size" attribute value.
Definition
DataRecorderConf.hpp:130
dunedaq::appmodel::DataRecorderConf::get_compression_algorithm
const std::string & get_compression_algorithm() const
Get "compression_algorithm" attribute value.
Definition
DataRecorderConf.hpp:161
dunedaq::appmodel::DataRecorderModule
Definition
DataRecorderModule.hpp:32
dunedaq::appmodel::DataRecorderModule::get_configuration
const dunedaq::appmodel::DataRecorderConf * get_configuration() const
Get "configuration" relationship value.
Definition
DataRecorderModule.hpp:102
dunedaq::confmodel::DaqModule::get_inputs
const std::vector< const dunedaq::confmodel::Connection * > & get_inputs() const
Get "inputs" relationship value. List of connections to/from this module.
Definition
DaqModule.hpp:111
dunedaq::datahandlinglibs::RecorderModel::m_bytes_processed
std::atomic< int > m_bytes_processed
Definition
RecorderModel.hpp:75
dunedaq::datahandlinglibs::RecorderModel::m_output_file
std::string m_output_file
Definition
RecorderModel.hpp:63
dunedaq::datahandlinglibs::RecorderModel::m_buffered_writer
BufferedFileWriter m_buffered_writer
Definition
RecorderModel.hpp:68
dunedaq::datahandlinglibs::RecorderModel::init
void init(const appmodel::DataRecorderModule *conf) override
Definition
RecorderModel.hxx:8
dunedaq::datahandlinglibs::RecorderModel::m_compression_algorithm
std::string m_compression_algorithm
Definition
RecorderModel.hpp:65
dunedaq::datahandlinglibs::RecorderModel::do_work
void do_work()
Definition
RecorderModel.hxx:70
dunedaq::datahandlinglibs::RecorderModel::do_start
void do_start(const appfwk::DAQModule::CommandData_t &) override
Definition
RecorderModel.hxx:49
dunedaq::datahandlinglibs::RecorderModel::m_run_marker
std::atomic< bool > m_run_marker
Definition
RecorderModel.hpp:72
dunedaq::datahandlinglibs::RecorderModel::m_data_receiver
std::shared_ptr< source_t > m_data_receiver
Definition
RecorderModel.hpp:59
dunedaq::datahandlinglibs::RecorderModel::m_packets_processed
std::atomic< int > m_packets_processed
Definition
RecorderModel.hpp:76
dunedaq::datahandlinglibs::RecorderModel::generate_opmon_data
virtual void generate_opmon_data() override
Definition
RecorderModel.hxx:25
dunedaq::datahandlinglibs::RecorderModel::m_use_o_direct
bool m_use_o_direct
Definition
RecorderModel.hpp:66
dunedaq::datahandlinglibs::RecorderModel::do_stop
void do_stop(const appfwk::DAQModule::CommandData_t &) override
Definition
RecorderModel.hxx:60
dunedaq::datahandlinglibs::RecorderModel::m_stream_buffer_size
size_t m_stream_buffer_size
Definition
RecorderModel.hpp:64
dunedaq::datahandlinglibs::RecorderModel::m_name
std::string m_name
Definition
RecorderModel.hpp:79
dunedaq::datahandlinglibs::RecorderModel::do_conf
void do_conf(const appfwk::DAQModule::CommandData_t &) override
Definition
RecorderModel.hxx:35
dunedaq::datahandlinglibs::RecorderModel::m_time_point_last_info
std::chrono::steady_clock::time_point m_time_point_last_info
Definition
RecorderModel.hpp:77
dunedaq::datahandlinglibs::RecorderModel::m_work_thread
utilities::ReusableThread m_work_thread
Definition
RecorderModel.hpp:71
dunedaq::datahandlinglibs::opmon::RecordingInfo
Definition
datahandling_info.pb.h:1054
ers::Issue
Base class for any user define issue.
Definition
Issue.hpp:80
TLOG
#define TLOG(...)
Definition
macro.hpp:22
dunedaq::datahandlinglibs
Definition
DataHandlingConcept.hpp:16
dunedaq
Including Qt Headers.
Definition
module.cpp:16
dunedaq::get_iom_receiver
static std::shared_ptr< iomanager::ReceiverConcept< Datatype > > get_iom_receiver(iomanager::ConnectionId const &id)
Definition
IOManager.hxx:178
ers::warning
void warning(const Issue &issue)
Definition
ers.hpp:126
Generated on
for DUNE-DAQ by
1.17.0