Index: trunk/ippScripts/scripts/chip_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/chip_imfile.pl	(revision 42388)
+++ trunk/ippScripts/scripts/chip_imfile.pl	(revision 42394)
@@ -86,4 +86,6 @@
 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR );
 
+my $burntoolStateGood;
+my $burntoolStateGoodUpdate;
 my $neb;
 my $scheme = file_scheme($outroot);
@@ -292,30 +294,43 @@
 
         ## Read camera config to get the current good burntool state :
-        ## XXX This is extremely slow. Any better way to do this?
-        ## my $camera_config_cmd = "$ppConfigDump -camera $camera -dump-camera -";
-        ## ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        ##     run(command => $camera_config_cmd, verbose => 0);
-        ## unless ($success) {
-        ##     $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-        ##     &my_die("Unable to perform ppConfigDump: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
-        ## }
-        ##
-        ## my $camData = $mdcParser->parse(join "", @$stdout_buf) or
-        ##     &my_die("Unable to parse ppConfigDump metadata", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
-
-        ## XXX short term hack until we have a C-based parser
-        my $burntoolStateGood = 14;
-        my $burntoolStateGoodUpdate = 13;
-        ## foreach my $camEntry (@$camData) {
-        ##     if ($camEntry->{name} eq "BURNTOOL.STATE.GOOD") {
-        ##         $burntoolStateGood = $camEntry->{value};
-        ##     }
-        ##     if ($camEntry->{name} eq "BURNTOOL.STATE.GOOD.UPDATE") {
-        ##         $burntoolStateGoodUpdate = $camEntry->{value};
-        ##     }
-        ## }
+        my $ppConfigDump_cmd = "$ppConfigDump -camera GPC1 -get-key BURNTOOL.STATE.GOOD";
+        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+            IPC::Cmd::run(command => $ppConfigDump_cmd, verbose => $verbose);
+        unless ($success) {
+            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+            warn ("Unable to perform ppConfigDump");
+            exit($error_code);
+        }
+
+        # This is ugly, but doing a full parse for one entry is a bit wasteful.
+        foreach my $line (split /\n/, (join "", @$stdout_buf)) {
+            if ($line =~ /BURNTOOL.STATE.GOOD/) {
+                $line =~ s/^\s+//;
+                $burntoolStateGood = (split /\s+/, $line)[2];
+                last;
+            }
+        }
+
+        my $ppConfigDump_cmd = "$ppConfigDump -camera GPC1 -get-key BURNTOOL.STATE.GOOD.UPDATE";
+        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+            IPC::Cmd::run(command => $ppConfigDump_cmd, verbose => $verbose);
+        unless ($success) {
+            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+            warn ("Unable to perform ppConfigDump");
+            exit($error_code);
+        }
+
+        # This is ugly, but doing a full parse for one entry is a bit wasteful.
+        foreach my $line (split /\n/, (join "", @$stdout_buf)) {
+            if ($line =~ /BURNTOOL.STATE.GOOD.UPDATE/) {
+                $line =~ s/^\s+//;
+                $burntoolStateGoodUpdate = (split /\s+/, $line)[2];
+                last;
+            }
+        }
 
         if ($run_state eq 'new') {
             print "burntool state vs burntoolStateGood : $burntoolState vs $burntoolStateGood\n";
+            $useBestBurntool = 0 if (abs($burntoolState) >= $burntoolStateGoodUpdate);
         } else {
             # if doing update go ahead if burntoolState is at least at BURNTOOL.STATE.GOOD.UPDATE
@@ -369,5 +384,9 @@
         if ($ppImageApplyBurntool && ($burntoolState == -1 * $burntoolStateGood)) {
             my $burntoolTable_uri = $uri;
-            $burntoolTable_uri =~ s/fits$/burn.tbl/;
+            if($burntoolStateGood >= 15) {
+              $burntoolTable_uri =~ s/fits$/burn.v15.tbl/;	    
+            } else {
+              $burntoolTable_uri =~ s/fits$/burn.tbl/;  	    
+            }
             my $burntoolTable_uriReal = $ipprc->file_resolve( $burntoolTable_uri );
             if ((!$burntoolTable_uriReal)||(!($ipprc->file_exists($burntoolTable_uri)))) {
@@ -416,5 +435,9 @@
             if ($burntoolState == -1 * $burntoolStateGood) {   # Burntool information stored in an external table.
                 $burntoolTable_uri = $uri;
-                $burntoolTable_uri =~ s/fits$/burn.tbl/;
+                if($burntoolStateGood >= 15) {
+                  $burntoolTable_uri =~ s/fits$/burn.v15.tbl/;	    
+                } else {
+                  $burntoolTable_uri =~ s/fits$/burn.tbl/;  	    
+                }
                 $burntoolTable_uriReal = $ipprc->file_resolve( $burntoolTable_uri );
                 if ((!$burntoolTable_uriReal)||(!($ipprc->file_exists($burntoolTable_uri)))) {
Index: trunk/ippScripts/scripts/dist_bundle.pl
===================================================================
--- trunk/ippScripts/scripts/dist_bundle.pl	(revision 42388)
+++ trunk/ippScripts/scripts/dist_bundle.pl	(revision 42394)
@@ -75,4 +75,5 @@
 my $file_cmd   = can_run('file') or (warn "can't find program file" and $missing_tools = 1);
 my $zcat   = can_run('zcat') or (warn "can't find program zcat" and $missing_tools = 1);
+my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
 if ($missing_tools) {
     warn("Can't find required tools.");
@@ -131,4 +132,27 @@
 }
 
+# Determine the value of a "good" burntool run.
+my $config_cmd = "$ppConfigDump -camera $camera -get-key BURNTOOL.STATE.GOOD";
+my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+    run ( command => $config_cmd, verbose => $verbose);
+unless ($success) {
+    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+    &my_die("Unable to perform ppConfigDump: $error_code", 0, 0, $class_id, $PS_EXIT_SYS_ERROR);
+}
+
+my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or
+    &my_die("Unable to parse metadata config doc", 0, 0, $class_id, $PS_EXIT_SYS_ERROR);
+
+my $burntoolStateGood = 999;
+foreach my $cfg (@$recipeData) {
+    if ($cfg->{name} eq 'BURNTOOL.STATE.GOOD') {
+        $burntoolStateGood = $cfg->{value};
+    }
+}
+if ($burntoolStateGood == 999) {
+    &my_die("Failed to determine BURNTOOL.STATE.GOOD", $burntoolStateGood, $class_id, 0, $PS_EXIT_SYS_ERROR);
+}
+
+
 $ipprc->redirect_output($logfile) if $logfile;
 
@@ -144,5 +168,5 @@
 # note: We my_die in get_file_list if something goes wrong.
 
-my $file_list = get_file_list($stage, $component, $path_base, $clean, $num_sky_inputs);
+my $file_list = get_file_list($stage, $component, $path_base, $clean, $num_sky_inputs,$burntoolStateGood);
 
 if (($stage ne 'raw') and ($stage ne 'fake') and ($stage ne 'stack_summary') and !$poor_quality) {
@@ -555,4 +579,5 @@
     my $clean = shift;
     my $num_sky_inputs = shift;
+    my $bt_state_good = shift;
 
     my @file_list;
@@ -576,5 +601,10 @@
                 my %burntool_table;
                 $burntool_table{file_rule} = "BURNTOOL.TABLE";
-                $burntool_table{name} = "$path_base.burn.tbl";
+		
+    		if($bt_state_good == 15) {
+    		    $burntool_table{name} = "$path_base.burn.v15.tbl";	
+    		} else {
+    		    $burntool_table{name} = "$path_base.burn.tbl";		
+    		}		
                 push @file_list, \%burntool_table;
             }
Index: trunk/ippScripts/scripts/ipp_apply_burntool.pl
===================================================================
--- trunk/ippScripts/scripts/ipp_apply_burntool.pl	(revision 42388)
+++ trunk/ippScripts/scripts/ipp_apply_burntool.pl	(revision 42394)
@@ -146,5 +146,10 @@
 
     my $outTable  = $file->{uri};
-    $outTable  =~ s/fits$/burn.tbl/;
+    
+    if($burntoolStateGood == 15) {
+        $outTable =~ s/fits$/burn.v15.tbl/;	    
+    } else {
+        $outTable =~ s/fits$/burn.tbl/;  	    
+    }
     my $outTableReal = $ipprc->file_resolve($outTable, 1);
 
Index: trunk/ippScripts/scripts/ipp_apply_burntool_fix.pl
===================================================================
--- trunk/ippScripts/scripts/ipp_apply_burntool_fix.pl	(revision 42388)
+++ trunk/ippScripts/scripts/ipp_apply_burntool_fix.pl	(revision 42394)
@@ -15,4 +15,5 @@
 my $missing_tools;
 my $regtool = can_run('regtool') or (warn "Can't find regtool" and $missing_tools = 1);
+my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
 my $burntool = can_run('ipp_apply_burntool_single.pl') or (warn "Can't find ipp_burntool_apply_single.pl" and $missing_tools = 1);
 if ($missing_tools) {
@@ -65,7 +66,35 @@
 die "failed to find uri in regtool output" unless $uri;
 
+# Determine the value of a "good" burntool run.
+my $config_cmd = "$ppConfigDump -camera $camera -get-key BURNTOOL.STATE.GOOD";
+my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+    run ( command => $config_cmd, verbose => $verbose);
+unless ($success) {
+    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+    carp("Unable to perform ppConfigDUmp $command: $error_code");
+    exit $error_code;
+}
+
+my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or die("Unable to parse Config metadata");
+
+my $burntoolStateGood = 999;
+foreach my $cfg (@$recipeData) {
+    if ($cfg->{name} eq 'BURNTOOL.STATE.GOOD') {
+        $burntoolStateGood = $cfg->{value};
+    }
+}
+if ($burntoolStateGood == 999) {
+    die("Failed to determine BURNTOOL.STATE.GOOD");
+}
+
+
 # Construct burntool table name
 my $table;
-($table = $uri) =~ s/\.fits/\.burn\.tbl/;
+if($burntoolStateGood == 15) {
+    ($table = $uri) =~ s/\.fits/\.burn\.v15\.tbl/;	
+} else {
+    ($table = $uri) =~ s/\.fits/\.burn\.tbl/;		
+}
+
 print "$table\n";
 
Index: trunk/ippScripts/scripts/ipp_apply_burntool_single.pl
===================================================================
--- trunk/ippScripts/scripts/ipp_apply_burntool_single.pl	(revision 42388)
+++ trunk/ippScripts/scripts/ipp_apply_burntool_single.pl	(revision 42394)
@@ -178,5 +178,10 @@
     
     my $outTable  = $this_uri;
-    $outTable  =~ s/fits$/burn.tbl/;
+    if($burntoolStateGood == 15) {
+        $outTable =~ s/fits$/burn.v15.tbl/;	    
+    } else {
+        $outTable =~ s/fits$/burn.tbl/;  	    
+    }
+
     my $outTableReal = $ipprc->file_resolve($outTable, 1);
     if (!$outTableReal) {
@@ -188,5 +193,9 @@
     if ($previous_uri) {
 	$previousTable = $previous_uri;
-	$previousTable =~ s/fits$/burn.tbl/;
+        if($burntoolStateGood == 15) {
+            $previousTable =~ s/fits$/burn.v15.tbl/;	    
+        } else {
+            $previousTable =~ s/fits$/burn.tbl/;  	    
+        }
 	$previousTableReal = $ipprc->file_resolve($previousTable, 0);
         if (!$previousTableReal) {
@@ -219,7 +228,9 @@
 # burntool
     if (($previousTableReal)&&($previousTableReal ne '')) {
+        print "Running: $burntool $tempPixels in=$previousTableReal out=$outTableReal tableonly=t persist=t\n";
 	$status = vsystem ("$burntool $tempPixels in=$previousTableReal out=$outTableReal tableonly=t persist=t", $REALRUN);
     }
     else {
+        print "Running: $burntool $tempPixels out=$outTableReal tableonly=t persist=t\n";
 	$status = vsystem ("$burntool $tempPixels out=$outTableReal tableonly=t persist=t", $REALRUN);
     }
Index: trunk/ippScripts/scripts/permcheck.pl
===================================================================
--- trunk/ippScripts/scripts/permcheck.pl	(revision 42388)
+++ trunk/ippScripts/scripts/permcheck.pl	(revision 42394)
@@ -375,7 +375,12 @@
 	    if ($product eq 'BURN.TABLE.DOESNT.HAVE.A.PRODUCT') {
 		my $bt_state = $entry->{burntool_state};
-		if ($bt_state != -14) { next; }
+		if ($bt_state > -14) { next; }
 		my $bt_file = $entry->{uri};
-		$bt_file    =~ s/fits$/burn.tbl/;
+
+                if($bt_state <= -15) {
+                  $bt_file =~ s/fits$/burn.v15.tbl/;	    
+                } else {
+                  $bt_file =~ s/fits$/burn.tbl/;  	    
+                }
 		push @keys, $bt_file;
 
Index: trunk/ippScripts/scripts/sc_prepare_chip.pl
===================================================================
--- trunk/ippScripts/scripts/sc_prepare_chip.pl	(revision 42388)
+++ trunk/ippScripts/scripts/sc_prepare_chip.pl	(revision 42394)
@@ -260,9 +260,37 @@
 	}
 
+
+        # Determine the value of a "good" burntool run.
+        my $config_cmd = "$ppConfigDump -camera $camera -get-key BURNTOOL.STATE.GOOD";
+        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+            run ( command => $config_cmd, verbose => $verbose);
+        unless ($success) {
+            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+            &my_die("Unable to perform ppConfigDump: $error_code", $exp_id, $class_id, $PS_EXIT_SYS_ERROR);
+        }
+
+        my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or
+            &my_die("Unable to parse metadata config doc", $exp_id, $class_id, $PS_EXIT_SYS_ERROR);
+
+        my $burntoolStateGood = 999;
+        foreach my $cfg (@$recipeData) {
+            if ($cfg->{name} eq 'BURNTOOL.STATE.GOOD') {
+                $burntoolStateGood = $cfg->{value};
+            }
+        }
+        if ($burntoolStateGood == 999) {
+            &my_die("Failed to determine BURNTOOL.STATE.GOOD", $exp_id, $class_id, $PS_EXIT_SYS_ERROR);
+        }
+
+
 	# The image exists, so continue.  This resets the variables, but also outputs the file locations.
 	($ipp_uri, $remote_uri) = uri_to_outputs_raw($uri);
         my $btt = $uri;
-        $btt =~ s/fits$/burn.tbl/;
-
+        if($burntoolStateGood == 15) {
+            $btt =~ s/fits$/burn.v15.tbl/;    
+        } else {
+            $btt =~ s/fits$/burn.tbl/;	    
+        }
+	
 	# Check burntool table for existance, and if it doesn't, regenerate it.
         my ($ipp_btt, $remote_btt) = uri_convert($btt);
