Changeset 6991 for trunk/ippTools/src/guidetool.c
- Timestamp:
- Apr 25, 2006, 5:11:15 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/guidetool.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/guidetool.c
r6981 r6991 9 9 10 10 static bool pendingMode(pxConfig *config); 11 static bool updateMode(pxConfig *config); 12 static psArray *newFrameSearchPending(pxConfig *config); 13 static p1PendingExpRow *newToP1PendingExp(newExpRow *newExp); 14 static p2PendingExpRow *newToP2PendingExp(newExpRow *newExp); 11 static bool defineMode(pxConfig *config); 12 static p1PendingExpRow *rawScienceTop1PendingExp(rawScienceExpRow *raw); 15 13 16 14 int main(int argc, char **argv) … … 24 22 } 25 23 break; 26 case PX_MODE_ UPDATE:27 if (! updateMode(config)) {24 case PX_MODE_DEFINE: 25 if (!defineMode(config)) { 28 26 goto FAIL; 29 27 } … … 44 42 PS_ASSERT_PTR_NON_NULL(config, false); 45 43 46 psArray * new = newFrameSearchPending(config);47 if (! new) {48 psError(PS_ERR_UNKNOWN, false, "no newFramesfound");44 psArray *p1PendingExp = p1PendingExpSelectRowObjects(config->dbh, NULL, 0); 45 if (!p1PendingExp) { 46 psError(PS_ERR_UNKNOWN, false, "no p1PendingExp found"); 49 47 return false; 50 48 } 51 49 52 bool status = newFramePrint(stdout, config, new); 53 if (!status) { 54 psError(PS_ERR_UNKNOWN, false,"newFramePrint() failed"); 55 return false; 50 psMetadata *output = psMetadataAlloc(); 51 52 for (long i = 0; i < psArrayLength(p1PendingExp); i++) { 53 psMetadata *md = p1PendingExpMetadataFromObject(p1PendingExp->data[i]); 54 psMetadataAddMetadata(output, PS_LIST_TAIL, "p1PendingExp", 55 PS_META_DUPLICATE_OK, NULL, md); 56 psFree(md); 56 57 } 58 59 psString str = psMetadataConfigFormat(output); 60 psFree(output); 61 62 fprintf(stdout, "%s\n", str); 63 psFree(str); 57 64 58 65 return true; 59 66 } 60 67 61 static bool updateMode(pxConfig *config)68 static bool defineMode(pxConfig *config) 62 69 { 63 70 PS_ASSERT_PTR_NON_NULL(config, false); 64 65 psArray *new = newFrameSearchPending(config);66 if (!new) {67 psError(PS_ERR_UNKNOWN, false, "no newFrames found");68 return true;69 }70 71 // insert 'new' rawScience & detrendframes72 if (new->n > 0) {73 for (long i = 0; i < new->n; i++) {74 newFrame *newFrame = new->data[i];75 if (strcmp(newFrame->exposure->exp_type, "object") == 0) {76 // it's a science frame77 rawScienceFrame *rawScienceFrame = newToRawScienceFrame(newFrame);78 if (!rawScienceFrameInsert(config, rawScienceFrame)) {79 // error80 }81 } else {82 // it's a detrend frame83 rawDetrendFrame *rawDetrendFrame = newToRawDetrendFrame(newFrame);84 if (!rawDetrendFrameInsert(config, rawDetrendFrame)) {85 // error86 }87 }88 89 /*90 // lookup camera name in p0CameraConfig91 psMetadata *where = psMetadataAlloc();92 //bool status = false;93 psMetadataAddStr(where, PS_LIST_TAIL, "camera", 0, NULL,94 newFrame->exposure->camera);95 psArray *configs = p0CameraConfigSelectRowObjects(config->dbh, where, MAX_ROWS);96 psFree(where);97 // if there is no match then we default to sending into into p298 if (!configs) {99 // convert newFrame->exposure to p2PendingExp100 p2PendingExpRow *p2PendingExp = newToP2PendingExp(101 newFrame->exposure102 );103 p2PendingExpInsertObject(config->dbh, p2PendingExp);104 psFree(p2PendingExp);105 continue;106 }107 108 // only use the first match109 int pX = ((p0CameraConfigRow *)configs->data[0])->phase;110 switch (pX) {111 case 1:112 // convert newFrame->exposure to p1PendingExp113 {114 p1PendingExpRow *p1PendingExp = newToP1PendingExp(115 newFrame->exposure116 );117 p1PendingExpInsertObject(config->dbh, p1PendingExp);118 psFree(p1PendingExp);119 }120 break;121 case 2:122 // convert newFrame->exposure to p2PendingExp123 {124 p2PendingExpRow *p2PendingExp = newToP2PendingExp(125 newFrame->exposure126 );127 p2PendingExpInsertObject(config->dbh, p2PendingExp);128 psFree(p2PendingExp);129 }130 break;131 default:132 // XXX add argv[0] to pxConfig133 psAbort("foo", "invalid phase (this should not happen)");134 }135 136 psFree(configs);137 */138 }139 psFree(new);140 }141 71 142 72 return true; 143 73 } 144 74 145 static psArray *newFrameSearchPending(pxConfig *config) 146 { 147 PS_ASSERT_PTR_NON_NULL(config, NULL); 148 149 psArray *new = newFrameSearch(config); 150 if (!new) { 151 psError(PS_ERR_UNKNOWN, false, "no newFrames found"); 152 return false; 153 } 154 155 psArray *raw = rawScienceFrameSearch(config); 156 if (!raw) { 157 psError(PS_ERR_UNKNOWN, false, "no rawScienceFrames found"); 158 // return false; 159 } 160 161 psArray *rawDetrend = rawDetrendFrameSearch(config); 162 if (!rawDetrend) { 163 psError(PS_ERR_UNKNOWN, false, "no rawDetrendFrames found"); 164 // return false; 165 } 166 167 // ignore duplicate raw frames 168 if (raw) { 169 for (long i = 0; i < new->n; i++) { 170 newFrame *newFrame = new->data[i]; 171 for (long j = 0; j < raw->n; j++) { 172 rawScienceFrame *rawScienceFrame = raw->data[j]; 173 if (strcmp(newFrame->exposure->exp_id, 174 rawScienceFrame->exposure->exp_id) == 0) { 175 psArrayRemove(new, newFrame); 176 // dec the counter as the array just got shorter 177 //and we don't want to skip elemnts 178 i--; 179 break; 180 } 181 } 182 } 183 psFree(raw); 184 } 185 186 // ignore duplicate rawDetrend frames 187 if (rawDetrend) { 188 for (long i = 0; i < new->n; i++) { 189 newFrame *newFrame = new->data[i]; 190 for (long j = 0; j < rawDetrend->n; j++) { 191 rawDetrendFrame *rawDetrendFrame = rawDetrend->data[j]; 192 if (strcmp(newFrame->exposure->exp_id, 193 rawDetrendFrame->exposure->exp_id) == 0) { 194 psArrayRemove(new, newFrame); 195 // dec the counter as the array just got shorter 196 //and we don't want to skip elemnts 197 i--; 198 break; 199 } 200 } 201 } 202 psFree(rawDetrend); 203 } 204 205 return new; 206 } 207 208 209 static p1PendingExpRow *newToP1PendingExp(newExpRow *newExp) 75 static p1PendingExpRow *rawScienceTop1PendingExp(rawScienceExpRow *raw) 210 76 { 211 77 return p1PendingExpRowAlloc( 212 newExp->exp_id,213 newExp->camera,214 newExp->telescope,215 newExp->exp_type,78 raw->exp_id, 79 raw->camera, 80 raw->telescope, 81 raw->exp_type, 216 82 // newExp->class, 217 newExp->imfiles,83 raw->imfiles, 218 84 "my filter", 219 85 "my stats", … … 222 88 ); 223 89 } 224 225 static p2PendingExpRow *newToP2PendingExp(newExpRow *newExp)226 {227 return p2PendingExpRowAlloc(228 newExp->exp_id,229 newExp->camera,230 newExp->telescope,231 newExp->exp_type,232 // newExp->class,233 newExp->imfiles,234 "my filter",235 "my stats",236 "my recipe",237 0xff, // XXX calc version number238 0xff // XXX calc version number239 );240 }
Note:
See TracChangeset
for help on using the changeset viewer.
