Index: trunk/ippTools/src/chiptool.h
===================================================================
--- trunk/ippTools/src/chiptool.h	(revision 6032)
+++ trunk/ippTools/src/chiptool.h	(revision 6060)
@@ -7,8 +7,11 @@
 # include <pmPSFtry.h>
 # include <pmModelGroup.h>
+# include <metadatadb.h>
 
 // load these values from the db in the init stage
 # define P2_TYPE_OBJECT 1
 # define P2_STATE_READY 2
+# define RECIPE "foo"
+# define MAX_ROWS 10e9
 
 typedef enum {
@@ -25,98 +28,59 @@
 typedef struct {
     p2mode mode;
-    psTime start;
-    psTime stop;
+    psTime *start;
+    psTime *stop;
     psSphere r1;
     psSphere r2;
-    char *camera;
+    psMetadata *camera;
+    char *camera_name;
     char *filter;
     psDB *database;
-} p2config;
-
-// this structure should be defined using the mddb api tools
-typedef struct {
-    char expID[32];			// free-form exposure ID string
-    char class;				// class of file: fpa (0), chip (1), cell (2), readout (3)?
-    int Nclass;				// number of files of this class
-    char camera[32];			// free-form camera ID string
-    char filter[32];			// free-form filter ID string
-    psTime time_start;			// exposure start time
-    psTime time_stop;			// exposure stop time
-    psTime exptime;			// exposure duration (seconds)
-    char exptype;			// type of exposure: object (0), bias (1), dark (2), flat (3), etc
-    float sky;				// measure sky brightness
-    float seeing;			// measured image quality 
-    float dettemp;			// temperature of detector
-} ppRawExposure;
-
-// this structure should be defined using the mddb api tools
-typedef struct {
-    char expID[32];			// free-form exposure ID string
-    char class;				// class of file: fpa (0), chip (1), cell (2), readout (3)?
-    char classID[32];			// identifier for class (chip00, cell00, etc)
-    char url[128];			// locator for file (neb / file)
-    char state;				// current load state
-} ppRawImfile;
-
-// this structure should be defined using the mddb api tools
-typedef struct {
-    char expID[32];			// free-form exposure ID string
-    psU8 P2version;
-    char class;				// class of file: fpa (0), chip (1), cell (2), readout (3)?
-    int Nclass;				// number of files of this class
-    psU8 P1version;
-} p2PendingExposure;
-
-// this structure should be defined using the mddb api tools
-typedef struct {
-    char expID[32];			// free-form exposure ID string
-    char P2version;
-    char class;				// class of file: fpa (0), chip (1), cell (2), readout (3)?
-    char classID[32];			// identifier for class (chip00, cell00, etc)
-    char urlroot[128];			// locator for file (neb / file)
-    char input[16];			// extension for input image
-    char output[16];			// extension for output image
-    char log[16];			// extension for log file
-    char smf[16];			// extension for object table
-} p2PendingImfile;
-
-// this structure should be defined using the mddb api tools
-typedef struct {
-    char expID[32];			// free-form exposure ID string
-    char class;				// class of file: fpa (0), chip (1), cell (2), readout (3)?
-    int Nclass;				// number of files of this class
-    int Ndone;				// number of files of this class
-    char P1version;
-    char P2version;
-    char state;
-} p2DoneExposure;
-
-// this structure should be defined using the mddb api tools
-typedef struct {
-    char expID[32];			// free-form exposure ID string
-    char P2version;
-    char class;				// class of file: fpa (0), chip (1), cell (2), readout (3)?
-    char classID[32];			// identifier for class (chip00, cell00, etc)
-    char urlroot[128];			// locator for file (neb / file)
-    char input[16];			// extension for input image
-    char output[16];			// extension for output image
-    char log[16];			// extension for log file
-    char smf[16];			// extension for object table
-    char state;				// current P2 state
-} p2DoneImfile;
+    psMetadata *site;
+    psMetadata *recipe;
+    psMetadata *arguments;
+} p2Config;
 
 typedef struct {
-    ppRawExposure *exposure;
+    rawScienceExpRow *exposure;
     psArray *images;
 } ppRawFrame;
 
+ppRawFrame *ppRawFrameAlloc(
+    rawScienceExpRow *exposure,
+    psArray *images
+);
+
 typedef struct {
-    ppPendingExposure *exposure;
+    p2PendingExpRow *exposure;
     psArray *images;
 } p2PendingFrame;
 
+p2PendingFrame *p2PendingFrameAlloc(
+    p2PendingExpRow *exposure,
+    psArray *images
+);
+
 typedef struct {
-    ppDoneExposure *exposure;
+    p2DoneExpRow *exposure;
     psArray *images;
 } p2DoneFrame;
 
+p2DoneFrame *p2DoneFrameAlloc(
+    p2DoneExpRow *exposure,
+    psArray *images
+);
+
+bool p2createTables (p2Config *config);
+bool p2deleteTables (p2Config *config);
+bool p2adminConfig (p2Config *config, int argc, char **argv);
+bool p2searchConfig (p2Config *config, int argc, char **argv);
+psArray *p2rawToPending (p2Config *config, psArray *rawFrames);
+psArray *p2searchRawFrames (p2Config *config);
+bool p2insertPendingFrames (p2Config *config, psArray *rawFrames);
+psArray *p2searchPendingFrames (p2Config *config);
+bool p2writePendingImages (p2Config *config, psArray *frames);
+bool p2updatePendingFrames (p2Config *config, psArray *pendingFrames);
+psArray *p2pendingToDone (p2Config *config, psArray *pendingFrames);
+bool p2insertDoneFrames (p2Config *config, psArray *doneFrames);
+bool psTimeIsZero(psTime *time);
+bool p2writePendingFrames (p2Config *config, psArray *frames);
