Index: trunk/ippTasks/flatcorr.pro
===================================================================
--- trunk/ippTasks/flatcorr.pro	(revision 20381)
+++ trunk/ippTasks/flatcorr.pro	(revision 20382)
@@ -66,19 +66,21 @@
 
   # check the list of pending flatcorr runs
-  periods      -poll 10
-  periods      -exec 120
+  periods      -poll $LOADPOLL
+  periods      -exec $LOADEXEC
   periods      -timeout 60
   npending 1
 
-  # define the command (does not depend on previous queries)
-  if ($DB:n == 0)
-    command flatcorr -addcamera
-  else
-    # save the DB name for the exit tasks
-    # note that this DB name refers to the ippdb, not the dvodb
-    option $DB:$flatcorr_addcamera_DB
-    command flatcorr -addcamera -dbname $DB:$flatcorr_addcamera_DB
-    $flatcorr_addcamera_DB ++
-    if ($flatcorr_addcamera_DB >= $DB:n) set flatcorr_addcamera_DB = 0
+  task.exec
+    # define the command (does not depend on previous queries)
+    if ($DB:n == 0)
+      command flatcorr -addcamera
+    else
+      # save the DB name for the exit tasks
+      # note that this DB name refers to the ippdb, not the dvodb
+      option $DB:$flatcorr_addcamera_DB
+      command flatcorr -addcamera -dbname $DB:$flatcorr_addcamera_DB
+      $flatcorr_addcamera_DB ++
+      if ($flatcorr_addcamera_DB >= $DB:n) set flatcorr_addcamera_DB = 0
+    end
   end
 
@@ -108,20 +110,24 @@
 
   # check the list of pending flatcorr runs
-  periods      -poll 10
-  periods      -exec 900
+  periods      -poll $LOADPOLL
+  periods      -exec $LOADEXEC
   periods      -timeout 60
   npending 1
 
   # define the command (does not depend on previous queries)
-  $run = flatcorr -pendingprocess
-  if ($DB:n != 0)
-    # save the DB name for the exit tasks
-    option $DB:$flatcorr_pendingprocess_DB
-    $run = $run -dbname $DB:$flatcorr_pendingprocess_DB
-    $flatcorr_pendingprocess_DB ++
-    if ($flatcorr_pendingprocess_DB >= $DB:n) set flatcorr_pendingprocess_DB = 0
-  end
-  add_poll_args run
-  command $run
+  task.exec
+    if ($DB:n == 0)
+      $run = flatcorr -pendingprocess
+    else 
+      $run = flatcorr -pendingprocess
+      # save the DB name for the exit tasks
+      option $DB:$flatcorr_pendingprocess_DB
+      $run = $run -dbname $DB:$flatcorr_pendingprocess_DB
+      $flatcorr_pendingprocess_DB ++
+      if ($flatcorr_pendingprocess_DB >= $DB:n) set flatcorr_pendingprocess_DB = 0
+    end
+    add_poll_args run
+    command $run
+  end
 
   # silently drop stdout
@@ -175,5 +181,6 @@
 
     # XXX probably need to set the output / log based on WORKDIR...
-    book getword flatcorrBook $pageName corr_id     -var ID
+    book getword flatcorrBook $pageName corr_id     -var CORR_ID
+    book getword flatcorrBook $pageName det_type    -var DET_TYPE
     book getword flatcorrBook $pageName dvodb       -var DVODB
     book getword flatcorrBook $pageName camera      -var CAMERA
@@ -181,5 +188,5 @@
     book getword flatcorrBook $pageName filter      -var FILTER
     book getword flatcorrBook $pageName dbname      -var DBNAME
-    book getword flatcorrBook $pageName workdir     -var WORKDIR
+    book getword flatcorrBook $pageName workdir     -var WORKDIR_TEMPLATE
 
     # specify choice of remote host
@@ -194,6 +201,12 @@
     options $pageName
 
+    # see chip.pro for examples
+    set.workdir.by.camera $CAMERA FPA $WORKDIR_TEMPLATE $default_host WORKDIR
+
+    ## generate outroot specific to this exposure (& chip)
+    sprintf outroot "%s/%s.flatcorr.%s" $WORKDIR $CAMERA $CORR_ID
+
     # XXX get these arguments right
-    $run = flatcorr_proc.pl --corr_id $ID --dvodb $DVODB --camera $CAMERA --region $REGION --filter $FILTER 
+    $run = flatcorr_proc.pl --corr_id $CORR_ID --det_type $DET_TYPE --dvodb $DVODB --camera $CAMERA --region $REGION --filter $FILTER --workdir $outroot
     add_standard_args run
 
