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

Create a not-quite-RAVE mode called "EFFECT" that disables lighting but does not modify the audio system

Zachary Kotlarek 13 лет назад
Родитель
Сommit
ed4e9bb2a1
5 измененных файлов с 30 добавлено и 13 удалено
  1. 2 2
      dmx/leds.pl
  2. 2 2
      dmx/overhead.pl
  3. 23 7
      dmx/rave.pl
  4. 2 2
      dmx/rope.pl
  5. 1 0
      dmx/state.pl

+ 2 - 2
dmx/leds.pl

@@ -112,8 +112,8 @@ while (1) {
 		die('No update on state socket in past ' . $PULL_TIMEOUT . " seconds. Exiting...\n");
 	}
 	
-	# Skip processing when in RAVE mode
-	if ($exists{'RAVE'}) {
+	# Skip processing when in RAVE or EFFECT mode
+	if ($exists{'RAVE'} || $exists{'EFFECT'}) {
 		if ($DEBUG) {
 			print STDERR "Suspending normal operation while in RAVE mode\n";
 		}

+ 2 - 2
dmx/overhead.pl

@@ -70,8 +70,8 @@ while (1) {
 		die('No update on state socket in past ' . $PULL_TIMEOUT . " seconds. Exiting...\n");
 	}
 
-	# Skip processing when in RAVE mode
-	if ($exists{'RAVE'}) {
+	# Skip processing when in RAVE or EFFECT mode
+	if ($exists{'RAVE'} || $exists{'EFFECT'}) {
 		if ($DEBUG) {
 			print STDERR "Suspending normal operation while in RAVE mode\n";
 		}

+ 23 - 7
dmx/rave.pl

@@ -28,6 +28,7 @@ my $DATA_DIR     = DMX::dataDir();
 my $OUTPUT_FILE  = $DATA_DIR . 'RAVE_CMD';
 my $STATE_SOCK   = $OUTPUT_FILE . '.socket';
 my $RAVE_FILE    = $DATA_DIR . 'RAVE';
+my $EFFECT_FILE  = $DATA_DIR . 'EFFECT';
 my $PUSH_TIMEOUT = 20;
 my $PULL_TIMEOUT = $PUSH_TIMEOUT * 3;
 my $DELAY        = $PULL_TIMEOUT / 2;
@@ -50,10 +51,13 @@ my $PID      = undef();
 my $EFFECT   = undef();
 my $PID_DATA = undef();
 
-# Always clear the RAVE file
+# Always clear the RAVE and EFFECT files
 if (-e $RAVE_FILE) {
 	unlink($RAVE_FILE);
 }
+if (-e $EFFECT_FILE) {
+	unlink($EFFECT_FILE);
+}
 
 # Loop forever
 while (1) {
@@ -113,10 +117,13 @@ while (1) {
 			$EFFECT   = undef();
 			$PID_DATA = undef();
 
-			# Clear the RAVE flag
+			# Clear the RAVE and EFFECT flags
 			if (-e $RAVE_FILE) {
 				unlink($RAVE_FILE);
 			}
+			if (-e $EFFECT_FILE) {
+				unlink($EFFECT_FILE);
+			}
 		}
 	}
 
@@ -129,25 +136,31 @@ while (1) {
 	# Handle effects by name
 	if (defined($EFFECTS{$newState})) {
 
-		# Initiate the RAVE state
-		touch($RAVE_FILE);
+		# Initiate the EFFECT state
+		touch($EFFECT_FILE);
 
 		# Dispatch the effect
 		$EFFECTS{$newState}{'cmd'}(\%exists, $EFFECTS{$newState});
 
-		# Clear the RAVE state if there is no background process
+		# Clear the EFFECT state if there is no background process
 		if (!defined($PID)) {
-			unlink($RAVE_FILE);
+			if (-e $EFFECT_FILE) {
+				unlink($EFFECT_FILE);
+			}
 		}
 
 		next;
 	}
 
-	# Clear the RAVE flag, just in case
+	# Clear the RAVE and EFFECT flags, just in case
 	if (-e $RAVE_FILE) {
 		unlink($RAVE_FILE);
 		die("Unexpected RAVE file\n");
 	}
+	if (-e $EFFECT_FILE) {
+		unlink($EFFECT_FILE);
+		die("Unexpected EFFECT file\n");
+	}
 }
 
 # ======================================
@@ -218,6 +231,9 @@ sub rave_init($$) {
 	stat($SILENCE);
 	stat($effect->{'file'});
 
+	# Initiate the RAVE state
+	touch($RAVE_FILE);
+
 	# Setup our loop handler
 	if ($effect->{'next'}) {
 		$EFFECT = $effect->{'next'};

+ 2 - 2
dmx/rope.pl

@@ -115,8 +115,8 @@ while (1) {
 		die('No update on state socket in past ' . $PULL_TIMEOUT . " seconds. Exiting...\n");
 	}
 
-	# Skip processing when in RAVE mode
-	if ($exists{'RAVE'}) {
+	# Skip processing when in RAVE or EFFECT mode
+	if ($exists{'RAVE'} || $exists{'EFFECT'}) {
 		if ($DEBUG) {
 			print STDERR "Suspending normal operation while in RAVE mode\n";
 		}

+ 1 - 0
dmx/state.pl

@@ -26,6 +26,7 @@ my %MON_FILES     = (
 	'FAN_CMD'   => 'EXISTS',
 	'NO_MOTION' => 'EXISTS',
 	'RAVE'      => 'EXISTS',
+	'EFFECT'    => 'EXISTS',
 	'LIGHTS'    => 'EXISTS_ON',
 
 	'/mnt/media/DMX/cmd/GARAGE_CMD' => 'EXISTS_CLEAR',