Index: trunk/ippdb/src/ippdb.h
===================================================================
--- trunk/ippdb/src/ippdb.h	(revision 13937)
+++ trunk/ippdb/src/ippdb.h	(revision 14061)
@@ -125,206 +125,11 @@
 );
 
-/** expTagCounterRow data structure
- *
- * Structure for representing a single row of expTagCounter table data.
+/** summitExpRow data structure
+ *
+ * Structure for representing a single row of summitExp table data.
  */
 
 typedef struct {
-    psU64           counter;
-} expTagCounterRow;
-
-/** Creates a new expTagCounterRow object
- *
- *  @return A new expTagCounterRow object or NULL on failure.
- */
-
-expTagCounterRow *expTagCounterRowAlloc(
-    psU64           counter
-);
-
-/** Creates a new expTagCounter table
- *
- * @return true on success
- */
-
-bool expTagCounterCreateTable(
-    psDB            *dbh                ///< Database handle
-);
-
-/** Deletes a expTagCounter table
- *
- * @return true on success
- */
-
-bool expTagCounterDropTable(
-    psDB            *dbh                ///< Database handle
-);
-
-/** Insert a single row into a table
- *
- * This function constructs and inserts a single row based on it's parameters.
- *
- * @return true on success
- */
-
-bool expTagCounterInsert(
-    psDB            *dbh,               ///< Database handle
-    psU64           counter
-);
-
-/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
- *
- * @return A The number of rows removed or a negative value on error
- */
-
-long long expTagCounterDelete(
-    psDB            *dbh,               ///< Database handle
-    const psMetadata *where,            ///< Row match criteria
-    unsigned long long limit            ///< Maximum number of elements to delete 
-);
-
-/** Insert a single expTagCounterRow object into a table
- *
- * This function constructs and inserts a single row based on it's parameters.
- *
- * @return true on success
- */
-
-bool expTagCounterInsertObject(
-    psDB            *dbh,               ///< Database handle
-    expTagCounterRow *object             ///< expTagCounterRow object
-);
-
-/** Insert an array of expTagCounterRow object into a table
- *
- * This function constructs and inserts multiple rows based on it's parameters.
- *
- * @return true on success
- */
-
-bool expTagCounterInsertObjects(
-    psDB            *dbh,               ///< Database handle
-    psArray         *objects            ///< array of expTagCounterRow objects
-);
-
-/** Insert data from a binary FITS table expTagCounterRow into the database
- *
- * This function expects a psFits object with a FITS table as the first
- * extension.  The table must have at least one row of data in it, that is of
- * the appropriate format (number of columns and their type).  All other
- * extensions are ignored.
- *
- * @return true on success
- */
-
-bool expTagCounterInsertFits(
-    psDB            *dbh,               ///< Database handle
-    const psFits    *fits               ///< psFits object
-);
-
-/** Selects up to limit from the database and returns them in a binary FITS table
- *
- * This function assumes an empty psFits object and will create a FITS table
- * as the first extension.
- *
- *  See psDBSelectRows() for documentation on the format of where.
- *
- * @return true on success
- */
-
-bool expTagCounterSelectRowsFits(
-    psDB            *dbh,               ///< Database handle
-    psFits          *fits,              ///< psFits object
-    const psMetadata *where,            ///< Row match criteria
-    unsigned long long limit            ///< Maximum number of elements to return
-);
-
-/** Convert a expTagCounterRow into an equivalent psMetadata
- *
- * @return A psMetadata pointer or NULL on error
- */
-
-psMetadata *expTagCounterMetadataFromObject(
-    const expTagCounterRow *object             ///< fooRow to convert into a psMetadata
-);
-
-/** Convert a psMetadata into an equivalent fooRow
- *
- * @return A expTagCounterRow pointer or NULL on error
- */
-
-expTagCounterRow *expTagCounterObjectFromMetadata(
-    psMetadata      *md                 ///< psMetadata to convert into a fooRow
-);
-/** Selects up to limit rows from the database and returns as expTagCounterRow objects in a psArray
- *
- *  See psDBSelectRows() for documentation on the format of where.
- *
- * @return A psArray pointer or NULL on error
- */
-
-psArray *expTagCounterSelectRowObjects(
-    psDB            *dbh,               ///< Database handle
-    const psMetadata *where,            ///< Row match criteria
-    unsigned long long limit            ///< Maximum number of elements to return
-);
-/** Deletes a row from the database coresponding to an expTagCounter
- *
- *  Note that a 'where' search psMetadata is constructed from each object and
- *  used to find rows to delete.
- *
- * @return A The number of rows removed or a negative value on error
- */
-
-bool expTagCounterDeleteObject(
-    psDB            *dbh,               ///< Database handle
-    const expTagCounterRow *object    ///< Object to delete
-);
-/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
- *
- *  Note that a 'where' search psMetadata is constructed from each object and
- *  used to find rows to delete.
- *
- * @return A The number of rows removed or a negative value on error
- */
-
-long long expTagCounterDeleteRowObjects(
-    psDB            *dbh,               ///< Database handle
-    const psArray   *objects,           ///< Array of objects to delete
-    unsigned long long limit            ///< Maximum number of elements to delete 
-);
-/** Formats and prints an array of expTagCounterRow objects
- *
- * When mdcf is set the formated output is in psMetadataConfig
- * format, otherwise it is in a simple tabular format.
- *
- * @return true on success
- */
-
-bool expTagCounterPrintObjects(
-    FILE            *stream,            ///< a stream
-    psArray         *objects,           ///< An array of expTagCounterRow objects
-    bool            mdcf                ///< format as mdconfig or simple
-);
-/** Formats and prints an expTagCounterRow object
- *
- * When mdcf is set the formated output is in psMetadataConfig
- * format, otherwise it is in a simple tabular format.
- *
- * @return true on success
- */
-
-bool expTagCounterPrintObject(
-    FILE            *stream,            ///< a stream
-    expTagCounterRow *object,    ///< an expTagCounterRow object
-    bool            mdcf                ///< format as mdconfig or simple
-);
-/** summitExpRow data structure
- *
- * Structure for representing a single row of summitExp table data.
- */
-
-typedef struct {
-    char            *exp_id;
+    char            *exp_name;
     char            *camera;
     char            *telescope;
@@ -341,5 +146,5 @@
 
 summitExpRow *summitExpRowAlloc(
-    const char      *exp_id,
+    const char      *exp_name,
     const char      *camera,
     const char      *telescope,
@@ -377,5 +182,5 @@
 bool summitExpInsert(
     psDB            *dbh,               ///< Database handle
-    const char      *exp_id,
+    const char      *exp_name,
     const char      *camera,
     const char      *telescope,
@@ -539,5 +344,5 @@
 
 typedef struct {
-    char            *exp_id;
+    char            *exp_name;
     char            *camera;
     char            *telescope;
@@ -556,5 +361,5 @@
 
 summitImfileRow *summitImfileRowAlloc(
-    const char      *exp_id,
+    const char      *exp_name,
     const char      *camera,
     const char      *telescope,
@@ -594,5 +399,5 @@
 bool summitImfileInsert(
     psDB            *dbh,               ///< Database handle
-    const char      *exp_id,
+    const char      *exp_name,
     const char      *camera,
     const char      *telescope,
@@ -758,5 +563,5 @@
 
 typedef struct {
-    char            *exp_id;
+    char            *exp_name;
     char            *camera;
     char            *telescope;
@@ -769,5 +574,5 @@
 
 pzPendingExpRow *pzPendingExpRowAlloc(
-    const char      *exp_id,
+    const char      *exp_name,
     const char      *camera,
     const char      *telescope
@@ -801,5 +606,5 @@
 bool pzPendingExpInsert(
     psDB            *dbh,               ///< Database handle
-    const char      *exp_id,
+    const char      *exp_name,
     const char      *camera,
     const char      *telescope
@@ -959,10 +764,10 @@
 
 typedef struct {
-    char            *exp_id;
+    char            *exp_name;
     char            *camera;
     char            *telescope;
     char            *class;
     char            *class_id;
-    char            *exp_tag;
+    psS64           exp_id;
 } pzPendingImfileRow;
 
@@ -973,10 +778,10 @@
 
 pzPendingImfileRow *pzPendingImfileRowAlloc(
-    const char      *exp_id,
+    const char      *exp_name,
     const char      *camera,
     const char      *telescope,
     const char      *class,
     const char      *class_id,
-    const char      *exp_tag
+    psS64           exp_id
 );
 
@@ -1008,10 +813,10 @@
 bool pzPendingImfileInsert(
     psDB            *dbh,               ///< Database handle
-    const char      *exp_id,
+    const char      *exp_name,
     const char      *camera,
     const char      *telescope,
     const char      *class,
     const char      *class_id,
-    const char      *exp_tag
+    psS64           exp_id
 );
 
@@ -1169,5 +974,5 @@
 
 typedef struct {
-    char            *exp_id;
+    char            *exp_name;
     char            *camera;
     char            *telescope;
@@ -1180,5 +985,5 @@
 
 pzDoneExpRow *pzDoneExpRowAlloc(
-    const char      *exp_id,
+    const char      *exp_name,
     const char      *camera,
     const char      *telescope
@@ -1212,5 +1017,5 @@
 bool pzDoneExpInsert(
     psDB            *dbh,               ///< Database handle
-    const char      *exp_id,
+    const char      *exp_name,
     const char      *camera,
     const char      *telescope
@@ -1370,10 +1175,10 @@
 
 typedef struct {
-    char            *exp_id;
+    char            *exp_name;
     char            *camera;
     char            *telescope;
     char            *class;
     char            *class_id;
-    char            *exp_tag;
+    psS64           exp_id;
     char            *uri;
 } pzDoneImfileRow;
@@ -1385,10 +1190,10 @@
 
 pzDoneImfileRow *pzDoneImfileRowAlloc(
-    const char      *exp_id,
+    const char      *exp_name,
     const char      *camera,
     const char      *telescope,
     const char      *class,
     const char      *class_id,
-    const char      *exp_tag,
+    psS64           exp_id,
     const char      *uri
 );
@@ -1421,10 +1226,10 @@
 bool pzDoneImfileInsert(
     psDB            *dbh,               ///< Database handle
-    const char      *exp_id,
+    const char      *exp_name,
     const char      *camera,
     const char      *telescope,
     const char      *class,
     const char      *class_id,
-    const char      *exp_tag,
+    psS64           exp_id,
     const char      *uri
 );
@@ -1583,10 +1388,11 @@
 
 typedef struct {
-    char            *exp_tag;
-    char            *exp_id;
-    char            *camera;
-    char            *telescope;
-    psS32           imfiles;
+    psS64           exp_id;
+    char            *tmp_exp_name;
+    char            *tmp_camera;
+    char            *tmp_telescope;
+    char            *state;
     char            *workdir;
+    char            *workdir_state;
 } newExpRow;
 
@@ -1597,10 +1403,11 @@
 
 newExpRow *newExpRowAlloc(
-    const char      *exp_tag,
-    const char      *exp_id,
-    const char      *camera,
-    const char      *telescope,
-    psS32           imfiles,
-    const char      *workdir
+    psS64           exp_id,
+    const char      *tmp_exp_name,
+    const char      *tmp_camera,
+    const char      *tmp_telescope,
+    const char      *state,
+    const char      *workdir,
+    const char      *workdir_state
 );
 
@@ -1632,10 +1439,11 @@
 bool newExpInsert(
     psDB            *dbh,               ///< Database handle
-    const char      *exp_tag,
-    const char      *exp_id,
-    const char      *camera,
-    const char      *telescope,
-    psS32           imfiles,
-    const char      *workdir
+    psS64           exp_id,
+    const char      *tmp_exp_name,
+    const char      *tmp_camera,
+    const char      *tmp_telescope,
+    const char      *state,
+    const char      *workdir,
+    const char      *workdir_state
 );
 
@@ -1793,7 +1601,6 @@
 
 typedef struct {
-    char            *exp_tag;
-    char            *class;
-    char            *class_id;
+    psS64           exp_id;
+    char            *tmp_class_id;
     char            *uri;
 } newImfileRow;
@@ -1805,7 +1612,6 @@
 
 newImfileRow *newImfileRowAlloc(
-    const char      *exp_tag,
-    const char      *class,
-    const char      *class_id,
+    psS64           exp_id,
+    const char      *tmp_class_id,
     const char      *uri
 );
@@ -1838,7 +1644,6 @@
 bool newImfileInsert(
     psDB            *dbh,               ///< Database handle
-    const char      *exp_tag,
-    const char      *class,
-    const char      *class_id,
+    psS64           exp_id,
+    const char      *tmp_class_id,
     const char      *uri
 );
@@ -1997,11 +1802,11 @@
 
 typedef struct {
-    char            *exp_tag;
-    char            *exp_id;
+    psS64           exp_id;
+    char            *exp_name;
     char            *camera;
     char            *telescope;
     psTime*         dateobs;
+    char            *exp_tag;
     char            *exp_type;
-    psS32           imfiles;
     char            *filelevel;
     char            *workdir;
@@ -2035,11 +1840,11 @@
 
 rawExpRow *rawExpRowAlloc(
-    const char      *exp_tag,
-    const char      *exp_id,
+    psS64           exp_id,
+    const char      *exp_name,
     const char      *camera,
     const char      *telescope,
     psTime*         dateobs,
+    const char      *exp_tag,
     const char      *exp_type,
-    psS32           imfiles,
     const char      *filelevel,
     const char      *workdir,
@@ -2094,11 +1899,11 @@
 bool rawExpInsert(
     psDB            *dbh,               ///< Database handle
-    const char      *exp_tag,
-    const char      *exp_id,
+    psS64           exp_id,
+    const char      *exp_name,
     const char      *camera,
     const char      *telescope,
     psTime*         dateobs,
+    const char      *exp_tag,
     const char      *exp_type,
-    psS32           imfiles,
     const char      *filelevel,
     const char      *workdir,
@@ -2279,5 +2084,10 @@
 
 typedef struct {
-    char            *exp_tag;
+    psS64           exp_id;
+    char            *exp_name;
+    char            *camera;
+    char            *telescope;
+    psTime*         dateobs;
+    char            *tmp_class_id;
     char            *class_id;
     char            *uri;
@@ -2303,5 +2113,4 @@
     psF64           user_5;
     char            *object;
-    psTime*         dateobs;
     psS16           fault;
 } rawImfileRow;
@@ -2313,5 +2122,10 @@
 
 rawImfileRow *rawImfileRowAlloc(
-    const char      *exp_tag,
+    psS64           exp_id,
+    const char      *exp_name,
+    const char      *camera,
+    const char      *telescope,
+    psTime*         dateobs,
+    const char      *tmp_class_id,
     const char      *class_id,
     const char      *uri,
@@ -2337,5 +2151,4 @@
     psF64           user_5,
     const char      *object,
-    psTime*         dateobs,
     psS16           fault
 );
@@ -2368,5 +2181,10 @@
 bool rawImfileInsert(
     psDB            *dbh,               ///< Database handle
-    const char      *exp_tag,
+    psS64           exp_id,
+    const char      *exp_name,
+    const char      *camera,
+    const char      *telescope,
+    psTime*         dateobs,
+    const char      *tmp_class_id,
     const char      *class_id,
     const char      *uri,
@@ -2392,5 +2210,4 @@
     psF64           user_5,
     const char      *object,
-    psTime*         dateobs,
     psS16           fault
 );
@@ -2550,5 +2367,5 @@
 typedef struct {
     psS64           guide_id;
-    char            *exp_tag;
+    psS64           exp_id;
     char            *recipe;
 } guidePendingExpRow;
@@ -2561,5 +2378,5 @@
 guidePendingExpRow *guidePendingExpRowAlloc(
     psS64           guide_id,
-    const char      *exp_tag,
+    psS64           exp_id,
     const char      *recipe
 );
@@ -2593,5 +2410,5 @@
     psDB            *dbh,               ///< Database handle
     psS64           guide_id,
-    const char      *exp_tag,
+    psS64           exp_id,
     const char      *recipe
 );
@@ -2744,30 +2561,30 @@
     bool            mdcf                ///< format as mdconfig or simple
 );
-/** chipPendingExpRow data structure
- *
- * Structure for representing a single row of chipPendingExp table data.
+/** chipRunRow data structure
+ *
+ * Structure for representing a single row of chipRun table data.
  */
 
 typedef struct {
     psS64           chip_id;
-    char            *exp_tag;
-    psS64           guide_id;
+    char            *state;
     char            *workdir;
+    char            *workdir_state;
     char            *label;
     char            *reduction;
     char            *expgroup;
     char            *dvodb;
-} chipPendingExpRow;
-
-/** Creates a new chipPendingExpRow object
- *
- *  @return A new chipPendingExpRow object or NULL on failure.
- */
-
-chipPendingExpRow *chipPendingExpRowAlloc(
+} chipRunRow;
+
+/** Creates a new chipRunRow object
+ *
+ *  @return A new chipRunRow object or NULL on failure.
+ */
+
+chipRunRow *chipRunRowAlloc(
     psS64           chip_id,
-    const char      *exp_tag,
-    psS64           guide_id,
+    const char      *state,
     const char      *workdir,
+    const char      *workdir_state,
     const char      *label,
     const char      *reduction,
@@ -2776,19 +2593,19 @@
 );
 
-/** Creates a new chipPendingExp table
- *
- * @return true on success
- */
-
-bool chipPendingExpCreateTable(
+/** Creates a new chipRun table
+ *
+ * @return true on success
+ */
+
+bool chipRunCreateTable(
     psDB            *dbh                ///< Database handle
 );
 
-/** Deletes a chipPendingExp table
- *
- * @return true on success
- */
-
-bool chipPendingExpDropTable(
+/** Deletes a chipRun table
+ *
+ * @return true on success
+ */
+
+bool chipRunDropTable(
     psDB            *dbh                ///< Database handle
 );
@@ -2801,10 +2618,10 @@
  */
 
-bool chipPendingExpInsert(
+bool chipRunInsert(
     psDB            *dbh,               ///< Database handle
     psS64           chip_id,
-    const char      *exp_tag,
-    psS64           guide_id,
+    const char      *state,
     const char      *workdir,
+    const char      *workdir_state,
     const char      *label,
     const char      *reduction,
@@ -2818,5 +2635,5 @@
  */
 
-long long chipPendingExpDelete(
+long long chipRunDelete(
     psDB            *dbh,               ///< Database handle
     const psMetadata *where,            ///< Row match criteria
@@ -2824,5 +2641,5 @@
 );
 
-/** Insert a single chipPendingExpRow object into a table
+/** Insert a single chipRunRow object into a table
  *
  * This function constructs and inserts a single row based on it's parameters.
@@ -2831,10 +2648,10 @@
  */
 
-bool chipPendingExpInsertObject(
-    psDB            *dbh,               ///< Database handle
-    chipPendingExpRow *object             ///< chipPendingExpRow object
-);
-
-/** Insert an array of chipPendingExpRow object into a table
+bool chipRunInsertObject(
+    psDB            *dbh,               ///< Database handle
+    chipRunRow      *object             ///< chipRunRow object
+);
+
+/** Insert an array of chipRunRow object into a table
  *
  * This function constructs and inserts multiple rows based on it's parameters.
@@ -2843,10 +2660,10 @@
  */
 
-bool chipPendingExpInsertObjects(
-    psDB            *dbh,               ///< Database handle
-    psArray         *objects            ///< array of chipPendingExpRow objects
-);
-
-/** Insert data from a binary FITS table chipPendingExpRow into the database
+bool chipRunInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of chipRunRow objects
+);
+
+/** Insert data from a binary FITS table chipRunRow into the database
  *
  * This function expects a psFits object with a FITS table as the first
@@ -2858,5 +2675,5 @@
  */
 
-bool chipPendingExpInsertFits(
+bool chipRunInsertFits(
     psDB            *dbh,               ///< Database handle
     const psFits    *fits               ///< psFits object
@@ -2873,5 +2690,5 @@
  */
 
-bool chipPendingExpSelectRowsFits(
+bool chipRunSelectRowsFits(
     psDB            *dbh,               ///< Database handle
     psFits          *fits,              ///< psFits object
@@ -2880,22 +2697,22 @@
 );
 
-/** Convert a chipPendingExpRow into an equivalent psMetadata
+/** Convert a chipRunRow into an equivalent psMetadata
  *
  * @return A psMetadata pointer or NULL on error
  */
 
-psMetadata *chipPendingExpMetadataFromObject(
-    const chipPendingExpRow *object             ///< fooRow to convert into a psMetadata
+psMetadata *chipRunMetadataFromObject(
+    const chipRunRow *object             ///< fooRow to convert into a psMetadata
 );
 
 /** Convert a psMetadata into an equivalent fooRow
  *
- * @return A chipPendingExpRow pointer or NULL on error
- */
-
-chipPendingExpRow *chipPendingExpObjectFromMetadata(
+ * @return A chipRunRow pointer or NULL on error
+ */
+
+chipRunRow *chipRunObjectFromMetadata(
     psMetadata      *md                 ///< psMetadata to convert into a fooRow
 );
-/** Selects up to limit rows from the database and returns as chipPendingExpRow objects in a psArray
+/** Selects up to limit rows from the database and returns as chipRunRow objects in a psArray
  *
  *  See psDBSelectRows() for documentation on the format of where.
@@ -2904,10 +2721,10 @@
  */
 
-psArray *chipPendingExpSelectRowObjects(
+psArray *chipRunSelectRowObjects(
     psDB            *dbh,               ///< Database handle
     const psMetadata *where,            ///< Row match criteria
     unsigned long long limit            ///< Maximum number of elements to return
 );
-/** Deletes a row from the database coresponding to an chipPendingExp
+/** Deletes a row from the database coresponding to an chipRun
  *
  *  Note that a 'where' search psMetadata is constructed from each object and
@@ -2917,7 +2734,7 @@
  */
 
-bool chipPendingExpDeleteObject(
-    psDB            *dbh,               ///< Database handle
-    const chipPendingExpRow *object    ///< Object to delete
+bool chipRunDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const chipRunRow *object    ///< Object to delete
 );
 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
@@ -2929,10 +2746,10 @@
  */
 
-long long chipPendingExpDeleteRowObjects(
+long long chipRunDeleteRowObjects(
     psDB            *dbh,               ///< Database handle
     const psArray   *objects,           ///< Array of objects to delete
     unsigned long long limit            ///< Maximum number of elements to delete 
 );
-/** Formats and prints an array of chipPendingExpRow objects
+/** Formats and prints an array of chipRunRow objects
  *
  * When mdcf is set the formated output is in psMetadataConfig
@@ -2942,10 +2759,10 @@
  */
 
-bool chipPendingExpPrintObjects(
+bool chipRunPrintObjects(
     FILE            *stream,            ///< a stream
-    psArray         *objects,           ///< An array of chipPendingExpRow objects
+    psArray         *objects,           ///< An array of chipRunRow objects
     bool            mdcf                ///< format as mdconfig or simple
 );
-/** Formats and prints an chipPendingExpRow object
+/** Formats and prints an chipRunRow object
  *
  * When mdcf is set the formated output is in psMetadataConfig
@@ -2955,46 +2772,46 @@
  */
 
-bool chipPendingExpPrintObject(
+bool chipRunPrintObject(
     FILE            *stream,            ///< a stream
-    chipPendingExpRow *object,    ///< an chipPendingExpRow object
+    chipRunRow *object,    ///< an chipRunRow object
     bool            mdcf                ///< format as mdconfig or simple
 );
-/** chipPendingImfileRow data structure
- *
- * Structure for representing a single row of chipPendingImfile table data.
+/** chipInputImfileRow data structure
+ *
+ * Structure for representing a single row of chipInputImfile table data.
  */
 
 typedef struct {
     psS64           chip_id;
+    psS64           exp_id;
     char            *class_id;
-    char            *uri;
-} chipPendingImfileRow;
-
-/** Creates a new chipPendingImfileRow object
- *
- *  @return A new chipPendingImfileRow object or NULL on failure.
- */
-
-chipPendingImfileRow *chipPendingImfileRowAlloc(
+} chipInputImfileRow;
+
+/** Creates a new chipInputImfileRow object
+ *
+ *  @return A new chipInputImfileRow object or NULL on failure.
+ */
+
+chipInputImfileRow *chipInputImfileRowAlloc(
     psS64           chip_id,
-    const char      *class_id,
-    const char      *uri
-);
-
-/** Creates a new chipPendingImfile table
- *
- * @return true on success
- */
-
-bool chipPendingImfileCreateTable(
+    psS64           exp_id,
+    const char      *class_id
+);
+
+/** Creates a new chipInputImfile table
+ *
+ * @return true on success
+ */
+
+bool chipInputImfileCreateTable(
     psDB            *dbh                ///< Database handle
 );
 
-/** Deletes a chipPendingImfile table
- *
- * @return true on success
- */
-
-bool chipPendingImfileDropTable(
+/** Deletes a chipInputImfile table
+ *
+ * @return true on success
+ */
+
+bool chipInputImfileDropTable(
     psDB            *dbh                ///< Database handle
 );
@@ -3007,9 +2824,9 @@
  */
 
-bool chipPendingImfileInsert(
+bool chipInputImfileInsert(
     psDB            *dbh,               ///< Database handle
     psS64           chip_id,
-    const char      *class_id,
-    const char      *uri
+    psS64           exp_id,
+    const char      *class_id
 );
 
@@ -3019,5 +2836,5 @@
  */
 
-long long chipPendingImfileDelete(
+long long chipInputImfileDelete(
     psDB            *dbh,               ///< Database handle
     const psMetadata *where,            ///< Row match criteria
@@ -3025,5 +2842,5 @@
 );
 
-/** Insert a single chipPendingImfileRow object into a table
+/** Insert a single chipInputImfileRow object into a table
  *
  * This function constructs and inserts a single row based on it's parameters.
@@ -3032,10 +2849,10 @@
  */
 
-bool chipPendingImfileInsertObject(
-    psDB            *dbh,               ///< Database handle
-    chipPendingImfileRow *object             ///< chipPendingImfileRow object
-);
-
-/** Insert an array of chipPendingImfileRow object into a table
+bool chipInputImfileInsertObject(
+    psDB            *dbh,               ///< Database handle
+    chipInputImfileRow *object             ///< chipInputImfileRow object
+);
+
+/** Insert an array of chipInputImfileRow object into a table
  *
  * This function constructs and inserts multiple rows based on it's parameters.
@@ -3044,10 +2861,10 @@
  */
 
-bool chipPendingImfileInsertObjects(
-    psDB            *dbh,               ///< Database handle
-    psArray         *objects            ///< array of chipPendingImfileRow objects
-);
-
-/** Insert data from a binary FITS table chipPendingImfileRow into the database
+bool chipInputImfileInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of chipInputImfileRow objects
+);
+
+/** Insert data from a binary FITS table chipInputImfileRow into the database
  *
  * This function expects a psFits object with a FITS table as the first
@@ -3059,5 +2876,5 @@
  */
 
-bool chipPendingImfileInsertFits(
+bool chipInputImfileInsertFits(
     psDB            *dbh,               ///< Database handle
     const psFits    *fits               ///< psFits object
@@ -3074,5 +2891,5 @@
  */
 
-bool chipPendingImfileSelectRowsFits(
+bool chipInputImfileSelectRowsFits(
     psDB            *dbh,               ///< Database handle
     psFits          *fits,              ///< psFits object
@@ -3081,22 +2898,22 @@
 );
 
-/** Convert a chipPendingImfileRow into an equivalent psMetadata
+/** Convert a chipInputImfileRow into an equivalent psMetadata
  *
  * @return A psMetadata pointer or NULL on error
  */
 
-psMetadata *chipPendingImfileMetadataFromObject(
-    const chipPendingImfileRow *object             ///< fooRow to convert into a psMetadata
+psMetadata *chipInputImfileMetadataFromObject(
+    const chipInputImfileRow *object             ///< fooRow to convert into a psMetadata
 );
 
 /** Convert a psMetadata into an equivalent fooRow
  *
- * @return A chipPendingImfileRow pointer or NULL on error
- */
-
-chipPendingImfileRow *chipPendingImfileObjectFromMetadata(
+ * @return A chipInputImfileRow pointer or NULL on error
+ */
+
+chipInputImfileRow *chipInputImfileObjectFromMetadata(
     psMetadata      *md                 ///< psMetadata to convert into a fooRow
 );
-/** Selects up to limit rows from the database and returns as chipPendingImfileRow objects in a psArray
+/** Selects up to limit rows from the database and returns as chipInputImfileRow objects in a psArray
  *
  *  See psDBSelectRows() for documentation on the format of where.
@@ -3105,10 +2922,10 @@
  */
 
-psArray *chipPendingImfileSelectRowObjects(
+psArray *chipInputImfileSelectRowObjects(
     psDB            *dbh,               ///< Database handle
     const psMetadata *where,            ///< Row match criteria
     unsigned long long limit            ///< Maximum number of elements to return
 );
-/** Deletes a row from the database coresponding to an chipPendingImfile
+/** Deletes a row from the database coresponding to an chipInputImfile
  *
  *  Note that a 'where' search psMetadata is constructed from each object and
@@ -3118,7 +2935,7 @@
  */
 
-bool chipPendingImfileDeleteObject(
-    psDB            *dbh,               ///< Database handle
-    const chipPendingImfileRow *object    ///< Object to delete
+bool chipInputImfileDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const chipInputImfileRow *object    ///< Object to delete
 );
 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
@@ -3130,10 +2947,10 @@
  */
 
-long long chipPendingImfileDeleteRowObjects(
+long long chipInputImfileDeleteRowObjects(
     psDB            *dbh,               ///< Database handle
     const psArray   *objects,           ///< Array of objects to delete
     unsigned long long limit            ///< Maximum number of elements to delete 
 );
-/** Formats and prints an array of chipPendingImfileRow objects
+/** Formats and prints an array of chipInputImfileRow objects
  *
  * When mdcf is set the formated output is in psMetadataConfig
@@ -3143,10 +2960,10 @@
  */
 
-bool chipPendingImfilePrintObjects(
+bool chipInputImfilePrintObjects(
     FILE            *stream,            ///< a stream
-    psArray         *objects,           ///< An array of chipPendingImfileRow objects
+    psArray         *objects,           ///< An array of chipInputImfileRow objects
     bool            mdcf                ///< format as mdconfig or simple
 );
-/** Formats and prints an chipPendingImfileRow object
+/** Formats and prints an chipInputImfileRow object
  *
  * When mdcf is set the formated output is in psMetadataConfig
@@ -3156,427 +2973,17 @@
  */
 
-bool chipPendingImfilePrintObject(
+bool chipInputImfilePrintObject(
     FILE            *stream,            ///< a stream
-    chipPendingImfileRow *object,    ///< an chipPendingImfileRow object
+    chipInputImfileRow *object,    ///< an chipInputImfileRow object
     bool            mdcf                ///< format as mdconfig or simple
 );
-/** chipProcessedExpRow data structure
- *
- * Structure for representing a single row of chipProcessedExp table data.
+/** chipProcessedImfileRow data structure
+ *
+ * Structure for representing a single row of chipProcessedImfile table data.
  */
 
 typedef struct {
     psS64           chip_id;
-    char            *exp_tag;
-    psS64           guide_id;
-    char            *workdir;
-    char            *label;
-    char            *reduction;
-    char            *expgroup;
-    char            *dvodb;
-} chipProcessedExpRow;
-
-/** Creates a new chipProcessedExpRow object
- *
- *  @return A new chipProcessedExpRow object or NULL on failure.
- */
-
-chipProcessedExpRow *chipProcessedExpRowAlloc(
-    psS64           chip_id,
-    const char      *exp_tag,
-    psS64           guide_id,
-    const char      *workdir,
-    const char      *label,
-    const char      *reduction,
-    const char      *expgroup,
-    const char      *dvodb
-);
-
-/** Creates a new chipProcessedExp table
- *
- * @return true on success
- */
-
-bool chipProcessedExpCreateTable(
-    psDB            *dbh                ///< Database handle
-);
-
-/** Deletes a chipProcessedExp table
- *
- * @return true on success
- */
-
-bool chipProcessedExpDropTable(
-    psDB            *dbh                ///< Database handle
-);
-
-/** Insert a single row into a table
- *
- * This function constructs and inserts a single row based on it's parameters.
- *
- * @return true on success
- */
-
-bool chipProcessedExpInsert(
-    psDB            *dbh,               ///< Database handle
-    psS64           chip_id,
-    const char      *exp_tag,
-    psS64           guide_id,
-    const char      *workdir,
-    const char      *label,
-    const char      *reduction,
-    const char      *expgroup,
-    const char      *dvodb
-);
-
-/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
- *
- * @return A The number of rows removed or a negative value on error
- */
-
-long long chipProcessedExpDelete(
-    psDB            *dbh,               ///< Database handle
-    const psMetadata *where,            ///< Row match criteria
-    unsigned long long limit            ///< Maximum number of elements to delete 
-);
-
-/** Insert a single chipProcessedExpRow object into a table
- *
- * This function constructs and inserts a single row based on it's parameters.
- *
- * @return true on success
- */
-
-bool chipProcessedExpInsertObject(
-    psDB            *dbh,               ///< Database handle
-    chipProcessedExpRow *object             ///< chipProcessedExpRow object
-);
-
-/** Insert an array of chipProcessedExpRow object into a table
- *
- * This function constructs and inserts multiple rows based on it's parameters.
- *
- * @return true on success
- */
-
-bool chipProcessedExpInsertObjects(
-    psDB            *dbh,               ///< Database handle
-    psArray         *objects            ///< array of chipProcessedExpRow objects
-);
-
-/** Insert data from a binary FITS table chipProcessedExpRow into the database
- *
- * This function expects a psFits object with a FITS table as the first
- * extension.  The table must have at least one row of data in it, that is of
- * the appropriate format (number of columns and their type).  All other
- * extensions are ignored.
- *
- * @return true on success
- */
-
-bool chipProcessedExpInsertFits(
-    psDB            *dbh,               ///< Database handle
-    const psFits    *fits               ///< psFits object
-);
-
-/** Selects up to limit from the database and returns them in a binary FITS table
- *
- * This function assumes an empty psFits object and will create a FITS table
- * as the first extension.
- *
- *  See psDBSelectRows() for documentation on the format of where.
- *
- * @return true on success
- */
-
-bool chipProcessedExpSelectRowsFits(
-    psDB            *dbh,               ///< Database handle
-    psFits          *fits,              ///< psFits object
-    const psMetadata *where,            ///< Row match criteria
-    unsigned long long limit            ///< Maximum number of elements to return
-);
-
-/** Convert a chipProcessedExpRow into an equivalent psMetadata
- *
- * @return A psMetadata pointer or NULL on error
- */
-
-psMetadata *chipProcessedExpMetadataFromObject(
-    const chipProcessedExpRow *object             ///< fooRow to convert into a psMetadata
-);
-
-/** Convert a psMetadata into an equivalent fooRow
- *
- * @return A chipProcessedExpRow pointer or NULL on error
- */
-
-chipProcessedExpRow *chipProcessedExpObjectFromMetadata(
-    psMetadata      *md                 ///< psMetadata to convert into a fooRow
-);
-/** Selects up to limit rows from the database and returns as chipProcessedExpRow objects in a psArray
- *
- *  See psDBSelectRows() for documentation on the format of where.
- *
- * @return A psArray pointer or NULL on error
- */
-
-psArray *chipProcessedExpSelectRowObjects(
-    psDB            *dbh,               ///< Database handle
-    const psMetadata *where,            ///< Row match criteria
-    unsigned long long limit            ///< Maximum number of elements to return
-);
-/** Deletes a row from the database coresponding to an chipProcessedExp
- *
- *  Note that a 'where' search psMetadata is constructed from each object and
- *  used to find rows to delete.
- *
- * @return A The number of rows removed or a negative value on error
- */
-
-bool chipProcessedExpDeleteObject(
-    psDB            *dbh,               ///< Database handle
-    const chipProcessedExpRow *object    ///< Object to delete
-);
-/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
- *
- *  Note that a 'where' search psMetadata is constructed from each object and
- *  used to find rows to delete.
- *
- * @return A The number of rows removed or a negative value on error
- */
-
-long long chipProcessedExpDeleteRowObjects(
-    psDB            *dbh,               ///< Database handle
-    const psArray   *objects,           ///< Array of objects to delete
-    unsigned long long limit            ///< Maximum number of elements to delete 
-);
-/** Formats and prints an array of chipProcessedExpRow objects
- *
- * When mdcf is set the formated output is in psMetadataConfig
- * format, otherwise it is in a simple tabular format.
- *
- * @return true on success
- */
-
-bool chipProcessedExpPrintObjects(
-    FILE            *stream,            ///< a stream
-    psArray         *objects,           ///< An array of chipProcessedExpRow objects
-    bool            mdcf                ///< format as mdconfig or simple
-);
-/** Formats and prints an chipProcessedExpRow object
- *
- * When mdcf is set the formated output is in psMetadataConfig
- * format, otherwise it is in a simple tabular format.
- *
- * @return true on success
- */
-
-bool chipProcessedExpPrintObject(
-    FILE            *stream,            ///< a stream
-    chipProcessedExpRow *object,    ///< an chipProcessedExpRow object
-    bool            mdcf                ///< format as mdconfig or simple
-);
-/** chipMaskRow data structure
- *
- * Structure for representing a single row of chipMask table data.
- */
-
-typedef struct {
-    char            *label;
-} chipMaskRow;
-
-/** Creates a new chipMaskRow object
- *
- *  @return A new chipMaskRow object or NULL on failure.
- */
-
-chipMaskRow *chipMaskRowAlloc(
-    const char      *label
-);
-
-/** Creates a new chipMask table
- *
- * @return true on success
- */
-
-bool chipMaskCreateTable(
-    psDB            *dbh                ///< Database handle
-);
-
-/** Deletes a chipMask table
- *
- * @return true on success
- */
-
-bool chipMaskDropTable(
-    psDB            *dbh                ///< Database handle
-);
-
-/** Insert a single row into a table
- *
- * This function constructs and inserts a single row based on it's parameters.
- *
- * @return true on success
- */
-
-bool chipMaskInsert(
-    psDB            *dbh,               ///< Database handle
-    const char      *label
-);
-
-/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
- *
- * @return A The number of rows removed or a negative value on error
- */
-
-long long chipMaskDelete(
-    psDB            *dbh,               ///< Database handle
-    const psMetadata *where,            ///< Row match criteria
-    unsigned long long limit            ///< Maximum number of elements to delete 
-);
-
-/** Insert a single chipMaskRow object into a table
- *
- * This function constructs and inserts a single row based on it's parameters.
- *
- * @return true on success
- */
-
-bool chipMaskInsertObject(
-    psDB            *dbh,               ///< Database handle
-    chipMaskRow     *object             ///< chipMaskRow object
-);
-
-/** Insert an array of chipMaskRow object into a table
- *
- * This function constructs and inserts multiple rows based on it's parameters.
- *
- * @return true on success
- */
-
-bool chipMaskInsertObjects(
-    psDB            *dbh,               ///< Database handle
-    psArray         *objects            ///< array of chipMaskRow objects
-);
-
-/** Insert data from a binary FITS table chipMaskRow into the database
- *
- * This function expects a psFits object with a FITS table as the first
- * extension.  The table must have at least one row of data in it, that is of
- * the appropriate format (number of columns and their type).  All other
- * extensions are ignored.
- *
- * @return true on success
- */
-
-bool chipMaskInsertFits(
-    psDB            *dbh,               ///< Database handle
-    const psFits    *fits               ///< psFits object
-);
-
-/** Selects up to limit from the database and returns them in a binary FITS table
- *
- * This function assumes an empty psFits object and will create a FITS table
- * as the first extension.
- *
- *  See psDBSelectRows() for documentation on the format of where.
- *
- * @return true on success
- */
-
-bool chipMaskSelectRowsFits(
-    psDB            *dbh,               ///< Database handle
-    psFits          *fits,              ///< psFits object
-    const psMetadata *where,            ///< Row match criteria
-    unsigned long long limit            ///< Maximum number of elements to return
-);
-
-/** Convert a chipMaskRow into an equivalent psMetadata
- *
- * @return A psMetadata pointer or NULL on error
- */
-
-psMetadata *chipMaskMetadataFromObject(
-    const chipMaskRow *object             ///< fooRow to convert into a psMetadata
-);
-
-/** Convert a psMetadata into an equivalent fooRow
- *
- * @return A chipMaskRow pointer or NULL on error
- */
-
-chipMaskRow *chipMaskObjectFromMetadata(
-    psMetadata      *md                 ///< psMetadata to convert into a fooRow
-);
-/** Selects up to limit rows from the database and returns as chipMaskRow objects in a psArray
- *
- *  See psDBSelectRows() for documentation on the format of where.
- *
- * @return A psArray pointer or NULL on error
- */
-
-psArray *chipMaskSelectRowObjects(
-    psDB            *dbh,               ///< Database handle
-    const psMetadata *where,            ///< Row match criteria
-    unsigned long long limit            ///< Maximum number of elements to return
-);
-/** Deletes a row from the database coresponding to an chipMask
- *
- *  Note that a 'where' search psMetadata is constructed from each object and
- *  used to find rows to delete.
- *
- * @return A The number of rows removed or a negative value on error
- */
-
-bool chipMaskDeleteObject(
-    psDB            *dbh,               ///< Database handle
-    const chipMaskRow *object    ///< Object to delete
-);
-/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
- *
- *  Note that a 'where' search psMetadata is constructed from each object and
- *  used to find rows to delete.
- *
- * @return A The number of rows removed or a negative value on error
- */
-
-long long chipMaskDeleteRowObjects(
-    psDB            *dbh,               ///< Database handle
-    const psArray   *objects,           ///< Array of objects to delete
-    unsigned long long limit            ///< Maximum number of elements to delete 
-);
-/** Formats and prints an array of chipMaskRow objects
- *
- * When mdcf is set the formated output is in psMetadataConfig
- * format, otherwise it is in a simple tabular format.
- *
- * @return true on success
- */
-
-bool chipMaskPrintObjects(
-    FILE            *stream,            ///< a stream
-    psArray         *objects,           ///< An array of chipMaskRow objects
-    bool            mdcf                ///< format as mdconfig or simple
-);
-/** Formats and prints an chipMaskRow object
- *
- * When mdcf is set the formated output is in psMetadataConfig
- * format, otherwise it is in a simple tabular format.
- *
- * @return true on success
- */
-
-bool chipMaskPrintObject(
-    FILE            *stream,            ///< a stream
-    chipMaskRow *object,    ///< an chipMaskRow object
-    bool            mdcf                ///< format as mdconfig or simple
-);
-/** chipProcessedImfileRow data structure
- *
- * Structure for representing a single row of chipProcessedImfile table data.
- */
-
-typedef struct {
-    psS64           chip_id;
+    psS64           exp_id;
     char            *class_id;
     char            *uri;
@@ -3610,4 +3017,5 @@
 chipProcessedImfileRow *chipProcessedImfileRowAlloc(
     psS64           chip_id,
+    psS64           exp_id,
     const char      *class_id,
     const char      *uri,
@@ -3662,4 +3070,5 @@
     psDB            *dbh,               ///< Database handle
     psS64           chip_id,
+    psS64           exp_id,
     const char      *class_id,
     const char      *uri,
@@ -3833,7 +3242,202 @@
     bool            mdcf                ///< format as mdconfig or simple
 );
-/** camPendingExpRow data structure
- *
- * Structure for representing a single row of camPendingExp table data.
+/** chipMaskRow data structure
+ *
+ * Structure for representing a single row of chipMask table data.
+ */
+
+typedef struct {
+    char            *label;
+} chipMaskRow;
+
+/** Creates a new chipMaskRow object
+ *
+ *  @return A new chipMaskRow object or NULL on failure.
+ */
+
+chipMaskRow *chipMaskRowAlloc(
+    const char      *label
+);
+
+/** Creates a new chipMask table
+ *
+ * @return true on success
+ */
+
+bool chipMaskCreateTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Deletes a chipMask table
+ *
+ * @return true on success
+ */
+
+bool chipMaskDropTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Insert a single row into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool chipMaskInsert(
+    psDB            *dbh,               ///< Database handle
+    const char      *label
+);
+
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long chipMaskDelete(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+
+/** Insert a single chipMaskRow object into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool chipMaskInsertObject(
+    psDB            *dbh,               ///< Database handle
+    chipMaskRow     *object             ///< chipMaskRow object
+);
+
+/** Insert an array of chipMaskRow object into a table
+ *
+ * This function constructs and inserts multiple rows based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool chipMaskInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of chipMaskRow objects
+);
+
+/** Insert data from a binary FITS table chipMaskRow into the database
+ *
+ * This function expects a psFits object with a FITS table as the first
+ * extension.  The table must have at least one row of data in it, that is of
+ * the appropriate format (number of columns and their type).  All other
+ * extensions are ignored.
+ *
+ * @return true on success
+ */
+
+bool chipMaskInsertFits(
+    psDB            *dbh,               ///< Database handle
+    const psFits    *fits               ///< psFits object
+);
+
+/** Selects up to limit from the database and returns them in a binary FITS table
+ *
+ * This function assumes an empty psFits object and will create a FITS table
+ * as the first extension.
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return true on success
+ */
+
+bool chipMaskSelectRowsFits(
+    psDB            *dbh,               ///< Database handle
+    psFits          *fits,              ///< psFits object
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+
+/** Convert a chipMaskRow into an equivalent psMetadata
+ *
+ * @return A psMetadata pointer or NULL on error
+ */
+
+psMetadata *chipMaskMetadataFromObject(
+    const chipMaskRow *object             ///< fooRow to convert into a psMetadata
+);
+
+/** Convert a psMetadata into an equivalent fooRow
+ *
+ * @return A chipMaskRow pointer or NULL on error
+ */
+
+chipMaskRow *chipMaskObjectFromMetadata(
+    psMetadata      *md                 ///< psMetadata to convert into a fooRow
+);
+/** Selects up to limit rows from the database and returns as chipMaskRow objects in a psArray
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return A psArray pointer or NULL on error
+ */
+
+psArray *chipMaskSelectRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+/** Deletes a row from the database coresponding to an chipMask
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+bool chipMaskDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const chipMaskRow *object    ///< Object to delete
+);
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long chipMaskDeleteRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psArray   *objects,           ///< Array of objects to delete
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+/** Formats and prints an array of chipMaskRow objects
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool chipMaskPrintObjects(
+    FILE            *stream,            ///< a stream
+    psArray         *objects,           ///< An array of chipMaskRow objects
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** Formats and prints an chipMaskRow object
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool chipMaskPrintObject(
+    FILE            *stream,            ///< a stream
+    chipMaskRow *object,    ///< an chipMaskRow object
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** camRunRow data structure
+ *
+ * Structure for representing a single row of camRun table data.
  */
 
@@ -3841,20 +3445,24 @@
     psS64           cam_id;
     psS64           chip_id;
+    char            *state;
     char            *workdir;
+    char            *workdir_state;
     char            *label;
     char            *reduction;
     char            *expgroup;
     char            *dvodb;
-} camPendingExpRow;
-
-/** Creates a new camPendingExpRow object
- *
- *  @return A new camPendingExpRow object or NULL on failure.
- */
-
-camPendingExpRow *camPendingExpRowAlloc(
+} camRunRow;
+
+/** Creates a new camRunRow object
+ *
+ *  @return A new camRunRow object or NULL on failure.
+ */
+
+camRunRow *camRunRowAlloc(
     psS64           cam_id,
     psS64           chip_id,
+    const char      *state,
     const char      *workdir,
+    const char      *workdir_state,
     const char      *label,
     const char      *reduction,
@@ -3863,19 +3471,19 @@
 );
 
-/** Creates a new camPendingExp table
- *
- * @return true on success
- */
-
-bool camPendingExpCreateTable(
+/** Creates a new camRun table
+ *
+ * @return true on success
+ */
+
+bool camRunCreateTable(
     psDB            *dbh                ///< Database handle
 );
 
-/** Deletes a camPendingExp table
- *
- * @return true on success
- */
-
-bool camPendingExpDropTable(
+/** Deletes a camRun table
+ *
+ * @return true on success
+ */
+
+bool camRunDropTable(
     psDB            *dbh                ///< Database handle
 );
@@ -3888,9 +3496,11 @@
  */
 
-bool camPendingExpInsert(
+bool camRunInsert(
     psDB            *dbh,               ///< Database handle
     psS64           cam_id,
     psS64           chip_id,
+    const char      *state,
     const char      *workdir,
+    const char      *workdir_state,
     const char      *label,
     const char      *reduction,
@@ -3904,5 +3514,5 @@
  */
 
-long long camPendingExpDelete(
+long long camRunDelete(
     psDB            *dbh,               ///< Database handle
     const psMetadata *where,            ///< Row match criteria
@@ -3910,5 +3520,5 @@
 );
 
-/** Insert a single camPendingExpRow object into a table
+/** Insert a single camRunRow object into a table
  *
  * This function constructs and inserts a single row based on it's parameters.
@@ -3917,10 +3527,10 @@
  */
 
-bool camPendingExpInsertObject(
-    psDB            *dbh,               ///< Database handle
-    camPendingExpRow *object             ///< camPendingExpRow object
-);
-
-/** Insert an array of camPendingExpRow object into a table
+bool camRunInsertObject(
+    psDB            *dbh,               ///< Database handle
+    camRunRow       *object             ///< camRunRow object
+);
+
+/** Insert an array of camRunRow object into a table
  *
  * This function constructs and inserts multiple rows based on it's parameters.
@@ -3929,10 +3539,10 @@
  */
 
-bool camPendingExpInsertObjects(
-    psDB            *dbh,               ///< Database handle
-    psArray         *objects            ///< array of camPendingExpRow objects
-);
-
-/** Insert data from a binary FITS table camPendingExpRow into the database
+bool camRunInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of camRunRow objects
+);
+
+/** Insert data from a binary FITS table camRunRow into the database
  *
  * This function expects a psFits object with a FITS table as the first
@@ -3944,5 +3554,5 @@
  */
 
-bool camPendingExpInsertFits(
+bool camRunInsertFits(
     psDB            *dbh,               ///< Database handle
     const psFits    *fits               ///< psFits object
@@ -3959,5 +3569,5 @@
  */
 
-bool camPendingExpSelectRowsFits(
+bool camRunSelectRowsFits(
     psDB            *dbh,               ///< Database handle
     psFits          *fits,              ///< psFits object
@@ -3966,22 +3576,22 @@
 );
 
-/** Convert a camPendingExpRow into an equivalent psMetadata
+/** Convert a camRunRow into an equivalent psMetadata
  *
  * @return A psMetadata pointer or NULL on error
  */
 
-psMetadata *camPendingExpMetadataFromObject(
-    const camPendingExpRow *object             ///< fooRow to convert into a psMetadata
+psMetadata *camRunMetadataFromObject(
+    const camRunRow *object             ///< fooRow to convert into a psMetadata
 );
 
 /** Convert a psMetadata into an equivalent fooRow
  *
- * @return A camPendingExpRow pointer or NULL on error
- */
-
-camPendingExpRow *camPendingExpObjectFromMetadata(
+ * @return A camRunRow pointer or NULL on error
+ */
+
+camRunRow *camRunObjectFromMetadata(
     psMetadata      *md                 ///< psMetadata to convert into a fooRow
 );
-/** Selects up to limit rows from the database and returns as camPendingExpRow objects in a psArray
+/** Selects up to limit rows from the database and returns as camRunRow objects in a psArray
  *
  *  See psDBSelectRows() for documentation on the format of where.
@@ -3990,10 +3600,10 @@
  */
 
-psArray *camPendingExpSelectRowObjects(
+psArray *camRunSelectRowObjects(
     psDB            *dbh,               ///< Database handle
     const psMetadata *where,            ///< Row match criteria
     unsigned long long limit            ///< Maximum number of elements to return
 );
-/** Deletes a row from the database coresponding to an camPendingExp
+/** Deletes a row from the database coresponding to an camRun
  *
  *  Note that a 'where' search psMetadata is constructed from each object and
@@ -4003,7 +3613,7 @@
  */
 
-bool camPendingExpDeleteObject(
-    psDB            *dbh,               ///< Database handle
-    const camPendingExpRow *object    ///< Object to delete
+bool camRunDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const camRunRow *object    ///< Object to delete
 );
 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
@@ -4015,10 +3625,10 @@
  */
 
-long long camPendingExpDeleteRowObjects(
+long long camRunDeleteRowObjects(
     psDB            *dbh,               ///< Database handle
     const psArray   *objects,           ///< Array of objects to delete
     unsigned long long limit            ///< Maximum number of elements to delete 
 );
-/** Formats and prints an array of camPendingExpRow objects
+/** Formats and prints an array of camRunRow objects
  *
  * When mdcf is set the formated output is in psMetadataConfig
@@ -4028,10 +3638,10 @@
  */
 
-bool camPendingExpPrintObjects(
+bool camRunPrintObjects(
     FILE            *stream,            ///< a stream
-    psArray         *objects,           ///< An array of camPendingExpRow objects
+    psArray         *objects,           ///< An array of camRunRow objects
     bool            mdcf                ///< format as mdconfig or simple
 );
-/** Formats and prints an camPendingExpRow object
+/** Formats and prints an camRunRow object
  *
  * When mdcf is set the formated output is in psMetadataConfig
@@ -4041,7 +3651,7 @@
  */
 
-bool camPendingExpPrintObject(
+bool camRunPrintObject(
     FILE            *stream,            ///< a stream
-    camPendingExpRow *object,    ///< an camPendingExpRow object
+    camRunRow *object,    ///< an camRunRow object
     bool            mdcf                ///< format as mdconfig or simple
 );
@@ -4054,9 +3664,4 @@
     psS64           cam_id;
     psS64           chip_id;
-    char            *workdir;
-    char            *label;
-    char            *reduction;
-    char            *expgroup;
-    char            *dvodb;
     char            *uri;
     psF32           bg;
@@ -4085,9 +3690,4 @@
     psS64           cam_id,
     psS64           chip_id,
-    const char      *workdir,
-    const char      *label,
-    const char      *reduction,
-    const char      *expgroup,
-    const char      *dvodb,
     const char      *uri,
     psF32           bg,
@@ -4137,9 +3737,4 @@
     psS64           cam_id,
     psS64           chip_id,
-    const char      *workdir,
-    const char      *label,
-    const char      *reduction,
-    const char      *expgroup,
-    const char      *dvodb,
     const char      *uri,
     psF32           bg,
@@ -6871,5 +6466,5 @@
     psS64           det_id;
     psS32           iteration;
-    char            *exp_tag;
+    psS64           exp_id;
     bool            include;
 } detInputExpRow;
@@ -6883,5 +6478,5 @@
     psS64           det_id,
     psS32           iteration,
-    const char      *exp_tag,
+    psS64           exp_id,
     bool            include
 );
@@ -6916,5 +6511,5 @@
     psS64           det_id,
     psS32           iteration,
-    const char      *exp_tag,
+    psS64           exp_id,
     bool            include
 );
@@ -7074,5 +6669,5 @@
 typedef struct {
     psS64           det_id;
-    char            *exp_tag;
+    psS64           exp_id;
     char            *class_id;
     char            *uri;
@@ -7100,5 +6695,5 @@
 detProcessedImfileRow *detProcessedImfileRowAlloc(
     psS64           det_id,
-    const char      *exp_tag,
+    psS64           exp_id,
     const char      *class_id,
     const char      *uri,
@@ -7147,5 +6742,5 @@
     psDB            *dbh,               ///< Database handle
     psS64           det_id,
-    const char      *exp_tag,
+    psS64           exp_id,
     const char      *class_id,
     const char      *uri,
@@ -7320,5 +6915,5 @@
 typedef struct {
     psS64           det_id;
-    char            *exp_tag;
+    psS64           exp_id;
     char            *recipe;
     psF64           bg;
@@ -7344,5 +6939,5 @@
 detProcessedExpRow *detProcessedExpRowAlloc(
     psS64           det_id,
-    const char      *exp_tag,
+    psS64           exp_id,
     const char      *recipe,
     psF64           bg,
@@ -7389,5 +6984,5 @@
     psDB            *dbh,               ///< Database handle
     psS64           det_id,
-    const char      *exp_tag,
+    psS64           exp_id,
     const char      *recipe,
     psF64           bg,
@@ -8467,5 +8062,5 @@
     psS64           det_id;
     psS32           iteration;
-    char            *exp_tag;
+    psS64           exp_id;
     char            *class_id;
     char            *uri;
@@ -8495,5 +8090,5 @@
     psS64           det_id,
     psS32           iteration,
-    const char      *exp_tag,
+    psS64           exp_id,
     const char      *class_id,
     const char      *uri,
@@ -8544,5 +8139,5 @@
     psS64           det_id,
     psS32           iteration,
-    const char      *exp_tag,
+    psS64           exp_id,
     const char      *class_id,
     const char      *uri,
@@ -8719,5 +8314,5 @@
     psS64           det_id;
     psS32           iteration;
-    char            *exp_tag;
+    psS64           exp_id;
     char            *recipe;
     psF64           bg;
@@ -8746,5 +8341,5 @@
     psS64           det_id,
     psS32           iteration,
-    const char      *exp_tag,
+    psS64           exp_id,
     const char      *recipe,
     psF64           bg,
@@ -8794,5 +8389,5 @@
     psS64           det_id,
     psS32           iteration,
-    const char      *exp_tag,
+    psS64           exp_id,
     const char      *recipe,
     psF64           bg,
