Index: /branches/eam_branches/ipp-20250626/tools/eam/burntool.20250520/src/bt.getchip.pt
===================================================================
--- /branches/eam_branches/ipp-20250626/tools/eam/burntool.20250520/src/bt.getchip.pt	(revision 42911)
+++ /branches/eam_branches/ipp-20250626/tools/eam/burntool.20250520/src/bt.getchip.pt	(revision 42912)
@@ -1,11 +1,15 @@
 
-# master book is btChipNight listing all CHIPNIGHT books
+# the master book btChipNights lists all of CHIPNIGHT books
 # CHIPNIGHT books are named after the nights and chips, e.g. 20250704.XY01
 
+if (not($BT_CHIPNIGHT_NSEQ)) set BT_CHIPNIGHT_NSEQ = 0
+
 # get the next available chip (one chip from an exposure for a single night)
-task bt.getchip.run
+# all ops are done within the task exec
+task bt.getchip
   periods      -poll $BT_POLL
   periods      -exec $BT_EXEC
   periods      -timeout 1800
+  host	       local
 
   task.exec
@@ -13,8 +17,9 @@
     periods -exec $BT_EXEC
 
+    # XXX is this sensible?  
     if ($BT_PAUSE) break
     
-    # how many hosts are defined?
-    book npages btChipNight -var Nnights
+    # how many nights are defined?
+    book npages btChipNights -var Nnights
 
     # if we have reached the end, restart the loop over chip hosts
@@ -25,14 +30,14 @@
     end
     
-    # XXX CHIPNIGHT could be the same as the page name
-    book getpage btChipNight $BT_CHIPNIGHT_NSEQ           -var BT_CHIPNIGHT_PAGE
-    book getword btChipNight $BT_CHIPNIGHT_PAGE CHIPNIGHT -var BT_CHIPNIGHT_BOOK
-    book getword btChipNight $BT_CHIPNIGHT_PAGE STATE     -var BT_CHIPNIGHT_STATE
+    # grab info for this CHIPNIGHT
+    book getpage btChipNights $BT_CHIPNIGHT_NSEQ           -var BT_CHIPNIGHT_PAGE
+    book getword btChipNights $BT_CHIPNIGHT_PAGE CHIPNIGHT -var BT_CHIPNIGHT_BOOK
+    book getword btChipNights $BT_CHIPNIGHT_PAGE STATE     -var BT_CHIPNIGHT_STATE
 
     # ENTRY tracks the sequence number in the CHIPNIGHT
-    book getword btChipNight $BT_CHIPNIGHT_PAGE ENTRY     -var BT_CHIPNIGHT_ENTRY
+    book getword btChipNights $BT_CHIPNIGHT_PAGE ENTRY     -var BT_CHIPNIGHT_ENTRY
 
-    # PREVTABLE (previousTable) will be NULL at the start (populated below)
-    book getword btChipNight $BT_CHIPNIGHT_PAGE PREVTABLE -var previousTable
+    # OUTTABLE (previousTable) will be NULL at the start (populated below)
+    book getword btChipNights $BT_CHIPNIGHT_PAGE OUTTABLE  -var previousTable
 
     # is this chip/night ready to go?
@@ -64,8 +69,7 @@
     book getpage $BT_CHIPNIGHT_BOOK $BT_CHIPNIGHT_ENTRY -var pageName
     if ("$pageName" == "NULL")
-      # this is a programming error
-      stop
+      ??
       echo "PROGRAMMING ERROR"
-      break
+      exit
     end
 
@@ -74,63 +78,16 @@
 
     # save info about currently active entry
-    book setword btChipNight $BT_CHIPNIGHT_PAGE STATE       RUN
-    book setword btChipNight $BT_CHIPNIGHT_PAGE ENTRY       $BT_CHIPNIGHT_ENTRY
-    book setword btChipNight $BT_CHIPNIGHT_PAGE PREVTABLE   $outTableReal
+    book setword btChipNights $BT_CHIPNIGHT_PAGE STATE       RUN
+    book setword btChipNights $BT_CHIPNIGHT_PAGE ENTRY       $BT_CHIPNIGHT_ENTRY
+    book setword btChipNights $BT_CHIPNIGHT_PAGE OUTTABLE    $outTableReal
 
     # 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
+    stdout log.bt.getchip
+    stderr log.bt.getchip
 
     periods -exec 0.05
     command echo selected $exposure, $class_id for processing
   end
-
-  task.exit 0
-    bt.getchip.exit OK
-  end
-
-  # exit values other than 0:
-  task.exit    default
-    bt.getchip.exit FAIL
-    showcommand failure
-  end
-
-  task.exit    crash
-    bt.getchip.exit CRASH
-    showcommand crash
-  end
-
-  # operation times out?
-  task.exit    timeout
-    bt.getchip TIMEOUT
-    showcommand timeout
-  end
 end
-
-macro bt.getchip.exit
-  if ($0 != 2)
-    echo "USAGE: bt.getchip.exit (quality)"
-    break
-  end
-
-  local myBook myPage chPage
-  $myBook = $options:0
-  $myPage = $options:1
-  $chPage = $options:2
-
-  book setword $myBook $myPage pantaskState DONE
-
-  # what else needs to happen after the job is done?
-
-  # decrement NRUN for this host
-  book getword btChipNight $chPage NRUN -var BT_CHIPNIGHT_NRUN
-  $BT_CHIPNIGHT_NRUN --
-  book setword btChipNight $chPage NRUN      $BT_CHIPNIGHT_NRUN
-
-  # update the night/exp/chip list as well
-  # this chip state set to DONE or FAIL
-  # book delpage burnhost.book $options:0
-end
-
 
 ######### supporting methods #############
@@ -149,5 +106,5 @@
   local rawImfileReal outTableReal previousTable expname chipID myHost
 
-  ### XXX need to track entry in btChipNight so bt.onechip.exit can update
+  ### XXX need to track entry in btChipNights so bt.onechip.exit can update
 
   book getword $BT_CHIPNIGHT_BOOK $pageName rawImfileReal -var rawImfileReal
