64{
66
67
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);
74
75
76 enum LocalState
77 {
78 no_update,
79 free_state,
80 busy_state
81 };
82 std::chrono::steady_clock::time_point current_time = std::chrono::steady_clock::now();
83
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;
89
90
91 while (running_flag.load()) {
92
93
94
95 try {
97 ++received_message_count;
98 TLOG_DEBUG(TLVL_WORK_STEPS) <<
get_name() <<
": Popped the TriggerDecision for trigger number "
99 << trig_dec.trigger_number << " off the input queue";
101 } catch (const iomanager::TimeoutExpired& excpt) {
102
103
104 }
105
106
107
108
109
111 if (threshold > 0) {
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;
118 }
119 } else {
120 if (current_state == busy_state) {
121 requested_state = free_state;
122 }
123 }
124 }
125
126
127
128
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) {
131 dfmessages::TriggerInhibit inhibit_message;
132 if (requested_state == busy_state) {
133 inhibit_message.busy = true;
134 } else {
135 inhibit_message.busy = false;
136 }
137
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";
140 try {
142 ++sent_message_count;
143#if 0
144
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";
149#endif
150
151
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) {
156
157
158
159
160
162 << ": TIMEOUT pushing a TriggerInhibit message onto the output queue";
163 }
164 }
165 }
166 }
167
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).";
174}
const std::string & get_name() const final
Get the name of this NamedObejct.
#define TLVL_ENTER_EXIT_METHODS
#define TLOG_DEBUG(lvl,...)