Index: trunk/ippTasks/register.pro
===================================================================
--- trunk/ippTasks/register.pro	(revision 25418)
+++ trunk/ippTasks/register.pro	(revision 30049)
@@ -8,8 +8,10 @@
 book init regPendingImfile
 book init regPendingExp
+book init regPendingBurntoolImfile
 
 macro register.reset
   book init regPendingImfile
   book init regPendingExp
+  book init regPendingBurntoolImfile
 end
 
@@ -18,4 +20,5 @@
   book listbook regPendingImfile
   book listbook regPendingExp
+  book listbook regPendingBurntoolImfile
 end
 
@@ -33,4 +36,10 @@
     active true
   end
+  task register.burntool.load
+    active true
+  end
+  task register.burntool.run
+    active true
+  end
 end
 
@@ -48,5 +57,13 @@
     active false
   end
-end
+  task register.burntool.load
+    active false
+  end
+  task register.burntool.run
+    active false
+  end
+end
+
+$valid_burntool_value = 14
 
 macro replace.survey.values
@@ -129,4 +146,5 @@
 # these variables will cycle through the known database names
 $regPendingImfile_DB = 0
+$regPendingBurntoolImfile_DB = 0
 $regPendingExp_DB = 0
 
@@ -429,3 +447,133 @@
 end
 
+
+# select imfiles that can now be burntooled.
+task       register.burntool.load
+  host     local
+
+  periods  -poll $LOADPOLL
+  periods  -exec $LOADEXEC
+  periods  -timeout 30
+  npending 1
+
+  # silently drop stdout
+  stdout NULL
+  stderr $LOGDIR/register.burntool.load.log
+  
+  # select entried from the current DB; cycle to the next DB, if it exists
+  task.exec
+    $run = regtool -pendingburntoolimfile
+    $today = `date -u +%Y-%m-%d`
+# debugging purposes
+    $today = "2010-12-06"
+    $run = $run -date $today -valid_burntool $valid_burntool_value
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      # save the DB name for the exit tasks
+      option $DB:$regPendingBurntoolImfile_DB
+      $run = $run -dbname $DB:$regPendingBurntoolImfile_DB
+      $regPendingBurntoolImfile_DB ++
+      if ($regPendingBurntoolImfile_DB >= $DB:n) set regPendingBurntoolImfile_DB = 0
+    end
+
+    echo $run
+    add_poll_args run
+    command $run
+  end
+
+  # success
+  task.exit $EXIT_SUCCESS
+    # convert 'stdout' to book format
+    ipptool2book stdout regPendingBurntoolImfile -key exp_id:class_id -uniq -setword dbname $options:0 -setword pantaskState INIT
+    book shuffle regPendingBurntoolImfile
+    if ($VERBOSE > 2)
+      book listbook regPendingBurntoolImfile
+    end
+
+    # delete existing entries in the appropriate pantasksStates
+    process_cleanup regPendingBurntoolImfile
+  end
+
+  # locked list
+  task.exit   default
+    showcommand failure
+  end
+  task.exit   crash
+    showcommand crash
+  end
+  task.exit   timeout
+    showcommand timeout
+  end
+end
+
+# run the ipp_apply_burntool_single.pl script on the pending images
+task          register.burntool.run
+  periods     -poll $RUNPOLL
+  periods     -exec $RUNEXEC
+  periods     -timeout 30
+
+  task.exec
+    if ($NETWORK == 0) break
+    book npages regPendingBurntoolImfile -var N
+    if ($N == 0) 
+      periods -exec $RUNEXEC
+      break
+    end
+    periods -exec 0.05
+
+    # look for new images to burn in regPendingBurntoolImfile
+    book getpage regPendingBurntoolImfile 0 -var pageName -key pantaskState INIT
+    if ("$pageName" == "NULL") break
+
+    book setword regPendingBurntoolImfile $pageName pantaskState RUN
+
+    book getword regPendingBurntoolImfile $pageName exp_id      -var EXP_ID
+    book getword regPendingBurntoolImfile $pageName class_id    -var CLASS_ID
+    book getword regPendingBurntoolImfile $pageName uri         -var THIS_URI
+    book getword regPendingBurntoolImfile $pageName previous_uri -var PREVIOUS_URI
+    book getword regPendingBurntoolImfile $pageName camera      -var CAMERA
+    book getword regPendingBurntoolImfile $pageName dbname      -var DBNAME
+    set.host.for.camera $CAMERA $CLASS_ID
+
+    stdout $LOGDIR/register.burntool.run.log
+    stderr $LOGDIR/register.burntool.run.log
+
+    $run = ipp_apply_burntool_single.pl --exp_id $EXP_ID --class_id $CLASS_ID --this_uri $THIS_URI
+    if ("$PREVIOUS_URI" != "NULL")
+      $run = $run --previous_uri $PREVIOUS_URI
+    end
+
+    add_standard_args run
+
+    options $pageName
+
+    if ($VERBOSE > 1) 
+      echo command $run
+    end
+    command $run
+  end
+
+  # default exit status
+  task.exit default
+    process_exit regPendingBurntoolImfile $options:0 $JOB_STATUS
+  end
+
+  # locked list
+  task.exit crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword regPendingBurntoolImfile $options:0 pantaskState CRASH
+  end
+
+  # operation timed out
+  task.exit  timeout
+    showcommand timeout
+    book setword regPendingBurntoolImfile $options:0 pantaskState TIMEOUT
+  end
+end
+
+    
+   
+  
 ## XXX add a global path to output files  
