Index: branches/eam_branches/ipp-ops-20130712/ippTasks/Makefile.am
===================================================================
--- branches/eam_branches/ipp-ops-20130712/ippTasks/Makefile.am	(revision 37064)
+++ branches/eam_branches/ipp-ops-20130712/ippTasks/Makefile.am	(revision 37068)
@@ -48,5 +48,7 @@
 	lapgroup.pro \
 	vp.pro \
-	bg.regeneration.pro
+	bg.regeneration.pro \
+	remote.pro \
+	fullforce.pro
 
 other_files = \
Index: branches/eam_branches/ipp-ops-20130712/ippTasks/dist.pro
===================================================================
--- branches/eam_branches/ipp-ops-20130712/ippTasks/dist.pro	(revision 37064)
+++ branches/eam_branches/ipp-ops-20130712/ippTasks/dist.pro	(revision 37068)
@@ -31,4 +31,6 @@
 list DIST_STAGE -add "warp_bg"
 list DIST_STAGE -add "sky"
+list DIST_STAGE -add "skycal"
+list DIST_STAGE -add "ff"
 
 $currentStage = 0
Index: branches/eam_branches/ipp-ops-20130712/ippTasks/fullforce.pro
===================================================================
--- branches/eam_branches/ipp-ops-20130712/ippTasks/fullforce.pro	(revision 37068)
+++ branches/eam_branches/ipp-ops-20130712/ippTasks/fullforce.pro	(revision 37068)
@@ -0,0 +1,458 @@
+## fullforce.pro : tasks for static sky calibration analysis : -*- sh -*-
+
+## This file contains panTasks definitions for performing the fullforce analysis. 
+
+# test for required global variables
+check.globals
+
+### Initialise the books containing the tasks to do
+book init fullForceRun
+book init fullForceSummary
+
+### Database lists
+$fullForce_DB = 0
+$fullForce_revert_DB = 0
+$fullForceSummary_DB = 0
+$fullForceSummary_revert_DB = 0
+
+### Check status of fullForce tasks
+macro fullforce.status
+  book listbook fullForceRun
+end
+
+### Reset fullForce tasks
+macro fullforce.reset
+  book init fullForceRun
+end
+macro fullforce.summary.status
+  book listbook fullForceSummary
+end
+
+### Reset fullForce tasks
+macro fullforce.summary.reset
+  book init fullForceSummary
+end
+
+### Turn fullForce tasks on
+macro fullforce.on
+  task fullforce.load
+    active true
+  end
+  task fullforce.run
+    active true
+  end
+  task fullforce.summary.load
+    active true
+  end
+  task fullforce.summary.run
+    active true
+  end
+end
+
+### Turn fullForce tasks off
+macro fullforce.off
+  task fullforce.load
+    active false
+  end
+  task fullforce.run
+    active false
+  end
+  task fullforce.summary.load
+    active false
+  end
+  task fullforce.summary.run
+    active false
+  end
+end
+
+macro fullforce.revert.on
+  task fullforce.revert
+    active true
+  end
+  task fullforce.summary.revert
+    active true
+  end
+end
+
+macro fullforce.revert.off
+  task fullforce.revert
+    active false
+  end
+  task fullforce.summary.revert
+    active false
+  end
+end
+
+### Load tasks for fullforce
+### Tasks are loaded into fullForceRun.
+task	       fullforce.load
+  host         local
+
+  periods      -poll $LOADPOLL
+  periods      -exec $LOADEXEC
+  periods      -timeout 30
+  npending     1
+
+  stdout NULL
+  stderr $LOGDIR/fullforce.log
+
+  task.exec
+    if ($LABEL:n == 0) break
+    $run = fftool -todo
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      # save the DB name for the exit tasks
+      option $DB:$fullForce_DB
+      $run = $run -dbname $DB:$fullForce_DB
+      $fullForce_DB ++
+      if ($fullForce_DB >= $DB:n) set fullForce_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 fullForceRun -key ff_id:warp_id -uniq -setword dbname $options:0 -setword pantaskState INIT
+    if ($VERBOSE > 2)
+      book listbook fullForceRun
+    end
+
+    # delete existing entries in the appropriate pantaskStates
+    process_cleanup fullForceRun
+  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
+
+### Run tasks for the fullforce analysis
+### Tasks are taken from fullForceRun.
+task	       fullforce.run
+  periods      -poll $RUNPOLL
+  periods      -exec $RUNEXEC
+  periods      -timeout 10800
+
+  task.exec
+    # if we are unable to run use "long" exectime
+    periods -exec $RUNEXEC
+    book npages fullForceRun -var N
+    if ($N == 0) break
+    if ($NETWORK == 0) break
+    if ($BURNTOOLING == 1) break
+
+
+    # look for new entries in fullForceRun (pantaskState == INIT)
+    book getpage fullForceRun 0 -var pageName -key pantaskState INIT
+    if ("$pageName" == "NULL") break
+
+    book setword fullForceRun $pageName pantaskState RUN
+    book getword fullForceRun $pageName ff_id -var FF_ID
+    book getword fullForceRun $pageName warp_id -var WARP_ID
+    book getword fullForceRun $pageName sources_path_base -var SOURCES_PATH_BASE
+    book getword fullForceRun $pageName tess_id -var TESS_DIR
+    book getword fullForceRun $pageName skycell_id -var SKYCELL_ID
+    book getword fullForceRun $pageName camera -var CAMERA
+    book getword fullForceRun $pageName workdir -var WORKDIR_TEMPLATE
+    book getword fullForceRun $pageName warp_path_base -var WARP_PATH_BASE
+    book getword fullForceRun $pageName reduction -var REDUCTION
+    book getword fullForceRun $pageName dbname -var DBNAME
+
+    # set the host and workdir based on the skycell hash
+    # set.host.for.skycell $SKYCELL_ID
+    host anyhost
+    set.workdir.by.skycell $SKYCELL_ID $WORKDIR_TEMPLATE $default_host WORKDIR
+
+    basename $TESS_DIR -var TESS_ID
+    sprintf outroot "%s/%s/%s/%s.%s.wrp.%s.ff.%s" $WORKDIR $TESS_ID $SKYCELL_ID $TESS_ID $SKYCELL_ID $WARP_ID $FF_ID
+
+    stdout $LOGDIR/fullforce.log
+    stderr $LOGDIR/fullforce.log
+
+    $run = psphot_fullforce_warp.pl --ff_id $FF_ID --warp_id $WARP_ID --outroot $outroot --redirect-output --camera $CAMERA --warp_path_base $WARP_PATH_BASE --sources_path_base $SOURCES_PATH_BASE --skycell_id $SKYCELL_ID --threads @MAX_THREADS@
+    if ("$REDUCTION" != "NULL")
+      $run = $run --reduction $REDUCTION
+    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
+    # since we have work to do shorten exec time
+    periods -exec .05
+    command $run
+  end
+
+  # default exit status
+  task.exit    default
+    process_exit fullForceRun $options:0 $JOB_STATUS
+  end
+
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword fullForceRun $options:0 pantaskState CRASH
+  end
+
+  # operation timed out?
+  task.exit    timeout
+    showcommand timeout
+    book setword fullForceRun $options:0 pantaskState TIMEOUT
+  end
+end
+
+task fullforce.revert
+  host         local
+
+  periods      -poll 10.0
+  periods      -exec 1200.0
+  periods      -timeout 120.0
+  npending     1
+  active true
+  
+  stdout NULL
+  stderr $LOGDIR/fullforce.revert.log
+
+  task.exec
+    if ($LABEL:n == 0) break
+    # Only revert failures with fault=2 (SYS_ERROR), which tend to be
+    # temporary filesystem problems.  Every other fault type is
+    # interesting and should be kept for debugging (and so it does not
+    # continue to occur).
+    $run = fftool -revert -fault 2
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      # save the DB name for the exit tasks
+      option $DB:$fullForce_revert_DB
+      $run = $run -dbname $DB:$fullForce_revert_DB
+      $fullForce_revert_DB ++
+      if ($fullForce_revert_DB >= $DB:n) set fullForce_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
+
+### Load tasks for fullForceSummary
+### Tasks are loaded into fullForceSummary.
+task	       fullforce.summary.load
+  host         local
+
+  periods      -poll $LOADPOLL
+  periods      -exec $LOADEXEC
+  periods      -timeout 30
+  npending     1
+
+  stdout NULL
+  stderr $LOGDIR/fullforce.summary.log
+
+  task.exec
+    if ($LABEL:n == 0) break
+    $run = fftool -toadvance
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      # save the DB name for the exit tasks
+      option $DB:$fullForceSummary_DB
+      $run = $run -dbname $DB:$fullForceSummary_DB
+      $fullForceSummary_DB ++
+      if ($fullForceSummary_DB >= $DB:n) set fullForceSummary_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 fullForceSummary -key ff_id -uniq -setword dbname $options:0 -setword pantaskState INIT
+    if ($VERBOSE > 2)
+      book listbook fullForceSummary
+    end
+
+    # delete existing entries in the appropriate pantaskStates
+    process_cleanup fullForceSummary
+  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
+
+### Run tasks for the fullForceSummary analyasis
+### Tasks are taken from fullForceSummary.
+task	       fullforce.summary.run
+  periods      -poll $RUNPOLL
+  periods      -exec $RUNEXEC
+  periods      -timeout 10800
+
+  task.exec
+    # if we are unable to run use "long" exectime
+    periods -exec $RUNEXEC
+    book npages fullForceSummary -var N
+    if ($N == 0) break
+    if ($NETWORK == 0) break
+    if ($BURNTOOLING == 1) break
+
+
+    # look for new entries in fullForceSummary (pantaskState == INIT)
+    book getpage fullForceSummary 0 -var pageName -key pantaskState INIT
+    if ("$pageName" == "NULL") break
+
+    book setword fullForceSummary $pageName pantaskState RUN
+    book getword fullForceSummary $pageName ff_id -var FF_ID
+    book getword fullForceSummary $pageName tess_id -var TESS_DIR
+    book getword fullForceSummary $pageName skycell_id -var SKYCELL_ID
+    book getword fullForceSummary $pageName camera -var CAMERA
+    book getword fullForceSummary $pageName workdir -var WORKDIR_TEMPLATE
+    book getword fullForceSummary $pageName reduction -var REDUCTION
+    book getword fullForceSummary $pageName dbname -var DBNAME
+
+    # set the host and workdir based on the skycell hash
+    # set.host.for.skycell $SKYCELL_ID
+    host anyhost
+    set.workdir.by.skycell $SKYCELL_ID $WORKDIR_TEMPLATE $default_host WORKDIR
+
+    basename $TESS_DIR -var TESS_ID
+    sprintf outroot "%s/%s/%s/%s.%s.ff.%s" $WORKDIR $TESS_ID $SKYCELL_ID $TESS_ID $SKYCELL_ID $FF_ID
+
+    stdout $LOGDIR/fullforce.summary.log
+    stderr $LOGDIR/fullforce.summary.log
+
+    $run = psphot_fullforce_summary.pl --ff_id $FF_ID --outroot $outroot --redirect-output --camera $CAMERA --threads @MAX_THREADS@
+    if ("$REDUCTION" != "NULL")
+      $run = $run --reduction $REDUCTION
+    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
+    # since we have work to do shorten exec time
+    periods -exec .05
+    command $run
+  end
+
+  # default exit status
+  task.exit    default
+    process_exit fullForceSummary $options:0 $JOB_STATUS
+  end
+
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword fullForceSummary $options:0 pantaskState CRASH
+  end
+
+  # operation timed out?
+  task.exit    timeout
+    showcommand timeout
+    book setword fullForceSummary $options:0 pantaskState TIMEOUT
+  end
+end
+
+task fullforce.summary.revert
+  host         local
+
+  periods      -poll 10.0
+  periods      -exec 1200.0
+  periods      -timeout 120.0
+  npending     1
+  active true
+  
+  stdout NULL
+  stderr $LOGDIR/fullforce.summary.revert.log
+
+  task.exec
+    if ($LABEL:n == 0) break
+    # Only revert failures with fault=2 (SYS_ERROR), which tend to be
+    # temporary filesystem problems.  Every other fault type is
+    # interesting and should be kept for debugging (and so it does not
+    # continue to occur).
+    $run = fftool -revertsummary -fault 2
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      # save the DB name for the exit tasks
+      option $DB:$fullForceSummary_revert_DB
+      $run = $run -dbname $DB:$fullForceSummary_revert_DB
+      $fullForceSummary_revert_DB ++
+      if ($fullForceSummary_revert_DB >= $DB:n) set fullForceSummary_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: branches/eam_branches/ipp-ops-20130712/ippTasks/minidvodb.pro
===================================================================
--- branches/eam_branches/ipp-ops-20130712/ippTasks/minidvodb.pro	(revision 37064)
+++ branches/eam_branches/ipp-ops-20130712/ippTasks/minidvodb.pro	(revision 37068)
@@ -449,5 +449,7 @@
     stderr $LOGDIR/minidvodb.premerge.run.log
 
-    $run = minidvodb_premerge.pl --camera $CAMERA --minidvodb $MINIDVODB_PATH --minidvodb_group $MINIDVODB_GROUP --minidvodb_id $MINIDVODB_ID
+    #still buggy
+
+    $run = minidvodb_premerge.pl --camera GPC1 --minidvodb $MINIDVODB_PATH --minidvodb_group $MINIDVODB_GROUP --minidvodb_id $MINIDVODB_ID
     
   if ($DB:n == 0)
Index: branches/eam_branches/ipp-ops-20130712/ippTasks/pstamp.pro
===================================================================
--- branches/eam_branches/ipp-ops-20130712/ippTasks/pstamp.pro	(revision 37064)
+++ branches/eam_branches/ipp-ops-20130712/ippTasks/pstamp.pro	(revision 37068)
@@ -175,4 +175,52 @@
 macro pstamp.find.off
     task pstamp.request.find
+        active false
+    end
+end
+macro pstamp.parse.on
+    task pstamp.request.load
+        active true
+    end
+    task pstamp.request.run
+        active true
+    end
+end
+macro pstamp.parse.off
+    task pstamp.request.load
+        active false
+    end
+    task pstamp.request.run
+        active false
+    end
+end
+macro pstamp.job.on
+    task pstamp.job.load
+        active true
+    end
+    task pstamp.job.run
+        active true
+    end
+end
+macro pstamp.job.off
+    task pstamp.job.load
+        active false
+    end
+    task pstamp.job.run
+        active false
+    end
+end
+macro pstamp.finish.on
+    task pstamp.finish.load
+        active true
+    end
+    task pstamp.finish.run
+        active true
+    end
+end
+macro pstamp.finish.off
+    task pstamp.finish.load
+        active false
+    end
+    task pstamp.finish.run
         active false
     end
Index: branches/eam_branches/ipp-ops-20130712/ippTasks/remote.pro
===================================================================
--- branches/eam_branches/ipp-ops-20130712/ippTasks/remote.pro	(revision 37068)
+++ branches/eam_branches/ipp-ops-20130712/ippTasks/remote.pro	(revision 37068)
@@ -0,0 +1,489 @@
+## remote.pro : -*- sh -*-
+
+check.globals
+
+# define chips
+
+book init remotePrepRuns
+book init remoteExecRuns
+book init remotePollRuns
+
+$remote_label_iter = 0
+$remote_label_iter2 = 0
+$remote_stage_iter = 0
+$remoteP_DB = 0
+$remoteE_DB = 0
+$remoteL_DB = 0
+
+list STAGES
+  chip
+  camera
+#  warp
+  stack
+end
+
+macro  remote.off
+  task  remote.define
+    active false
+  end
+  task  remote.define.warp
+    active false
+  end
+  task  remote.prep.load
+    active false
+  end
+  task  remote.prep.run
+    active false
+  end
+  task  remote.exec.load
+    active false
+  end
+  task  remote.exec.run
+    active false
+  end
+  task  remote.poll.load
+    active false
+  end
+  task  remote.poll.run
+    active false
+  end
+end
+
+macro  remote.on
+  task  remote.define
+    active true
+  end
+  task  remote.define.warp
+    active true
+  end
+  task  remote.prep.load
+    active true
+  end
+  task  remote.prep.run
+    active true
+  end
+  task  remote.exec.load
+    active true
+  end
+  task  remote.exec.run
+    active true
+  end
+  task  remote.poll.load
+    active true
+  end
+  task  remote.poll.run
+    active true
+  end
+end
+
+
+task          remote.define
+  host        local
+  periods     -poll $LOADPOLL
+  periods     -exec 300
+  periods     -timeout 30
+  npending    1
+
+  task.exec
+    stdout NULL
+    stderr $LOGDIR/remote.define.chip
+
+    $label = $LABEL:$remote_label_iter
+
+    $stage = $STAGES:$remote_stage_iter
+    $remote_stage_iter ++
+
+    if ($remote_stage_iter >= $STAGES:n) 
+       set remote_stage_iter = 0
+       $remote_label_iter ++
+       if ($remote_label_iter >= $LABEL:n) set remote_label_iter = 0
+       echo $remote_stage_iter $remote_label_iter $label $stage
+    end
+
+    $run = remotetool -definebyquery -label $label -stage $stage -path_base neb://@HOST@.0/remote/$label -limit 500
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      option $DB:$remoteP_DB
+      $run = $run -dbname $DB:$remoteP_DB
+      $remoteP_DB ++
+      if ($remoteP_DB >= $DB:n) set remoteP_DB = 0
+    end
+
+    echo $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
+
+task          remote.define.warp
+  host        local
+  periods     -poll $LOADPOLL
+  periods     -exec 1800
+  periods     -timeout 30
+  npending    1
+
+  task.exec
+    stdout NULL
+    stderr $LOGDIR/remote.define.chip
+
+    $label = $LABEL:$remote_label_iter2
+
+    if ($remote_label_iter >= $LABEL:n) set remote_label_iter = 0
+    echo  $remote_label_iter $label warp
+
+    $run = remotetool -definebyquery -label $label -stage warp -path_base neb://@HOST@.0/remote/$label -limit 500
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      option $DB:$remoteP_DB
+      $run = $run -dbname $DB:$remoteP_DB
+      $remoteP_DB ++
+      if ($remoteP_DB >= $DB:n) set remoteP_DB = 0
+    end
+
+    echo $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
+
+task         remote.prep.load
+  host       local
+  periods    -poll $LOADPOLL
+  periods    -exec 30
+  npending   1
+
+  task.exec
+    stdout NULL
+    stderr $LOGDIR/remote.prep.load
+
+    $run = remotetool -listrun -state new
+
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      option $DB:$remoteP_DB
+      $run = $run -dbname $DB:$remoteP_DB
+      $remoteP_DB ++
+      if ($remoteP_DB >= $DB:n) set remoteP_DB = 0
+    end
+
+    add_poll_labels run
+    command $run
+  end
+  # success
+  task.exit  0
+    ipptool2book stdout remotePrepRuns -uniq -key remote_id -setword dbname $options:0 -setword pantaskState INIT
+    process_cleanup remotePrepRuns
+
+    if ($VERBOSE > 2)
+      book listbook remotePrepRuns
+    end
+  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
+
+task           remote.prep.run
+  # this probably shouldn't be local
+  host         local
+  periods      -poll $LOADPOLL
+  periods      -exec $LOADEXEC
+  periods      -timeout 600000
+  active       true
+  npending     10
+
+  task.exec
+    stdout $LOGDIR/remote.prep.run
+    stderr $LOGDIR/remote.prep.run
+
+    book npages remotePrepRuns -var N
+    if ($N == 0) break
+    if ($NETWORK == 0) break
+
+    book getpage remotePrepRuns 0 -var pageName -key pantaskState INIT
+    if ("$pageName" == "NULL") break
+
+    book setword remotePrepRuns $pageName pantaskState RUN
+    book getword remotePrepRuns $pageName remote_id -var REMOTE_ID
+    book getword remotePrepRuns $pageName stage     -var STAGE
+    book getword remotePrepRuns $pageName path_base -var PATH_BASE
+#    book getword remotePrepRuns $pageName label     -var LABEL
+    book getword remotePrepRuns $pageName dbname    -var DBNAME
+
+    sprintf outroot "%s/remote_%s.%s" $PATH_BASE $STAGE $REMOTE_ID
+
+    if ("$STAGE" == "chip")
+      $command = sc_prepare_chip.pl --camera GPC1 --remote_id $REMOTE_ID --path_base $outroot --dbname $DBNAME
+    end
+    if ("$STAGE" == "camera")
+      $command = sc_prepare_camera.pl --camera GPC1 --remote_id $REMOTE_ID --path_base $outroot --dbname $DBNAME
+    end
+    if ("$STAGE" == "warp")
+      $command = sc_prepare_warp.pl --camera GPC1 --remote_id $REMOTE_ID --path_base $outroot --dbname $DBNAME
+    end
+    if ("$STAGE" == "stack")
+      $command = sc_prepare_stack.pl --camera GPC1 --remote_id $REMOTE_ID --path_base $outroot --dbname $DBNAME
+    end
+
+    options $pageName
+    command $command
+  end
+
+  # default exit status
+  task.exit    default
+    process_exit remotePrepRuns $options:0 $JOB_STATUS
+  end
+  # locked list
+  task.exit    crash
+    process_exit remotePrepRuns $options:0 $EXIT_CRASH_ERR
+  end
+
+  # operation timed out?
+  task.exit    timeout
+    showcommand timeout
+    book setword remotePrepRuns $options:0 pantaskState TIMEOUT
+  end
+end
+
+
+task         remote.exec.load
+  host       local
+  periods    -poll $LOADPOLL
+  periods    -exec $LOADEXEC
+  npending   1
+
+  task.exec
+    stdout NULL
+    stderr $LOGDIR/remote.exec.load
+
+#    $end_date = `date +%Y-%m-%dT%H:%M:%S`
+    $run = remotetool -listrun -state pending 
+# -poll_end $end_date
+
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      option $DB:$remoteE_DB
+      $run = $run -dbname $DB:$remoteE_DB
+      $remoteE_DB ++
+      if ($remoteE_DB >= $DB:n) set remoteE_DB = 0
+    end
+
+    add_poll_labels run
+    command $run
+  end
+  # success
+  task.exit  0
+    ipptool2book stdout remoteExecRuns -uniq -key remote_id -setword dbname $options:0 -setword pantaskState INIT
+    process_cleanup remoteExecRuns
+
+    if ($VERBOSE > 2)
+      book listbook remoteExecRuns
+    end
+  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
+
+task           remote.exec.run
+  # this probably shouldn't be local
+  host         local
+  periods      -poll $LOADPOLL
+  periods      -exec 30
+  periods      -timeout 6000000
+  active       true
+  npending     3
+
+  task.exec
+    stdout $LOGDIR/remote.exec.run
+    stderr $LOGDIR/remote.exec.run
+
+    book npages remoteExecRuns -var N
+    if ($N == 0) break
+    if ($NETWORK == 0) break
+
+    book getpage remoteExecRuns 0 -var pageName -key pantaskState INIT
+    if ("$pageName" == "NULL") break
+
+    book setword remoteExecRuns $pageName pantaskState RUN
+    book getword remoteExecRuns $pageName remote_id -var REMOTE_ID
+    book getword remoteExecRuns $pageName stage     -var STAGE
+    book getword remoteExecRuns $pageName path_base -var PATH_BASE
+#    book getword remoteExecRuns $pageName label     -var LABEL
+    book getword remoteExecRuns $pageName job_id    -var JOB_ID
+    book getword remoteExecRuns $pageName dbname    -var DBNAME
+
+    sprintf outroot "%s/remote_%s.%s" $PATH_BASE $STAGE $REMOTE_ID
+
+    $command = sc_remote_exec.pl --remote_id $REMOTE_ID --path_base $outroot --verbose --dbname $DBNAME --camera GPC1
+
+    options $pageName
+    command $command
+  end
+
+  # default exit status
+  task.exit    default
+    process_exit remoteExecRuns $options:0 $JOB_STATUS
+  end
+  # locked list
+  task.exit    crash
+    process_exit remoteExecRuns $options:0 $EXIT_CRASH_ERR
+  end
+
+  # operation timed out?
+  task.exit    timeout
+    showcommand timeout
+    book setword remoteExecRuns $options:0 pantaskState TIMEOUT
+  end
+end
+
+
+task         remote.poll.load
+  host       local
+  periods    -poll $LOADPOLL
+  periods    -exec $LOADEXEC
+  npending   1
+
+  task.exec
+    stdout NULL
+    stderr $LOGDIR/remote.poll.load
+
+    $end_date = `date +%Y-%m-%dT%H:%M:%S -d '1 hour ago'`
+    $run = remotetool -listrun -state run -poll_end $end_date
+
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      option $DB:$remoteL_DB
+      $run = $run -dbname $DB:$remoteL_DB
+      $remoteL_DB ++
+      if ($remoteL_DB >= $DB:n) set remoteL_DB = 0
+    end
+
+    add_poll_labels run
+    command $run
+  end
+  # success
+  task.exit  0
+    ipptool2book stdout remotePollRuns -uniq -key remote_id -setword dbname $options:0 -setword pantaskState INIT
+    process_cleanup remotePollRuns
+
+    if ($VERBOSE > 2)
+      book listbook remotePollRuns
+    end
+  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
+
+task           remote.poll.run
+  # this probably shouldn't be local
+  host         local
+  periods      -poll $LOADPOLL
+  periods      -exec 30
+  periods      -timeout 6000000
+  active       true
+  npending     3
+
+  task.exec
+    stdout $LOGDIR/remote.poll.run
+    stderr $LOGDIR/remote.poll.run
+
+    book npages remotePollRuns -var N
+    if ($N == 0) break
+    if ($NETWORK == 0) break
+
+    book getpage remotePollRuns 0 -var pageName -key pantaskState INIT
+    if ("$pageName" == "NULL") break
+
+    book setword remotePollRuns $pageName pantaskState RUN
+    book getword remotePollRuns $pageName remote_id -var REMOTE_ID
+    book getword remotePollRuns $pageName stage     -var STAGE
+    book getword remotePollRuns $pageName path_base -var PATH_BASE
+#    book getword remotePollRuns $pageName label     -var LABEL
+    book getword remotePollRuns $pageName job_id    -var JOB_ID
+    book getword remotePollRuns $pageName dbname    -var DBNAME
+
+    sprintf outroot "%s/remote_%s.%s" $PATH_BASE $STAGE $REMOTE_ID
+
+    # This can't have an invalid job_id
+    if ($JOB_ID == -1) break
+    $command = sc_remote_exec.pl --remote_id $REMOTE_ID --path_base $outroot --verbose --dbname $DBNAME --camera GPC1 --poll --job_id $JOB_ID
+
+    options $pageName
+    command $command
+  end
+
+  # default exit status
+  task.exit    default
+    process_exit remotePollRuns $options:0 $JOB_STATUS
+  end
+  # locked list
+  task.exit    crash
+    process_exit remotePollRuns $options:0 $EXIT_CRASH_ERR
+  end
+
+  # operation timed out?
+  task.exit    timeout
+    showcommand timeout
+    book setword remotePollRuns $options:0 pantaskState TIMEOUT
+  end
+end
+
Index: branches/eam_branches/ipp-ops-20130712/ippTasks/staticsky.pro
===================================================================
--- branches/eam_branches/ipp-ops-20130712/ippTasks/staticsky.pro	(revision 37064)
+++ branches/eam_branches/ipp-ops-20130712/ippTasks/staticsky.pro	(revision 37068)
@@ -64,4 +64,17 @@
 end
 
+$RA_POLL_MAX = 0
+
+macro set.ra.max
+    if ($0 != 2) 
+        echo "USAGE: set.ra.max (ra_max_deg)"
+        break
+    end
+    $RA_POLL_MAX = $1
+end
+macro get.ra.max
+    echo $RA_POLL_MAX
+end
+
 ### Load tasks for staticsky
 ### Tasks are loaded into staticskyResult.
@@ -80,4 +93,7 @@
     if ($LABEL:n == 0) break
     $run = staticskytool -todo
+    if ($RA_POLL_MAX > 0) 
+        $run = $run -ra_max $RA_POLL_MAX
+    end
     if ($DB:n == 0)
       option DEFAULT
