Zachary Kotlarek hace 13 años
padre
commit
535ee69d3e
Se han modificado 1 ficheros con 3 adiciones y 17 borrados
  1. 3 17
      dmx/garage.pl

+ 3 - 17
dmx/garage.pl

@@ -24,9 +24,7 @@ my %DIM          = (
 my $DATA_DIR     = DMX::dataDir();
 my $DATA_DIR     = DMX::dataDir();
 my $OUTPUT_FILE  = $DATA_DIR . 'GARAGE';
 my $OUTPUT_FILE  = $DATA_DIR . 'GARAGE';
 my $STATE_SOCK   = $OUTPUT_FILE . '.socket';
 my $STATE_SOCK   = $OUTPUT_FILE . '.socket';
-my $PUSH_TIMEOUT = 20;
-my $PULL_TIMEOUT = $PUSH_TIMEOUT * 3;
-my $DELAY        = $PULL_TIMEOUT / 2;
+my $DELAY        = 30;
 
 
 # Debug
 # Debug
 my $DEBUG = 0;
 my $DEBUG = 0;
@@ -42,7 +40,6 @@ my $state     = 'OFF';
 my $stateLast = $state;
 my $stateLast = $state;
 my %exists    = ();
 my %exists    = ();
 my $pushLast  = 0;
 my $pushLast  = 0;
-my $pullLast  = time();
 my $update    = 0;
 my $update    = 0;
 
 
 # Always force lights out at launch
 # Always force lights out at launch
@@ -52,13 +49,12 @@ DMX::dim({ 'channel' => 16, 'value' => 0, 'time' => 0 });
 while (1) {
 while (1) {
 
 
 	# State is calculated; use newState to gather data
 	# State is calculated; use newState to gather data
-	my $newState = $state;
+	my $newState = 'OFF';
 
 
 	# Wait for state updates
 	# Wait for state updates
 	my $cmdState = DMX::readState($DELAY, \%exists, undef());
 	my $cmdState = DMX::readState($DELAY, \%exists, undef());
 	if (defined($cmdState)) {
 	if (defined($cmdState)) {
 		$newState = $cmdState;
 		$newState = $cmdState;
-		$pullLast = time();
 	}
 	}
 
 
 	# Calculate the new state
 	# Calculate the new state
@@ -69,18 +65,8 @@ while (1) {
 		$state = 'OFF';
 		$state = 'OFF';
 	}
 	}
 
 
-	# Force updates on a periodic basis
-	if (time() - $pushLast > $PUSH_TIMEOUT) {
-		$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 ($state eq 'TOGGLE') {
+	if ($state ne $stateLast) {
 		if ($DEBUG) {
 		if ($DEBUG) {
 			print STDERR 'State change: ' . $stateLast . ' => ' . $state . "\n";
 			print STDERR 'State change: ' . $stateLast . ' => ' . $state . "\n";
 		}
 		}