Changeset 6286 for trunk/ippTools/src/regtool.c
- Timestamp:
- Feb 1, 2006, 12:23:04 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/regtool.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/regtool.c
r6262 r6286 5 5 static bool pendingMode(pxConfig *config); 6 6 static bool updateMode(pxConfig *config); 7 static psArray *newFrameSearchPending(pxConfig *config); 7 8 8 9 int main(int argc, char **argv) … … 32 33 static bool pendingMode(pxConfig *config) 33 34 { 34 psArray *pendingFrames = newFrameSearch(config); 35 if (!pendingFrames) { 35 PS_ASSERT_PTR_NON_NULL(config, false); 36 37 psArray *new = newFrameSearchPending(config); 38 if (!new) { 36 39 psError(PS_ERR_UNKNOWN, false, "no newFrames found"); 37 40 return false; 38 41 } 39 bool status = newFramePrint(stdout, config, pendingFrames); 42 43 bool status = newFramePrint(stdout, config, new); 40 44 if (!status) { 41 45 psError(PS_ERR_UNKNOWN, false,"newFramePrint() failed"); … … 48 52 static bool updateMode(pxConfig *config) 49 53 { 50 // get exp_id/class/class_id/url from the CLI // add the completed imfile to 51 // the p2DoneImfile tables // remove corresponding entries from the 52 // p2PendingImfile table // check to see if any p2PendingExps have no 53 // associated p2PendingImfiles // if so move the p2PendingExp(s) to 54 // p2DoneExp 54 PS_ASSERT_PTR_NON_NULL(config, false); 55 55 56 // find pending 57 psArray *pendingImfiles = p2searchPendingImfiles(config); 58 if (!pendingImfiles) { 59 psError(PS_ERR_UNKNOWN, false, "no p2PendingImfiles found"); 60 return false; 61 } 62 // insert into done 63 psArray *doneImfiles = p2pendingToDoneImfile(pendingImfiles); 64 for (int i = 0; i < doneImfiles->n; i++) { 65 if (!p2DoneImfileInsertObject(config->database, doneImfiles->data[i])) { 66 psError(PS_ERR_UNKNOWN, false, "database access failed"); 67 return false; 56 psArray *new = newFrameSearchPending(config); 57 58 // insert 'new' rawScience & detrendframes 59 if (new->n > 0) { 60 for (long i = 0; i < new->n; i++) { 61 newFrame *newFrame = new->data[i]; 62 if (strcmp(newFrame->exposure->exp_type, "object") == 0) { 63 // it's a science frame 64 rawScienceFrame *rawScienceFrame = newToRawScienceFrame(newFrame); 65 if (!rawScienceFrameInsert(config, rawScienceFrame)) { 66 // error 67 } 68 } else { 69 // it's a detrend frame 70 rawDetrendFrame *rawDetrendFrame = newToRawDetrendFrame(newFrame); 71 if (!rawDetrendFrameInsert(config, rawDetrendFrame)) { 72 // error 73 } 74 } 68 75 } 69 76 } 70 // delete from pending 71 if (p2PendingImfileDeleteRowObjects(config->database, pendingImfiles, MAX_ROWS) < 0) { 72 // there must be atleast 1 Imfile to get this far 73 psError(PS_ERR_UNKNOWN, false, "database access failed"); 77 78 return true; 79 } 80 81 static psArray *newFrameSearchPending(pxConfig *config) 82 { 83 PS_ASSERT_PTR_NON_NULL(config, NULL); 84 85 psArray *new = newFrameSearch(config); 86 if (!new) { 87 psError(PS_ERR_UNKNOWN, false, "no newFrames found"); 74 88 return false; 75 89 } 76 90 77 // look for pending exposures 78 psArray *pendingExps = p2searchPendingExp(config); 79 if (!pendingExps) { 80 psError(PS_ERR_UNKNOWN, false, "no p2PendingExps found"); 81 return false; 91 psArray *raw = rawScienceFrameSearch(config); 92 if (!raw) { 93 psError(PS_ERR_UNKNOWN, false, "no rawScienceFrames found"); 94 // return false; 82 95 } 83 96 84 for (int i = 0; i < pendingExps->n; i++) { 85 p2PendingExpRow *pendingExp = pendingExps->data[i]; 97 psArray *rawDetrend = rawDetrendFrameSearch(config); 98 if (!rawDetrend) { 99 psError(PS_ERR_UNKNOWN, false, "no rawDetrendFrames found"); 100 // return false; 101 } 86 102 87 psMetadata *where = psMetadataAlloc(); 88 psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", pendingExp->exp_id); 89 psArray *pendingImfiles = p2PendingImfileSelectRowObjects(config->database, where, MAX_ROWS); 90 psFree(where) 91 if (!pendingImfiles) { 92 // exp has no coresponding imfiles 93 psArray *nukeMe = psArrayAlloc(1); 94 nukeMe->n = 0; 95 psArrayAdd(nukeMe, 0, pendingExp); 96 bool status = p2PendingExpDeleteRowObjects(config->database, nukeMe, MAX_ROWS); 97 psFree(nukeMe); 98 if (!status) { 99 psError(PS_ERR_UNKNOWN, false, "database access failed"); 100 return false; 101 } 102 // XXX need a func to convert from p2PendingExp -> p2DoneExp 103 104 p2DoneExpRow *doneExp = p2pendingToDoneExp(pendingExp); 105 if (!doneExp) { 106 psError(PS_ERR_UNKNOWN, false, "p2PendingExp -> p2DoneExp failed"); 107 return false; 108 } 109 if (!p2DoneExpInsertObject(config->database, doneExp)) { 110 psError(PS_ERR_UNKNOWN, false, "database access failed"); 111 return false; 103 // ignore duplicate raw frames 104 if (raw) { 105 for (long i = 0; i < new->n; i++) { 106 newFrame *newFrame = new->data[i]; 107 for (long j = 0; j < raw->n; j++) { 108 rawScienceFrame *rawScienceFrame = raw->data[j]; 109 if (strcmp(newFrame->exposure->exp_id, 110 rawScienceFrame->exposure->exp_id) == 0) { 111 psArrayRemove(new, newFrame); 112 // dec the counter as the array just got shorter 113 //and we don't want to skip elemnts 114 i--; 115 break; 116 } 112 117 } 113 118 } 114 // skip phase 3 for the time being 115 psFree(pendingImfiles); 119 psFree(raw); 116 120 } 117 121 118 /* 119 psArray *doneFrames = p2pendingToDone(config, pendingFrames); 120 if (!doneFrames) { 121 psError(PS_ERR_UNKNOWN, false, "p2pendingToDone() failed"); 122 return false; 122 // ignore duplicate rawDetrend frames 123 if (rawDetrend) { 124 for (long i = 0; i < new->n; i++) { 125 newFrame *newFrame = new->data[i]; 126 for (long j = 0; j < rawDetrend->n; j++) { 127 rawDetrendFrame *rawDetrendFrame = rawDetrend->data[j]; 128 if (strcmp(newFrame->exposure->exp_id, 129 rawDetrendFrame->exposure->exp_id) == 0) { 130 psArrayRemove(new, newFrame); 131 // dec the counter as the array just got shorter 132 //and we don't want to skip elemnts 133 i--; 134 break; 135 } 136 } 137 } 138 psFree(rawDetrend); 123 139 } 124 bool status = p2insertDoneFrames(config, doneFrames);125 if (!status) {126 psError(PS_ERR_UNKNOWN, false, "p2insertDoneFrames() failed");127 return false;128 }129 */130 140 131 return true;141 return new; 132 142 }
Note:
See TracChangeset
for help on using the changeset viewer.
