Index: /branches/eam_branch_20080719/ippTools/notes.txt
===================================================================
--- /branches/eam_branch_20080719/ippTools/notes.txt	(revision 18658)
+++ /branches/eam_branch_20080719/ippTools/notes.txt	(revision 18659)
@@ -11,5 +11,4 @@
     * difftool
     * stacktool
-    * magictool
     * dettool processedimfile
     * dettool processedexp
@@ -20,4 +19,13 @@
     * dettool residimfile
     * dettool residexp
+
+    * I am modifiying the tools to use the new states: new, full, goto_cleaned, etc.
+      I am NOT changing: regtool, pztool, magictool, flatcorr, pxregister, pstamptool
+
+    * for dettool, I have added a new field, 'data_state' to the
+      detRunSummary.  My plan here is that a complete detRunIteration
+      is cleaned at once.  I've added functions to all of the dettool
+      major modes to list pending entries to be cleaned and a function
+      to update the data_state when cleaning is done.
 
 2008.07.11 EAM 
Index: /branches/eam_branch_20080719/ippTools/src/camtool.c
===================================================================
--- /branches/eam_branch_20080719/ippTools/src/camtool.c	(revision 18658)
+++ /branches/eam_branch_20080719/ippTools/src/camtool.c	(revision 18659)
@@ -576,5 +576,5 @@
 
     // since there is only one exp per 'run' set camRun.state = 'stop'
-    if (!pxcamRunSetState(config, row->cam_id, "stop")) {
+    if (!pxcamRunSetState(config, row->cam_id, "full")) {
         psError(PS_ERR_UNKNOWN, false, "failed to change camRun.state for cam_id: %" PRId64, row->cam_id);
         psFree(row);
Index: /branches/eam_branch_20080719/ippTools/src/difftool.c
===================================================================
--- /branches/eam_branch_20080719/ippTools/src/difftool.c	(revision 18658)
+++ /branches/eam_branch_20080719/ippTools/src/difftool.c	(revision 18659)
@@ -265,5 +265,5 @@
 
     if (count == 2) {
-        if (!setdiffRunState(config, diff_id, "run")) {
+        if (!setdiffRunState(config, diff_id, "new")) {
             if (!psDBRollback(config->dbh)) {
                 psError(PS_ERR_UNKNOWN, false, "database error");
@@ -502,5 +502,5 @@
     }
 
-    if (!setdiffRunState(config, diff_id, "stop")) {
+    if (!setdiffRunState(config, diff_id, "full")) {
         if (!psDBRollback(config->dbh)) {
             psError(PS_ERR_UNKNOWN, false, "database error");
@@ -636,12 +636,6 @@
 
     // check that state is a valid string value
-    if (!(
-            (strncmp(state, "run", 4) == 0)
-            || (strncmp(state, "stop", 5) == 0)
-            || (strncmp(state, "reg", 4) == 0)
-        )
-    ) {
-        psError(PS_ERR_UNKNOWN, false,
-                "invalid diffRun state: %s", state);
+    if (!pxIsValidState(state)) {
+        psError(PS_ERR_UNKNOWN, false, "invalid diffRun state: %s", state);
         return false;
     }
Index: /branches/eam_branch_20080719/ippTools/src/faketool.c
===================================================================
--- /branches/eam_branch_20080719/ippTools/src/faketool.c	(revision 18658)
+++ /branches/eam_branch_20080719/ippTools/src/faketool.c	(revision 18659)
@@ -1080,6 +1080,6 @@
 
         fakeRunRow *fakeRun = fakeRunObjectFromMetadata(row);
-        // set fakeRun.state to 'stop'
-        if (!pxfakeRunSetState(config, fakeRun->fake_id, "stop")) {
+        // set fakeRun.state to 'full'
+        if (!pxfakeRunSetState(config, fakeRun->fake_id, "full")) {
             psError(PS_ERR_UNKNOWN, false, "failed to change fakeRun.state for fake_id: %" PRId64, fakeRun->fake_id);
             psFree(fakeRun);
Index: /branches/eam_branch_20080719/ippTools/src/pxcam.c
===================================================================
--- /branches/eam_branch_20080719/ippTools/src/pxcam.c	(revision 18658)
+++ /branches/eam_branch_20080719/ippTools/src/pxcam.c	(revision 18659)
@@ -35,10 +35,5 @@
 
     // check that state is a valid string value
-    if (!(
-            (strncmp(state, "run", 4) == 0)
-            || (strncmp(state, "stop", 5) == 0)
-            || (strncmp(state, "reg", 4) == 0)
-        )
-    ) {
+    if (!pxIsValidState(state)) {
         psError(PS_ERR_UNKNOWN, false,
                 "invalid camRun state: %s", state);
@@ -63,10 +58,5 @@
 
     // check that state is a valid string value
-    if (!(
-            (strncmp(state, "run", 4) == 0)
-            || (strncmp(state, "stop", 5) == 0)
-            || (strncmp(state, "reg", 4) == 0)
-        )
-    ) {
+    if (!pxIsValidState(state)) {
         psError(PS_ERR_UNKNOWN, false,
                 "invalid chipRun state: %s", state);
@@ -108,5 +98,4 @@
     return true;
 }
-
 
 bool pxcamRunSetLabelByQuery(pxConfig *config, psMetadata *where, const char *label)
@@ -162,5 +151,5 @@
     // different on 32/64
     if (!p_psDBRunQuery(config->dbh, query,
-                "run", // state
+                "new", // state
                 workdir  ? workdir  : "NULL",
                 "dirty", //workdir_state
Index: /branches/eam_branch_20080719/ippTools/src/pxfake.c
===================================================================
--- /branches/eam_branch_20080719/ippTools/src/pxfake.c	(revision 18658)
+++ /branches/eam_branch_20080719/ippTools/src/pxfake.c	(revision 18659)
@@ -35,10 +35,5 @@
 
     // check that state is a valid string value
-    if (!(
-            (strncmp(state, "run", 4) == 0)
-            || (strncmp(state, "stop", 5) == 0)
-            || (strncmp(state, "reg", 4) == 0)
-        )
-    ) {
+    if (!pxIsValidState(state)) {
         psError(PS_ERR_UNKNOWN, false,
                 "invalid fakeRun state: %s", state);
@@ -63,10 +58,5 @@
 
     // check that state is a valid string value
-    if (!(
-            (strncmp(state, "run", 4) == 0)
-            || (strncmp(state, "stop", 5) == 0)
-            || (strncmp(state, "reg", 4) == 0)
-        )
-    ) {
+    if (!pxIsValidState(state)) {
         psError(PS_ERR_UNKNOWN, false,
                 "invalid fakeRun state: %s", state);
@@ -164,5 +154,5 @@
     // different on 32/64
     if (!p_psDBRunQuery(config->dbh, query,
-                "run", // state
+                "new", // state
                 workdir  ? workdir  : "NULL",
                 label    ? label    : "NULL",
Index: /branches/eam_branch_20080719/ippTools/src/pxtools.c
===================================================================
--- /branches/eam_branch_20080719/ippTools/src/pxtools.c	(revision 18658)
+++ /branches/eam_branch_20080719/ippTools/src/pxtools.c	(revision 18659)
@@ -29,6 +29,9 @@
 {
     PS_ASSERT_PTR_NON_NULL(state, false);
+    
+    // XXX replace strncmp with strcmp
 
     if (!((strncmp(state, "new", 4) == 0)
+    || (strncmp(state, "reg", 3) == 0)
     || (strncmp(state, "full", 5) == 0)
     || (strncmp(state, "goto_cleaned", 8) == 0)
Index: /branches/eam_branch_20080719/ippTools/src/pxwarp.c
===================================================================
--- /branches/eam_branch_20080719/ippTools/src/pxwarp.c	(revision 18658)
+++ /branches/eam_branch_20080719/ippTools/src/pxwarp.c	(revision 18659)
@@ -35,12 +35,6 @@
 
     // check that state is a valid string value
-    if (!(
-            (strncmp(state, "run", 4) == 0)
-            || (strncmp(state, "stop", 5) == 0)
-            || (strncmp(state, "reg", 4) == 0)
-        )
-    ) {
-        psError(PS_ERR_UNKNOWN, false,
-                "invalid warpRun state: %s", state);
+    if (!pxIsValidState(state)) {
+        psError(PS_ERR_UNKNOWN, false, "invalid warpRun state: %s", state);
         return false;
     }
@@ -63,12 +57,6 @@
 
     // check that state is a valid string value
-    if (!(
-            (strncmp(state, "run", 4) == 0)
-            || (strncmp(state, "stop", 5) == 0)
-            || (strncmp(state, "reg", 4) == 0)
-        )
-    ) {
-        psError(PS_ERR_UNKNOWN, false,
-                "invalid chipRun state: %s", state);
+    if (!pxIsValidState(state)) {
+        psError(PS_ERR_UNKNOWN, false, "invalid chipRun state: %s", state);
         return false;
     }
@@ -152,5 +140,5 @@
         fake_id,
         "warp",     // mode
-        "run",      // state
+        "new",      // state
         workdir,
         "dirty",    // workdir_state
Index: /branches/eam_branch_20080719/ippTools/src/stacktool.c
===================================================================
--- /branches/eam_branch_20080719/ippTools/src/stacktool.c	(revision 18658)
+++ /branches/eam_branch_20080719/ippTools/src/stacktool.c	(revision 18659)
@@ -278,5 +278,14 @@
 
         // create a new stackRun for this stack
-        stackRunRow *run = stackRunRowAlloc(0, "run", workdir, NULL, registered, skycell_id, tess_id, filter);
+        stackRunRow *run = stackRunRowAlloc(
+	    0, 				// ID
+	    "new", 			// state
+	    workdir, 
+	    NULL, 			// workdir_state
+	    registered, 
+	    skycell_id, 
+	    tess_id, 
+	    filter);
+
         if (!stackRunInsertObject(config->dbh, run)) {
             if (!psDBRollback(config->dbh)) {
@@ -363,5 +372,14 @@
     }
 
-    stackRunRow *run = stackRunRowAlloc(0, "run", workdir, NULL, registered, skycell_id, tess_id, filter);
+    stackRunRow *run = stackRunRowAlloc(
+	0, 				// ID
+	"new", 				// state
+	workdir, 
+	NULL, 				// workdir_state
+	registered, 
+	skycell_id, 
+	tess_id, 
+	filter);
+
     if (!run) {
         psError(PS_ERR_UNKNOWN, false, "failed to alloc stackRun object");
@@ -656,5 +674,5 @@
     }
 
-    if (!setstackRunState(config, stack_id, "stop")) {
+    if (!setstackRunState(config, stack_id, "full")) {
         if (!psDBRollback(config->dbh)) {
             psError(PS_ERR_UNKNOWN, false, "database error");
@@ -788,12 +806,6 @@
 
     // check that state is a valid string value
-    if (!(
-            (strncmp(state, "run", 4) == 0)
-            || (strncmp(state, "stop", 5) == 0)
-            || (strncmp(state, "reg", 4) == 0)
-        )
-    ) {
-        psError(PS_ERR_UNKNOWN, false,
-                "invalid warpRun state: %s", state);
+    if (!pxIsValidState(state)) {
+        psError(PS_ERR_UNKNOWN, false, "invalid stackRun state: %s", state);
         return false;
     }
Index: /branches/eam_branch_20080719/ippTools/src/warptool.c
===================================================================
--- /branches/eam_branch_20080719/ippTools/src/warptool.c	(revision 18658)
+++ /branches/eam_branch_20080719/ippTools/src/warptool.c	(revision 18659)
@@ -137,5 +137,5 @@
             fake_id,
             mode,
-            "run",      // state
+            "new",      // state
             workdir,
             "dirty",    // workdir_state
