Index: /trunk/ippTasks/camera.pro
===================================================================
--- /trunk/ippTasks/camera.pro	(revision 12016)
+++ /trunk/ippTasks/camera.pro	(revision 12016)
@@ -0,0 +1,141 @@
+## this file contains the tasks for running the phase 3 stage
+## these tasks use the book camPendingExp
+
+if ($?network == 0)
+  $network = 1
+end
+if ($?parallel == 0)
+  $parallel = 0
+end
+if ($?VERBOSE == 0)
+  echo "VERBOSE not defined: load pantasks.pro first"
+  break
+end
+if ($?LOGDIR == 0)
+  echo "LOGDIR not defined: load pantasks.pro first"
+  break
+end
+
+$LOGSUBDIR = $LOGDIR/camera
+exec mkdir -p $LOGSUBDIR
+
+book init camPendingExp
+
+macro camera.status
+  book listbook camPendingExp
+end
+
+# this variable will cycle through the known database names
+$camera_DB = 0
+
+# select images ready for camera analysis
+# new entries are added to camPendingExp
+# skip already-present entries
+task	       camera.exp.load
+  host         local
+
+  periods      -poll $loadpoll
+  periods      -exec $loadexec
+  periods      -timeout 30
+  npending     1
+
+  stdout $LOGSUBDIR/camera.exp.log
+  stderr $LOGSUBDIR/camera.exp.log
+
+  task.exec
+    if ($DB:n == 0)
+      option DEFAULT
+      command camtool -pendingexp -limit 20
+    else
+      # save the DB name for the exit tasks
+      option $DB:$camera_DB
+      command camtool -pendingexp -limit 20 -dbname $DB:$camera_DB
+      $camera_DB ++
+      if ($camera_DB >= $DB:n) set camera_DB = 0
+    end
+  end
+
+  # success
+  task.exit    0
+    # convert 'stdout' to book format
+    ipptool2book stdout camPendingExp -key exp_tag -uniq -setword dbname $options:0
+    if ($VERBOSE > 2)
+      book listbook camPendingExp
+    end
+
+    # delete existing entries in the appropriate states
+    process_cleanup camPendingExp
+  end
+
+  # default exit status
+  task.exit    default
+    showcommand failure
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+  end
+end
+
+# run the cameraexposure script on pending images
+task	       camera.exp.run
+  periods      -poll $runpoll
+  periods      -exec $runexec
+  periods      -timeout 10
+
+  task.exec
+    book npages camPendingExp -var N
+    if ($N == 0) break
+    if ($network == 0) break
+    
+    # look for new images in camPendingExp (state == NULL)
+    book getpage camPendingExp 0 -var pageName -key state NULL
+    if ($pageName == NULL) break
+
+    book setword camPendingExp $pageName state RUN
+    book getword camPendingExp $pageName camera -var CAMERA
+    book getword camPendingExp $pageName exp_tag -var EXP_TAG
+    book getword camPendingExp $pageName workdir -var WORKDIR
+    book getword camPendingExp $pageName dbname -var DBNAME
+    set_standard_args
+
+    # specify choice of remote host:(need to choose based on chips)
+    if ($parallel)
+      host anyhost
+    else
+      host local
+    end
+
+    # output log from filerule
+    $outroot = `ipp_datapath.pl $WORKDIR`
+    $outroot = $outroot/$EXP_TAG
+    # $logfile = `ipp_filename.pl CAMERA.LOG $outroot $CLASS_ID`
+    $logfile = $outroot/$EXP_TAG.$CLASS_ID.cam.log
+    stdout $logfile
+    stderr $logfile
+    exec mkdir -p $outroot
+
+    # save the pageName for future reference below
+    options $pageName
+
+    # create the command line
+    if ($VERBOSE > 1)
+      echo command camera_exp.pl --exp_tag $EXP_TAG $ARGS
+    end
+    command camera_exp.pl --exp_tag $EXP_TAG --camera $CAMERA $ARGS
+  end
+
+  # success
+  task.exit default
+    process_exit camPendingExp $options:0 $JOB_STATUS
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+    book setword camPendingExp $options:0 state TIMEOUT
+  end
+end
+
+## XXX add a global path to output files  
Index: /trunk/ippTasks/chip.pro
===================================================================
--- /trunk/ippTasks/chip.pro	(revision 12016)
+++ /trunk/ippTasks/chip.pro	(revision 12016)
@@ -0,0 +1,165 @@
+## this file contains the tasks for running the phase 0 stage
+## these tasks use the book chipPendingImfile
+
+if ($?network == 0)
+  $network = 1
+end
+if ($?parallel == 0)
+  $parallel = 0
+end
+if ($?VERBOSE == 0)
+  echo "VERBOSE not defined: load pantasks.pro first"
+  break
+end
+if ($?LOGDIR == 0)
+  echo "LOGDIR not defined: load pantasks.pro first"
+  break
+end
+
+$LOGSUBDIR = $LOGDIR/chip
+exec mkdir -p $LOGSUBDIR
+
+book init chipPendingImfile
+
+macro chip.status
+  book listbook chipPendingImfile
+end
+
+macro chip.reset
+  book init chipPendingImfile
+end
+
+macro chip.on
+  task chip.imfile.load
+    active true
+  end
+  task chip.imfile.run
+    active true
+  end
+end
+
+macro chip.off
+  task chip.imfile.load
+    active false
+  end
+  task chip.imfile.run
+    active false
+  end
+end
+
+# this variable will cycle through the known database names
+$chip_DB = 0
+
+# select images ready for chip analysis
+# new entries are added to chipPendingImfile
+# skip already-present entries
+task	       chip.imfile.load
+  host         local
+
+  periods      -poll $loadpoll
+  periods      -exec $loadexec
+  periods      -timeout 30
+  npending     1
+
+  stdout NULL
+  stderr $LOGSUBDIR/chip.imfile.log
+
+  task.exec
+    if ($DB:n == 0)
+      option DEFAULT
+      command chiptool -pendingimfile -limit 20
+    else
+      # save the DB name for the exit tasks
+      option $DB:$chip_DB
+      command chiptool -pendingimfile -limit 20 -dbname $DB:$chip_DB
+      $chip_DB ++
+      if ($chip_DB >= $DB:n) set chip_DB = 0
+    end
+  end
+
+  # success
+  task.exit    0
+    # convert 'stdout' to book format
+    ipptool2book stdout chipPendingImfile -key exp_tag:class_id -uniq -setword dbname $options:0
+    if ($VERBOSE > 2)
+      book listbook chipPendingImfile
+    end
+
+    # delete existing entries in the appropriate states
+    process_cleanup chipPendingImfile
+  end
+
+  # locked list
+  task.exit    default
+    showcommand failure
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+  end
+end
+
+# run the chip_imfile.pl script on pending images
+task	       chip.imfile.run
+  periods      -poll $runpoll
+  periods      -exec $runexec
+  periods      -timeout 60
+
+  task.exec
+    book npages chipPendingImfile -var N
+    if ($N == 0) break
+    if ($network == 0) break
+    
+    # look for new images in chipPendingImfile (state == NULL)
+    book getpage chipPendingImfile 0 -var pageName -key state NULL
+    if ($pageName == NULL) break
+
+    book setword chipPendingImfile $pageName state RUN
+    book getword chipPendingImfile $pageName camera -var CAMERA
+    book getword chipPendingImfile $pageName exp_tag -var EXP_TAG
+    book getword chipPendingImfile $pageName workdir -var WORKDIR
+    book getword chipPendingImfile $pageName class_id -var CLASS_ID
+    book getword chipPendingImfile $pageName uri -var URI
+    book getword chipPendingImfile $pageName workdir -var WORKDIR
+    book getword chipPendingImfile $pageName dbname -var DBNAME
+    set_standard_args
+
+    # specify choice of remote host
+    # XXX need to choose based on chips
+    if ($parallel)
+      host anyhost
+    else
+      host local
+    end
+
+    ## generate output log based on filerule
+    $outroot = `ipp_datapath.pl $WORKDIR`
+    $outroot = $outroot/$EXP_TAG
+    # $logfile = `ipp_filename.pl CHIP.LOG $outroot $CLASS_ID`
+    $logfile = $outroot/$EXP_TAG.$CLASS_ID.chip.log
+    stdout $logfile
+    stderr $logfile
+    exec mkdir -p $outroot
+
+    # save the pageName for future reference below
+    options $pageName
+
+    # create the command line
+    if ($VERBOSE > 1)
+      echo command chip_imfile.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI --camera $CAMERA $ARGS
+    end
+    command chip_imfile.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI --camera $CAMERA $ARGS
+  end
+
+  # default exit status
+  task.exit    default
+    process_exit chipPendingImfile $options:0 $JOB_STATUS
+  end
+
+  # operation timed out?
+  task.exit    timeout
+    showcommand timeout
+    book setword chipPendingImfile $options:0 state TIMEOUT
+  end
+end
Index: /trunk/ippTasks/pantasks.pro
===================================================================
--- /trunk/ippTasks/pantasks.pro	(revision 12015)
+++ /trunk/ippTasks/pantasks.pro	(revision 12016)
@@ -124,7 +124,7 @@
 
 macro module.tasks
-  module phase0.pro
-# module $scripts/phase2.pro
-# module $scripts/phase3.pro
+  module register.pro
+# module $scripts/chip.pro
+# module $scripts/camera.pro
   module detrend.process.pro
   module detrend.stack.pro
Index: unk/ippTasks/phase0.pro
===================================================================
--- /trunk/ippTasks/phase0.pro	(revision 12015)
+++ 	(revision )
@@ -1,290 +1,0 @@
-## this file contains the tasks for running the phase 0 stage
-## these tasks use the books p0PendingImfile and p0PendingExp
-
-if ($?network == 0)
-  $network = 1
-end
-if ($?parallel == 0)
-  $parallel = 0
-end
-if ($?VERBOSE == 0)
-  echo "VERBOSE not defined: load pantasks.pro first"
-  break
-end
-if ($?LOGDIR == 0)
-  echo "LOGDIR not defined: load pantasks.pro first"
-  break
-end
-
-$LOGSUBDIR = $LOGDIR/phase0
-exec mkdir -p $LOGSUBDIR
-
-book init p0PendingImfile
-book init p0PendingExp
-
-macro phase0.reset
-  book init p0PendingImfile
-  book init p0PendingExp
-end
-
-macro phase0.status
-  book listbook p0PendingImfile
-  book listbook p0PendingExp
-end
-
-macro phase0.on
-  task phase0.imfile.load
-    active true
-  end
-  task phase0.imfile.run
-    active true
-  end
-  task phase0.exp.load
-    active true
-  end
-  task phase0.exp.run
-    active true
-  end
-end
-
-macro phase0.off
-  task phase0.imfile.load
-    active false
-  end
-  task phase0.imfile.run
-    active false
-  end
-  task phase0.exp.load
-    active false
-  end
-  task phase0.exp.run
-    active false
-  end
-end
-
-# these variables will cycle through the known database names
-$p0PendingImfile_DB = 0
-$p0PendingExp_DB = 0
-
-# select images ready for phase0 analysis
-# new entries are added to p0PendingImfile
-# compare the new list with the ones already selected
-task	       phase0.imfile.load
-  host         local
-
-  periods      -poll $loadpoll
-  periods      -exec $loadexec
-  periods      -timeout 30
-  npending     1
-
-  # silently drop stdout
-  stdout NULL
-  stderr $LOGSUBDIR/phase0.imfile.log
-
-  # select entries from the current DB; cycle to the next DB, if it exists
-  # iff the DB list is not set, use the value defined in .ipprc
-  task.exec
-    if ($DB:n == 0)
-      option DEFAULT
-      command p0tool -pendingimfile -limit 20
-    else
-      # save the DB name for the exit tasks
-      option $DB:$p0PendingImfile_DB
-      command p0tool -pendingimfile -limit 20 -dbname $DB:$p0PendingImfile_DB
-      $p0PendingImfile_DB ++
-      if ($p0PendingImfile_DB >= $DB:n) set p0PendingImfile_DB = 0
-    end
-  end
-
-  # success
-  task.exit $EXIT_SUCCESS
-    # convert 'stdout' to book format
-    ipptool2book stdout p0PendingImfile -key exp_tag -uniq -setword dbname $options:0
-    if ($VERBOSE > 2)
-      book listbook p0PendingImfile
-    end
-
-    # delete existing entries in the appropriate states
-    process_cleanup p0PendingImfile
-  end
-
-  # locked list
-  task.exit    default
-    showcommand failure
-  end
-
-  # operation times out?
-  task.exit    timeout
-    showcommand timeout
-  end
-end
-
-# run the phase0_imfile.pl script on pending images
-task	       phase0.imfile.run
-  periods      -poll $runpoll
-  periods      -exec $runexec
-  periods      -timeout 30
-
-  task.exec
-    book npages p0PendingImfile -var N
-    if ($N == 0) break
-    if ($network == 0) break
-    
-    # look for new images in p0PendingImfile
-    book getpage p0PendingImfile 0 -var pageName -key state NULL
-    if ($pageName == NULL) break
-
-    book setword p0PendingImfile $pageName state RUN
-
-    book getword p0PendingImfile $pageName exp_tag -var EXP_TAG
-    book getword p0PendingImfile $pageName class -var CLASS
-    book getword p0PendingImfile $pageName class_id -var CLASS_ID
-    book getword p0PendingImfile $pageName uri -var URI
-    book getword p0PendingImfile $pageName workdir -var WORKDIR
-    book getword p0PendingImfile $pageName dbname -var DBNAME
-    set_standard_args
-
-    # specify choice of remote host
-    if ($parallel)
-      host anyhost
-    else
-      host local
-    end
-
-    ## generate output log based on filerule XXX put this in a function?
-    $outroot = `ipp_datapath.pl $WORKDIR`
-    $outroot = $outroot/$EXP_TAG
-    # $logfile = `ipp_filename.pl PHASE0.LOG $outroot $CLASS_ID`
-    $logfile = $outroot/$EXP_TAG.$CLASS_ID.p0.log
-    stdout $logfile
-    stderr $logfile
-    exec mkdir -p $outroot
-
-    # save the pageName for future reference below
-    options $pageName
-
-    # create the command line
-    if ($VERBOSE > 1)
-      echo command phase0_imfile.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI $ARGS
-    end
-    command phase0_imfile.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI $ARGS
-  end
-
-  # default exit status
-  task.exit default
-    process_exit p0PendingImfile $options:0 $JOB_STATUS
-  end
-
-  # operation timed out?
-  task.exit    timeout
-    showcommand timeout
-    book setword p0PendingImfile $options:0 state TIMEOUT
-  end
-end
-
-# select exposures ready for phase0_exp.pl
-task	       phase0.exp.load
-  host         local
-
-  periods      -poll $loadpoll
-  periods      -exec $loadexec
-  periods      -timeout 30
-
-  stdout NULL
-  stderr $LOGSUBDIR/phase0.exp.log
-
-  task.exec
-    if ($DB:n == 0)
-      option DEFAULT
-      command p0tool -pendingexp -limit 20
-    else
-      # save the DB name for the exit tasks
-      option $DB:$p0PendingExp_DB
-      command p0tool -pendingexp -limit 20 -dbname $DB:$p0PendingExp_DB
-      $p0PendingExp_DB ++
-      if ($p0PendingExp_DB >= $DB:n) set p0PendingExp_DB = 0
-    end
-  end
-
-  # success
-  task.exit $EXIT_SUCCESS
-    # convert 'stdout' to book format
-    ipptool2book stdout p0PendingExp -key exp_tag -uniq -setword dbname $options:0
-    if ($VERBOSE > 2)
-      book listbook p0PendingExp
-    end
-
-    # delete existing entries in the appropriate states
-    process_cleanup p0PendingExp
-  end
-
-  # default exit status
-  task.exit    default
-    showcommand failure
-  end
-
-  # operation times out?
-  task.exit    timeout
-    showcommand timeout
-  end
-end
-
-# run the phase0_exp.pl script on pending exposures
-task	       phase0.exp.run
-  periods      -poll $runpoll
-  periods      -exec $runexec
-  periods      -timeout 30
-
-  task.exec
-    book npages p0PendingExp -var N
-    if ($N == 0) break
-    if ($network == 0) break
-    
-    # look for new images in p0PendingExp (state == NULL)
-    book getpage p0PendingExp 0 -var pageName -key state NULL
-    if ($pageName == NULL) break
-
-    book setword p0PendingExp $pageName state RUN
-    book getword p0PendingExp $pageName exp_tag -var EXP_TAG
-    book getword p0PendingExp $pageName workdir -var WORKDIR
-    book getword p0PendingExp $pageName dbname -var DBNAME
-    set_standard_args
-
-    # specify choice of remote host:(need to choose based on chips)
-    if ($parallel)
-      host anyhost
-    else
-      host local
-    end
-
-    ## generate output log based on filerule
-    $outroot = `ipp_datapath.pl $WORKDIR`
-    $outroot = $outroot/$EXP_TAG
-    $logfile = $outroot/$EXP_TAG.p0.log
-    stdout $logfile
-    stderr $logfile
-    exec mkdir -p $outroot
-
-    # save the pageName for future reference below
-    options $pageName
-
-    # create the command line
-    if ($VERBOSE > 1)
-      echo command phase0_exp.pl --exp_tag $EXP_TAG $ARGS
-    end
-    command phase0_exp.pl --exp_tag $EXP_TAG $ARGS
-  end
-
-  # success
-  task.exit default
-    process_exit p0PendingExp $options:0 $JOB_STATUS
-  end
-
-  # operation times out?
-  task.exit    timeout
-    showcommand timeout
-    book setword p0PendingExp $options:0 state TIMEOUT
-  end
-end
-
-## XXX add a global path to output files  
Index: unk/ippTasks/phase2.pro
===================================================================
--- /trunk/ippTasks/phase2.pro	(revision 12015)
+++ 	(revision )
@@ -1,165 +1,0 @@
-## this file contains the tasks for running the phase 0 stage
-## these tasks use the book p2PendingImfile
-
-if ($?network == 0)
-  $network = 1
-end
-if ($?parallel == 0)
-  $parallel = 0
-end
-if ($?VERBOSE == 0)
-  echo "VERBOSE not defined: load pantasks.pro first"
-  break
-end
-if ($?LOGDIR == 0)
-  echo "LOGDIR not defined: load pantasks.pro first"
-  break
-end
-
-$LOGSUBDIR = $LOGDIR/phase2
-exec mkdir -p $LOGSUBDIR
-
-book init p2PendingImfile
-
-macro phase2.status
-  book listbook p2PendingImfile
-end
-
-macro phase2.reset
-  book init p2PendingImfile
-end
-
-macro phase2.on
-  task phase2.imfile.load
-    active true
-  end
-  task phase2.imfile.run
-    active true
-  end
-end
-
-macro phase2.off
-  task phase2.imfile.load
-    active false
-  end
-  task phase2.imfile.run
-    active false
-  end
-end
-
-# this variable will cycle through the known database names
-$phase2_DB = 0
-
-# select images ready for phase2 analysis
-# new entries are added to p2PendingImfile
-# skip already-present entries
-task	       phase2.imfile.load
-  host         local
-
-  periods      -poll $loadpoll
-  periods      -exec $loadexec
-  periods      -timeout 30
-  npending     1
-
-  stdout NULL
-  stderr $LOGSUBDIR/phase2.imfile.log
-
-  task.exec
-    if ($DB:n == 0)
-      option DEFAULT
-      command p2tool -pendingimfile -limit 20
-    else
-      # save the DB name for the exit tasks
-      option $DB:$phase2_DB
-      command p2tool -pendingimfile -limit 20 -dbname $DB:$phase2_DB
-      $phase2_DB ++
-      if ($phase2_DB >= $DB:n) set phase2_DB = 0
-    end
-  end
-
-  # success
-  task.exit    0
-    # convert 'stdout' to book format
-    ipptool2book stdout p2PendingImfile -key exp_tag:class_id -uniq -setword dbname $options:0
-    if ($VERBOSE > 2)
-      book listbook p2PendingImfile
-    end
-
-    # delete existing entries in the appropriate states
-    process_cleanup p2PendingImfile
-  end
-
-  # locked list
-  task.exit    default
-    showcommand failure
-  end
-
-  # operation times out?
-  task.exit    timeout
-    showcommand timeout
-  end
-end
-
-# run the phase2.pl script on pending images
-task	       phase2.imfile.run
-  periods      -poll $runpoll
-  periods      -exec $runexec
-  periods      -timeout 60
-
-  task.exec
-    book npages p2PendingImfile -var N
-    if ($N == 0) break
-    if ($network == 0) break
-    
-    # look for new images in p2PendingImfile (state == NULL)
-    book getpage p2PendingImfile 0 -var pageName -key state NULL
-    if ($pageName == NULL) break
-
-    book setword p2PendingImfile $pageName state RUN
-    book getword p2PendingImfile $pageName camera -var CAMERA
-    book getword p2PendingImfile $pageName exp_tag -var EXP_TAG
-    book getword p2PendingImfile $pageName workdir -var WORKDIR
-    book getword p2PendingImfile $pageName class_id -var CLASS_ID
-    book getword p2PendingImfile $pageName uri -var URI
-    book getword p2PendingImfile $pageName workdir -var WORKDIR
-    book getword p2PendingImfile $pageName dbname -var DBNAME
-    set_standard_args
-
-    # specify choice of remote host
-    # XXX need to choose based on chips
-    if ($parallel)
-      host anyhost
-    else
-      host local
-    end
-
-    ## generate output log based on filerule
-    $outroot = `ipp_datapath.pl $WORKDIR`
-    $outroot = $outroot/$EXP_TAG
-    # $logfile = `ipp_filename.pl PHASE2.LOG $outroot $CLASS_ID`
-    $logfile = $outroot/$EXP_TAG.$CLASS_ID.p2.log
-    stdout $logfile
-    stderr $logfile
-    exec mkdir -p $outroot
-
-    # save the pageName for future reference below
-    options $pageName
-
-    # create the command line
-    if ($VERBOSE > 1)
-      echo command phase2.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI --camera $CAMERA $ARGS
-    end
-    command phase2.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI --camera $CAMERA $ARGS
-  end
-
-  # default exit status
-  task.exit    default
-    process_exit p2PendingImfile $options:0 $JOB_STATUS
-  end
-
-  # operation timed out?
-  task.exit    timeout
-    showcommand timeout
-    book setword p2PendingImfile $options:0 state TIMEOUT
-  end
-end
Index: unk/ippTasks/phase3.pro
===================================================================
--- /trunk/ippTasks/phase3.pro	(revision 12015)
+++ 	(revision )
@@ -1,141 +1,0 @@
-## this file contains the tasks for running the phase 3 stage
-## these tasks use the book p3PendingExp
-
-if ($?network == 0)
-  $network = 1
-end
-if ($?parallel == 0)
-  $parallel = 0
-end
-if ($?VERBOSE == 0)
-  echo "VERBOSE not defined: load pantasks.pro first"
-  break
-end
-if ($?LOGDIR == 0)
-  echo "LOGDIR not defined: load pantasks.pro first"
-  break
-end
-
-$LOGSUBDIR = $LOGDIR/phase3
-exec mkdir -p $LOGSUBDIR
-
-book init p3PendingExp
-
-macro phase3.status
-  book listbook p3PendingExp
-end
-
-# this variable will cycle through the known database names
-$phase3_DB = 0
-
-# select images ready for phase3 analysis
-# new entries are added to p3PendingExp
-# skip already-present entries
-task	       phase3.exp.load
-  host         local
-
-  periods      -poll $loadpoll
-  periods      -exec $loadexec
-  periods      -timeout 30
-  npending     1
-
-  stdout $LOGSUBDIR/phase3.exp.log
-  stderr $LOGSUBDIR/phase3.exp.log
-
-  task.exec
-    if ($DB:n == 0)
-      option DEFAULT
-      command p3tool -pendingexp -limit 20
-    else
-      # save the DB name for the exit tasks
-      option $DB:$phase3_DB
-      command p3tool -pendingexp -limit 20 -dbname $DB:$phase3_DB
-      $phase3_DB ++
-      if ($phase3_DB >= $DB:n) set phase3_DB = 0
-    end
-  end
-
-  # success
-  task.exit    0
-    # convert 'stdout' to book format
-    ipptool2book stdout p3PendingExp -key exp_tag -uniq -setword dbname $options:0
-    if ($VERBOSE > 2)
-      book listbook p3PendingExp
-    end
-
-    # delete existing entries in the appropriate states
-    process_cleanup p3PendingExp
-  end
-
-  # default exit status
-  task.exit    default
-    showcommand failure
-  end
-
-  # operation times out?
-  task.exit    timeout
-    showcommand timeout
-  end
-end
-
-# run the phase3exposure script on pending images
-task	       phase3.exp.run
-  periods      -poll $runpoll
-  periods      -exec $runexec
-  periods      -timeout 10
-
-  task.exec
-    book npages p3PendingExp -var N
-    if ($N == 0) break
-    if ($network == 0) break
-    
-    # look for new images in p3PendingExp (state == NULL)
-    book getpage p3PendingExp 0 -var pageName -key state NULL
-    if ($pageName == NULL) break
-
-    book setword p3PendingExp $pageName state RUN
-    book getword p3PendingExp $pageName camera -var CAMERA
-    book getword p3PendingExp $pageName exp_tag -var EXP_TAG
-    book getword p3PendingExp $pageName workdir -var WORKDIR
-    book getword p3PendingExp $pageName dbname -var DBNAME
-    set_standard_args
-
-    # specify choice of remote host:(need to choose based on chips)
-    if ($parallel)
-      host anyhost
-    else
-      host local
-    end
-
-    # output log from filerule
-    $outroot = `ipp_datapath.pl $WORKDIR`
-    $outroot = $outroot/$EXP_TAG
-    # $logfile = `ipp_filename.pl PHASE3.LOG $outroot $CLASS_ID`
-    $logfile = $outroot/$EXP_TAG.$CLASS_ID.p3.log
-    stdout $logfile
-    stderr $logfile
-    exec mkdir -p $outroot
-
-    # save the pageName for future reference below
-    options $pageName
-
-    # create the command line
-    if ($VERBOSE > 1)
-      echo command phase3.pl --exp_tag $EXP_TAG $ARGS
-    end
-    command phase3.pl --exp_tag $EXP_TAG --camera $CAMERA $ARGS
-  end
-
-  # success
-  task.exit default
-    process_exit p3PendingExp $options:0 $JOB_STATUS
-  end
-
-  # operation times out?
-  task.exit    timeout
-    showcommand timeout
-    book setword p3PendingExp $options:0 state TIMEOUT
-  end
-end
-
-## XXX add a global path to output files  
Index: /trunk/ippTasks/register.pro
===================================================================
--- /trunk/ippTasks/register.pro	(revision 12016)
+++ /trunk/ippTasks/register.pro	(revision 12016)
@@ -0,0 +1,290 @@
+## this file contains the tasks for running the registration stage
+## these tasks use the books regPendingImfile and regPendingExp
+
+if ($?network == 0)
+  $network = 1
+end
+if ($?parallel == 0)
+  $parallel = 0
+end
+if ($?VERBOSE == 0)
+  echo "VERBOSE not defined: load pantasks.pro first"
+  break
+end
+if ($?LOGDIR == 0)
+  echo "LOGDIR not defined: load pantasks.pro first"
+  break
+end
+
+$LOGSUBDIR = $LOGDIR/register
+exec mkdir -p $LOGSUBDIR
+
+book init regPendingImfile
+book init regPendingExp
+
+macro register.reset
+  book init regPendingImfile
+  book init regPendingExp
+end
+
+macro register.status
+  book listbook regPendingImfile
+  book listbook regPendingExp
+end
+
+macro register.on
+  task register.imfile.load
+    active true
+  end
+  task register.imfile.run
+    active true
+  end
+  task register.exp.load
+    active true
+  end
+  task register.exp.run
+    active true
+  end
+end
+
+macro register.off
+  task register.imfile.load
+    active false
+  end
+  task register.imfile.run
+    active false
+  end
+  task register.exp.load
+    active false
+  end
+  task register.exp.run
+    active false
+  end
+end
+
+# these variables will cycle through the known database names
+$regPendingImfile_DB = 0
+$regPendingExp_DB = 0
+
+# select images ready for register analysis
+# new entries are added to regPendingImfile
+# compare the new list with the ones already selected
+task	       register.imfile.load
+  host         local
+
+  periods      -poll $loadpoll
+  periods      -exec $loadexec
+  periods      -timeout 30
+  npending     1
+
+  # silently drop stdout
+  stdout NULL
+  stderr $LOGSUBDIR/register.imfile.log
+
+  # select entries from the current DB; cycle to the next DB, if it exists
+  # iff the DB list is not set, use the value defined in .ipprc
+  task.exec
+    if ($DB:n == 0)
+      option DEFAULT
+      command regtool -pendingimfile -limit 20
+    else
+      # save the DB name for the exit tasks
+      option $DB:$regPendingImfile_DB
+      command regtool -pendingimfile -limit 20 -dbname $DB:$regPendingImfile_DB
+      $regPendingImfile_DB ++
+      if ($regPendingImfile_DB >= $DB:n) set regPendingImfile_DB = 0
+    end
+  end
+
+  # success
+  task.exit $EXIT_SUCCESS
+    # convert 'stdout' to book format
+    ipptool2book stdout regPendingImfile -key exp_tag -uniq -setword dbname $options:0
+    if ($VERBOSE > 2)
+      book listbook regPendingImfile
+    end
+
+    # delete existing entries in the appropriate states
+    process_cleanup regPendingImfile
+  end
+
+  # locked list
+  task.exit    default
+    showcommand failure
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+  end
+end
+
+# run the register_imfile.pl script on pending images
+task	       register.imfile.run
+  periods      -poll $runpoll
+  periods      -exec $runexec
+  periods      -timeout 30
+
+  task.exec
+    book npages regPendingImfile -var N
+    if ($N == 0) break
+    if ($network == 0) break
+    
+    # look for new images in regPendingImfile
+    book getpage regPendingImfile 0 -var pageName -key state NULL
+    if ($pageName == NULL) break
+
+    book setword regPendingImfile $pageName state RUN
+
+    book getword regPendingImfile $pageName exp_tag -var EXP_TAG
+    book getword regPendingImfile $pageName class -var CLASS
+    book getword regPendingImfile $pageName class_id -var CLASS_ID
+    book getword regPendingImfile $pageName uri -var URI
+    book getword regPendingImfile $pageName workdir -var WORKDIR
+    book getword regPendingImfile $pageName dbname -var DBNAME
+    set_standard_args
+
+    # specify choice of remote host
+    if ($parallel)
+      host anyhost
+    else
+      host local
+    end
+
+    ## generate output log based on filerule XXX put this in a function?
+    $outroot = `ipp_datapath.pl $WORKDIR`
+    $outroot = $outroot/$EXP_TAG
+    # $logfile = `ipp_filename.pl REGISTER.LOG $outroot $CLASS_ID`
+    $logfile = $outroot/$EXP_TAG.$CLASS_ID.reg.log
+    stdout $logfile
+    stderr $logfile
+    exec mkdir -p $outroot
+
+    # save the pageName for future reference below
+    options $pageName
+
+    # create the command line
+    if ($VERBOSE > 1)
+      echo command register_imfile.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI $ARGS
+    end
+    command register_imfile.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI $ARGS
+  end
+
+  # default exit status
+  task.exit default
+    process_exit regPendingImfile $options:0 $JOB_STATUS
+  end
+
+  # operation timed out?
+  task.exit    timeout
+    showcommand timeout
+    book setword regPendingImfile $options:0 state TIMEOUT
+  end
+end
+
+# select exposures ready for register_exp.pl
+task	       register.exp.load
+  host         local
+
+  periods      -poll $loadpoll
+  periods      -exec $loadexec
+  periods      -timeout 30
+
+  stdout NULL
+  stderr $LOGSUBDIR/register.exp.log
+
+  task.exec
+    if ($DB:n == 0)
+      option DEFAULT
+      command regtool -pendingexp -limit 20
+    else
+      # save the DB name for the exit tasks
+      option $DB:$regPendingExp_DB
+      command regtool -pendingexp -limit 20 -dbname $DB:$regPendingExp_DB
+      $regPendingExp_DB ++
+      if ($regPendingExp_DB >= $DB:n) set regPendingExp_DB = 0
+    end
+  end
+
+  # success
+  task.exit $EXIT_SUCCESS
+    # convert 'stdout' to book format
+    ipptool2book stdout regPendingExp -key exp_tag -uniq -setword dbname $options:0
+    if ($VERBOSE > 2)
+      book listbook regPendingExp
+    end
+
+    # delete existing entries in the appropriate states
+    process_cleanup regPendingExp
+  end
+
+  # default exit status
+  task.exit    default
+    showcommand failure
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+  end
+end
+
+# run the register_exp.pl script on pending exposures
+task	       register.exp.run
+  periods      -poll $runpoll
+  periods      -exec $runexec
+  periods      -timeout 30
+
+  task.exec
+    book npages regPendingExp -var N
+    if ($N == 0) break
+    if ($network == 0) break
+    
+    # look for new images in regPendingExp (state == NULL)
+    book getpage regPendingExp 0 -var pageName -key state NULL
+    if ($pageName == NULL) break
+
+    book setword regPendingExp $pageName state RUN
+    book getword regPendingExp $pageName exp_tag -var EXP_TAG
+    book getword regPendingExp $pageName workdir -var WORKDIR
+    book getword regPendingExp $pageName dbname -var DBNAME
+    set_standard_args
+
+    # specify choice of remote host:(need to choose based on chips)
+    if ($parallel)
+      host anyhost
+    else
+      host local
+    end
+
+    ## generate output log based on filerule
+    $outroot = `ipp_datapath.pl $WORKDIR`
+    $outroot = $outroot/$EXP_TAG
+    $logfile = $outroot/$EXP_TAG.reg.log
+    stdout $logfile
+    stderr $logfile
+    exec mkdir -p $outroot
+
+    # save the pageName for future reference below
+    options $pageName
+
+    # create the command line
+    if ($VERBOSE > 1)
+      echo command register_exp.pl --exp_tag $EXP_TAG $ARGS
+    end
+    command register_exp.pl --exp_tag $EXP_TAG $ARGS
+  end
+
+  # success
+  task.exit default
+    process_exit regPendingExp $options:0 $JOB_STATUS
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+    book setword regPendingExp $options:0 state TIMEOUT
+  end
+end
+
+## XXX add a global path to output files  
