Просмотр исходного кода

Suspend procesing while under RAVE conditions

Zachary Kotlarek 13 лет назад
Родитель
Сommit
fd2ef9563e
2 измененных файлов с 32 добавлено и 12 удалено
  1. 16 6
      dmx/overhead.pl
  2. 16 6
      dmx/rope.pl

+ 16 - 6
dmx/overhead.pl

@@ -69,6 +69,7 @@ my $stateLast = $state;
 my %exists    = ();
 my $pushLast  = 0;
 my $pullLast  = time();
+my $update    = 0;
 
 # Always force lights out at launch
 DMX::dim({ 'channel' => 4, 'value' => 0, 'time' => 0 });
@@ -76,9 +77,6 @@ DMX::dim({ 'channel' => 4, 'value' => 0, 'time' => 0 });
 # Loop forever
 while (1) {
 
-	# Set anywhere to force an update this cycle
-	my $forceUpdate = 0;
-
 	# State is calculated; use newState to gather data
 	my $newState = $state;
 
@@ -89,6 +87,15 @@ while (1) {
 		$pullLast = time();
 	}
 
+	# Skip processing when in RAVE mode
+	if ($exists{'RAVE'}) {
+		if ($DEBUG) {
+			print STDERR "Suspending normal operation while in RAVE mode\n";
+		}
+		$update = 1;
+		next;
+	}
+
 	# Calculate the new state
 	$stateLast = $state;
 	if ($exists{'LIGHTS'}) {
@@ -104,7 +111,7 @@ while (1) {
 
 	# Force updates on a periodic basis
 	if (time() - $pushLast > $PUSH_TIMEOUT) {
-		$forceUpdate = 1;
+		$update = 1;
 	}
 
 	# Die if we don't see regular updates
@@ -117,15 +124,18 @@ while (1) {
 		if ($DEBUG) {
 			print STDERR 'State change: ' . $stateLast . ' => ' . $state . "\n";
 		}
-		$forceUpdate = 1;
+		$update = 1;
 	}
 
 	# Update the lighting
-	if ($forceUpdate) {
+	if ($update) {
 		# Update
 		DMX::applyDataset($DIM{$state}, $state, $OUTPUT_FILE);
 
 		# Update the push time
 		$pushLast = time();
+
+		# Clear the update flag
+		$update = 0;
 	}
 }

+ 16 - 6
dmx/rope.pl

@@ -97,6 +97,7 @@ my $stateLast = $state;
 my %exists    = ();
 my $pushLast  = 0;
 my $pullLast  = time();
+my $update    = 0;
 
 # Always force lights out at launch
 DMX::dim({ 'channel' => 0, 'value' => 0, 'time' => 0 });
@@ -104,9 +105,6 @@ DMX::dim({ 'channel' => 0, 'value' => 0, 'time' => 0 });
 # Loop forever
 while (1) {
 
-	# Set anywhere to force an update this cycle
-	my $forceUpdate = 0;
-
 	# State is calculated; use newState to gather data
 	my $newState = $state;
 
@@ -117,6 +115,15 @@ while (1) {
 		$pullLast = time();
 	}
 
+	# Skip processing when in RAVE mode
+	if ($exists{'RAVE'}) {
+		if ($DEBUG) {
+			print STDERR "Suspending normal operation while in RAVE mode\n";
+		}
+		$update = 1;
+		next;
+	}
+
 	# Calculate the new state
 	$stateLast = $state;
 	if ($exists{'LIGHTS'}) {
@@ -132,7 +139,7 @@ while (1) {
 
 	# Force updates on a periodic basis
 	if (time() - $pushLast > $PUSH_TIMEOUT) {
-		$forceUpdate = 1;
+		$update = 1;
 	}
 
 	# Die if we don't see regular updates
@@ -145,15 +152,18 @@ while (1) {
 		if ($DEBUG) {
 			print STDERR 'State change: ' . $stateLast . ' => ' . $state . "\n";
 		}
-		$forceUpdate = 1;
+		$update = 1;
 	}
 
 	# Update the lighting
-	if ($forceUpdate) {
+	if ($update) {
 		# Update
 		DMX::applyDataset($DIM{$state}, $state, $OUTPUT_FILE);
 
 		# Update the push time
 		$pushLast = time();
+
+		# Clear the update flag
+		$update = 0;
 	}
 }