65{
67
68
69 int fake_busy_interval_sec = 0;
70 std::chrono::seconds chrono_fake_busy_interval(fake_busy_interval_sec);
71 int fake_busy_duration_sec = 0;
72 std::chrono::seconds chrono_fake_busy_duration(fake_busy_duration_sec);
73 int min_interval_between_inhibit_messages_msec = 0;
74 std::chrono::milliseconds chrono_min_interval_between_inhibit_messages(min_interval_between_inhibit_messages_msec);
75
76
77 enum LocalState
78 {
79 no_update,
80 free_state,
81 busy_state
82 };
83 std::chrono::steady_clock::time_point current_time = std::chrono::steady_clock::now();
84
85 std::chrono::steady_clock::time_point last_sent_time = current_time;
86 LocalState requested_state = no_update;
87 LocalState current_state = free_state;
88 int32_t received_message_count = 0;
89 int32_t sent_message_count = 0;
90
91
92 while (running_flag.load()) {
93
94
95
96 try {
98 ++received_message_count;
100 << trig_dec.trigger_number << " off the input queue";
102 } catch (const iomanager::TimeoutExpired& excpt) {
103
104
105 }
106
107
108
109
110
112 if (threshold > 0) {
115 if (temp_trig_num_at_start >= temp_trig_num_at_end &&
116 (temp_trig_num_at_start - temp_trig_num_at_end) >= threshold) {
117 if (current_state == free_state) {
118 requested_state = busy_state;
119 }
120 } else {
121 if (current_state == busy_state) {
122 requested_state = free_state;
123 }
124 }
125 }
126
127
128
129
130 if (requested_state != no_update && requested_state != current_state) {
131 if ((std::chrono::steady_clock::now() - last_sent_time) >= chrono_min_interval_between_inhibit_messages) {
132 dfmessages::TriggerInhibit inhibit_message;
133 if (requested_state == busy_state) {
134 inhibit_message.busy = true;
135 } else {
136 inhibit_message.busy = false;
137 }
138
140 << inhibit_message.busy << " onto the output queue";
141 try {
143 ++sent_message_count;
144#if 0
145
146 std::ostringstream oss_sent;
147 oss_sent << ": Successfully pushed a TriggerInhibit message with busy state set to " << inhibit_message.busy
148 << " onto the output queue";
150#endif
151
152
153 current_state = requested_state;
154 requested_state = no_update;
155 last_sent_time = std::chrono::steady_clock::now();
156 } catch (const iomanager::TimeoutExpired& excpt) {
157
158
159
160
161
163 << ": TIMEOUT pushing a TriggerInhibit message onto the output queue";
164 }
165 }
166 }
167 }
168
169 std::ostringstream oss_summ;
170 oss_summ << ": Exiting the do_work() method, received " << received_message_count
171 << " TriggerDecision messages and sent " << sent_message_count
172 << " TriggerInhibit messages of all types (both Busy and Free).";
175}
virtual const std::string & get_name() const =0
Get the name of this Named.
#define TLVL_ENTER_EXIT_METHODS
#define TLOG_DEBUG(lvl,...)