2template<
class T,
class... Vs>
4TimingController::configure_hardware_or_recover_state(
const nlohmann::json& data, std::string timing_entity_description,
const Vs& ... args)
6 bool conf_commands_sent=
false;
8 if (!m_hardware_state_recovery_enabled)
10 TLOG_DEBUG(3) <<
"State recovery not enabled. Sending configure commands...";
11 send_configure_hardware_commands(data);
12 conf_commands_sent=
true;
15 auto time_of_conf = std::chrono::high_resolution_clock::now();
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);
21 TLOG_DEBUG(3) << timing_entity_description <<
" (" << m_timing_device <<
") ready: " << m_device_ready <<
", infos received: " << m_device_infos_received_count;
23 if (m_device_ready.load() && m_device_infos_received_count.load())
25 if (!conf_commands_sent)
32 if (ms_since_conf > m_device_ready_timeout)
34 if (conf_commands_sent)
36 throw T(
ERS_HERE,m_timing_device, args...);
40 TLOG_DEBUG(3) <<
"State not recovered! Sending configure commands...";
41 send_configure_hardware_commands(data);
42 time_of_conf = std::chrono::high_resolution_clock::now();
43 conf_commands_sent=
true;
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));