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, std::string timing_entity_description,
const
Vs& ... args)
5
{
6
bool
conf_commands_sent=
false
;
7
8
if
(!m_hardware_state_recovery_enabled)
9
{
10
TLOG_DEBUG
(3) <<
"State recovery not enabled. Sending configure commands..."
;
11
send_configure_hardware_commands(
static_cast<
CommandData_t
>
(data));
12
conf_commands_sent=
true
;
13
}
14
15
auto
time_of_conf = std::chrono::high_resolution_clock::now();
16
while
(
true
)
17
{
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 <<
", infos received: "
<< m_device_infos_received_count;
22
23
if
(m_device_ready.load() && m_device_infos_received_count.load())
24
{
25
if
(!conf_commands_sent)
26
{
27
TLOG_DEBUG
(3) <<
"State recovered!"
;
28
}
29
break
;
30
}
31
32
if
(ms_since_conf > m_device_ready_timeout)
33
{
34
if
(conf_commands_sent)
35
{
36
throw
T(
ERS_HERE
,m_timing_device, args...);
37
}
38
else
39
{
40
TLOG_DEBUG
(3) <<
"State not recovered! Sending configure commands..."
;
41
send_configure_hardware_commands(
static_cast<
CommandData_t
>
(data));
42
time_of_conf = std::chrono::high_resolution_clock::now();
43
conf_commands_sent=
true
;
44
}
45
}
46
TLOG_DEBUG
(3) <<
"Waiting for "
<< timing_entity_description <<
" "
<< m_timing_device <<
" to become ready for (ms) "
<< ms_since_conf.count();
47
std::this_thread::sleep_for(std::chrono::microseconds(250000));
48
}
49
}
50
51
}
ERS_HERE
#define ERS_HERE
Definition
LocalContext.hpp:141
now
static int64_t now()
Definition
kafka_opmon_consumer.cxx:44
TLOG_DEBUG
#define TLOG_DEBUG(lvl,...)
Definition
Logging.hpp:112
dunedaq::timinglibs
Definition
TimingController.hxx:1
Generated on
for DUNE-DAQ by
1.17.0