Index: /branches/backtrack/ippTools/scripts/camtest.sh
===================================================================
--- /branches/backtrack/ippTools/scripts/camtest.sh	(revision 13968)
+++ /branches/backtrack/ippTools/scripts/camtest.sh	(revision 13969)
@@ -8,4 +8,4 @@
 camtool -pendingimfile || exit 1
 
-camtool -addprocessedexp -cam_id 1 -uri file:///cam -bg 1 -bg_stdev 2 -bg_mean_stdev 3 -sigma_ra 1 -sigma_dec 2 -nastro 42 -path_base file:///foo -zp_mean 1 -zp_stdev 2 || exit 1
-camtool -addprocessedexp -cam_id 2 -uri file:///cam -bg 1 -bg_stdev 2 -bg_mean_stdev 3 -sigma_ra 1 -sigma_dec 2 -nastro 42 -path_base file:///foo -zp_mean 1 -zp_stdev 2 || exit 1
+camtool -addprocessedexp -cam_id 1 -chip_id 1 -uri file:///cam -bg 1 -bg_stdev 2 -bg_mean_stdev 3 -sigma_ra 1 -sigma_dec 2 -nastro 42 -path_base file:///foo -zp_mean 1 -zp_stdev 2 || exit 1
+camtool -addprocessedexp -cam_id 2 -chip_id 2 -uri file:///cam -bg 1 -bg_stdev 2 -bg_mean_stdev 3 -sigma_ra 1 -sigma_dec 2 -nastro 42 -path_base file:///foo -zp_mean 1 -zp_stdev 2 || exit 1
Index: /branches/backtrack/ippTools/scripts/regtest.sh
===================================================================
--- /branches/backtrack/ippTools/scripts/regtest.sh	(revision 13968)
+++ /branches/backtrack/ippTools/scripts/regtest.sh	(revision 13969)
@@ -11,12 +11,16 @@
 
 for ID in `seq 0 3`; do
-    $inject -newImfile -exp_tag $exp_tag1 -class OTA -class_id $ID -uri file://$ID || exit 1
+    $inject -newImfile -exp_tag $exp_tag1 -class_id $ID -uri file://$ID || exit 1
 done;
+
+$inject -updatenewExp -exp_tag $exp_tag1 -state run
 
 exp_tag2=`$inject -newExp -exp_id t11 -inst gpc -telescope ps1 -imfiles 4 -workdir file::///some/path -simple` || exit 1
 
 for ID in `seq 0 3`; do
-    $inject -newImfile -exp_tag $exp_tag2 -class OTA -class_id $ID -uri file://$ID || exit 1
+    $inject -newImfile -exp_tag $exp_tag2 -class_id $ID -uri file://$ID || exit 1
 done;
+
+$inject -updatenewExp -exp_tag $exp_tag2 -state run
 
 $regtool -pendingimfile || exit 1
Index: /branches/backtrack/ippTools/share/regtool_find_unprocessed_exp.sql
===================================================================
--- /branches/backtrack/ippTools/share/regtool_find_unprocessed_exp.sql	(revision 13968)
+++ /branches/backtrack/ippTools/share/regtool_find_unprocessed_exp.sql	(revision 13969)
@@ -1,15 +1,16 @@
-SELECT
-   newExp.*
-FROM newExp
-LEFT JOIN newImfile
-   USING(exp_tag)
-LEFT JOIN rawExp
-   USING(exp_tag)
+SELECT DISTINCT * FROM
+    (SELECT
+       newExp.*
+    FROM newExp
+    JOIN newImfile
+       USING(exp_tag)
+    LEFT JOIN rawExp
+       USING(exp_tag)
+    WHERE
+        newExp.state = 'run'
+        AND rawExp.exp_tag IS NULL
+        AND newExp.imfiles =
+        (SELECT COUNT(exp_tag) FROM rawImfile
+            WHERE rawImfile.exp_tag = newExp.exp_tag)) as Foo
 WHERE
-    newExp.exp_tag IS NOT NULL
-    AND newImfile.exp_tag IS NULL
-    AND rawExp.exp_tag IS NULL
-    AND newExp.imfiles =
-    (SELECT COUNT(exp_tag) FROM rawImfile
-        WHERE rawImfile.exp_tag = newExp.exp_tag)
-    AND newExp.exp_tag = '%s'
+    exp_tag = '%s'
Index: /branches/backtrack/ippTools/share/regtool_find_unprocessed_imfile.sql
===================================================================
--- /branches/backtrack/ippTools/share/regtool_find_unprocessed_imfile.sql	(revision 13968)
+++ /branches/backtrack/ippTools/share/regtool_find_unprocessed_imfile.sql	(revision 13969)
@@ -1,8 +1,11 @@
-SELECT
-    *
-FROM
-    (SELECT newImfile.* FROM newImfile
-        LEFT JOIN newExp USING(exp_tag)
-        LEFT JOIN rawExp USING(exp_tag)
-        WHERE newExp.exp_tag IS NOT NULL
+SELECT DISTINCT * FROM
+    (SELECT
+        newImfile.*
+    FROM newImfile
+    JOIN newExp
+        USING(exp_tag)
+    LEFT JOIN rawExp
+        USING(exp_tag)
+    WHERE
+        newExp.state = 'run'
         AND rawExp.exp_tag IS NULL) as Foo
Index: /branches/backtrack/ippTools/share/regtool_pendingexp.sql
===================================================================
--- /branches/backtrack/ippTools/share/regtool_pendingexp.sql	(revision 13968)
+++ /branches/backtrack/ippTools/share/regtool_pendingexp.sql	(revision 13969)
@@ -2,10 +2,10 @@
     newExp.*
 FROM newExp
-LEFT JOIN newImfile
+JOIN newImfile
     USING(exp_tag)
 LEFT JOIN rawExp
     USING(exp_tag)
 WHERE
-    newImfile.exp_tag IS NULL
+    newExp.state = 'run'
     AND rawExp.exp_tag IS NULL
     AND newExp.imfiles =
