Index: /trunk/tools/eam/burntool.20250520/src/burntool.pt
===================================================================
--- /trunk/tools/eam/burntool.20250520/src/burntool.pt	(revision 42907)
+++ /trunk/tools/eam/burntool.20250520/src/burntool.pt	(revision 42908)
@@ -1,66 +1,25 @@
-## pantasks scripts to manage the raw exposure data repair / cleanup
-## this is for the initial chip instance checks
-## use the top-level rawfix.pt to load
-
-if (not($?RAWFIX_BURNTOOL_INIT))
-  book init burntool.book
-  book init burnhost.book
-  $RAWFIX_BURNTOOL_INIT = 1
-end
-
-$MAX_BURNHOST = 2
-
-# select nights in state burntool.new
-# output: burntool.book
-task nights.burntool.load
-  host local
-  periods -poll $TPOLL
-  periods -exec $TEXEC
-  periods -timeout 30
-
-  stdout $LOGDIR/burntool.load.stdout.log  
-  stderr $LOGDIR/burntool.load.stderr.log
-
-  # only run one of these tasks at a time
-  npending 1
-
-  task.exec
-    command check.rawfix.sh state burntool.new 
-  end
-
-  task.exit 0
-    # convert the stdout 'queue' to entries in a book
-    # fields in the table will become words in the page
-    queue2book -raw-columns -key dateobs -uniq -setword pantaskState INIT -setword pantasksQuality OK stdout burntool.book
-    book delpage burntool.book -key pantaskState DONE
-  end
-
-  # exit values other than 0:
-  task.exit    default
-    showcommand failure
-  end
-
-  task.exit    crash
-    showcommand crash
-  end
-
-  # operation times out?
-  task.exit    timeout
-    showcommand timeout
-  end
-end
-
-# output: burnhost.book
-task nights.burntool.loadhosts
+## pantasks script to manage the burntool processing
+
+if (not($?BURNTOOL_INIT))
+  book init XXX
+  book init XXX
+  $BURNTOOL_BOOKS:n = 0; # total number of books available
+  $BURNTOOL_BOOKS:N = 0; # current book of interest
+  $BURNTOOL_INIT = 1
+  $MAX_BURNHOST = 2
+end
+
+# burntool_night_chip.pl : run once per night/chip, output used to generate a book with name like YYYYMMDD.XXnn
+
+# we use the following lists 
+# BURNTOOL_BOOK_NAME  : list of the names of the night/chip books
+# BURNTOOL_BOOK_PAGE  : current active item in this book
+# BURNTOOL_BOOK_STATE : status of current active item (
+
+# run a single night/exposure/chip job
+task burntool.onechip.run
   periods      -poll $RPOLL
   periods      -exec $REXEC
-  periods      -timeout 60
-  host		local
-  npending 1
-  # note: the tasks which return their results via stdout
-  # seem to fail if run remotely.  
-
-  stdout $LOGDIR/burntool.loadhosts.stdout.log  
-  stderr $LOGDIR/burntool.loadhosts.stderr.log
+  periods      -timeout 1800
 
   task.exec
@@ -68,103 +27,76 @@
     periods -exec $REXEC
 
-    book npages burntool.book -var N
+    # if we have reached the end, restart the loop over books
+    if ($BURNTOOL_BOOK_NVAL >= $BURNTOOL_BOOK_NAME:n)
+      $BURNTOOL_BOOK_NVAL = 0
+      break
+    end
+    
+    # allowed state for a given book:
+    # RUN : current entry is still running
+    # STOP : current entry is done, ready for next entry
+    # WAIT : current entry has not yet started
+    # DONE : entry book is done
+
+    # only this task may manipulate $BURNTOOL_BOOK_NVAL or $BURNTOOL_BOOK_PAGE:i
+
+    # state of the current book
+    $myState = $BURNTOOL_BOOK_STATE:$BURNTOOL_BOOK_NVAL
+
+    # if the current page in the current book is running, go to the next book
+    if ("$myState" == "RUN")
+      $BURNTOOL_BOOK_NVAL ++
+      periods -exec 0.05
+      break
+    end
+
+    # if the current page in the current book is done, go to the next page
+    # (advance page counter and set state to WAIT)
+    if ("$myState" == "STOP")
+      # advance to the next entry
+      $BURNTOOL_BOOK_STATE:$BURNTOOL_BOOK_NVAL = WAIT
+      $BURNTOOL_BOOK_PAGE:$BURNTOOL_BOOK_NVAL ++
+      $BURNTOOL_BOOK_NVAL ++
+      periods -exec 0.05
+      break
+    end
+
+    # if the current page in the current book is done, go to the next book
+    if ("$myState" == "DONE")
+      $BURNTOOL_BOOK_NVAL ++
+      periods -exec 0.05
+      break
+    end
+
+    $myBook = $BURNTOOL_BOOK_NAME:$BURNTOOL_BOOK_NVAL
+    $myPage = $BURNTOOL_BOOK_PAGE:$BURNTOOL_BOOK_NVAL
+
+    # if the current page in the current book is done, go to the next book
+    if ("$myState" != "WAIT")
+      echo "unexpected state for book $myBook ($BURNTOOL_BOOK_NVAL)
+      $BURNTOOL_BOOK_NVAL ++
+      break
+    end
+
+    book npages $myBook -var N
     if ($N == 0) break
     if ($NETWORK == 0) break
     
-    # look for new nights in burntool.book (pantaskState == INIT)
-    book getpage burntool.book 0 -var pageName -key pantaskState INIT
+    # select current page in book
+    book getpage $myBook $myPage -var pageName
     if ("$pageName" == "NULL") break
 
-    book setword burntool.book $pageName pantaskState RUN
-    book getword burntool.book $pageName dateobs -var DATEOBS
-    book getword burntool.book $pageName iter    -var ITER
-    option $pageName
-    # save the page so we can use it below
-
-    substr $DATEOBS 0 4 YEAR
-
-    # write an entry point in the log for this night
-    sprintf tmpline "%s/%s/%s/log.burntool.runhosts.v%d" $mypath $YEAR $DATEOBS $ITER
-    date -var mydate
-    exec echo "\\# start runhosts $mydate" >> $tmpline
-
-    # get_hosts_fixchip.sh selects the most used machine at ITC
-    # the command returns these fields: dateobs stage fixhost chipID
-    # NOTE: stage == ITER
-    command get_hosts_fixchip.sh $mypath $DATEOBS $ITER
-  end
-
-  task.exit 0
-    # convert the stdout 'queue' to entries in a book
-    # fields in the table will become words in the page
-    # queueprint stdout
-    queuesize stdout -var Nhosts
-    queue2book -raw-columns -key dateobs:chipID -uniq -setword pantaskState INIT stdout burnhost.book
-    book setword burntool.book $options:0 NHOST {$Nhosts - 1}
-    book setword burntool.book $options:0 NDONE 0
-    # book list
-    # book listbook burntool.book
-    # use the queuesize (Nhosts) to track how many jobs are done / to be done
-  end
-
-  # exit values other than 0:
-  task.exit    default
-    showcommand failure
-    book setword burntool.book $options:0 pantasksQuality FAIL
-  end
-
-  task.exit    crash
-    showcommand crash
-    book setword burntool.book $options:0 pantasksQuality CRASH
-  end
-
-  # operation times out?
-  task.exit    timeout
-    showcommand timeout
-    book setword burntool.book $options:0 pantasksQuality TIMEOUT
-  end
-end
-
-task nights.burntool.run
-  periods      -poll $RPOLL
-  periods      -exec $REXEC
-  periods      -timeout 1800
-
-  task.exec
-    # if we are unable to run the 'exec', use a long retry time
-    periods -exec $REXEC
-
-    book npages burnhost.book -var N
-    if ($N == 0) break
-    if ($NETWORK == 0) break
-    
-    # look for new nights in burnhost.book (pantaskState == INIT)
-    book getpage burnhost.book 0 -var pageName -key pantaskState INIT
-    if ("$pageName" == "NULL") break
-
-    book setword burnhost.book $pageName pantaskState RUN
-    book getword burnhost.book $pageName dateobs -var DATEOBS
-    book getword burnhost.book $pageName iter    -var ITER
-    book getword burnhost.book $pageName fixhost -var BURNHOST
-    book getword burnhost.book $pageName chipID  -var CHIP_ID
-
-    substr $DATEOBS 0 4 YEAR
-    substr $DATEOBS 4 2 MONTH
-    substr $DATEOBS 6 2 DAY
-    sprintf STARTDATE "%s/%s/%s" $YEAR $MONTH $DAY
-    sprintf ENDDATE "%s/%s/%s,23:59:59" $YEAR $MONTH $DAY
-
-    option $pageName $DATEOBS $YEAR
-    # save DATEOBS so we can find the md5sum.book entry
-    # also save YEAR for output log
-
-    stdout $mypath/$YEAR/$DATEOBS/log.burntool.run.$CHIP_ID.v$ITER
-    stderr $mypath/$YEAR/$DATEOBS/log.burntool.run.$CHIP_ID.v$ITER
-
-   
-    host $BURNHOST
-#   host -required $BURNHOST
-#   too many jobs wanted the same machines so the processing was clogged.
-#   allow them to go elsewhere if needed.
+    book getword burnhost.book $pageName rawImfileReal -var rawImfileReal
+    book getword burnhost.book $pageName outTableReal  -var outTableReal 
+    book getword burnhost.book $pageName exposure      -var exposure     
+    book getword burnhost.book $pageName class_id      -var class_id     
+    book getword burnhost.book $pageName fullname      -var fullname     
+    book getword burnhost.book $pageName datahost      -var BURNHOST
+
+    # XXX choose something sensible:
+    # stdout $mypath/$YEAR/$DATEOBS/log.burntool.run.$CHIP_ID.v$ITER
+    # stderr $mypath/$YEAR/$DATEOBS/log.burntool.run.$CHIP_ID.v$ITER
+
+    host -required $BURNHOST
     
     ## check if this host needs to be launched
@@ -179,9 +111,13 @@
 
     sprintf psvidOutput "%s/%s/%s" $mypath $YEAR $DATEOBS
+    if ("$previousTable" != "NULL")
+      $addtable = --prevtable=$previousTable
+    else
+      $addtable =
+    end
 
     # if we are able to run the 'exec', use a short retry time to launch all outstanding jobs
     periods -exec 0.05
-    command ipp_apply_burntool_psvideo.pl --rerun --dateobs_begin $STARTDATE --dateobs_end $ENDDATE --class_id $CHIP_ID --dbname gpc1 --psvidOutput $psvidOutput
-    ## NOTE the rerun option is set here
+    command burntool_one_chip.pl --rerun --imfile $rawImfileReal --outtable=$outTableReal $addtable 
   end
 
@@ -332,2 +268,48 @@
 end
 
+
+
+
+
+if (0) 
+  # select nights in state burntool.new
+  # output: burntool.book
+  task nights.burntool.load
+    host local
+    periods -poll $TPOLL
+    periods -exec $TEXEC
+    periods -timeout 30
+  
+    stdout $LOGDIR/burntool.load.stdout.log  
+    stderr $LOGDIR/burntool.load.stderr.log
+  
+    # only run one of these tasks at a time
+    npending 1
+  
+    task.exec
+      command check.rawfix.sh state burntool.new 
+    end
+  
+    task.exit 0
+      # convert the stdout 'queue' to entries in a book
+      # fields in the table will become words in the page
+      queue2book -raw-columns -key dateobs -uniq -setword pantaskState INIT -setword pantasksQuality OK stdout burntool.book
+      book delpage burntool.book -key pantaskState DONE
+    end
+  
+    # exit values other than 0:
+    task.exit    default
+      showcommand failure
+    end
+  
+    task.exit    crash
+      showcommand crash
+    end
+  
+    # operation times out?
+    task.exit    timeout
+      showcommand timeout
+    end
+  end
+end
+
Index: /trunk/tools/eam/burntool.20250520/src/burntool_night_chip.pl
===================================================================
--- /trunk/tools/eam/burntool.20250520/src/burntool_night_chip.pl	(revision 42907)
+++ /trunk/tools/eam/burntool.20250520/src/burntool_night_chip.pl	(revision 42908)
@@ -22,5 +22,6 @@
 my $date = `date`;
 print "\n\n";
-print "Starting script $0 on $host at $date\n\n";
+# print "Starting script $0 on $host at $date\n\n";
+print "data MULTI\n\n";
 
 my ( $class_id, $dateobs, $dbname, $rerun, $verbose, $save_temps);
@@ -53,6 +54,4 @@
 my $missing_tools;
 my $regtool      = can_run('regtool')         or (warn "Can't find regtool"         and $missing_tools = 1);
-my $funpack      = can_run('funpack')         or (warn "Can't find funpack"         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.");
@@ -72,4 +71,5 @@
 $command .= " -ordered_by_date";
 $command .= " -dbname $dbname" if defined $dbname;
+$command .= " -limit 10";
 
 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -111,5 +111,5 @@
 foreach my $file (@$files) {
     my $exp_id     = $file->{exp_id};
-    my $exp_name   = $file->{exp_id};
+    my $exp_name   = $file->{exp_name};
     my $state      = $file->{burntool_state};
     my $data_state = $file->{data_state};
@@ -126,4 +126,9 @@
 	next;
     }
+
+    # extract the storage host name
+    my ($datahost) = $rawImfileReal =~ m|/data/(ipp[a-z0-9]+).[0123]|;
+    # print STDERR "datahost: $datahost\n";
+    # next;
 
     # instantiate the burntable instance for use by the actual analysis script
@@ -137,14 +142,11 @@
 
     my $process = 1;
-    my $previousTableStyle = 0;
 
     if ($state == -2) { &my_die("Aborting as $rawImfile has modified pixel data!"); }
-    if ($state == +1 * $burntoolStateGood) {
-        $process = 0;
-        $previousTableStyle = 1;
-    }
+    if ($state == +1 * $burntoolStateGood) { &my_die("Unexpected burntool State $state"); }
+
+    # $state = -15, $burntoolStateGood = +15
     if ($state == -1 * $burntoolStateGood) {
         $process = 0;
-        $previousTableStyle = -1;
     }
     if ($rerun) { $process = 1; }
@@ -156,16 +158,23 @@
 
     if (($process == 1) || ($processNext == 1)) {
-	my $status;
+	# we now have $rawImfileReal, $previousTable, $outTableReal
+	print STDOUT "data METADATA\n";
+	print STDOUT "     rawImfileReal STR $rawImfileReal\n";
+	print STDOUT "     outTableReal  STR $outTableReal\n";
+	print STDOUT "     exposure      STR $exp_name\n";
+	print STDOUT "     class_id      STR $class_id\n";
+	print STDOUT "     fullname      STR $exp_name.$class_id\n";
+	print STDOUT "     datahost      STR $datahost\n";
+	if ($previousTable ne "") {
+	    print STDOUT "     previousTable STR $previousTable\n";
+	}
+	print STDOUT "END\n\n";
+
         $processNext = 1;
-
-	# we now have $rawImfileReal, $previousTable, $outTableReal
-	print STDERR "$rawImfileReal $previousTable $outTableReal\n";
-
-        $previousTableStyle = -1;
     }
 
     ### XXX I think I can make the assumption that we are saving the tables as separate files since we
     ### want to get to burntool state -15 (v15)
-    $previousTable = "in=$outTableReal";
+    $previousTable = "$outTableReal";
 }
 
