Index: trunk/ippScripts/scripts/chip_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/chip_imfile.pl	(revision 40387)
+++ 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)))) {
