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

Check the change time of the projector file, in addition to the state. This avoid situations where the projector is powered down immediately after power-up due to Plex timeout.

Zachary Kotlarek 14 лет назад
Родитель
Сommit
8c3722a870
1 измененных файлов с 9 добавлено и 4 удалено
  1. 9 4
      projector/projectorPower.pl

+ 9 - 4
projector/projectorPower.pl

@@ -48,21 +48,21 @@ while (1) {
 
 
 	# Monitor the GUI and PLAYING files for changes only
 	# Monitor the GUI and PLAYING files for changes only
 	{
 	{
-		my $mtime = mtime($DATA_DIR . '/PLAYING');
+		my $mtime = mtime($DATA_DIR . 'PLAYING');
 		if ($mtime > $updateLast) {
 		if ($mtime > $updateLast) {
 			$updateLast = $mtime;
 			$updateLast = $mtime;
 		}
 		}
-		$mtime = mtime($DATA_DIR . '/GUI');
+		$mtime = mtime($DATA_DIR . 'GUI');
 		if ($mtime > $updateLast) {
 		if ($mtime > $updateLast) {
 			$updateLast = $mtime;
 			$updateLast = $mtime;
 		}
 		}
 	}
 	}
 
 
-	# Monitor the PROJECTOR file for state only
+	# Monitor the PROJECTOR file for state and changes
 	{
 	{
 		$projector = 0;
 		$projector = 0;
 		my $fh;
 		my $fh;
-		open($fh, $DATA_DIR . '/PROJECTOR')
+		open($fh, $DATA_DIR . 'PROJECTOR')
 		  or die("Unable to open PROJECTOR\n");
 		  or die("Unable to open PROJECTOR\n");
 		my $text = <$fh>;
 		my $text = <$fh>;
 		close($fh);
 		close($fh);
@@ -72,6 +72,11 @@ while (1) {
 		if ($DEBUG) {
 		if ($DEBUG) {
 			print STDERR 'Projector: ' . $projector . "\n";
 			print STDERR 'Projector: ' . $projector . "\n";
 		}
 		}
+
+		$mtime = mtime($DATA_DIR . 'PROJECTOR');
+		if ($mtime > $updateLast) {
+			$updateLast = $mtime;
+		}
 	}
 	}
 
 
 	# Calculate the new state
 	# Calculate the new state