Index: trunk/ippTasks/detrend.reject.pro
===================================================================
--- trunk/ippTasks/detrend.reject.pro	(revision 10745)
+++ trunk/ippTasks/detrend.reject.pro	(revision 11210)
@@ -1,17 +1,5 @@
+## this file contains the tasks for running the detrend processing stage
+## these tasks use the book detRejectExp
 
-## this file contains the tasks for running the detrend processing stage
-
-# dettool -residdetrun -simple
-# 1      0    bias
-# DET_ID ITER TYPE
-
-# detrend_reject_exp.pl 1      0    bias
-# detrend_reject_exp.pl DET_ID ITER TYPE
-
-## these tasks use the queue DetrendResidExp
-## the DetrendRejectExp queue contains:
-## STATE DET_ID ITER TYPE
-
-queueinit DetrendRejectExp
 if ($?network == 0)
   $network = 1
@@ -20,7 +8,4 @@
   $parallel = 0
 end
-
-$DetrendRejectExpFail = 0
-
 if ($?VERBOSE == 0)
   echo "VERBOSE not defined: load pantasks.pro first"
@@ -31,14 +16,16 @@
   break
 end
+
 $LOGSUBDIR = $LOGDIR/detrend
 exec mkdir -p $LOGSUBDIR
 
+book init detRejectExp
+
 macro detreject.status
-  queueprint DetrendRejectExp
-  echo "DetrendRejectExpFail: $DetrendRejectExpFail"
+  book listbook detRejectExp
 end
 
 # select images ready for copy 
-# new entries are added to queue DetrendRejectExp
+# new entries are added to detRejectExp
 # compare the new list with the ones already selected
 task	       dettool.reject.load
@@ -49,34 +36,21 @@
   periods      -timeout 30
 
-  stdout $LOGSUBDIR/dettool.reject.log
+  stdout NULL
   stderr $LOGSUBDIR/dettool.reject.log
 
   task.exec
-    command dettool -residdetrun -simple -limit {$DetrendRejectExpFail + 20}
+    command dettool -residdetrun -limit 20
   end
 
   # success
   task.exit    0
-    local i Nqueue
-
-    # compare output with newImage queue
-    # only add entries which don't exist in queue
-    queuesize stdout -var Nqueue
-    for i 0 $Nqueue
-      queuepop stdout -var line
-      if ($VERBOSE > 2)
-        echo $line
-      end
-      list word -split $line
-      $DET_ID   = $word:0
-      $ITER     = $word:1
-      $DET_TYPE = $word:2
-      $MODE     = $word:3
-      $CAMERA   = $word:4
-      queuepush DetrendRejectExp -uniq -key 1:2 "NEW $DET_ID $ITER $DET_TYPE $MODE $CAMERA"
+    # convert 'stdout' to book format
+    ipptool2book stdout detRejectExp -key det_id:iteration -uniq
+    if ($VERBOSE > 2)
+      book listbook detRejectExp
     end
 
     # delete existing entries which are DONE
-    queuedrop DetrendRejectExp -key 0 DONE
+    book delpage detRejectExp -key state DONE
   end
 
@@ -99,30 +73,18 @@
 
   task.exec
-    queuesize DetrendRejectExp -var N
+    book npages detRejectExp -var N
     if ($N == 0) break
     if ($network == 0) break
     
-    # look for new images on the internal DetrendRejectExp queue
-    # caution with these 'if' statements: syntax errors 
-    # will make the task fail without given a good status
-    queuepop DetrendRejectExp -var line -key 0 NEW
-    if ("$line" == "NULL") break
+    # look for new images in detRejectExp
+    book getpage detRejectExp 0 -var pageName -key state NULL
+    if ($pageName == NULL) break
 
-    strpop line state
-    queuepush DetrendRejectExp -replace -key 1:2 "RUN $line"
-
-    ## the DetrendRejectExp queue contains:
-    ## STATE DET_ID ITER TYPE
-    ## NOTE: the queue has the STATE prepended 
-    list word -split $line
-    $DET_ID   = $word:0
-    $ITER     = $word:1
-    $DET_TYPE = $word:2
-    $MODE     = $word:3
-    $CAMERA   = $word:4
-
-    # I'd like to add CAMERA to the log file...
-    stdout $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
-    stderr $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITER.log
+    book setword detRejectExp $pageName state RUN
+    book getword detRejectExp $pageName det_id    -var DET_ID   
+    book getword detRejectExp $pageName iteration -var ITERATION     
+    book getword detRejectExp $pageName det_type  -var DET_TYPE 
+    book getword detRejectExp $pageName mode      -var MODE     
+    book getword detRejectExp $pageName camera    -var CAMERA   
 
     # specify choice of remote host:
@@ -133,22 +95,21 @@
     end
 
+    # I'd like to add CAMERA to the log file...
+    stdout $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITERATION.log
+    stderr $LOGSUBDIR/$CAMERA.$DET_TYPE.$DET_ID.$ITERATION.log
+
+    # save the pageName for future reference below
+    options $pageName
+
     # create example job options as a demonstration
-    options "$line"
     if ($VERBOSE > 1)
-      echo command detrend_reject_exp.pl --det_id $DET_ID --iteration $ITER --det_type $DET_TYPE --camera $CAMERA
+      echo command detrend_reject_exp.pl --det_id $DET_ID --iteration $ITERATION --det_type $DET_TYPE --camera $CAMERA
     end
-    command detrend_reject_exp.pl --det_id $DET_ID --iteration $ITER --det_type $DET_TYPE --camera $CAMERA
+    command detrend_reject_exp.pl --det_id $DET_ID --iteration $ITERATION --det_type $DET_TYPE --camera $CAMERA
  end
-
-  # success
-  task.exit 0
-    queuepush DetrendRejectExp -replace -key 1:2 "DONE $options:0"
-  end
 
   # default exit status
   task.exit    default
-    showcommand failure
-    queuepush DetrendRejectExp -replace -key 1:2 "FAIL $options:0"
-    $DetrendRejectExpFail ++
+    process_exit detRejectExp $options:0 state FAIL
   end
 
@@ -156,6 +117,5 @@
   task.exit    timeout
     showcommand failure
-    queuepush DetrendRejectExp -replace -key 1:2 "TIMEOUT $options:0"
-   $DetrendRejectExpFail ++
+    book setword detRejectExp $options:0 state TIMEOUT
   end
 end
