DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
timinglibs
include
timinglibs
detail
TimingController.hxx
Go to the documentation of this file.
1
namespace
dunedaq::timinglibs
{
2
template
<
class
T,
class
... Vs>
3
void
4
TimingController::configure_hardware_or_recover_state(
const
nlohmann::json& data,
5
std::string timing_entity_description,
6
const
Vs&... args)
7
{
8
bool
conf_commands_sent =
false
;
9
10
if
(!m_hardware_state_recovery_enabled) {
11
TLOG_DEBUG
(3) <<
"State recovery not enabled. Sending configure commands..."
;
12
send_configure_hardware_commands(
static_cast<
CommandData_t
>
(data));
13
conf_commands_sent =
true
;
14
}
15
16
auto
time_of_conf = std::chrono::high_resolution_clock::now();
17
while
(
true
) {
18
auto
now = std::chrono::high_resolution_clock::now();
19
auto
ms_since_conf = std::chrono::duration_cast<std::chrono::milliseconds>(now - time_of_conf);
20
21
TLOG_DEBUG
(3) << timing_entity_description <<
" ("
<< m_timing_device <<
") ready: "
<< m_device_ready
22
<<
", infos received: "
<< m_device_infos_received_count;
23
24
if
(m_device_ready.load() && m_device_infos_received_count.load()) {
25
if
(!conf_commands_sent) {
26
TLOG_DEBUG
(3) <<
"State recovered!"
;
27
}
28
break
;
29
}
30
31
if
(ms_since_conf > m_device_ready_timeout) {
32
if
(conf_commands_sent) {
33
throw
T(
ERS_HERE
, m_timing_device, args...);
34
}
else
{
35
TLOG_DEBUG
(3) <<
"State not recovered! Sending configure commands..."
;
36
send_configure_hardware_commands(
static_cast<
CommandData_t
>
(data));
37
time_of_conf = std::chrono::high_resolution_clock::now();
38
conf_commands_sent =
true
;
39
}
40
}
41
TLOG_DEBUG
(3) <<
"Waiting for "
<< timing_entity_description <<
" "
<< m_timing_device
42
<<
" to become ready for (ms) "
<< ms_since_conf.count();
43
std::this_thread::sleep_for(std::chrono::microseconds(250000));
44
}
45
}
46
47
}
ERS_HERE
#define ERS_HERE
Definition
LocalContext.hpp:127
TLOG_DEBUG
#define TLOG_DEBUG(lvl,...)
Definition
Logging.hpp:116
dunedaq::timinglibs
Definition
TimingController.hxx:1
Generated on
for DUNE-DAQ by
1.18.0