Zachary Kotlarek 13 лет назад
Родитель
Сommit
aaed2f78da
6 измененных файлов с 22 добавлено и 34 удалено
  1. 15 0
      dmx/DMX.pm
  2. 2 7
      dmx/bias.pl
  3. 1 3
      dmx/fan.pl
  4. 1 10
      dmx/leds.pl
  5. 2 7
      dmx/overhead.pl
  6. 1 7
      dmx/rope.pl

+ 15 - 0
dmx/DMX.pm

@@ -139,5 +139,20 @@ sub dim($) {
 	  or die('Unable to write command to DMX socket: ' . $cmd . ": ${!}\n");
 }
 
+sub printDataset($) {
+	my ($data_set) = @_;
+
+	my $sum = 0;
+	foreach my $data (@{ $data_set }) {
+		$sum += $data->{'value'};
+		my $delay = '';
+		if ($data->{'delay'}) {
+			$delay = ' (Delay: ' . $data->{'delay'} . ')';
+		}
+		print STDERR "\t" . $data->{'channel'} . ' => ' . int($data->{'value'}) . ' @ ' . $data->{'time'} . $delay . "\n";
+	}
+	print STDERR "\tTotal: " . $sum . "\n";
+}
+
 # Always return true
 1;

+ 2 - 7
dmx/bias.pl

@@ -110,13 +110,8 @@ while (1) {
 	# Update the fan state
 	if ($forceUpdate || $stateLast ne $state) {
 		if ($DEBUG) {
-			foreach my $data (@{ $DIM{$state} }) {
-				my $delay = '';
-				if ($data->{'delay'}) {
-					$delay = ' (Delay: ' . $data->{'delay'} . ')';
-				}
-				print STDERR "\t" . $data->{'channel'} . ' => ' . $data->{'value'} . ' @ ' . $data->{'time'} . $delay . "\n";
-			}
+			print STDERR 'State: ' . $stateLast . ' => ' . $state . "\n";
+			DMX::printDataset($DIM{$state});
 		}
 
 		# Send the dim command

+ 1 - 3
dmx/fan.pl

@@ -109,9 +109,7 @@ while (1) {
 	if ($forceUpdate || $stateLast ne $state) {
 		if ($DEBUG) {
 			print STDERR 'State: ' . $stateLast . ' => ' . $state . "\n";
-			foreach my $data (@{ $DIM{$state} }) {
-				print STDERR "\t" . $data->{'channel'} . ' => ' . $data->{'value'} . ' @ ' . $data->{'time'} . "\n";
-			}
+			DMX::printDataset($DIM{$state});
 		}
 
 		# Send the dim command

+ 1 - 10
dmx/leds.pl

@@ -243,17 +243,8 @@ while (1) {
 
 		# Debug
 		if ($DEBUG) {
-			my $sum = 0;
 			print STDERR 'State: ' . $stateLast . ' => ' . $state . ' (Color: ' . scalar(@COLOR) . ")\n";
-			foreach my $data (@{ $DIM{$state} }) {
-				$sum += $data->{'value'};
-				my $delay = '';
-				if ($data->{'delay'}) {
-					$delay = ' (Delay: ' . $data->{'delay'} . ')';
-				}
-				print STDERR "\t" . $data->{'channel'} . ' => ' . $data->{'value'} . ' @ ' . $data->{'time'} . $delay . "\n";
-			}
-			print STDERR "\tTotal: " . $sum . "\n";
+			DMX::printDataset(\@data_set);
 		}
 
 		# Send the dim command

+ 2 - 7
dmx/overhead.pl

@@ -122,13 +122,8 @@ while (1) {
 	# Update the fan state
 	if ($forceUpdate || $stateLast ne $state) {
 		if ($DEBUG) {
-			foreach my $data (@{ $DIM{$state} }) {
-				my $delay = '';
-				if ($data->{'delay'}) {
-					$delay = ' (Delay: ' . $data->{'delay'} . ')';
-				}
-				print STDERR "\t" . $data->{'channel'} . ' => ' . $data->{'value'} . ' @ ' . $data->{'time'} . $delay . "\n";
-			}
+			print STDERR 'State: ' . $stateLast . ' => ' . $state . "\n";
+			DMX::printDataset($DIM{$state});
 		}
 
 		# Send the dim command

+ 1 - 7
dmx/rope.pl

@@ -151,13 +151,7 @@ while (1) {
 	if ($forceUpdate || $stateLast ne $state) {
 		if ($DEBUG) {
 			print STDERR 'State: ' . $stateLast . ' => ' . $state . "\n";
-			foreach my $data (@{ $DIM{$state} }) {
-				my $delay = '';
-				if ($data->{'delay'}) {
-					$delay = ' (Delay: ' . $data->{'delay'} . ')';
-				}
-				print STDERR "\t" . $data->{'channel'} . ' => ' . $data->{'value'} . ' @ ' . $data->{'time'} . $delay . "\n";
-			}
+			DMX::printDataset($DIM{$state});
 		}
 
 		# Send the dim command