|
@@ -139,6 +139,11 @@ while (1) {
|
|
|
$newState = $cmdState;
|
|
$newState = $cmdState;
|
|
|
$pullLast = time();
|
|
$pullLast = time();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ # Die if we don't see regular updates
|
|
|
|
|
+ if (time() - $pullLast > $PULL_TIMEOUT) {
|
|
|
|
|
+ die('No update on state socket in past ' . $PULL_TIMEOUT . " seconds. Exiting...\n");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
# Handle "STOP" commands
|
|
# Handle "STOP" commands
|
|
|
if ($newState eq 'STOP') {
|
|
if ($newState eq 'STOP') {
|
|
@@ -250,27 +255,25 @@ while (1) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
# Force updates on a periodic basis
|
|
# Force updates on a periodic basis
|
|
|
- if (time() - $pushLast > $PUSH_TIMEOUT) {
|
|
|
|
|
|
|
+ if (!$update && time() - $pushLast > $PUSH_TIMEOUT) {
|
|
|
|
|
+ if ($DEBUG) {
|
|
|
|
|
+ print STDERR "Forcing periodic update\n";
|
|
|
|
|
+ }
|
|
|
$update = 1;
|
|
$update = 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- # Die if we don't see regular updates
|
|
|
|
|
- if (time() - $pullLast > $PULL_TIMEOUT) {
|
|
|
|
|
- die('No update on state socket in past ' . $PULL_TIMEOUT . " seconds. Exiting...\n");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
# Force updates on any state change
|
|
# Force updates on any state change
|
|
|
- if ($stateLast ne $state) {
|
|
|
|
|
|
|
+ if (!$update && $stateLast ne $state) {
|
|
|
if ($DEBUG) {
|
|
if ($DEBUG) {
|
|
|
print STDERR 'State change: ' . $stateLast . ' => ' . $state . "\n";
|
|
print STDERR 'State change: ' . $stateLast . ' => ' . $state . "\n";
|
|
|
}
|
|
}
|
|
|
$update = 1;
|
|
$update = 1;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
# Reset the color change sequence, so we always spend 1 cycle at white
|
|
# Reset the color change sequence, so we always spend 1 cycle at white
|
|
|
@COLOR = ();
|
|
@COLOR = ();
|
|
|
$colorChange = time() + $COLOR_TIME_MIN;
|
|
$colorChange = time() + $COLOR_TIME_MIN;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
# Update the lighting
|
|
# Update the lighting
|
|
|
if ($update) {
|
|
if ($update) {
|
|
|
|
|
|