Changeset 6060
- Timestamp:
- Jan 19, 2006, 4:16:26 PM (21 years ago)
- Location:
- trunk/ippTools/src
- Files:
-
- 1 added
- 13 edited
-
chiptool.c (modified) (1 diff)
-
chiptool.h (modified) (2 diffs)
-
chiptoolConfig.c (modified) (3 diffs)
-
p2insertDoneFrames.c (modified) (1 diff)
-
p2insertPendingFrames.c (modified) (3 diffs)
-
p2pendingToDone.c (modified) (1 diff)
-
p2rawToPending.c (modified) (2 diffs)
-
p2searchPendingFrames.c (modified) (3 diffs)
-
p2searchRawFrames.c (modified) (3 diffs)
-
p2updatePending.c (modified) (2 diffs)
-
p2writePendingFrames.c (modified) (2 diffs)
-
pxadmin.c (modified) (1 diff)
-
pxadminConfig.c (modified) (3 diffs)
-
pxalloc.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/chiptool.c
r5881 r6060 3 3 int main (int argc, char **argv) { 4 4 5 psArray *rawFrames; 6 psArray *doneFrames; 7 psArray *pendingFrames; 5 psArray *rawFrames = NULL; 6 psArray *doneFrames = NULL; 7 psArray *pendingFrames = NULL; 8 9 p2Config config; 8 10 9 11 p2searchConfig (&config, argc, argv); 10 12 11 if (config ->mode == P2_MODE_QUICK) {12 rawFrames = p2searchRawFrames (config);13 pendingFrames = p2rawToPending (config, rawFrames);14 p2writePendingFrames (config, pendingFrames);13 if (config.mode == P2_MODE_QUICK) { 14 rawFrames = p2searchRawFrames (&config); 15 pendingFrames = p2rawToPending (&config, rawFrames); 16 p2writePendingFrames (&config, pendingFrames); 15 17 } 16 18 17 if (config ->mode == P2_MODE_DEFINE) {18 rawFrames = p2searchRawFrames (config);19 p2insertPendingFrames (config, rawFrames);19 if (config.mode == P2_MODE_DEFINE) { 20 rawFrames = p2searchRawFrames (&config); 21 p2insertPendingFrames (&config, rawFrames); 20 22 } 21 23 22 if (config ->mode == P2_MODE_PENDING) {23 pendingFrames = p2searchPendingFrames (config, FALSE);24 p2writePendingImages (config, pendingFrames);24 if (config.mode == P2_MODE_PENDING) { 25 pendingFrames = p2searchPendingFrames (&config); 26 p2writePendingFrames (&config, pendingFrames); 25 27 } 26 28 27 if (config ->mode == P2_MODE_UPDATE) {28 p2updatePendingFrames (config, pendingFrames);29 if (config.mode == P2_MODE_UPDATE) { 30 p2updatePendingFrames (&config, pendingFrames); 29 31 } 30 32 31 if (config ->mode == P2_MODE_DONE) {32 pendingFrames = p2searchPendingFrames (config, TRUE);33 doneFrames = p2pendingToDone (config);34 p2insertDoneFrames (config, doneFrames);33 if (config.mode == P2_MODE_DONE) { 34 pendingFrames = p2searchPendingFrames (&config); 35 doneFrames = p2pendingToDone (&config, pendingFrames); 36 p2insertDoneFrames (&config, doneFrames); 35 37 } 36 38 -
trunk/ippTools/src/chiptool.h
r6032 r6060 7 7 # include <pmPSFtry.h> 8 8 # include <pmModelGroup.h> 9 # include <metadatadb.h> 9 10 10 11 // load these values from the db in the init stage 11 12 # define P2_TYPE_OBJECT 1 12 13 # define P2_STATE_READY 2 14 # define RECIPE "foo" 15 # define MAX_ROWS 10e9 13 16 14 17 typedef enum { … … 25 28 typedef struct { 26 29 p2mode mode; 27 psTime start;28 psTime stop;30 psTime *start; 31 psTime *stop; 29 32 psSphere r1; 30 33 psSphere r2; 31 char *camera; 34 psMetadata *camera; 35 char *camera_name; 32 36 char *filter; 33 37 psDB *database; 34 } p2config; 35 36 // this structure should be defined using the mddb api tools 37 typedef struct { 38 char expID[32]; // free-form exposure ID string 39 char class; // class of file: fpa (0), chip (1), cell (2), readout (3)? 40 int Nclass; // number of files of this class 41 char camera[32]; // free-form camera ID string 42 char filter[32]; // free-form filter ID string 43 psTime time_start; // exposure start time 44 psTime time_stop; // exposure stop time 45 psTime exptime; // exposure duration (seconds) 46 char exptype; // type of exposure: object (0), bias (1), dark (2), flat (3), etc 47 float sky; // measure sky brightness 48 float seeing; // measured image quality 49 float dettemp; // temperature of detector 50 } ppRawExposure; 51 52 // this structure should be defined using the mddb api tools 53 typedef struct { 54 char expID[32]; // free-form exposure ID string 55 char class; // class of file: fpa (0), chip (1), cell (2), readout (3)? 56 char classID[32]; // identifier for class (chip00, cell00, etc) 57 char url[128]; // locator for file (neb / file) 58 char state; // current load state 59 } ppRawImfile; 60 61 // this structure should be defined using the mddb api tools 62 typedef struct { 63 char expID[32]; // free-form exposure ID string 64 psU8 P2version; 65 char class; // class of file: fpa (0), chip (1), cell (2), readout (3)? 66 int Nclass; // number of files of this class 67 psU8 P1version; 68 } p2PendingExposure; 69 70 // this structure should be defined using the mddb api tools 71 typedef struct { 72 char expID[32]; // free-form exposure ID string 73 char P2version; 74 char class; // class of file: fpa (0), chip (1), cell (2), readout (3)? 75 char classID[32]; // identifier for class (chip00, cell00, etc) 76 char urlroot[128]; // locator for file (neb / file) 77 char input[16]; // extension for input image 78 char output[16]; // extension for output image 79 char log[16]; // extension for log file 80 char smf[16]; // extension for object table 81 } p2PendingImfile; 82 83 // this structure should be defined using the mddb api tools 84 typedef struct { 85 char expID[32]; // free-form exposure ID string 86 char class; // class of file: fpa (0), chip (1), cell (2), readout (3)? 87 int Nclass; // number of files of this class 88 int Ndone; // number of files of this class 89 char P1version; 90 char P2version; 91 char state; 92 } p2DoneExposure; 93 94 // this structure should be defined using the mddb api tools 95 typedef struct { 96 char expID[32]; // free-form exposure ID string 97 char P2version; 98 char class; // class of file: fpa (0), chip (1), cell (2), readout (3)? 99 char classID[32]; // identifier for class (chip00, cell00, etc) 100 char urlroot[128]; // locator for file (neb / file) 101 char input[16]; // extension for input image 102 char output[16]; // extension for output image 103 char log[16]; // extension for log file 104 char smf[16]; // extension for object table 105 char state; // current P2 state 106 } p2DoneImfile; 38 psMetadata *site; 39 psMetadata *recipe; 40 psMetadata *arguments; 41 } p2Config; 107 42 108 43 typedef struct { 109 ppRawExposure*exposure;44 rawScienceExpRow *exposure; 110 45 psArray *images; 111 46 } ppRawFrame; 112 47 48 ppRawFrame *ppRawFrameAlloc( 49 rawScienceExpRow *exposure, 50 psArray *images 51 ); 52 113 53 typedef struct { 114 p pPendingExposure*exposure;54 p2PendingExpRow *exposure; 115 55 psArray *images; 116 56 } p2PendingFrame; 117 57 58 p2PendingFrame *p2PendingFrameAlloc( 59 p2PendingExpRow *exposure, 60 psArray *images 61 ); 62 118 63 typedef struct { 119 p pDoneExposure*exposure;64 p2DoneExpRow *exposure; 120 65 psArray *images; 121 66 } p2DoneFrame; 122 67 68 p2DoneFrame *p2DoneFrameAlloc( 69 p2DoneExpRow *exposure, 70 psArray *images 71 ); 72 73 bool p2createTables (p2Config *config); 74 bool p2deleteTables (p2Config *config); 75 bool p2adminConfig (p2Config *config, int argc, char **argv); 76 bool p2searchConfig (p2Config *config, int argc, char **argv); 77 psArray *p2rawToPending (p2Config *config, psArray *rawFrames); 78 psArray *p2searchRawFrames (p2Config *config); 79 bool p2insertPendingFrames (p2Config *config, psArray *rawFrames); 80 psArray *p2searchPendingFrames (p2Config *config); 81 bool p2writePendingImages (p2Config *config, psArray *frames); 82 bool p2updatePendingFrames (p2Config *config, psArray *pendingFrames); 83 psArray *p2pendingToDone (p2Config *config, psArray *pendingFrames); 84 bool p2insertDoneFrames (p2Config *config, psArray *doneFrames); 85 bool psTimeIsZero(psTime *time); 86 bool p2writePendingFrames (p2Config *config, psArray *frames); -
trunk/ippTools/src/chiptoolConfig.c
r5881 r6060 1 #include <pmConfig.h> 2 1 3 # include "p2search.h" 2 4 3 bool p2searchConfig (p sConfig *config, int argc, char **argv) {5 bool p2searchConfig (p2Config *config, int argc, char **argv) { 4 6 5 7 // Parse the configurations (re-org a la ppImage) … … 15 17 config->arguments = psMetadataAlloc(); // The arguments, with default values 16 18 19 int N; 17 20 config->mode = P2_MODE_NONE; 18 if ((N = psArgumentGet ( *argc, argv, "-quick"))) {19 psArgumentRemove (N,argc, argv);20 if (config->mode) psAbort ("p2search", "only one mode selection is allowed");21 config->mode = P2_MODE_QUICK;21 if ((N = psArgumentGet (argc, argv, "-quick"))) { 22 psArgumentRemove (N, &argc, argv); 23 if (config->mode) psAbort ("p2search", "only one mode selection is allowed"); 24 config->mode = P2_MODE_QUICK; 22 25 } 23 if ((N = psArgumentGet ( *argc, argv, "-define"))) {24 psArgumentRemove (N,argc, argv);25 if (config->mode) psAbort ("p2search", "only one mode selection is allowed");26 config->mode = P2_MODE_DEFINE;26 if ((N = psArgumentGet (argc, argv, "-define"))) { 27 psArgumentRemove (N, &argc, argv); 28 if (config->mode) psAbort ("p2search", "only one mode selection is allowed"); 29 config->mode = P2_MODE_DEFINE; 27 30 } 28 if ((N = psArgumentGet ( *argc, argv, "-pending"))) {29 psArgumentRemove (N,argc, argv);30 if (config->mode) psAbort ("p2search", "only one mode selection is allowed");31 config->mode = P2_MODE_PENDING;31 if ((N = psArgumentGet (argc, argv, "-pending"))) { 32 psArgumentRemove (N, &argc, argv); 33 if (config->mode) psAbort ("p2search", "only one mode selection is allowed"); 34 config->mode = P2_MODE_PENDING; 32 35 } 33 if ((N = psArgumentGet ( *argc, argv, "-update"))) {34 psArgumentRemove (N,argc, argv);35 if (config->mode) psAbort ("p2search", "only one mode selection is allowed");36 config->mode = P2_MODE_UPDATE;36 if ((N = psArgumentGet (argc, argv, "-update"))) { 37 psArgumentRemove (N, &argc, argv); 38 if (config->mode) psAbort ("p2search", "only one mode selection is allowed"); 39 config->mode = P2_MODE_UPDATE; 37 40 } 38 if ((N = psArgumentGet ( *argc, argv, "-done"))) {39 psArgumentRemove (N,argc, argv);40 if (config->mode) psAbort ("p2search", "only one mode selection is allowed");41 config->mode = P2_MODE_UPDATE;41 if ((N = psArgumentGet (argc, argv, "-done"))) { 42 psArgumentRemove (N, &argc, argv); 43 if (config->mode) psAbort ("p2search", "only one mode selection is allowed"); 44 config->mode = P2_MODE_UPDATE; 42 45 } 43 46 … … 47 50 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "-pending", 0, "examine pending image table, write ppImage output", ""); 48 51 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "-update", 0, "update pending image table", ""); 49 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "-time", 0, "define time range of interest", "");50 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "-camera", 0, "define camera of interest", "");51 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "-filter", 0, "define filter of interest", "");52 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "-time", 0, "define time range of interest", 0); 53 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "-camera", 0, "define camera of interest", 0); 54 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "-filter", 0, "define filter of interest", 0); 52 55 53 56 if (! psArgumentParse(config->arguments, &argc, argv) || argc != 2) { -
trunk/ippTools/src/p2insertDoneFrames.c
r5881 r6060 1 # include <metadatadb.h> 1 2 # include "p2search.h" 2 3 3 4 // select pending frames (exposure+images) which are done/not done 4 bool p2insertDoneFrames (p2 SearchConfig *config, psArray *doneFrames) {5 bool p2insertDoneFrames (p2Config *config, psArray *doneFrames) { 5 6 6 7 for (int i = 0; i < doneFrames->n; i++) { 7 p2DoneFrame *doneFrame = doneFrames->data[i]; 8 p2DoneExposure *doneExposure = doneFrame->exposure; 9 10 psArray *doneImages = doneFrame->images; 11 12 p2DoneExposureInsertOneRow (config->database, doneExposure); 13 p2DoneImageInsertRows (config->database, doneImages); 8 p2DoneFrame *doneFrame = doneFrames->data[i]; 9 p2DoneExpRow *doneExposure = doneFrame->exposure; 10 11 psArray *doneImages = doneFrame->images; 12 13 p2DoneExpInsertObject(config->database, doneExposure); 14 15 for (int i = 0; i < doneImages->n; i++) { 16 p2DoneImfileInsertObject(config->database, doneImages->data[i]); 17 } 14 18 } 15 19 return true; -
trunk/ippTools/src/p2insertPendingFrames.c
r6032 r6060 1 #include <metadatadb.h> 1 2 # include "p2search.h" 2 3 … … 4 5 // NOTE this function converts the rawFrames to pendingFrames AND inserts them 5 6 // this is useful since the table must be locked the whole time, to get the versions 6 bool p2insertPendingFrames (p2 SearchConfig *config, psArray *rawFrames) {7 bool p2insertPendingFrames (p2Config *config, psArray *rawFrames) { 7 8 8 9 psMetadata *where = psMetadataAlloc (); … … 12 13 13 14 // find the next available version numbers 14 psMetadataAddStr (where, PS_LIST_TAIL, "EXP_ID", PS_META_REPLACE, "==", rawFrame->exposure->exp ID);15 psArray *exposures = p2PendingExp osureSelectRows(config->database, where, MAX_ROWS);15 psMetadataAddStr (where, PS_LIST_TAIL, "EXP_ID", PS_META_REPLACE, "==", rawFrame->exposure->exp_id); 16 psArray *exposures = p2PendingExpSelectRowObjects(config->database, where, MAX_ROWS); 16 17 int version = -1; 17 18 for (int j = 0; j < exposures->n; j++) { 18 p2PendingExp osure*exposure = exposures->data[j];19 version = PS_MAX (version, exposure-> P2version);19 p2PendingExpRow *exposure = exposures->data[j]; 20 version = PS_MAX (version, exposure->p2_version); 20 21 } 21 22 version ++; 22 23 23 p2PendingExposureRow *pendingExposure = p2PendingExposureAlloc (); 24 strcpy (pendingExposure->expID, rawFrame->exposure->expID); 25 pendingExposure->class = rawFrame->exposure->class; 26 pendingExposure->Nclass = rawFrame->exposure->Nclass; 27 pendingExposure->Ndone = 0; 28 pendingExposure->P1version = 0xff; 29 pendingExposure->P2version = version; 30 pendingExposure->state = P2_STATE_PENDING; 24 p2PendingExpRow *pendingExposure = p2PendingExpRowAlloc( 25 rawFrame->exposure->exp_id, 26 rawFrame->exposure->class, 27 rawFrame->exposure->nclass, 28 0xff, 29 version 30 // pendingExposure->Ndone = 0; 31 // pendingExposure->state = P2_STATE_PENDING; 32 ); 31 33 32 34 psArray *pendingImages = psArrayAlloc (rawFrame->images->n); 33 35 pendingImages->n = 0; 34 36 for (int j = 0; j < rawFrame->images->n; j++) { 35 ppRawImage *rawImage = rawFrame->images->data[j]; 36 p2PendingImage *pendingImage = p2PendingImageAlloc (); 37 38 strcpy (pendingImage->expID, rawImage->expID); 39 pendingImage->P2version = version; 40 pendingImage->class = rawImage->class; 41 strcpy (pendingImage->classID, rawImage->classID); 42 43 // XXX cleanup the url somehow 44 strcpy (pendingImage->urlroot = rawImage->url); 45 strcpy (pendingImage->input, "raw.fits"); 46 strcpy (pendingImage->output, "flt.fits"); 47 strcpy (pendingImage->log, "log"); 48 strcpy (pendingImage->smf, "smf"); 49 pendingImage->state = P2_STATE_PENDING; 37 rawImfileRow *rawImage = rawFrame->images->data[j]; 38 p2PendingImfileRow *pendingImage = p2PendingImfileRowAlloc( 39 rawImage->exp_id, 40 rawImage->class, 41 rawImage->class_id, 42 version, // p1 43 version, // p2 44 "", 45 "", 46 // XXX cleanup the url somehow 47 rawImage->url 48 ); 50 49 51 50 psArrayAdd (pendingImages, 100, pendingImage); 52 51 } 53 52 54 p2PendingExposureInsertObject (config->database, pendingExposure); 55 p2PendingImageInsertObjects (config->database, pendingImages); 53 p2PendingExpInsertObject (config->database, pendingExposure); 54 55 for (int i = 0; i < pendingImages->n; i++) { 56 p2PendingImfileInsertObject(config->database, pendingImages->data[i]); 57 } 58 56 59 } 57 60 return true; -
trunk/ippTools/src/p2pendingToDone.c
r5881 r6060 2 2 3 3 // select pending frames (exposure+images) which are done/not done 4 psArray *p2pendingToDone (p2 SearchConfig *config, psArray *pendingFrames) {4 psArray *p2pendingToDone (p2Config *config, psArray *pendingFrames) { 5 5 6 psArray *doneFrames = psArrayAlloc (frames->n);6 psArray *doneFrames = psArrayAlloc(pendingFrames->n); 7 7 doneFrames->n = 0; 8 8 9 9 for (int i = 0; i < pendingFrames->n; i++) { 10 ppPendingFrame *pendingFrame = pendingFrames->data[i];11 if (pendingFrame->exposure->state != P2_STATE_DONE) continue;10 p2PendingFrame *pendingFrame = pendingFrames->data[i]; 11 // if (pendingFrame->exposure->state != P2_STATE_DONE) continue; 12 12 13 p2DoneExposure *doneExposure = p2DoneExposureAlloc (); 14 strcpy (doneExposure->expID, pendingFrame->exposure->expID); 15 doneExposure->class = pendingFrame->exposure->class; 16 doneExposure->Nclass = pendingFrame->exposure->Nclass; 17 doneExposure->Ndone = pendingFrame->exposure->Nclass; 18 doneExposure->P1version = pendingFrame->exposure->P1version; 19 doneExposure->P2version = pendingFrame->exposure->P2version; 20 doneExposure->state = P2_STATE_DONE; 13 p2DoneExpRow *doneExposure = p2DoneExpRowAlloc( 14 pendingFrame->exposure->exp_id, 15 pendingFrame->exposure->class, 16 pendingFrame->exposure->nclass, 17 pendingFrame->exposure->nclass, // XXX ndone is uneeded? 18 pendingFrame->exposure->p1_version, 19 pendingFrame->exposure->p2_version 20 //doneExposure->state = P2_STATE_DONE; 21 ); 21 22 22 23 psArray *doneImages = psArrayAlloc (pendingFrame->images->n); 23 24 doneImages->n = 0; 24 25 for (int j = 0; j < pendingFrame->images->n; j++) { 25 ppPendingImage *pendingImage = pendingFrame->images->data[j]; 26 p2PendingImfileRow *pendingImage = pendingFrame->images->data[j]; 27 28 /* 26 29 if (pendingImage->state != P2_STATE_DONE) { 27 30 psAbort ("p2search", "programming error!"); 28 31 } 32 */ 29 33 30 p2DoneImage *doneImage = p2DoneImageAlloc (); 34 p2DoneImfileRow *doneImage = p2DoneImfileRowAlloc( 35 pendingImage->exp_id, 36 pendingImage->class, 37 pendingImage->class_id, 38 pendingImage->p1_version, 39 pendingImage->p2_version, 40 "", // recipe 41 "", // stats 42 pendingImage->url 43 ); 31 44 32 strcpy (doneImage->expID, pendingImage->expID);33 doneImage->P2version = pendingImage->P2version;34 doneImage->class = pendingImage->class;35 strcpy (doneImage->classID, pendingImage->classID);36 strcpy (doneImage->urlroot, pendingImage->urlroot);37 strcpy (doneImage->input, pendingImage->input);38 strcpy (doneImage->output, pendingImage->output);39 strcpy (doneImage->log, pendingImage->log);40 strcpy (doneImage->smf, pendingImage->smf);41 doneImage->state = P2_STATE_DONE;42 45 psArrayAdd (doneImages, 100, doneImage); 43 46 } 44 47 45 p2DoneFrame *doneFrame = p2DoneFrameAlloc (doneExposure, doneImages); 48 // XXX FIXME 49 p2DoneFrame *doneFrame = p2DoneFrameAlloc(doneExposure, doneImages); 50 46 51 psArrayAdd (doneFrames, 100, doneFrame); 47 52 } -
trunk/ippTools/src/p2rawToPending.c
r5881 r6060 2 2 3 3 // select pending frames (exposure+images) which are done/not done 4 psArray *p2rawToPending (p2 SearchConfig *config, psArray *rawFrames) {4 psArray *p2rawToPending (p2Config *config, psArray *rawFrames) { 5 5 6 psArray *pendingFrames = psArrayAlloc ( frames->n);6 psArray *pendingFrames = psArrayAlloc (rawFrames->n); 7 7 pendingFrames->n = 0; 8 8 … … 10 10 ppRawFrame *rawFrame = rawFrames->data[i]; 11 11 12 p2PendingExposure *pendingExposure = p2PendingExposureAlloc (); 13 strcpy (pendingExposure->expID, rawFrame->exposure->expID); 14 pendingExposure->class = rawFrame->exposure->class; 15 pendingExposure->Nclass = rawFrame->exposure->Nclass; 16 pendingExposure->Ndone = 0; 17 pendingExposure->P1version = 0xff; 18 pendingExposure->P2version = 0xff; 19 pendingExposure->state = P2_STATE_PENDING; 12 p2PendingExpRow *pendingExposure = p2PendingExpRowAlloc( 13 rawFrame->exposure->exp_id, 14 rawFrame->exposure->class, 15 rawFrame->exposure->nclass, 16 0xff, // p1 17 0xff // p2 18 ); 20 19 21 20 psArray *pendingImages = psArrayAlloc (rawFrame->images->n); 22 21 pendingImages->n = 0; 23 22 for (int j = 0; j < rawFrame->images->n; j++) { 24 ppRawImage *rawImage = rawFrame->images->data[j]; 25 p2PendingImage *pendingImage = p2PendingImageAlloc (); 26 27 strcpy (pendingImage->expID, rawImage->expID); 28 pendingImage->P2version = 0xff; 29 pendingImage->class = rawImage->; 30 strcpy (pendingImage->classID, rawImage->classID); 31 32 pendingImage->urlroot = rawImage->; 33 strcpy (pendingImage->input, "raw.fits"); 34 strcpy (pendingImage->output, "flt.fits"); 35 strcpy (pendingImage->log, "log"); 36 strcpy (pendingImage->smf, "smf"); 37 pendingImage->state = P2_STATE_PENDING; 23 rawImfileRow *rawImage = rawFrame->images->data[j]; 24 p2PendingImfileRow *pendingImage = p2PendingImfileRowAlloc( 25 rawImage->exp_id, 26 rawImage->class, 27 rawImage->class_id, 28 0xff, // p1 29 0xff, // p2 30 "", // recipe 31 "", // stats 32 rawImage->url 33 ); 38 34 39 35 psArrayAdd (pendingImages, 100, pendingImage); -
trunk/ippTools/src/p2searchPendingFrames.c
r6032 r6060 1 1 # include "p2search.h" 2 2 3 bool psTimeIsZero(psTime *time) { 4 if (time->sec == 0 || time->nsec == 0) { 5 return false; 6 } 7 8 return true; 9 } 10 3 11 // select pending frames (exposure+images) which are done/not done 4 psArray *p2searchPendingFrames (p2 SearchConfig *config) {12 psArray *p2searchPendingFrames (p2Config *config) { 5 13 6 14 // build 'where' structure … … 9 17 // in order to include these restrictions, we need to define these table columns 10 18 if (config->camera != NULL) { 11 psMetadataAddStr (where, PS_LIST_TAIL, "CAMERA", 0, "==", config->camera);19 psMetadataAddStr (where, PS_LIST_TAIL, "CAMERA", 0, "==", config->camera_name); 12 20 } 13 21 if (config->filter != NULL) { 14 psMetadataAddStr (where, PS_LIST_TAIL, "FILTER", 0, "==", config->filter);22 psMetadataAddStr (where, PS_LIST_TAIL, "FILTER", 0, "==", config->filter); 15 23 } 16 24 if (!psTimeIsZero(config->start) && !psTimeIsZero(config->stop)) { 17 psMetadataAddTime (where, PS_LIST_TAIL, "TIME_START", 0, "<", config->time_stop);18 psMetadataAddTime (where, PS_LIST_TAIL, "TIME_STOP", 0, ">", config->time_start);25 psMetadataAddTime (where, PS_LIST_TAIL, "TIME_START", 0, "<", config->stop); 26 psMetadataAddTime (where, PS_LIST_TAIL, "TIME_STOP", 0, ">", config->start); 19 27 } 20 28 21 psArray *exposures = p2PendingExp osureSelectRows (config->database, where, MAX_ROWS);29 psArray *exposures = p2PendingExpSelectRowObjects (config->database, where, MAX_ROWS); 22 30 psFree (where); 23 31 … … 26 34 27 35 // 'where' to select each exposure 28 psMetadata *where = psMetadataAlloc ();36 where = psMetadataAlloc (); 29 37 for (int i = 0; i < exposures->n; i++) { 30 p2PendingExp osure*exposure = exposures->data[i];38 p2PendingExpRow *exposure = exposures->data[i]; 31 39 32 psMetadataAddStr (where, PS_LIST_TAIL, "EXP_ID", PS_META_REPLACE, "==", exposure->exp ID);33 psMetadataAddS tr (where, PS_LIST_TAIL, "P2_VERSION", PS_META_REPLACE, "==", exposure->P2version);40 psMetadataAddStr (where, PS_LIST_TAIL, "EXP_ID", PS_META_REPLACE, "==", exposure->exp_id); 41 psMetadataAddS32 (where, PS_LIST_TAIL, "P2_VERSION", PS_META_REPLACE, "==", exposure->p2_version); 34 42 35 psArray *images = p pPendingImageSelectRows (config->database, where, MAX_ROWS);43 psArray *images = p2PendingImfileSelectRowObjects (config->database, where, MAX_ROWS); 36 44 37 p pPendingFrame *frame = ppPendingFrameAlloc (exposure, images);45 p2PendingFrame *frame = p2PendingFrameAlloc (exposure, images); 38 46 39 47 psArrayAdd (frames, 100, frame); -
trunk/ippTools/src/p2searchRawFrames.c
r6032 r6060 2 2 3 3 // select raw frames (exposure+images) which match the given config options 4 psArray p2searchRawImages (p2SearchConfig *config) {4 psArray *p2searchRawFrames (p2Config *config) { 5 5 6 6 // build 'where' structure 7 7 psMetadata *where = psMetadataAlloc (); 8 8 9 psMetadataAdd U8(where, PS_LIST_TAIL, "TYPE", 0, "==", P2_TYPE_OBJECT);9 psMetadataAddS32 (where, PS_LIST_TAIL, "TYPE", 0, "==", P2_TYPE_OBJECT); 10 10 11 11 if (config->camera != NULL) { 12 psMetadataAddStr (where, PS_LIST_TAIL, "CAMERA", 0, "==", config->camera );12 psMetadataAddStr (where, PS_LIST_TAIL, "CAMERA", 0, "==", config->camera_name); 13 13 } 14 14 if (config->filter != NULL) { … … 16 16 } 17 17 if (!psTimeIsZero(config->start) && !psTimeIsZero(config->stop)) { 18 psMetadataAddTime (where, PS_LIST_TAIL, "TIME_START", 0, "<", config-> time_stop);19 psMetadataAddTime (where, PS_LIST_TAIL, "TIME_STOP", 0, ">", config-> time_start);18 psMetadataAddTime (where, PS_LIST_TAIL, "TIME_START", 0, "<", config->stop); 19 psMetadataAddTime (where, PS_LIST_TAIL, "TIME_STOP", 0, ">", config->start); 20 20 } 21 21 22 psArray *exposures = ppRawExposureSelectRows (config->database, where, MAX_ROWS);22 psArray *exposures = rawScienceExpSelectRowObjects (config->database, where, MAX_ROWS); 23 23 psFree (where); 24 24 … … 27 27 28 28 // 'where' to select each exposure 29 psMetadata *where = psMetadataAlloc ();29 where = psMetadataAlloc (); 30 30 for (int i = 0; i < exposures->n; i++) { 31 ppRawExposure*exposure = exposures->data[i];31 rawScienceExpRow *exposure = exposures->data[i]; 32 32 33 psMetadataAddStr (where, PS_LIST_TAIL, "EXP_ID", PS_META_REPLACE, "==", exposure->exp ID);33 psMetadataAddStr (where, PS_LIST_TAIL, "EXP_ID", PS_META_REPLACE, "==", exposure->exp_id); 34 34 35 psArray *images = ppRawImageSelectRows (config->database, where, MAX_ROWS);35 psArray *images = rawImfileSelectRowObjects (config->database, where, MAX_ROWS); 36 36 37 37 ppRawFrame *frame = ppRawFrameAlloc (exposure, images); -
trunk/ippTools/src/p2updatePending.c
r5881 r6060 2 2 3 3 // select pending frames (exposure+images) which are not done, select their done images, count, update 4 bool p2updatePendingFrames (p2 SearchConfig *config, psArray *pendingFrames) {4 bool p2updatePendingFrames (p2Config *config, psArray *pendingFrames) { 5 5 6 6 psMetadata *where = psMetadataAlloc (); 7 7 8 8 // select all of the exposures which are still pending 9 psMetadataAddS tr (where, PS_LIST_TAIL, "STATE", 0, "==", P2_STATE_PENDING);10 psArray *exposures = p2PendingExp osureSelectRows (config->database, where, MAX_ROWS);9 psMetadataAddS32 (where, PS_LIST_TAIL, "STATE", 0, "==", P2_MODE_PENDING); 10 psArray *exposures = p2PendingExpSelectRowObjects (config->database, where, MAX_ROWS); 11 11 12 12 // we will now select all of the matching images which are done 13 psMetadataAddS tr (where, PS_LIST_TAIL, "STATE", PS_META_REPLACE, "==", P2_STATE_DONE);13 psMetadataAddS32 (where, PS_LIST_TAIL, "STATE", PS_META_REPLACE, "==", P2_MODE_DONE); 14 14 for (int i = 0; i < exposures->n; i++) { 15 p2PendingExp osure*exposure = exposures->data[i];15 p2PendingExpRow *exposure = exposures->data[i]; 16 16 17 17 // find the next available version numbers 18 psMetadataAddStr (where, PS_LIST_TAIL, "EXP_ID", PS_META_REPLACE, "==", exposure->exp ID);19 psMetadataAddS tr (where, PS_LIST_TAIL, "P2_VERSION", PS_META_REPLACE, "==", exposure->P2version);20 psArray *images = p2PendingIm ageSelectRows (config->database, where, MAX_ROWS);21 if (images->n != exposure-> Nclass) {18 psMetadataAddStr (where, PS_LIST_TAIL, "EXP_ID", PS_META_REPLACE, "==", exposure->exp_id); 19 psMetadataAddS32 (where, PS_LIST_TAIL, "P2_VERSION", PS_META_REPLACE, "==", exposure->p2_version); 20 psArray *images = p2PendingImfileSelectRowObjects (config->database, where, MAX_ROWS); 21 if (images->n != exposure->nclass) { 22 22 // free things 23 23 continue; … … 25 25 // frame is complete, set exposure state to done 26 26 // XXX add P2 stats here? 27 exposure->state = P2_STATE_DONE;28 p2PendingExposureUpdateRows (config->database, exposure);27 // exposure->state = P2_MODE_DONE; 28 // p2PendingExposureUpdateRows (config->database, exposure); 29 29 } 30 30 return true; -
trunk/ippTools/src/p2writePendingFrames.c
r5881 r6060 2 2 3 3 // select pending frames (exposure+images) which are done/not done 4 bool p2writePending Images (p2SearchConfig *config, psArray *frames) {4 bool p2writePendingFrames (p2Config *config, psArray *frames) { 5 5 6 6 for (int i = 0; i < frames->n; i++) { … … 8 8 9 9 for (int j = 0; j < frame->images->n; j++) { 10 p2PendingIm age*image = frame->images->data[j];11 fprintf (stdout, "%s % c %c %s %s %s %s %s %s %c\n",12 image->exp ID,13 image-> P2version,10 p2PendingImfileRow *image = frame->images->data[j]; 11 fprintf (stdout, "%s %d %s %s %s\n", 12 image->exp_id, 13 image->p2_version, 14 14 image->class, 15 image->classID, 16 image->urlroot, 17 image->input, 18 image->output, 19 image->log, 20 image->smf, 21 image->state); 15 image->class_id, 16 image->url); 22 17 } 23 18 } -
trunk/ippTools/src/pxadmin.c
r5881 r6060 1 # include <metadatadb.h> 2 1 3 # include "p2search.h" 2 4 3 5 int main (int argc, char **argv) { 6 p2Config config; 4 7 5 8 p2adminConfig (&config, argc, argv); 6 9 7 if (config ->mode == P2_MODE_CREATE) {8 p2deleteTables (config);10 if (config.mode == P2_MODE_CREATE) { 11 p2deleteTables (&config); 9 12 } 10 13 11 if (config ->mode == P2_MODE_DELETE) {12 p2createTables (config);14 if (config.mode == P2_MODE_DELETE) { 15 p2createTables (&config); 13 16 } 14 17 -
trunk/ippTools/src/pxadminConfig.c
r5881 r6060 1 # include <pmConfig.h> 1 2 # include "p2search.h" 2 3 3 bool p2adminConfig (p sConfig *config, int argc, char **argv) {4 bool p2adminConfig (p2Config *config, int argc, char **argv) { 4 5 5 6 // Parse the configurations (re-org a la ppImage) … … 15 16 config->arguments = psMetadataAlloc(); // The arguments, with default values 16 17 18 int N; 17 19 config->mode = P2_MODE_NONE; 18 if ((N = psArgumentGet ( *argc, argv, "-create"))) {19 psArgumentRemove (N, argc, argv);20 if ((N = psArgumentGet (argc, argv, "-create"))) { 21 psArgumentRemove (N, &argc, argv); 20 22 if (config->mode) psAbort ("p2search", "only one mode selection is allowed"); 21 23 config->mode = P2_MODE_CREATE; 22 24 } 23 if ((N = psArgumentGet ( *argc, argv, "-delete"))) {24 psArgumentRemove (N, argc, argv);25 if ((N = psArgumentGet (argc, argv, "-delete"))) { 26 psArgumentRemove (N, &argc, argv); 25 27 if (config->mode) psAbort ("p2search", "only one mode selection is allowed"); 26 28 config->mode = P2_MODE_DELETE; … … 38 40 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "-delete", 0, "delete the P2 tables", ""); 39 41 40 if ((N = psArgumentGet ( *argc, argv, "-help"))) {42 if ((N = psArgumentGet (argc, argv, "-help"))) { 41 43 psArgumentHelp(config->arguments); 42 44 psFree(config->arguments);
Note:
See TracChangeset
for help on using the changeset viewer.
