Index: trunk/ippTasks/automate.pro
===================================================================
--- trunk/ippTasks/automate.pro	(revision 16609)
+++ trunk/ippTasks/automate.pro	(revision 16610)
@@ -1,3 +1,3 @@
-## mkdetrend.pro : autorun the detrend analysis : -*- sh -*-
+## automate.pro : autorun the detrend analysis : -*- sh -*-
 
 # example automation stage
@@ -30,4 +30,28 @@
 end
 
+macro automate.on
+  task automate.block
+    active true
+  end
+  task automate.check
+    active true
+  end
+  task automate.launch
+    active true
+  end
+end
+
+macro automate.off
+  task automate.block
+    active false
+  end
+  task automate.check
+    active false
+  end
+  task automate.launch
+    active false
+  end
+end
+
 $automate_Nblock = -1
 task automate.block
@@ -46,5 +70,7 @@
     book npages automate -var Npage -key pantaskState INIT.BLOCK
     if ($Npage == 0) 
-      echo "no entries in INIT.BLOCK state"
+      if ($VERBOSE >= 2) 
+        echo "no entries in INIT.BLOCK state"
+      end
       break
     end
@@ -53,10 +79,11 @@
     $automate_Nblock ++
     if ($automate_Nblock >= $Npage) set automate_Nblock = 0
-    echo "automate.block $automate_Nblock"
 
     # search the automate book for an entry which is unstarted (state INIT.BLOCK) 
     book getpage automate $automate_Nblock -var pageName -key pantaskState INIT.BLOCK
     if ("$pageName" == "NULL") 
-      echo "entry $automate_Nblock not in INIT.BLOCK state"
+      if ($VERBOSE >= 2) 
+        echo "entry $automate_Nblock not in INIT.BLOCK state"
+      end
       break 
     end
@@ -66,5 +93,7 @@
       # if there is no block needed, we can immediate progress to the next stage (INIT.CHECK)
       book setword automate $pageName pantaskState INIT.CHECK
-      echo "$pageName is ready : INIT.CHECK"
+      if ($VERBOSE >= 2) 
+        echo "$pageName is ready : INIT.CHECK"
+      end
       break
     end
@@ -72,5 +101,5 @@
     book setword automate $pageName pantaskState RUN.BLOCK
 
-    if ($VERBOSE >= 1)
+    if ($VERBOSE >= 2)
       echo "starting automate block for $pageName"
       echo "command $blockCommand"
@@ -86,25 +115,27 @@
     $pageName = $options:0
 
-    echo "complete $pageName test, checking results"
-
     # convert 'stdout' to book format
     # XXX to use other tests, we'll need to modify this 
-    ipptool2book stdout detExp -key det_id -uniq
+    ipptool2book stdout tmpBlock
     if ($VERBOSE > 2)
-      book listbook detExp
+      book listbook tmpBlock
     end
 
     # if the block test returns any valid pages (valid results), the block is set, don't move to check
-    book npages detExp -var Npage 
-    if ($Npage == 0) 
-      echo "$pageName is not blocked, ready for CHECK"
+    book npages tmpBlock -var Npage 
+    if ($Npage == 0) 
+      if ($VERBOSE >= 2)
+        echo "$pageName is not blocked, ready for CHECK"
+      end
       book setword automate $pageName pantaskState INIT.CHECK
     else
-      echo "$pageName is blocked, not ready for CHECK"
+      if ($VERBOSE >= 2)
+        echo "$pageName is blocked, not ready for CHECK"
+      end
       book setword automate $pageName pantaskState INIT.BLOCK
     end
 
     # drop the detExt book after we've grabbed the state
-    book delete detExp
+    book delete tmpBlock
   end
 
@@ -136,5 +167,7 @@
     book npages automate -var Npage -key pantaskState INIT.CHECK
     if ($Npage == 0) 
-      echo "no entries in INIT.CHECK state"
+      if ($VERBOSE >= 2) 
+        echo "no entries in INIT.CHECK state"
+      end
       break
     end
@@ -143,10 +176,11 @@
     $automate_Ncheck ++
     if ($automate_Ncheck >= $Npage) set automate_Ncheck = 0
-    echo "automate.check $automate_Ncheck"
 
     # search the automate book for an entry which is unstarted (state INIT.CHECK) 
     book getpage automate $automate_Ncheck -var pageName -key pantaskState INIT.CHECK
     if ("$pageName" == "NULL") 
-      echo "entry $automate_Ncheck not in INIT.CHECK state"
+      if ($VERBOSE >= 2) 
+        echo "entry $automate_Ncheck not in INIT.CHECK state"
+      end
       break 
     end
@@ -156,5 +190,7 @@
       # if there is no check needed, we can immediate progress to the next stage (INIT.LAUNCH)
       book setword automate $pageName pantaskState INIT.LAUNCH
-      echo "$pageName is ready : INIT.LAUNCH"
+      if ($VERBOSE >= 2) 
+        echo "$pageName is ready : INIT.LAUNCH"
+      end
       break
     end
@@ -162,5 +198,5 @@
     book setword automate $pageName pantaskState RUN.CHECK
 
-    if ($VERBOSE >= 1)
+    if ($VERBOSE >= 2)
       echo "starting automate check for $pageName"
       echo "command $checkCommand"
@@ -176,24 +212,26 @@
     $pageName = $options:0
 
-    echo "complete $pageName test, checking results"
-
     # convert 'stdout' to book format
     # XXX to use other tests, we'll need to modify this 
-    ipptool2book stdout detExp -key det_id -uniq
+    ipptool2book stdout tmpCheck
     if ($VERBOSE > 2)
-      book listbook detExp
-    end
-
-    book npages detExp -var Npage 
-    if ($Npage == 0) 
-      echo "$pageName not ready for LAUNCH"
+      book listbook tmpCheck
+    end
+
+    book npages tmpCheck -var Npage 
+    if ($Npage == 0) 
+      if ($VERBOSE >= 2) 
+        echo "$pageName not ready for LAUNCH"
+      end
       book setword automate $pageName pantaskState INIT.CHECK
     else
-      echo "$pageName is ready for LAUNCH"
+      if ($VERBOSE >= 2) 
+        echo "$pageName is ready for LAUNCH"
+      end
       book setword automate $pageName pantaskState INIT.LAUNCH
     end
 
     # drop the detExt book after we've grabbed the state
-    book delete detExp
+    book delete tmpCheck
   end
 
@@ -225,5 +263,7 @@
     book npages automate -var Npage -key pantaskState INIT.LAUNCH
     if ($Npage == 0) 
-      echo "no entries in INIT.LAUNCH state"
+      if ($VERBOSE >= 2)
+        echo "no entries in INIT.LAUNCH state"
+      end
       break
     end
@@ -232,10 +272,11 @@
     $automate_Nlaunch ++
     if ($automate_Nlaunch >= $Npage) set automate_Nlaunch = 0
-    echo "automate.launch $automate_Nlaunch"
 
     # search the automate book for an entry which is unstarted (state INIT.LAUNCH) 
     book getpage automate $automate_Nlaunch -var pageName -key pantaskState INIT.LAUNCH
     if ("$pageName" == "NULL") 
-      echo "entry $automate_Nlaunch not in INIT.LAUNCH state"
+      if ($VERBOSE >= 2)
+        echo "entry $automate_Nlaunch not in INIT.LAUNCH state"
+      end
       break 
     end
@@ -245,5 +286,7 @@
       # if there is no launch needed, we can immediate progress to the next stage (INIT.LAUNCH)
       book setword automate $pageName pantaskState INIT.LAUNCH
-      echo "$pageName is ready : INIT.LAUNCH"
+      if ($VERBOSE >= 2)
+        echo "$pageName is ready : INIT.LAUNCH"
+      end
       break
     end
@@ -251,5 +294,5 @@
     book setword automate $pageName pantaskState RUN.LAUNCH
 
-    if ($VERBOSE >= 1)
+    if ($VERBOSE >= 2)
       echo "starting automate launch for $pageName"
       echo "command $launchCommand"
@@ -265,5 +308,4 @@
     $pageName = $options:0
 
-    echo "completed $pageName launch"
     book setword automate $pageName pantaskState DONE.LAUNCH
   end
Index: trunk/ippTasks/simtest.auto
===================================================================
--- trunk/ippTasks/simtest.auto	(revision 16609)
+++ trunk/ippTasks/simtest.auto	(revision 16610)
@@ -4,5 +4,5 @@
 automate METADATA
   name       STR BIAS
-  block      STR "dettool -runs -det_type BIAS -dbname eamtest"
+  block      STR "dettool -runs -active -det_type BIAS -dbname eamtest"
   check      STR NONE
   launch     STR "dettool -definebyquery -workdir path://EAMWORK -inst SIMTEST -det_type BIAS -select_exp_type BIAS -dbname eamtest"
@@ -11,5 +11,5 @@
 automate METADATA
   name       STR DARK
-  block      STR "dettool -runs -det_type DARK -dbname eamtest"
+  block      STR "dettool -runs -active -det_type DARK -dbname eamtest"
   check      STR "detselect -search -inst SIMTEST -det_type BIAS -dbname eamtest"
   launch     STR "dettool -definebyquery -workdir path://EAMWORK -inst SIMTEST -det_type DARK -select_exp_type DARK -dbname eamtest"
@@ -18,5 +18,5 @@
 automate METADATA
   name       STR SHUTTER
-  block      STR "dettool -runs -det_type SHUTTER -dbname eamtest"
+  block      STR "dettool -runs -active -det_type SHUTTER -dbname eamtest"
   check      STR "detselect -search -inst SIMTEST -det_type DARK -dbname eamtest"
   launch     STR "dettool -definebyquery -workdir path://EAMWORK -inst SIMTEST -det_type SHUTTER -filter r -select_exp_type FLAT -select_filter r -dbname eamtest"
@@ -25,5 +25,5 @@
 automate METADATA
   name       STR FLAT-r
-  block      STR "dettool -runs -det_type FLAT -filter r -dbname eamtest"
+  block      STR "dettool -runs -active -det_type FLAT -filter r -dbname eamtest"
   check      STR "detselect -search -inst SIMTEST -det_type SHUTTER -dbname eamtest"
   launch     STR "dettool -definebyquery -workdir path://EAMWORK -inst SIMTEST -det_type FLAT -filter r -select_exp_type FLAT -select_filter r -dbname eamtest"
@@ -32,5 +32,5 @@
 automate METADATA
   name       STR FLAT-i
-  block      STR "dettool -runs -det_type FLAT -filter i -dbname eamtest"
+  block      STR "dettool -runs -active -det_type FLAT -filter i -dbname eamtest"
   check      STR "detselect -search -inst SIMTEST -det_type SHUTTER -dbname eamtest"
   launch     STR "dettool -definebyquery -workdir path://EAMWORK -inst SIMTEST -det_type FLAT -filter i -select_exp_type FLAT -select_filter i -dbname eamtest"
@@ -39,5 +39,5 @@
 automate METADATA
   name       STR OBJECT-r
-  block      STR "chiptool -block -label object.r -dbname eamtest"
+  block      STR "chiptool -unmasked -label object.r -dbname eamtest"
   check      STR "detselect -search -inst SIMTEST -det_type FLAT -dbname eamtest -filter r"
   launch     STR "chiptool -unblock -label object.r -dbname eamtest"
@@ -46,7 +46,30 @@
 automate METADATA
   name       STR OBJECT-i
-  block      STR "chiptool -block -label object.i -dbname eamtest"
+  block      STR "chiptool -unmasked -label object.i -dbname eamtest"
   check      STR "detselect -search -inst SIMTEST -det_type FLAT -dbname eamtest -filter i"
   launch     STR "chiptool -unblock -label object.i -dbname eamtest"
 END
 
+### there is a weakness in the label / block business: the labels are
+### generic, and the blocks are against those fairly generic words.
+### that makes it difficult to block and unblock science exposures
+### based on different detrend types that are available.  For example,
+### to block the r-band against the absence of the desired r-band
+### flat, we would need to specify a label specific to the r-band
+### images and remove that block when ready.
+
+### a better approach might be to modify the labels rather than the
+### blocks.  we can define, eg, chiptool -set_label -definebyquery to
+### turn assign the label names based on various properties of the
+### interesting images.
+
+### here is what the automate element might look like for such a circumstance:
+
+### automate METADATA
+###   name       STR OBJECT-i
+###   block      STR "chiptool -dbname eamtest -unmasked -label wait -filter i -time_begin 2008/1/1 -time_end 2008/1/2"
+###   check      STR "detselect -dbname eamtest -search -inst SIMTEST -det_type FLAT -dbname eamtest -filter i -time_begin 2008/1/1 -time_end 2008/1/2" 
+###   launch     STR "chiptool -dbname eamtest -set_label proc -label wait -dbname eamtest -time_begin 2008/1/1 -time_end 2008/1/2"
+### END
+
+### XXX still not quite there....
