From c3cf352b0cc66bd59c50955bb7326ba168a3b541 Mon Sep 17 00:00:00 2001 From: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com> Date: Thu, 26 Mar 2020 19:37:39 +0100 Subject: [PATCH] SIGUSR1/SIGUSR2 implemented again (#725) Signed-off-by: Paulchen-Panther --- include/hyperion/HyperionIManager.h | 6 ++++++ libsrc/hyperion/HyperionIManager.cpp | 10 ++++++++++ src/hyperiond/main.cpp | 8 ++------ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/hyperion/HyperionIManager.h b/include/hyperion/HyperionIManager.h index 0e88bdad..d5e83ee9 100644 --- a/include/hyperion/HyperionIManager.h +++ b/include/hyperion/HyperionIManager.h @@ -67,6 +67,12 @@ public slots: /// bool stopInstance(const quint8& inst); + /// + /// @brief Toggle the state of all Hyperion instances + /// @param pause If true all instances toggle to pause, else to resume + /// + void toggleStateAllInstances(const bool& pause = false); + /// /// @brief Create a new Hyperion instance entry in db /// @param name The friendly name of the instance diff --git a/libsrc/hyperion/HyperionIManager.cpp b/libsrc/hyperion/HyperionIManager.cpp index 2e57015c..0b5e319a 100644 --- a/libsrc/hyperion/HyperionIManager.cpp +++ b/libsrc/hyperion/HyperionIManager.cpp @@ -57,6 +57,16 @@ void HyperionIManager::stopAll() } } +void HyperionIManager::toggleStateAllInstances(const bool& pause) +{ + // copy the instances due to loop corruption, even with .erase() return next iter + QMap instCopy = _runningInstances; + for(const auto instance : instCopy) + { + emit instance->compStateChangeRequest(hyperion::COMP_ALL, pause); + } +} + bool HyperionIManager::startInstance(const quint8& inst, const bool& block) { if(_instanceTable->instanceExist(inst)) diff --git a/src/hyperiond/main.cpp b/src/hyperiond/main.cpp index 17df633a..25f3e21f 100644 --- a/src/hyperiond/main.cpp +++ b/src/hyperiond/main.cpp @@ -115,8 +115,6 @@ unsigned int getProcessIdsByProcessName(const char* processName, QStringList &li void signal_handler(const int signum) { -// SIGUSR1 and SIGUSR2 must be rewritten - // Hyperion Managment instance HyperionIManager* _hyperion = HyperionIManager::getInstance(); @@ -130,8 +128,7 @@ void signal_handler(const int signum) { if (_hyperion != nullptr) { -// _hyperion->setComponentState(hyperion::COMP_SMOOTHING, false); -// _hyperion->setComponentState(hyperion::COMP_LEDDEVICE, false); + _hyperion->toggleStateAllInstances(false); } return; } @@ -139,8 +136,7 @@ void signal_handler(const int signum) { if (_hyperion != nullptr) { -// _hyperion->setComponentState(hyperion::COMP_LEDDEVICE, true); -// _hyperion->setComponentState(hyperion::COMP_SMOOTHING, true); + _hyperion->toggleStateAllInstances(true); } return; }