Index: /trunk/ippScripts/scripts/register_imfile.pl
===================================================================
--- /trunk/ippScripts/scripts/register_imfile.pl	(revision 30181)
+++ /trunk/ippScripts/scripts/register_imfile.pl	(revision 30182)
@@ -84,6 +84,6 @@
 
 my $cmdflags;
-my $burntoolStateGood;
-my $burntoolState;
+my $burntoolStateTarget;
+my $burntoolStateCurrent;
 # Run ppStats on the input file
 {
@@ -116,11 +116,11 @@
 
     # Manually parse the burntool_state entry.
-    $burntoolState = 0;
+    $burntoolStateCurrent = 0;
     my $isGPC1 = 0;
-    $burntoolStateGood = 0;
+    $burntoolStateTarget = 0;
     foreach my $line (split /\n/, $out1) {
         if ($line =~ /FPA.BURNTOOL.APPLIED/) {
             $line =~ s/^\s+//;
-            $burntoolState = (split /\s+/, $line)[2];
+            $burntoolStateCurrent = (split /\s+/, $line)[2];
         }
         if ($line =~ /FPA.CAMERA/) {
@@ -132,8 +132,8 @@
     }
     if ($isGPC1 != 1) {
-        $burntoolState = 0; # If it's not GPC1, you shouldn't have run burntool.
-    }
-    elsif (($isGPC1 == 1) && ($burntoolState == 1)) {
-#       print STDERR "In the good region: >>$burntoolState<<\n";
+        $burntoolStateCurrent = 0; # If it's not GPC1, you shouldn't have run burntool.
+    }
+    elsif (($isGPC1 == 1) && ($burntoolStateCurrent == 1)) {
+#       print STDERR "In the good region: >>$burntoolStateCurrent<<\n";
         my $ppConfigDump_cmd = "$ppConfigDump -camera GPC1 -dump-camera -";
         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -149,16 +149,18 @@
             if ($line =~ /BURNTOOL.STATE.GOOD/) {
                 $line =~ s/^\s+//;
-                $burntoolStateGood = (split /\s+/, $line)[2];
+                $burntoolStateTarget = (split /\s+/, $line)[2];
                 last;
             }
         }
-        $burntoolState = $burntoolStateGood; # Positive because this has the header table.
-
-    }
-    $cmdflags .= " -burntool_state $burntoolState ";
+        # XXX why was this being equated??
+        # $burntoolState = $burntoolStateGood; # Positive because this has the header table.
+
+    }
+    $cmdflags .= " -burntool_state $burntoolStateTarget ";
 }
 
 $now_time = localtime();
 printf STDERR "\ndone with ppStats: %s\n", $now_time if $verbose;
+printf STDERR "\nburntool state current: %d target: %d\n", $burntoolStateCurrent, $burntoolStateTarget;
 
 # we require at a minimum: -telescope, -inst, -filelevel, -class_id, -exp_type
@@ -178,5 +180,5 @@
 $command .= " -hostname $host" if defined $host;
 $command .= " -dbname $dbname" if defined $dbname;
-if (abs($burntoolState) == $burntoolStateGood) {
+if (abs($burntoolStateCurrent) == $burntoolStateTarget) {
     $command .= " -data_state full";
 }
@@ -222,5 +224,5 @@
 # lock file?
 # if exp_type = DARK and date > MIDNIGHT HST { wait }
-# system("ipp_apply_burntool.pl --class_id $class_id --dateobs_begin $date_start --dateobs_end $date_end --dbname gpc1 --logfile /data/$host.0/burntool_logs/$class_id.$start_date.log"); 
+# system("ipp_apply_burntool.pl --class_id $class_id --dateobs_begin $date_start --dateobs_end $date_end --dbname gpc1 --logfile /data/$host.0/burntool_logs/$class_id.$start_date.log");
 
 $now_time = localtime();
@@ -242,5 +244,5 @@
 # We now have an imfile in the database, check if we can burntool it.  If not, continue on.
 
-if (abs($burntoolState) != $burntoolStateGood) { 
+if (abs($burntoolStateCurrent) != $burntoolStateTarget) {
     my $mdcParser  = PS::IPP::Metadata::Config->new;
 
@@ -249,19 +251,19 @@
     $check_date =~ s/T.*$//;
     my $exp_name   = $tmp_exp_name;
-    
+
 
     my $bt_check_command = "$regtool -checkburntoolimfile ";
     $bt_check_command .= " -class_id $class_id ";
     $bt_check_command .= " -date $check_date ";
-    $bt_check_command .= " -valid_burntool $burntoolStateGood ";
+    $bt_check_command .= " -valid_burntool $burntoolStateTarget ";
     $bt_check_command .= " -exp_name $exp_name ";
     $bt_check_command .= " -dbname $dbname" if defined $dbname;
 
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run ( command => $bt_check_command, verbose => $verbose);
+        run ( command => $bt_check_command, verbose => $verbose);
     unless ($success) {
-	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die_for_update("Unable to perform regtool: $error_code", 
-			   $exp_id, $exp_name, $class_id, $PS_EXIT_SYS_ERROR);
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        &my_die_for_update("Unable to perform regtool: $error_code",
+                           $exp_id, $exp_name, $class_id, $PS_EXIT_SYS_ERROR);
     }
 
@@ -270,20 +272,20 @@
     my $exposures;
     while ( scalar @whole > 0 ) {
-	my $value = shift @whole;
-	push @single, $value;
-	if ($value =~ /^\s*END\s*$/) {
-	    push @single, "\n";
-	    
-	    my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) );
-	    &my_die_for_update("Unable to parse output from regtool", 
-			       $exp_id, $exp_name, $class_id, $PS_EXIT_SYS_ERROR) unless
-				   defined $list;
-	    push @{ $exposures }, @$list;
-	    @single = ();
-	}
-    }
-    
+        my $value = shift @whole;
+        push @single, $value;
+        if ($value =~ /^\s*END\s*$/) {
+            push @single, "\n";
+
+            my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) );
+            &my_die_for_update("Unable to parse output from regtool",
+                               $exp_id, $exp_name, $class_id, $PS_EXIT_SYS_ERROR) unless
+                                   defined $list;
+            push @{ $exposures }, @$list;
+            @single = ();
+        }
+    }
+
     # We only care about the final entry, as that contains the exposure we are.
-    
+
     my $regtool_update = "$regtool -updateprocessedimfile ";
     $regtool_update .= "-dbname $dbname " if defined $dbname;
@@ -292,35 +294,35 @@
     my $burntool_data = pop(@{ $exposures });
     if ($burntool_data->{burnable} == 0) {
-	$regtool_update .= " -burntool_state 0 -set_state pending_burntool ";
-	unless ($no_update) {
-	    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-		IPC::Cmd::run(command => $regtool_update, verbose => $verbose);
-	    unless ($success) {
-		$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-		warn ("Unable to perform regtool -addprocessedimfile: $error_code");
-		exit($error_code);
-	    }
-	} else {
-	    print "skipping command: $command\n";
-	}
+        $regtool_update .= " -burntool_state 0 -set_state pending_burntool ";
+        unless ($no_update) {
+            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+                IPC::Cmd::run(command => $regtool_update, verbose => $verbose);
+            unless ($success) {
+                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+                warn ("Unable to perform regtool -addprocessedimfile: $error_code");
+                exit($error_code);
+            }
+        } else {
+            print "skipping command: $command\n";
+        }
     }
     else {
-	my $apply_command = "$ippApplyBurntoolSingle --dbname $dbname ";
-	$apply_command .= " --class_id $class_id --exp_id $exp_id ";
-	$apply_command .= " --this_uri $burntool_data->{uri} ";
-	$apply_command .= " --previous_uri $burntool_data->{previous_uri} " if defined $burntool_data->{previous_uri};
-	$apply_command .= " --imfile_state $burntool_data->{imfile_state} ";
-	$apply_command .= " --verbose " if $verbose;
-	print "$apply_command\n";
-	unless ($no_update) {
-	    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-		IPC::Cmd::run(command => $apply_command, verbose => $verbose);
-	    unless ($success) {
-		$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-		warn ("Unable to perform ipp_apply_burntool_single.pl: $error_code");
-		exit($error_code);
-	    }
-	}
-    }    
+        my $apply_command = "$ippApplyBurntoolSingle --dbname $dbname ";
+        $apply_command .= " --class_id $class_id --exp_id $exp_id ";
+        $apply_command .= " --this_uri $burntool_data->{uri} ";
+        $apply_command .= " --previous_uri $burntool_data->{previous_uri} " if defined $burntool_data->{previous_uri};
+        $apply_command .= " --imfile_state $burntool_data->{imfile_state} ";
+        $apply_command .= " --verbose " if $verbose;
+        print "$apply_command\n";
+        unless ($no_update) {
+            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+                IPC::Cmd::run(command => $apply_command, verbose => $verbose);
+            unless ($success) {
+                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+                warn ("Unable to perform ipp_apply_burntool_single.pl: $error_code");
+                exit($error_code);
+            }
+        }
+    }
 
 
