32 std::string return_string;
35 return_string =
"SYSTEM : period";
38 return_string =
"SYSTEM : pre period";
41 return_string =
"SYSTEM : post period";
44 return_string =
"SYSTEM : Period value requested";
47 return_string =
"SYSTEM : thread insert";
50 return_string =
"SYSTEM : thread remove";
53 return_string =
"SYSTEM : device insert";
56 return_string =
"SYSTEM : shutdown";
59 return_string =
"SYSTEM : device remove";
62 return_string =
"SYSTEM : Thread paused";
65 return_string =
"SYSTEM : Thread unpaused";
68 return_string =
"SYSTEM : Device paused";
71 return_string =
"SYSTEM : Device unpaused";
74 return_string =
"SYSTEM : parameter change";
77 return_string =
"SYSTEM : Widget State change";
80 return_string =
"CONNECTOR : Blocks Connected";
83 return_string =
"CONNECTOR : Blocks Disconnected";
86 return_string =
"CONNECTOR : Block list requested";
89 return_string =
"CONNECTOR : Request for connection info";
92 return_string =
"CONNECTOR : Request for all connections";
95 return_string =
"CONNECTOR : Request for block output info";
98 return_string =
"WIDGET : plugin insert";
101 return_string =
"WIDGET : plugin remove";
104 return_string =
"MANAGER : daq query event";
107 return_string =
"SYSTEM : settings object insert";
110 return_string =
"SYSTEM : settings object remove";
113 return_string =
"SYSTEM : open file";
116 return_string =
"SYSTEM : start recording";
119 return_string =
"SYSTEM : stop recording";
122 return_string =
"SYSTEM : async data";
125 return_string =
"SYSTEM : threshold crossing event";
128 return_string =
"SYSTEM : start genicam recording";
131 return_string =
"SYSTEM : pause genicam recording";
134 return_string =
"SYSTEM : stop genicam recording";
137 return_string =
"SYSTEM : genicam snap";
140 return_string =
"WIDGET : Generic Widget Event";
143 return_string =
"EVENT MANAGER : UI Manager shutdown event";
146 return_string =
"SYSTEM : no operation";
149 return_string =
"UNKNOWN EVENT!";
151 return return_string;
161 , event_type(obj.event_type)
172 for (
const auto& parameter : params) {
173 if (parameter.name == param_name) {
174 return parameter.value;
183 for (
auto& parameter : params) {
184 if (parameter.name == param_name) {
192 const std::any& param_value)
194 for (
auto& parameter : params) {
195 if (parameter.name == param_name) {
196 parameter.value = param_value;
202 temp.name = param_name;
203 temp.value = param_value;
204 params.push_back(temp);
209 std::unique_lock<std::mutex> done_lock(this->processing_done_mut);
210 this->processing_done_cond.wait(done_lock,
211 [
this]() {
return this->processed; });
217 std::unique_lock<std::mutex> done_lock(this->processing_done_mut);
218 this->processed =
true;
220 this->processing_done_cond.notify_one();
225 return this->processed;
230 return this->event_type;
236 this->logger = std::make_unique<eventLogger>();
241 while (this->running) {
244 std::unique_lock<std::mutex> event_lock(this->event_mut);
245 this->available_event_cond.wait(
247 [
this] {
return !(this->event_q.empty()) || !this->running; });
249 if (this->event_q.empty()) {
252 event = this->event_q.front();
257 this->logger->log(event);
260 std::shared_lock<std::shared_mutex> handlerlist_lock(
261 this->handlerlist_mut);
262 for (
auto* handler : this->handlerList) {
263 handler->receiveEvent(event);
265 handlerlist_lock.unlock();
274 for (
size_t count = 0; count < 2; count++) {
275 this->thread_pool.emplace_back(task);
277 for (
auto& thread : this->thread_pool) {
285 this->postEvent(&event);
286 this->running.store(
false);
287 this->available_event_cond.notify_all();
288 for (
auto& thread : this->thread_pool) {
289 if (thread.joinable()) {
293 while (!this->event_q.empty()) {
294 event_q.front()->done();
302 if (!this->running) {
306 std::unique_lock<std::mutex> lk(this->event_mut);
307 this->event_q.push(event);
308 this->available_event_cond.notify_one();
318 if (!this->running) {
323 std::unique_lock<std::mutex> lk(this->event_mut);
324 for (
auto& event : events) {
325 this->event_q.push(&event);
328 this->available_event_cond.notify_all();
329 for (
auto& event : events) {
330 if (!event.isdone()) {
338 std::unique_lock<std::shared_mutex> write_lock(this->handlerlist_mut);
339 auto location = std::find(handlerList.begin(), handlerList.end(), handler);
340 if (location == handlerList.end()) {
341 handlerList.push_back(handler);
348 std::unique_lock<std::shared_mutex> write_lock(this->handlerlist_mut);
349 auto location = std::find(handlerList.begin(), handlerList.end(), handler);
350 if (location != handlerList.end()) {
351 handlerList.erase(location);
358 const std::shared_lock<std::shared_mutex> read_lock(this->handlerlist_mut);
359 auto location = std::find(handlerList.begin(), handlerList.end(), handler);
360 return location != handlerList.end();
bool isRegistered(Handler *handler)
void unregisterHandler(Handler *handler)
void registerHandler(Handler *handler)
void postEvent(Object *event)
void setParam(const std::string ¶m_name, const std::any ¶m_value)
bool paramExists(const std::string ¶m_name)
Event::Type getType() const
std::any getParam(const std::string ¶m_name) const
std::string type_to_string(Type event_type)
@ RT_WIDGET_PARAMETER_CHANGE_EVENT
@ THRESHOLD_CROSSING_EVENT
@ RT_DEVICE_UNPAUSE_EVENT
@ SETTINGS_OBJECT_REMOVE_EVENT
@ START_GENICAM_RECORDING_EVENT
@ RT_THREAD_UNPAUSE_EVENT
@ RT_WIDGET_STATE_CHANGE_EVENT
@ SETTINGS_OBJECT_INSERT_EVENT
@ IO_ALL_CONNECTIONS_QUERY_EVENT
@ IO_CONNECTION_QUERY_EVENT
@ PAUSE_GENICAM_RECORDING_EVENT
@ IO_BLOCK_OUTPUTS_QUERY_EVENT
@ STOP_GENICAM_RECORDING_EVENT
void renameOSThread(std::thread &thread, const std::string &name)