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(
m_output_file
,
m_stream_buffer_size
,
m_compression_algorithm
,
m_use_o_direct
);
43
m_work_thread
.set_name(
m_name
, 0);
44
}
45
46
template
<
class
ReadoutType>
47
void
48
RecorderModel<ReadoutType>::do_start
(
const
appfwk::DAQModule::CommandData_t&
/* args */
)
49
{
50
m_packets_processed
= 0;
51
m_bytes_processed
= 0;
52
53
m_run_marker
.store(
true
);
54
m_work_thread
.set_work(&
RecorderModel<ReadoutType>::do_work
,
this
);
55
}
56
57
template
<
class
ReadoutType>
58
void
59
RecorderModel<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
67
template
<
class
ReadoutType>
68
void
69
RecorderModel<ReadoutType>::do_work
()
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
}
81
m_packets_processed
++;
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
TLVL_WORK_STEPS
@ TLVL_WORK_STEPS
Definition
CardControllerWrapper.cpp:33
ERS_HERE
#define ERS_HERE
Definition
LocalContext.hpp:127
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:76
dunedaq::datahandlinglibs::RecorderModel::m_output_file
std::string m_output_file
Definition
RecorderModel.hpp:64
dunedaq::datahandlinglibs::RecorderModel::m_buffered_writer
BufferedFileWriter m_buffered_writer
Definition
RecorderModel.hpp:69
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:66
dunedaq::datahandlinglibs::RecorderModel::do_work
void do_work()
Definition
RecorderModel.hxx:69
dunedaq::datahandlinglibs::RecorderModel::do_start
void do_start(const appfwk::DAQModule::CommandData_t &) override
Definition
RecorderModel.hxx:48
dunedaq::datahandlinglibs::RecorderModel::m_run_marker
std::atomic< bool > m_run_marker
Definition
RecorderModel.hpp:73
dunedaq::datahandlinglibs::RecorderModel::m_data_receiver
std::shared_ptr< source_t > m_data_receiver
Definition
RecorderModel.hpp:60
dunedaq::datahandlinglibs::RecorderModel::m_packets_processed
std::atomic< int > m_packets_processed
Definition
RecorderModel.hpp:77
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:67
dunedaq::datahandlinglibs::RecorderModel::do_stop
void do_stop(const appfwk::DAQModule::CommandData_t &) override
Definition
RecorderModel.hxx:59
dunedaq::datahandlinglibs::RecorderModel::m_stream_buffer_size
size_t m_stream_buffer_size
Definition
RecorderModel.hpp:65
dunedaq::datahandlinglibs::RecorderModel::m_name
std::string m_name
Definition
RecorderModel.hpp:80
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:78
dunedaq::datahandlinglibs::RecorderModel::m_work_thread
utilities::ReusableThread m_work_thread
Definition
RecorderModel.hpp:72
dunedaq::datahandlinglibs::opmon::RecordingInfo
Definition
datahandling_info.pb.h:1054
ers::Issue
Base class for any user define issue.
Definition
Issue.hpp:76
TLOG
#define TLOG(...)
Definition
macro.hpp:21
dunedaq::datahandlinglibs
Definition
DataHandlingConcept.hpp:16
dunedaq
The DUNE-DAQ namespace.
Definition
cib_utilities.cpp:5
ers::warning
void warning(const Issue &issue)
Definition
ers.hpp:150
Generated on
for DUNE-DAQ by
1.18.0