Index: /trunk/ippTools/doc/p2tools.sh
===================================================================
--- /trunk/ippTools/doc/p2tools.sh	(revision 6021)
+++ /trunk/ippTools/doc/p2tools.sh	(revision 6021)
@@ -0,0 +1,97 @@
+
+## PanTasks scripts for Phase 2
+
+# tasks: p2pending p2update ppImage
+#
+# queues: 
+#   p2pending: (url) (expID) (cameraID) (chipID) (state)
+#
+# globals: 
+
+# p2pending : search for images to be processed
+task	       p2pending
+  command      p2search -pending
+  host         local
+
+  # timeout shorter than exec so jobs do not build up
+  periods      -exec     5
+  periods      -poll     1
+  periods      -timeout  4
+
+  # success
+  task.exit    0
+    local i Nstdout
+    # keep only new, unique entries (URL is key)
+    queuesize stdout -var Nstdout
+    for i 0 $Nstdout
+      queuepop stdout -var line
+      queuepush p2pending -uniq -key 0 "$line new"
+    end
+  end
+end
+
+# ppImage : submit an image for processing by ppImage
+task	       ppImage
+  periods      -exec 0.1
+  periods      -timeout 120
+
+  task.exec
+    local Npending
+    queuesize  p2pending -var Npending
+    if ($Npending == 0) break
+
+    # add in system status interruptions later
+    # if ($network == 0) break
+    
+    queuepop p2pending -var line -key 4 new
+    if ("$line" == "NULL") break
+
+    list tmp -split $line
+    $url    = $tmp:0
+    $expID  = $tmp:1
+    $camera = $tmp:2
+    $chip   = $tmp:3
+    queuepush p2pending "$url $expID $camera $chip run"
+
+    # need to decide real name for this function
+    $host = `chip.host $camera $chip`
+    host $host
+    command ppImage $url $chip
+  end
+
+  # success
+  task.exit    0
+    # if ppImage updates the DB:
+    queueinit stdout
+    queuepush p2pending $taskargs:0 $taskargs:1 $taskargs:2 $taskargs:3 done
+    
+    # if ppImage does NOT update the DB:
+    queueinit stdout
+    exec p2search -done $taskargs:0 $taskargs:1 $taskargs:2 
+    queuepush p2pending $taskargs:0 $taskargs:1 $taskargs:2 $taskargs:3 done
+  end
+
+end
+
+# p2update : search for images to be processed
+task	       p2update
+  command      p2search -update
+  host         local
+
+  # timeout shorter than exec so jobs do not build up
+  periods      -exec     5
+  periods      -poll     1
+  periods      -timeout  4
+end
+
+# p2done : search for images to be processed
+task	       p2done
+  command      p2search -done
+  host         local
+
+  # timeout shorter than exec so jobs do not build up
+  periods      -exec     5
+  periods      -poll     1
+  periods      -timeout  4
+end
+
Index: /trunk/ippTools/doc/p2tools.txt
===================================================================
--- /trunk/ippTools/doc/p2tools.txt	(revision 6020)
+++ /trunk/ippTools/doc/p2tools.txt	(revision 6021)
@@ -14,9 +14,9 @@
   * input: searches mddb:P2_exposures_pending,P2_images_pending
   * output: Nlines consisting of:
-    (expID) (class) (URL) 
+    (URL) (expID) (class)
   * options: ?
 
 p2search -update
-  * examine the imfiles and identify any comleted exposures
+  * examine the imfiles and identify any completed exposures
 
 p2search -done
@@ -32,2 +32,3 @@
   -camera (camera) 
   -region (ra,dec) (ra,dec)
+
