Index: trunk/ippTasks/detrend.resid.pro
===================================================================
--- trunk/ippTasks/detrend.resid.pro	(revision 8193)
+++ trunk/ippTasks/detrend.resid.pro	(revision 8691)
@@ -2,7 +2,15 @@
 ## this file contains the tasks for running the detrend processing stage
 
+# dettool -toresid -simple
+# 0    bias 1      850131b mc       o_850131b.mc.fit PPIMAGE_O 1.492870 2.848350 292.565582
+# ITER TYPE DET_ID EXP_KEY CLASS_ID URI-IN           
+
+# detrend_create_resid.pl 1      0    850131b mc       bias bias_mc_1_0.fit o_850131b.mc.fit 850131b
+# detrend_create_resid.pl DET_ID ITER EXP_KEY CLASS_ID TYPE (URI-DET)       (URL-IN)         (EXP_KEY)
+# URL-DET: $TYPE\_$CLASS_ID\_$DET_ID\_$ITER.fit
+
 ## these tasks use the queue DetrendResidImfiles
 ## the DetrendResidImfiles queue contains:
-## STATE .....
+## STATE ITER TYPE DET_ID EXP_KEY CLASS_ID URI_IN
 
 # select images ready for copy 
@@ -10,5 +18,5 @@
 # compare the new list with the ones already selected
 task	       dettool.resid.load
-  command      dettool -resid
+  command      dettool -toresid -simple
   host         local
 
@@ -16,5 +24,4 @@
   periods      -exec 5
   periods      -timeout 30
-  trange       18:00 23:59
 
   # success
@@ -29,5 +36,12 @@
     for i 0 $Nqueue
       queuepop stdout -var line
-      queuepush DetrendResidImfiles -uniq -key 1:2:4 "NEW $line"
+      list word -split $line
+      $ITER     = $word:0
+      $TYPE     = $word:1
+      $DET_ID   = $word:2
+      $EXP_KEY  = $word:3
+      $CLASS_ID = $word:4
+      $URI_IN   = $word:5
+      queuepush DetrendResidImfiles -uniq -key 1:3:4:5 "NEW $ITER $TYPE $DET_ID $EXP_KEY $CLASS_ID $URI_IN"
     end
 
@@ -70,42 +84,40 @@
 
     strpop line state
-    queuepush DetrendResidImfiles -replace -key 0 "RUN $line"
+    queuepush DetrendResidImfiles -replace -key 1:3:4:5 "RUN $line"
+
+    ## the DetrendResidImfiles queue contains:
+    ## STATE ITER TYPE DET_ID EXP_KEY CLASS_ID URI_IN
+    ## NOTE: the queue has the STATE prepended 
+    list word -split $line
+    $ITER     = $word:1
+    $TYPE     = $word:2
+    $DET_ID   = $word:3
+    $EXP_KEY  = $word:4
+    $CLASS_ID = $word:5
+    $URI_IN   = $word:6
 
     # 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"
-
-    # need to choose different variations based on the type
-    # need to supply the matched detrend images...
-    command ppImage -file $uri $uri_out -recipe PPIMAGE $recipe -bias $master
-    command ppImage -file $uri $uri_out -recipe PPIMAGE $recipe -flat $master
+    # detrend_create_resid.pl DET_ID ITER EXP_KEY CLASS_ID TYPE (URI-DET) (URL-IN) (EXP_KEY ???)
+    $URL_DET = $TYPE\_$CLASS_ID\_$DET_ID\_$ITER.fit
+    command detrend_create_resid.pl $DET_ID $ITER $EXP_KEY $CLASS_ID $TYPE $URI_DET $URL_IN $EXP_KEY
   end
 
   # success
   task.exit 0
-    # XXX need to parse the options to identify the values below (if not part of cmdline?)
-    exec dettool -addprocessed -det_id $det_id -exp_id $exp_id -class_id $class_id -uri $output_uri -procrecipe $recipe
-    queuepush DetrendResidImfiles -replace -key 1:2:4 "DONE $options:0"
+    queuepush DetrendResidImfiles -replace -key 1:3:4:5 "DONE $options:0"
   end
 
   # default exit status
   task.exit    default
-    queuepush DetrendResidImfiles -replace -key 0 "FAIL $options:0"
+    queuepush DetrendResidImfiles -replace -key 1:3:4:5 "FAIL $options:0"
   end
 
   # operation times out?
   task.exit    timeout
-    queuepush DetrendResidImfiles -replace -key 0 "FAIL $options:0"
+    queuepush DetrendResidImfiles -replace -key 1:3:4:5 "FAIL $options:0"
   end
 end
