Index: /trunk/ippTasks/calibration.pro
===================================================================
--- /trunk/ippTasks/calibration.pro	(revision 16274)
+++ /trunk/ippTasks/calibration.pro	(revision 16275)
@@ -1,4 +1,4 @@
 ## this file contains the tasks for running the calibration stage
-## these tasks use the books XXX
+## these tasks use the book 'calBook'
 
 if ($?network == 0)
@@ -42,18 +42,23 @@
 end
 
-# these variables will cycle through the known database names
+# these variables will cycle through the known ippdb database names
 $calInit_DB = 0
+
+# we have three steps here:
+# 1) get the list of dvo databases:  caltool -dbs
+# 2) define a new calibration run for each of the dvo dbs
+#    caltool 
 
 # create new calibration entries for the currently known DVO databases
 # run this multiple times once an hour - on pass for each db
-task	       calibration.init
+task	       calibration.load
   host         local
 
-  periods      -poll $loadpoll
-  periods      -exec $loadexec
+  # check the list of available dvo dbs regularly
+  periods      -poll 10
+  periods      -exec 900
   periods      -timeout 60
-  trange        Hourly@00:00 Hourly@00:10
-  # every hour on the hour
 
+  # this is a strange construction; what is the purpose?
   if ($DB:n == 0) 
     npending $DB:n
@@ -62,37 +67,25 @@
   end
 
+  # define the command (does not depend on previous queries)
+  if ($DB:n == 0)
+    command caltool -dbs -active true
+  else
+    # save the DB name for the exit tasks
+    # note that this DB name refers to the ippdb, not the dvodb
+    option $DB:$calInit_DB
+    command caltool -dbs -dbname $DB:$calInit_DB
+    $calInit_DB ++
+    if ($calInit_DB >= $DB:n) set calInit_DB = 0
+  end
+
   # silently drop stdout
   stdout NULL
   stderr $LOGSUBDIR/calibration.log
 
-  ## XXX have caltool define the regions, or have the task.exit below do it? 
-
-  # generate queues for all of the known (and active) DVO databases
-  task.exec
-    # get the current ST: 
-    $RAs = 15*($ST - 1)
-    $RAe = 15*($ST - 2)
-    $DECs = -90.0
-    $DECe = +90.0
-
-    $REGION = "$RAs,$RAe:$DECs,$DECe"
-
-    if ($DB:n == 0)
-      option DEFAULT
-      command caltool -databases -active true
-    else
-      # save the DB name for the exit tasks
-      option $DB:$calInit_DB
-      option $REGION
-      command caltool -databases -dbname $DB:$calInit_DB -region $REGION
-      $calInit_DB ++
-      if ($calInit_DB >= $DB:n) set calInit_DB = 0
-    end
-  end
-
   # success
   task.exit $EXIT_SUCCESS
     # convert 'stdout' to book format
-    ipptool2book stdout calBook -key dbname:dvo_id -uniq -setword dbname $options:0 -setword region $options:1 -setword pantaskState INIT
+    # XXX have ippTools report the dbname?
+    ipptool2book stdout calBook -key dbname:cal_id -uniq -setword dbname $options:0 -setword pantaskState INIT
     if ($VERBOSE > 2)
       book listbook calBook
@@ -115,5 +108,6 @@
 
 # create new calibration entries for the currently known DVO databases
-# run this multiple times once an hour - on pass for each db
+# run this multiple times once an hour - one pass for each db
+# can we include information that the db has been updated without a recent cal analysis?
 task	       calibration.resort
   host         local
@@ -122,4 +116,6 @@
   periods      -exec $loadexec
   periods      -timeout 60
+  # trange     Hourly@00:00 Hourly@00:10
+  # every hour on the hour
   npending     1
 
@@ -138,12 +134,22 @@
     if ("$pageName" == "NULL") break
 
+    # get the current ST: 
+    $RAs = 15*($ST - 1)
+    $RAe = 15*($ST - 2)
+    $DECs = -90.0
+    $DECe = +90.0
+
+    $REGION = "$RAs,$RAe:$DECs,$DECe"
+
     book setword calBook $pageName pantaskState     RUN
+    book setword calBook $pageName region           $REGION
 
     # XXX probably need to set the output / log based on WORKDIR...
-    book getword calBook $pageName catdir -var CATDIR
-    book getword calBook $pageName region -var REGION
-    book getword calBook $pageName dbname -var DBNAME
+    book getword calBook $pageName cal_id      -var ID
+    book getword calBook $pageName dvodb       -var DVODB
+    book getword calBook $pageName dbname      -var DBNAME
 
     # specify choice of remote host
+    # set a specific DVO host here 
     if ($parallel)
       host anyhost
@@ -152,12 +158,9 @@
     end
 
-    ## XXX generate output log based on filerule?
-    ## XXX put this in a function?
-
     # save the pageName for future reference below
     options $pageName
 
     # XXX do we modify relphot to loop over the filters?
-    $run = calibrate_dvo.pl --catdir $CATDIR --region $REGION
+    $run = calibrate_dvo.pl --cal_id $ID --dvodb $DVODB --region $REGION
     add_standard_args run
 
