Переглянути джерело

Monitor the status even if the file has not set the update time. It is a bit more disk traffic, but it is not worth the hassle to track the individual update states separately, and we are already stating the file unconditionally.

Zachary Kotlarek 14 роки тому
батько
коміт
34573b3ce1
1 змінених файлів з 26 додано та 20 видалено
  1. 26 20
      dmx/rope.pl

+ 26 - 20
dmx/rope.pl

@@ -65,17 +65,20 @@ while (1) {
 		my $mtime = mtime($DATA_DIR . '/PLAY_STATUS');
 		if ($mtime > $updateLast) {
 			$updateLast = $mtime;
+		}
 
-			# Grab the PLAY_STATUS value
-			$playing = 0;
-			my $fh;
-			open($fh, $DATA_DIR . '/PLAY_STATUS')
-			  or die("Unable to open PLAY_STATUS\n");
-			my $text = <$fh>;
-			close($fh);
-			if ($text =~ /1/) {
-				$playing = 1;
-			}
+		# Grab the PLAY_STATUS value
+		$playing = 0;
+		my $fh;
+		open($fh, $DATA_DIR . '/PLAY_STATUS')
+		  or die("Unable to open PLAY_STATUS\n");
+		my $text = <$fh>;
+		close($fh);
+		if ($text =~ /1/) {
+			$playing = 1;
+		}
+		if ($DEBUG) {
+			print STDERR 'Playing: ' . $playing . "\n";
 		}
 	}
 
@@ -84,17 +87,20 @@ while (1) {
 		my $mtime = mtime($DATA_DIR . '/PROJECTOR');
 		if ($mtime > $updateLast) {
 			$updateLast = $mtime;
+		}
 
-			# Grab the PROJECTOR value
-			$projector = 0;
-			my $fh;
-			open($fh, $DATA_DIR . '/PROJECTOR')
-			  or die("Unable to open PROJECTOR\n");
-			my $text = <$fh>;
-			close($fh);
-			if ($text =~ /1/) {
-				$projector = 1;
-			}
+		# Grab the PROJECTOR value
+		$projector = 0;
+		my $fh;
+		open($fh, $DATA_DIR . '/PROJECTOR')
+		  or die("Unable to open PROJECTOR\n");
+		my $text = <$fh>;
+		close($fh);
+		if ($text =~ /1/) {
+			$projector = 1;
+		}
+		if ($DEBUG) {
+			print STDERR 'Projector: ' . $projector . "\n";
 		}
 	}