Ver Fonte

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 há 14 anos atrás
pai
commit
34573b3ce1
1 ficheiros alterados com 26 adições e 20 exclusões
  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";
 		}
 	}