Index: trunk/tools/examine_burntool_pcontrol.pl
===================================================================
--- trunk/tools/examine_burntool_pcontrol.pl	(revision 25458)
+++ trunk/tools/examine_burntool_pcontrol.pl	(revision 25472)
@@ -5,8 +5,10 @@
 use Getopt::Std;
 
-getopts('hf',\%opt);
+getopts('hfcP',\%opt);
 if (exists($opt{h})) {
     print STDERR "Usage: examine_burntool_pcontrol.pl [-f] <pcontrol.pro>\n";
     print STDERR "         -f          Read all burntool entries, even those commented out.\n";
+    print STDERR "         -c          Print out the needed mysql statement to do a convert. DOES NOT EXECUTE THIS!\n";
+    print STDERR "         -P          Print out the ipp_apply_burntool.pl commands, even if fully updated.\n";
     print STDERR "\n";
     print STDERR "         Reads in the pcontrol.pro file you're using to run burntool, and uses the\n";
@@ -19,4 +21,5 @@
     print STDERR "                  B             Current version value for burntool_state. Burntool succeeded.\n";
     print STDERR "                  b             Old version value for burntool_state. Burntool needs to be rerun.\n";
+    print STDERR "                  ?             No matching rawImfile entry found in database.\n";
     exit(1);
 }
@@ -36,4 +39,5 @@
     print STDERR "GOOD == $burntoolStateGood\n";
 }
+$convert_bt_state = -1.0 * $burntoolStateGood;
 
 # Read a class_id and burntool_state pair, and set the correct cell of the (sorry, global) character array vector
@@ -121,4 +125,6 @@
     # images on a single night.
     $sth = "SELECT exp_id,exp_name,obs_mode,dateobs,class_id,burntool_state,comment FROM rawImfile WHERE dateobs >= '${dmin}' AND dateobs <= '${dmax}' order by dateobs limit 60000";
+
+    $no_sth = "UPDATE rawImfile SET burntool_state = $convert_bt_state WHERE dateobs >= '${dmin}' AND dateobs <= '${dmax}' AND user_1 = 1.0;";
     $data_ref = $db->selectall_arrayref( $sth );
 
@@ -133,4 +139,7 @@
     # Print out query for clarity, and the header:
     print "#### $sth\n";
+    if (exists($opt{c})) {
+	print "#### $no_sth\n";
+    }
     print "#                                                     0       1       2       3       4       5       6       7       \n";
     print "#exp_i exp_name       obs_mode dateobs             nB 0123456701234567012345670123456701234567012345670123456701234567 comment\n";
@@ -176,5 +185,5 @@
 		    }
 		    else {
-			$vector[$j] = '[32m?[m';
+			$vector[$j] = '[36;40;01m?[m';
 		    }
 		}
@@ -192,8 +201,8 @@
 
     # If we didn't find that all 60 chips had succesful burntools run, print out the ipp_apply_burntool.pl command we would need to fix this:
-    if ($burncount != 60) {
+    if (($burncount != 60)||(exists($opt{P}))) {
 	for ($j = 0; $j < 64; $j++) {
 #	    printf("%d %s %d\n",$j, $vector[$j], ($vector[$j] !~ /B/));
-	    if ($vector[$j] !~ /B/) {
+	    if (($vector[$j] !~ /B/)||(exists($opt{P}))) {
 		if ($vector[$j] ne '_') {
 		    $id = sprintf("XY%d%d",int($j / 8),$j % 8);
Index: trunk/tools/ipp_apply_burntool.pl
===================================================================
--- trunk/tools/ipp_apply_burntool.pl	(revision 25458)
+++ trunk/tools/ipp_apply_burntool.pl	(revision 25472)
@@ -67,5 +67,5 @@
 
 # Determine the value of a "good" burntool run.
-my $config_cmd = "$ppConfigDump -camera $camera -dump-camera - | grep BURNTOOL";
+my $config_cmd = "$ppConfigDump -camera $camera -dump-camera - | grep BURNTOOL | uniq";
 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     run ( command => $config_cmd, verbose => $verbose);
@@ -110,5 +110,5 @@
 
 my $files = parse_md_list($metadata) or
-    &my_die("Unable to parse metadat list", $class_id, $dateobs_begin, $dateobs_end, $PS_EXIT_SYS_ERROR);
+    &my_die("Unable to parse metadata list", $class_id, $dateobs_begin, $dateobs_end, $PS_EXIT_SYS_ERROR);
 
 my $REALRUN = 1;
@@ -130,4 +130,5 @@
     
     my $process = 0;
+    my $previousTableStyle = 0;
 
     if ($state == 0) {
@@ -145,14 +146,18 @@
     elsif ($state == $burntoolStateGood) {
 	$process = 0;
-	$previousTable = "infits=$rawImfileReal";
+	$previousTableStyle = 1;
     }
     elsif ($state == -1 * $burntoolStateGood) {
 	$process = 0;
-	$previousTable = "in=$outTableReal";
+#	$previousTable = "in=$outTableReal";
+	$previousTableStyle = -1;
     }
     else {
 	$process = 1;
     }
-
+    if ($REALRUN == 0) {
+	print "##Pretending to process as instructed!\n";
+	$process = 1;
+    }
     if (($process == 1)||($processNext == 1)) {
 	$processNext = 1;
@@ -190,8 +195,19 @@
 	}
 
+	$previousTableStyle = -1;
+	
+	print "\n";
+    }
+    
+    if ($previousTableStyle == 1) {
+	$previousTable = "infits=$rawImfileReal";
+    }
+    elsif ($previousTableStyle == -1) {
 	$previousTable = "in=$outTableReal";
-
-	print "\n";
-    }
+    }
+    else {
+	die "previousTableStyle undefined!\n";
+    }
+    
 }
     
