Index: /trunk/ippTools/doc/p2tools.sh
===================================================================
--- /trunk/ippTools/doc/p2tools.sh	(revision 6179)
+++ /trunk/ippTools/doc/p2tools.sh	(revision 6180)
@@ -5,11 +5,27 @@
 #
 # queues: 
-#   p2pending: (url) (expID) (cameraID) (chipID) (state)
+#   p2pending: expID class classID url
 #
 # globals: 
 
+queueinit stdout
+queueinit stderr
+queueinit p2pending
+
+macro p2parse
+  if ($0 != 7)
+    echo "usage: p2parse (key) (expID) (class) (classID) (url) (state)"
+    break
+  end
+  $expID   = $2
+  $class   = $3
+  $classID = $4
+  $url     = $5
+  $key     = $expID.$classID
+end
+
 # p2pending : search for images to be processed
 task	       p2pending
-  command      p2search -pending
+  command      p2search.sh -pending
   host         local
 
@@ -22,10 +38,17 @@
   task.exit    0
     local i Nstdout
+
+    # pop off the header line
+    queuepop stdout
+
     # 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"
+      p2parse unknown $line new
+      queuepush p2pending -uniq -key 0 "$key $line new"
     end
+    echo "loaded p2pending, current state:"
+    queueprint p2pending
   end
 end
@@ -33,5 +56,5 @@
 # ppImage : submit an image for processing by ppImage
 task	       ppImage
-  periods      -exec 0.1
+  periods      -exec 1
   periods      -timeout 120
 
@@ -44,18 +67,18 @@
     # if ($network == 0) break
     
-    queuepop p2pending -var line -key 4 new
+    queuepop p2pending -var line -key 5 new
     if ("$line" == "NULL") break
+    p2parse $line
 
-    list tmp -split $line
-    $url    = $tmp:0
-    $expID  = $tmp:1
-    $camera = $tmp:2
-    $chip   = $tmp:3
-    queuepush p2pending "$url $expID $camera $chip run"
+    echo "new ppImaage: $key $expID $class $classID $url run"
+    queuepush p2pending "$key $expID $class $classID $url run"
 
     # need to decide real name for this function
-    $host = `chip.host $camera $chip`
-    host $host
-    command ppImage $url $chip
+    # $host = `chip.host $camera $chip`
+    # host $host
+
+    host local
+    echo command ppImage.sh $key $url $classID
+    command ppImage.sh $key $url $classID
   end
 
@@ -63,11 +86,19 @@
   task.exit    0
     # if ppImage updates the DB:
+    echo "done with $taskarg:1"
     queueinit stdout
-    queuepush p2pending $taskargs:0 $taskargs:1 $taskargs:2 $taskargs:3 done
+    queuepop p2pending -key 0 $taskarg:1 -var line
+    echo "got line: $line"
+
+    if ("$line" == "NULL") 
+      echo "missing entry in p2pending queue?"
+      break
+    end
+
+    p2parse $line
+    queuepush p2pending "$key $expID $class $classID $url done"
+    echo queuepush p2pending "$key $expID $class $classID $url 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
 
@@ -80,7 +111,12 @@
 
   # timeout shorter than exec so jobs do not build up
-  periods      -exec     5
+  periods      -exec     100
   periods      -poll     1
   periods      -timeout  4
+
+  # task is never allowed to run
+  task.exec
+    break
+  end
 end
 
@@ -91,7 +127,11 @@
 
   # timeout shorter than exec so jobs do not build up
-  periods      -exec     5
+  periods      -exec     100
   periods      -poll     1
   periods      -timeout  4
+
+  # task is never allowed to run
+  task.exec
+    break
+  end
 end
-
