Skip to content

Commit c3cf352

Browse files
SIGUSR1/SIGUSR2 implemented again (#725)
Signed-off-by: Paulchen-Panther <Paulchen-Panter@protonmail.com>
1 parent aaa4235 commit c3cf352

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

include/hyperion/HyperionIManager.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ public slots:
6767
///
6868
bool stopInstance(const quint8& inst);
6969

70+
///
71+
/// @brief Toggle the state of all Hyperion instances
72+
/// @param pause If true all instances toggle to pause, else to resume
73+
///
74+
void toggleStateAllInstances(const bool& pause = false);
75+
7076
///
7177
/// @brief Create a new Hyperion instance entry in db
7278
/// @param name The friendly name of the instance

libsrc/hyperion/HyperionIManager.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ void HyperionIManager::stopAll()
5757
}
5858
}
5959

60+
void HyperionIManager::toggleStateAllInstances(const bool& pause)
61+
{
62+
// copy the instances due to loop corruption, even with .erase() return next iter
63+
QMap<quint8, Hyperion*> instCopy = _runningInstances;
64+
for(const auto instance : instCopy)
65+
{
66+
emit instance->compStateChangeRequest(hyperion::COMP_ALL, pause);
67+
}
68+
}
69+
6070
bool HyperionIManager::startInstance(const quint8& inst, const bool& block)
6171
{
6272
if(_instanceTable->instanceExist(inst))

src/hyperiond/main.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ unsigned int getProcessIdsByProcessName(const char* processName, QStringList &li
115115

116116
void signal_handler(const int signum)
117117
{
118-
// SIGUSR1 and SIGUSR2 must be rewritten
119-
120118
// Hyperion Managment instance
121119
HyperionIManager* _hyperion = HyperionIManager::getInstance();
122120

@@ -130,17 +128,15 @@ void signal_handler(const int signum)
130128
{
131129
if (_hyperion != nullptr)
132130
{
133-
// _hyperion->setComponentState(hyperion::COMP_SMOOTHING, false);
134-
// _hyperion->setComponentState(hyperion::COMP_LEDDEVICE, false);
131+
_hyperion->toggleStateAllInstances(false);
135132
}
136133
return;
137134
}
138135
else if (signum == SIGUSR2)
139136
{
140137
if (_hyperion != nullptr)
141138
{
142-
// _hyperion->setComponentState(hyperion::COMP_LEDDEVICE, true);
143-
// _hyperion->setComponentState(hyperion::COMP_SMOOTHING, true);
139+
_hyperion->toggleStateAllInstances(true);
144140
}
145141
return;
146142
}

0 commit comments

Comments
 (0)