Index: trunk/ippTasks/Makefile.am
===================================================================
--- trunk/ippTasks/Makefile.am	(revision 25282)
+++ trunk/ippTasks/Makefile.am	(revision 25299)
@@ -13,4 +13,5 @@
 	chip.pro \
 	camera.pro \
+	addstar.pro \
 	fake.pro \
 	warp.pro \
Index: trunk/ippTasks/addstar.pro
===================================================================
--- trunk/ippTasks/addstar.pro	(revision 25299)
+++ trunk/ippTasks/addstar.pro	(revision 25299)
@@ -0,0 +1,227 @@
+## addstar.pro : globals and support macros : -*- sh -*-
+## this file contains the tasks for running the addstar analysis stage
+## these tasks use the book addPendingExp
+
+# test for required global variables
+check.globals
+
+book init addPendingExp
+
+macro addstar.status
+  book listbook addPendingExp
+end
+
+macro addstar.reset
+  book init addPendingExp
+end
+
+macro addstar.on
+  task addstar.exp.load
+    active true
+  end
+  task addstar.exp.run
+    active true
+  end
+end
+
+macro addstar.off
+  task addstar.exp.load
+    active false
+  end
+  task addstar.exp.run
+    active false
+  end
+end
+
+# this variable will cycle through the known database names
+$addstar_DB = 0
+$addstar_revert_DB = 0
+
+# select images ready for addstar analysis
+# new entries are added to addPendingExp
+# skip already-present entries
+task	       addstar.exp.load
+  host         local
+
+  periods      -poll $LOADPOLL
+  periods      -exec $LOADEXEC
+  periods      -timeout 30
+  npending     1
+
+  stdout NULL
+  stderr $LOGDIR/addstar.exp.log
+
+  task.exec
+    if ($LABEL:n == 0) break
+    $run = addtool -pendingexp
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      # save the DB name for the exit tasks
+      option $DB:$addstar_DB
+      $run = $run -dbname $DB:$addstar_DB
+      $addstar_DB ++
+      if ($addstar_DB >= $DB:n) set addstar_DB = 0
+    end
+    add_poll_args run
+    add_poll_labels run
+    command $run
+  end
+
+  # success
+  task.exit    0
+    # convert 'stdout' to book format
+    ipptool2book stdout addPendingExp -key add_id -uniq -setword dbname $options:0 -setword pantaskState INIT
+    if ($VERBOSE > 2)
+      book listbook addPendingExp
+    end
+
+    # delete existing entries in the appropriate pantaskStates
+    process_cleanup addPendingExp
+  end
+
+  # default exit status
+  task.exit    default
+    showcommand failure
+  end
+
+  task.exit    crash
+    showcommand crash
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+  end
+end
+
+# run the addstar script on pending exposures
+task	       addstar.exp.run
+  periods      -poll $RUNPOLL
+  periods      -exec $RUNEXEC
+  periods      -timeout 10
+
+  task.exec
+    book npages addPendingExp -var N
+    if ($N == 0) break
+    if ($NETWORK == 0) break
+    
+    # look for new images in addPendingExp (pantaskState == INIT)
+    book getpage addPendingExp 0 -var pageName -key pantaskState INIT
+    if ("$pageName" == "NULL") break
+
+    book setword addPendingExp $pageName pantaskState RUN
+    book getword addPendingExp $pageName camera -var CAMERA
+    book getword addPendingExp $pageName exp_tag -var EXP_TAG
+    book getword addPendingExp $pageName add_id -var ADD_ID
+    book getword addPendingExp $pageName cam_id -var CAM_ID
+    book getword addPendingExp $pageName workdir -var WORKDIR_TEMPLATE
+    book getword addPendingExp $pageName dvodb  -var DVODB
+    book getword addPendingExp $pageName dbname -var DBNAME
+    book getword addPendingExp $pageName reduction -var REDUCTION
+    book getword addPendingExp $pageName state -var RUN_STATE
+
+    # specify choice of remote host based on camera and chip (class_id)
+    set.host.for.camera $CAMERA FPA
+
+    # set the WORKDIR variable
+    set.workdir.by.camera $CAMERA FPA $WORKDIR_TEMPLATE $default_host WORKDIR
+
+    # notes on how this works:
+    # -- raw workdir examples:
+    # file://data/@HOST@.0/gpc1/20080130
+    # neb:///@HOST@-vol0/gpc1/20080130 (need to supply volname?, or are we re-defining this each time?)
+    # -- out workdir examples:
+    # file://data/ipp004.0/gpc1/20080130
+    # neb:///ipp004-vol0/gpc1/20080130
+
+    ## generate outroot specific to this exposure (& chip)
+    sprintf outroot "%s/%s/%s.add.%s" $WORKDIR $EXP_TAG $EXP_TAG $ADD_ID
+    sprintf camroot "%s/%s/%s.cm.%s" $WORKDIR $EXP_TAG $EXP_TAG $CAM_ID
+
+    stdout $LOGDIR/addstar.exp.log
+    stderr $LOGDIR/addstar.exp.log
+
+    $run = addstar_run.pl --exp_tag $EXP_TAG --add_id $ADD_ID --camera $CAMERA --outroot $outroot --camroot $camroot --redirect-output --run-state $RUN_STATE
+    if ("$REDUCTION" != "NULL")
+      $run = $run --reduction $REDUCTION
+    end
+    if ("$DVODB" != "NULL")
+      $run = $run --dvodb $DVODB
+    end
+    add_standard_args run
+
+    # save the pageName for future reference below
+    options $pageName
+
+    # create the command line
+    if ($VERBOSE > 1)
+      echo command $run
+    end
+    command $run
+  end
+
+  # success
+  task.exit default
+    process_exit addPendingExp $options:0 $JOB_STATUS
+  end
+
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword addPendingExp $options:0 pantaskState CRASH
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+    book setword addPendingExp $options:0 pantaskState TIMEOUT
+  end
+end
+
+task addstar.revert
+  host         local
+
+  periods      -poll 5.0
+  periods      -exec 60.0
+  periods      -timeout 120.0
+  npending     1
+
+  stdout NULL
+  stderr $LOGDIR/revert.log
+
+  task.exec
+    if ($LABEL:n == 0) break
+    $run = addtool -revertprocessedexp
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      # save the DB name for the exit tasks
+      option $DB:$addstar_revert_DB
+      $run = $run -dbname $DB:$addstar_revert_DB
+      $addstar_revert_DB ++
+      if ($addstar_revert_DB >= $DB:n) set addstar_revert_DB = 0
+    end
+    add_poll_labels run
+    command $run
+  end
+
+  # success
+  task.exit    0
+  end
+
+  # locked list
+  task.exit    default
+    showcommand failure
+  end
+
+  task.exit    crash
+    showcommand crash
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+  end
+end
Index: trunk/ippTasks/pantasks.pro
===================================================================
--- trunk/ippTasks/pantasks.pro	(revision 25282)
+++ trunk/ippTasks/pantasks.pro	(revision 25299)
@@ -213,4 +213,5 @@
   chip.on
   camera.on
+  addstar.on
   fake.on
   warp.on
@@ -225,4 +226,5 @@
   chip.off
   camera.off
+  addstar.off
   fake.off
   warp.off
@@ -242,4 +244,5 @@
   module chip.pro
   module camera.pro
+  module addstar.pro
   module fake.pro
   module warp.pro
Index: trunk/ippTasks/summit.copy.pro
===================================================================
--- trunk/ippTasks/summit.copy.pro	(revision 25282)
+++ trunk/ippTasks/summit.copy.pro	(revision 25299)
@@ -449,4 +449,5 @@
         end
         if (("$MD5SUM" != "NULL") && ("$MD5SUM" != "0") && (not($COMPRESS)))
+# && (($YEAR > 2008) || (("$YEAR" = "2007") && ($MONTH > 8))))
             $run = $run --md5 $MD5SUM
         end
