Explorar el Código

Make ALARM persistent with the master state

Zachary Kotlarek hace 12 años
padre
commit
03a2bc2648
Se han modificado 1 ficheros con 16 adiciones y 13 borrados
  1. 16 13
      dmx/state.pl

+ 16 - 13
dmx/state.pl

@@ -232,6 +232,9 @@ foreach my $name (keys(%MON_FILES)) {
 	if ($attr{'extra'}) {
 	if ($attr{'extra'}) {
 		$attr{'no_value'} = 1;
 		$attr{'no_value'} = 1;
 	}
 	}
+	if ($attr{'no_value'}) {
+		$attr{'no_update'} = 1;
+	}
 	if ($attr{'line'}) {
 	if ($attr{'line'}) {
 		$attr{'value'} = 1;
 		$attr{'value'} = 1;
 	}
 	}
@@ -276,7 +279,7 @@ my $startTime       = time() + $START_DELAY;
 my $pushLast        = 0;
 my $pushLast        = 0;
 
 
 # Announce startup
 # Announce startup
-DMX::say('System initalizing');
+DMX::say('System initializing');
 
 
 # Loop forever
 # Loop forever
 while (1) {
 while (1) {
@@ -477,18 +480,6 @@ while (1) {
 		}
 		}
 	}
 	}
 
 
-	# Determine if we should ALARM before anything else
-	{
-		my $alarm = 0;
-		if (exists($files{'LOCK'}) && $files{'LOCK'}->{'value'} && exists($files{'MOTION'}) && $files{'MOTION'}->{'value'}) {
-			$alarm = 1;
-		}
-		if (!exists($files{'ALARM'}->{'value'}) || $files{'ALARM'}->{'value'} != $alarm) {
-			$files{'ALARM'}->{'update'} = $now;
-		}
-		$files{'ALARM'}->{'value'} = $alarm;
-	}
-
 	# Simulate the old GUI indicator
 	# Simulate the old GUI indicator
 	{
 	{
 		my $gui = 0;
 		my $gui = 0;
@@ -585,6 +576,18 @@ while (1) {
 		$state = 'OFF';
 		$state = 'OFF';
 	}
 	}
 
 
+	# ALARM if LOCK exists and the master state is not OFF
+	{
+		my $alarm = 0;
+		if (exists($files{'LOCK'}) && $files{'LOCK'}->{'value'} && $state ne 'OFF') {
+			$alarm = 1;
+		}
+		if (!exists($files{'ALARM'}->{'value'}) || $files{'ALARM'}->{'value'} != $alarm) {
+			$files{'ALARM'}->{'update'} = $now;
+		}
+		$files{'ALARM'}->{'value'} = $alarm;
+	}
+
 	# Clear EXISTS_ON files when the main state is "OFF" (and before we append their status)
 	# Clear EXISTS_ON files when the main state is "OFF" (and before we append their status)
 	foreach my $file (values(%files)) {
 	foreach my $file (values(%files)) {
 		if (   $file->{'attr'}->{'clear_off'}
 		if (   $file->{'attr'}->{'clear_off'}