Changeset 6670
- Timestamp:
- Mar 21, 2006, 5:17:21 PM (20 years ago)
- Location:
- trunk/ippTools/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pxtools.h
r6668 r6670 47 47 char *class_id; 48 48 char *uri; 49 psMetadata *args; 49 50 psMetadata *where; 50 51 } pxConfig; … … 129 130 p2DoneExpRow *p2pendingToDoneExp(p2PendingExpRow *pendingExp); 130 131 132 bool pzPendingFramePrint(FILE *stream, pxConfig *config, psArray *frames); 133 psArray *pzPendingFrameSearch(pxConfig *config); 134 131 135 bool rawScienceFramePrint(FILE *stream, pxConfig *config, psArray *frames); 132 136 psArray *rawScienceFrameSearch(pxConfig *config); -
trunk/ippTools/src/pztool.c
r6669 r6670 7 7 static bool copydoneMode(pxConfig *config); 8 8 bool summitExpPrint(FILE *stream, summitExpRow *summitExp); 9 psArray *pzsearchPendingImfiles(pxConfig *config); 10 bool pzsearchFlushPendingExp(pxConfig *config); 9 11 10 12 int main(int argc, char **argv) … … 89 91 PS_ASSERT_PTR_NON_NULL(config, false); 90 92 91 psArray * new= pzPendingFrameSearch(config);92 if (! new) {93 psArray *pending = pzPendingFrameSearch(config); 94 if (!pending) { 93 95 psError(PS_ERR_UNKNOWN, false, "no pzPendingFrames found"); 94 96 return false; 95 97 } 96 97 bool status = pzPendingFramePrint(stdout, config, new); 98 if (!status) { 98 if (!pzPendingFramePrint(stdout, config, pending)) { 99 99 psError(PS_ERR_UNKNOWN, false, "pzPendingFramePrint() failed"); 100 100 return false; … … 107 107 { 108 108 PS_ASSERT_PTR_NON_NULL(config, false); 109 110 // we don't have to operate on complete frames here as it's ok to start 111 // downloading the imfiles before the exp has been registered 112 psArray *pending = pzsearchPendingImfiles(config); 113 if (!pending) { 114 psError(PS_ERR_UNKNOWN, false, "no pzPendingImfiles found"); 115 return false; 116 } 117 118 // XXX start transaction 119 120 for (long i = 0; i < pending->n; i++) { 121 pzPendingImfileRow *pendingImfile = pending->data[i]; 122 newImfileRow *newImfile = newImfileRowAlloc( 123 pendingImfile->exp_id, 124 pendingImfile->class, 125 pendingImfile->class_id, 126 // XXX get this from the CLI 127 pendingImfile->uri 128 ); 129 130 if (!newImfileInsertObject(config->dbh, newImfile)) { 131 psError(PS_ERR_UNKNOWN, false, "dbh access failed"); 132 return false; 133 } 134 } 135 136 if (pzPendingImfileDeleteRowObjects(config->dbh, pending, MAX_ROWS) 137 < 0) { 138 psError(PS_ERR_UNKNOWN, false, "dbh access failed"); 139 return false; 140 } 141 142 // XXX commit transaction 143 144 // check for completed exps 145 if (!pzsearchFlushPendingExp(config)) { 146 psError(PS_ERR_UNKNOWN, false, "pzsearchFlushPendingExp() failed"); 147 return false; 148 } 149 150 return true; 109 151 } 110 152 … … 124 166 return true; 125 167 } 168 169 psArray *pzsearchPendingImfiles(pxConfig *config) 170 { 171 PS_ASSERT_PTR_NON_NULL(config, NULL); 172 173 psArray *imfiles = pzPendingImfileSelectRowObjects(config->dbh, 174 config->where, MAX_ROWS); 175 if (!imfiles) { 176 psError(PS_ERR_UNKNOWN, false, "no pzPendingImfile rows found"); 177 178 return NULL; 179 } 180 181 return imfiles; 182 } 183 184 bool pzsearchFlushPendingExp(pxConfig *config) 185 { 186 PS_ASSERT_PTR_NON_NULL(config, false); 187 188 return true; 189 } -
trunk/ippTools/src/pztoolConfig.c
r6659 r6670 45 45 "indicate that an image file has been downloaded", ""); 46 46 47 // -pending search 48 /* 49 psMetadata *pendingArgs = psMetadataAlloc(); 50 psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-exp_id", 0, 47 // -copydone search 48 psMetadata *copydoneArgs = psMetadataAlloc(); 49 psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-exp_id", 0, 51 50 "define exposure ID", ""); 52 psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-inst", 0, 53 "define camera of interest", ""); 54 psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-telescope", 0, 55 "define camera of interest", ""); 56 psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-exp_type", 0, 51 psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-class", 0, 57 52 "define class", ""); 58 psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-class", 0, 59 "define class", ""); 60 */ 53 psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-class_id", 0, 54 "define class_id", ""); 55 psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-suri", 0, 56 "define storage uri", ""); 61 57 62 58 bool argErr = false; … … 73 69 printf("Usage: %s <mode> [<options>]\n\n", argv[0]); 74 70 printf(" <mode> : -seen | -pending | -copydone\n\n"); 75 /* 76 fprintf (stdout, "-pending "); 77 psArgumentHelp(pendingArgs); 78 fprintf (stdout, "-update "); 79 psArgumentHelp(updateArgs); 80 */ 71 fprintf (stdout, "-copydone "); 72 psArgumentHelp(copydoneArgs); 81 73 psFree(args); 82 /* 83 psFree(pendingArgs); 84 psFree(updateArgs); 85 */ 74 psFree(copydoneArgs); 86 75 exit(EXIT_FAILURE); 87 76 } 77 78 psFree(copydoneArgs); 88 79 89 80 // XXX why is "" being returned when -[foo] isn't specified? … … 93 84 } 94 85 95 /* 96 switch (config->mode) { 97 bool status; 98 case PX_MODE_PENDING: 99 // -exp_id 100 config->exp_id = psMetadataLookupStr(&status, args, "-exp_id"); 101 psMemIncrRefCounter(config->exp_id); 102 EMPTY_TO_NULL_STRING(config->exp_id); 103 // -inst 104 config->camera_name = psMetadataLookupStr(&status, args, "-inst"); 105 psMemIncrRefCounter(config->camera_name); 106 EMPTY_TO_NULL_STRING(config->camera_name); 107 // -telescope 108 config->camera_name = psMetadataLookupStr(&status, args, 109 "-telescope"); 110 psMemIncrRefCounter(config->telescope); 111 EMPTY_TO_NULL_STRING(config->telescope); 112 // -exp_type 113 config->class = psMetadataLookupStr(&status, args, "-exp_type"); 114 psMemIncrRefCounter(config->exp_type); 115 EMPTY_TO_NULL_STRING(config->exp_type); 116 // -class 117 config->class = psMetadataLookupStr(&status, args, "-class"); 118 psMemIncrRefCounter(config->class); 119 EMPTY_TO_NULL_STRING(config->class); 120 break; 121 case PX_MODE_UPDATE: 122 // -exp_id 123 config->exp_id = psMetadataLookupStr(&status, args, "-exp_id"); 124 psMemIncrRefCounter(config->exp_id); 125 EMPTY_TO_NULL_STRING(config->exp_id); 126 // -filter 127 config->filter = psMetadataLookupStr(&status, args, "-filter"); 128 psMemIncrRefCounter(config->filter); 129 EMPTY_TO_NULL_STRING(config->filter); 86 config->args = args; 130 87 131 break; 132 default: 133 psAbort(argv[0], "invalid option (this should not happen)"); 134 } 135 */ 136 137 psFree(args); 138 /* 139 psFree(pendingArgs); 140 psFree(updateArgs); 141 */ 142 143 88 if (config->mode == PX_MODE_COPYDONE) { 144 89 psMetadata *where = psMetadataAlloc(); 145 90 146 /*147 if (config->camera_name != NULL) {148 if (!psMetadataAddStr(where, PS_LIST_TAIL, "camera", 0, "==",149 config->camera_name)) {150 psError(PS_ERR_UNKNOWN, false, "failed to add item camera");91 bool status; 92 psString str; 93 if ((str = psMetadataLookupStr(&status, args, "-exp_id"))) { 94 if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", str)) { 95 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 151 96 psFree(where); 152 97 return NULL; 153 98 } 154 99 } 155 if (config->filter != NULL) { 156 psMetadataAddStr(where, PS_LIST_TAIL, "filter", 0, "==", 157 config->filter); 100 if ((str = psMetadataLookupStr(&status, args, "-class"))) { 101 if (!psMetadataAddStr(where, PS_LIST_TAIL, "class", 0, "==", str)) { 102 psError(PS_ERR_UNKNOWN, false, "failed to add item class"); 103 psFree(where); 104 return NULL; 105 } 158 106 } 159 if (config->exp_id != NULL) { 160 psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", 161 config->exp_id); 107 if ((str = psMetadataLookupStr(&status, args, "-class_id"))) { 108 if (!psMetadataAddStr(where, PS_LIST_TAIL, "class_id", 0, "==", str)) { 109 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 110 psFree(where); 111 return NULL; 112 } 162 113 } 163 if (config->class != NULL) {164 psMetadataAddStr(where, PS_LIST_TAIL, "class", 0, "==",165 config->class);166 }167 if (config->class_id != NULL) {168 psMetadataAddStr(where, PS_LIST_TAIL, "class_id", 0, "==",169 config->class_id);170 }171 */172 173 /*174 // psMetadataConfig does not support times yet175 if (!psTimeIsZero(config->start) && !psTimeIsZero(config->stop)) {176 psMetadataAddTime (where, PS_LIST_TAIL, "TIME_START", 0, "<", config->stop);177 psMetadataAddTime (where, PS_LIST_TAIL, "TIME_STOP", 0, ">", config->start);178 }179 */180 114 181 115 if (where->list->n < 1) { … … 183 117 where = NULL; 184 118 } 185 186 119 config->where = where; 187 188 189 // add the input and output images to the args list 190 //psMetadataAddStr (args, PS_LIST_TAIL, "-output", 0, "Name of the output image", argv[1]); 120 } 191 121 192 122 // define Database handle, if used
Note:
See TracChangeset
for help on using the changeset viewer.
