Index: trunk/ippTasks/detrend.stack.pro
===================================================================
--- trunk/ippTasks/detrend.stack.pro	(revision 8193)
+++ trunk/ippTasks/detrend.stack.pro	(revision 8691)
@@ -1,6 +1,17 @@
-
 ## this file contains the tasks for running the detrend stacking stage
 
+# get a list of imfiles to stack
+# dettool -tostack -simple
+# 1 0 bias mc
+# DET_ID ITER TYPE CLASS_ID 
+
+# function to stack the imfiles:
+# detrend_stack.pl 1 0 mc bias
+
 ## these tasks use the queue DetrendClassIDtoStack
+
+## these tasks use the queue DetrendImfilesToProcess
+## the DetrendClassIDtoStack queue contains:
+## STATE DET_ID ITER TYPE CLASS_ID 
 
 # select images ready for copy 
@@ -8,5 +19,5 @@
 # compare the new list with the ones already selected
 task	       dettool.stack.load
-  command      dettool -chip -processed
+  command      dettool -tostack -simple
   host         local
 
@@ -22,9 +33,14 @@
 
     # compare output with newImage queue
-    # only add entries which don't exist in queue
+    # only add entries which do not exist in queue
     queuesize stdout -var Nqueue
     for i 0 $Nqueue
       queuepop stdout -var line
-      queuepush DetrendClassIDtoStack -uniq -key 1:2:4 "NEW $line"
+      list word -split $line
+      $DET_ID   = $word:0
+      $ITER     = $word:1
+      $TYPE     = $word:2
+      $CLASS_ID = $word:3
+      queuepush DetrendClassIDtoStack -uniq -key 1:2:4 "NEW $DET_ID $ITER $TYPE $CLASS_ID"
     end
 
@@ -68,32 +84,26 @@
 
     strpop line state
-    queuepush DetrendClassIDtoStack -replace -key 0 "RUN $line"
+    queuepush DetrendClassIDtoStack -replace -key 1:2:4 "RUN $line"
+
+    # the DetrendClassIDtoStack queue contains:
+    # STATE DET_ID ITER TYPE CLASS_ID 
+    ## NOTE: the queue has the STATE prepended 
+    list word -split $line
+    $DET_ID   = $word:1
+    $ITER     = $word:2
+    $TYPE     = $word:3
+    $CLASS_ID = $word:4
 
     # specify choice of remote host:
-    # 'anyhost' specified random remote host
-    # if we needed to specify a host explicitly, use a command like
-    # one of the following.  the -required forces execution on the
-    # named host, and blocks the task until the host is available
-    # host kiawe
-    # host alala -required 
     host anyhost
-
-    # choose the default recipe appropriate to this type of file
-    $recipe = `get.recipe $type`
 
     # create example job options as a demonstration
     options "$line"
-
-    # we can put the dettool and ppMerge commands here, or wrap them in a single script
-    # $urilist = `dettool -processed -det_id $det_id -iteration $iteration -chip"
-    # $uri_out = ???
-    # command ppMerge $uri_out $uri $uri ... -recipe PPMERGE $recipe
-    command ppMerge.dettool $uri_out -det_id $det_id -iteration $iteration -recipe PPMERGE $recipe
+    # detrend_stack.pl 1 0 mc bias
+    command detrend_stack.pl $DET_ID $ITER $CLASS_ID $TYPE
   end
 
   # success
   task.exit 0
-    # XXX need to parse the options to identify the values below (if not part of cmdline?)
-    exec dettool -addstacked -det_id $det_id -iteration $iteration -class_id $class_id -procrecipe $recipe
     queuepush DetrendClassIDtoStack -replace -key 1:2:4 "DONE $options:0"
   end
@@ -101,10 +111,10 @@
   # default exit status
   task.exit    default
-    queuepush DetrendClassIDtoStack -replace -key 0 "FAIL $options:0"
+    queuepush DetrendClassIDtoStack -replace -key 1:2:4 "FAIL $options:0"
   end
 
   # operation times out?
   task.exit    timeout
-    queuepush DetrendClassIDtoStack -replace -key 0 "FAIL $options:0"
+    queuepush DetrendClassIDtoStack -replace -key 1:2:4 "FAIL $options:0"
   end
 end
