32 std::shared_ptr<trigdecreceiver_t> our_input,
33 std::shared_ptr<triginhsender_t> our_output)
34 : NamedObject(parent_name +
"::TriggerInhibitAgent")
36 , m_queue_timeout(100)
37 , m_threshold_for_inhibit(1)
38 , m_trigger_decision_receiver(our_input)
39 , m_trigger_inhibit_sender(our_output)
40 , m_trigger_number_at_start_of_processing_chain(0)
41 , m_trigger_number_at_end_of_processing_chain(0)
68 int fake_busy_interval_sec = 0;
69 std::chrono::seconds chrono_fake_busy_interval(fake_busy_interval_sec);
70 int fake_busy_duration_sec = 0;
71 std::chrono::seconds chrono_fake_busy_duration(fake_busy_duration_sec);
72 int min_interval_between_inhibit_messages_msec = 0;
73 std::chrono::milliseconds chrono_min_interval_between_inhibit_messages(min_interval_between_inhibit_messages_msec);
82 std::chrono::steady_clock::time_point current_time = std::chrono::steady_clock::now();
84 std::chrono::steady_clock::time_point last_sent_time = current_time;
85 LocalState requested_state = no_update;
86 LocalState current_state = free_state;
87 int32_t received_message_count = 0;
88 int32_t sent_message_count = 0;
91 while (running_flag.load()) {
97 ++received_message_count;
98 TLOG_DEBUG(TLVL_WORK_STEPS) <<
get_name() <<
": Popped the TriggerDecision for trigger number "
101 }
catch (
const iomanager::TimeoutExpired& excpt) {
114 if (temp_trig_num_at_start >= temp_trig_num_at_end &&
115 (temp_trig_num_at_start - temp_trig_num_at_end) >= threshold) {
116 if (current_state == free_state) {
117 requested_state = busy_state;
120 if (current_state == busy_state) {
121 requested_state = free_state;
129 if (requested_state != no_update && requested_state != current_state) {
130 if ((std::chrono::steady_clock::now() - last_sent_time) >= chrono_min_interval_between_inhibit_messages) {
132 if (requested_state == busy_state) {
133 inhibit_message.
busy =
true;
135 inhibit_message.
busy =
false;
138 TLOG_DEBUG(TLVL_WORK_STEPS) <<
get_name() <<
": Pushing a TriggerInhibit message with busy state set to "
139 << inhibit_message.
busy <<
" onto the output queue";
142 ++sent_message_count;
145 std::ostringstream oss_sent;
146 oss_sent <<
": Successfully pushed a TriggerInhibit message with busy state set to " << inhibit_message.
busy
147 <<
" onto the output queue";
152 current_state = requested_state;
153 requested_state = no_update;
154 last_sent_time = std::chrono::steady_clock::now();
155 }
catch (
const iomanager::TimeoutExpired& excpt) {
162 <<
": TIMEOUT pushing a TriggerInhibit message onto the output queue";
168 std::ostringstream oss_summ;
169 oss_summ <<
": Exiting the do_work() method, received " << received_message_count
170 <<
" TriggerDecision messages and sent " << sent_message_count
171 <<
" TriggerInhibit messages of all types (both Busy and Free).";