瀏覽代碼

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";
 		}
 	}