Changeset 8661
- Timestamp:
- Aug 28, 2006, 2:21:28 PM (20 years ago)
- Location:
- trunk/ippTools/src
- Files:
-
- 6 edited
-
Makefile.am (modified) (1 diff)
-
chiptool.c (modified) (11 diffs)
-
pxframes.c (modified) (1 diff)
-
pxtables.c (modified) (2 diffs)
-
pxtools.h (modified) (2 diffs)
-
regtool.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/Makefile.am
r8537 r8661 28 28 libpxtools_la_LDFLAGS = -release $(PACKAGE_VERSION) 29 29 libpxtools_la_SOURCES = \ 30 p2searchDoneFrames.c \31 30 p2insertPendingFrames.c \ 32 p2pendingToDone.c \33 31 p2searchPendingFrames.c \ 34 32 pxconfig.c \ -
trunk/ippTools/src/chiptool.c
r8658 r8661 12 12 static bool pendingimfileMode(pxConfig *config); 13 13 static bool addprocessedimfileMode(pxConfig *config); 14 static p2DoneImfileRow *p2pendingToDoneImfile(pxConfig *config, p2PendingImfileRow *imfile); 14 static p2ProcessedImfileRow *p2pendingToProcessedImfile(pxConfig *config, p2PendingImfileRow *imfile); 15 static p2ProcessedExpRow *p2PendingToProcessedExp(pxConfig *config, p2PendingExpRow *pendingExp); 15 16 16 17 # define MODECASE(caseName, func) \ … … 70 71 { 71 72 PS_ASSERT_PTR_NON_NULL(config, NULL); 73 #if 0 72 74 73 75 psArray *rawFrames = rawScienceFrameSearch(config); … … 132 134 } 133 135 136 #endif 134 137 return true; 135 138 } 139 136 140 137 141 static bool pendingimfileMode(pxConfig *config) … … 166 170 static bool addprocessedimfileMode(pxConfig *config) 167 171 { 168 PS_ASSERT_PTR_NON_NULL(config, NULL); 169 170 // -uri is always required 171 bool status = false; 172 psString uri = psMetadataLookupStr(&status, config->args, "-uri"); 173 if (!status) { 174 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri"); 175 return NULL; 176 } 177 if (!uri) { 178 psError(PS_ERR_UNKNOWN, true, "-uri is required"); 179 return NULL; 180 } 181 // get exp_id/class/class_id/uri from the CLI 172 PS_ASSERT_PTR_NON_NULL(config, false); 173 174 // select * from p2ProcessedImfiles 175 // where 176 // exp_id & class_id are not in p2PendingImfile 177 182 178 // add the completed imfile to 183 // the p2 DoneImfile tables179 // the p2ProcessedeImfile tables 184 180 // remove corresponding entries from the 185 181 // p2PendingImfile table 186 182 // check to see if any p2PendingExps have no 187 183 // associated p2PendingImfiles 188 // if so move the p2PendingExp(s) to p2DoneExp 184 // if so move the p2PendingExp(s) to p2ProcessedExp 185 186 psString query = psStringCopy( 187 "SELECT DISTINCT" 188 " p2PendingImfile.*" 189 " FROM p2PendingImfile " 190 " LEFT JOIN p2ProcessedImfile" 191 " USING(exp_id, class_id)" 192 " WHERE" 193 " p2ProcessedImfile.exp_id IS NULL" 194 " AND p2ProcessedImfile.class_id IS NULL" 195 ); 196 { 197 psMetadata *where = psMetadataAlloc(); 198 bool status = false; 199 psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id"); if (!status) { 200 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id"); 201 psFree(query); 202 return false; 203 } 204 if (exp_id) { 205 if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", exp_id)) { 206 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 207 psFree(where); 208 psFree(query); 209 return false; 210 } 211 } 212 psString class_id = psMetadataLookupStr(&status, config->args, "-class_id"); 213 if (!status) { 214 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -class_id"); 215 psFree(query); 216 return false; 217 } 218 if (class_id) { 219 if (!psMetadataAddStr(where, PS_LIST_TAIL, "class_id", 0, "==", class_id)) { 220 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 221 psFree(where); 222 psFree(query); 223 return false; 224 } 225 } 226 227 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p2PendingImfile"); 228 psFree(where) 229 if (whereClaus) { 230 psStringAppend(&query, " AND %s", whereClause); 231 psFree(whereClause); 232 } 233 } 234 235 if (!p_psDBRunQuery(config->dbh, query)) { 236 psError(PS_ERR_UNKNOWN, false, "database error"); 237 psFree(query); 238 return false; 239 } 240 psFree(query); 241 242 psArray *output = p_psDBFetchResult(config->dbh); 243 if (!output) { 244 // XXX check psError here 245 psError(PS_ERR_UNKNOWN, false, "no pending rawDetrendExp rows found"); 246 return false; 247 } 189 248 190 249 // find pending … … 205 264 // insert into done 206 265 for (long i = 0; i < psArrayLength(pendingImfiles); i++) { 207 p2 DoneImfileRow *imfile = p2pendingToDoneImfile(config, pendingImfiles->data[0]);266 p2ProcessedImfileRow *imfile = p2pendingToProcessedImfile(config, pendingImfiles->data[0]); 208 267 if (!imfile) { 209 268 // rollback … … 211 270 psError(PS_ERR_UNKNOWN, false, "database error"); 212 271 } 213 psError(PS_ERR_UNKNOWN, false, "failed to convert p2PendingImfile to p2 DoneImfile");272 psError(PS_ERR_UNKNOWN, false, "failed to convert p2PendingImfile to p2ProcessedImfile"); 214 273 psFree(pendingImfiles); 215 274 return false; 216 275 } 217 if (!p2 DoneImfileInsertObject(config->dbh, imfile)) {276 if (!p2ProcessedImfileInsertObject(config->dbh, imfile)) { 218 277 // rollback 219 278 if (!psDBRollback(config->dbh)) { … … 280 339 } 281 340 282 p2 DoneExpRow *doneExp = p2pendingToDoneExp(pendingExp);341 p2ProcessedExpRow *doneExp = p2PendingToProcessedExp(config, pendingExp); 283 342 if (!doneExp) { 284 343 // rollback … … 286 345 psError(PS_ERR_UNKNOWN, false, "database error"); 287 346 } 288 psError(PS_ERR_UNKNOWN, false, "p2PendingExp -> p2 DoneExp failed");347 psError(PS_ERR_UNKNOWN, false, "p2PendingExp -> p2ProcessedExp failed"); 289 348 psFree(pendingExps); 290 349 return false; 291 350 } 292 if (!p2 DoneExpInsertObject(config->dbh, doneExp)) {351 if (!p2ProcessedExpInsertObject(config->dbh, doneExp)) { 293 352 // rollback 294 353 if (!psDBRollback(config->dbh)) { … … 308 367 psFree(pendingExps); 309 368 310 // point of no return for p2PendingImfile -> p2 DoneImfile311 // point of no return for p2PendingExp -> p2 DoneExp369 // point of no return for p2PendingImfile -> p2ProcessedImfile 370 // point of no return for p2PendingExp -> p2ProcessedExp 312 371 if (!psDBCommit(config->dbh)) { 313 372 psError(PS_ERR_UNKNOWN, false, "database error"); … … 330 389 } 331 390 332 // XXX the filename layout is defined by this code 333 static p2DoneImfileRow *p2pendingToDoneImfile(pxConfig *config, p2PendingImfileRow *imfile) 391 static p2ProcessedImfileRow *p2pendingToProcessedImfile(pxConfig *config, p2PendingImfileRow *imfile) 334 392 { 335 393 PS_ASSERT_PTR_NON_NULL(config, NULL); … … 340 398 if (!status) { 341 399 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri"); 342 return NULL;400 return false; 343 401 } 344 402 if (!uri) { 345 403 psError(PS_ERR_UNKNOWN, true, "-uri is required"); 346 return NULL; 347 } 348 349 return p2DoneImfileRowAlloc( 404 return false; 405 } 406 407 psString recipe = psMetadataLookupStr(&status, config->args, "-recip"); 408 if (!status) { 409 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -recip"); 410 return false; 411 } 412 if (!recipe) { 413 psError(PS_ERR_UNKNOWN, true, "-recip is required"); 414 return false; 415 } 416 417 psF64 bg = psMetadataLookupF64(&status, config->args, "-bg"); 418 if (!status) { 419 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg"); 420 return false; 421 } 422 if (isnan(bg)) { 423 psError(PS_ERR_UNKNOWN, true, "-bg is required"); 424 return false; 425 } 426 427 psF64 bg_stdev = psMetadataLookupF64(&status, config->args, "-bg_stdev"); 428 if (!status) { 429 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_stdev"); 430 return false; 431 } 432 if (isnan(bg_stdev)) { 433 psError(PS_ERR_UNKNOWN, true, "-bg_stdev is required"); 434 return false; 435 } 436 437 psF64 bg_mean_stdev = psMetadataLookupF64(&status, config->args, "-bg_mean_stdev"); 438 if (!status) { 439 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_mean_stdev"); 440 return false; 441 } 442 if (isnan(bg_mean_stdev)) { 443 psError(PS_ERR_UNKNOWN, true, "-bg_mean_stdev is required"); 444 return false; 445 } 446 447 // optional 448 psString b1_uri = psMetadataLookupStr(&status, config->args, "-b1_uri"); 449 if (!status) { 450 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -b1_uri"); 451 return false; 452 } 453 454 psString b2_uri = psMetadataLookupStr(&status, config->args, "-b2_uri"); 455 if (!status) { 456 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -b2_uri"); 457 return false; 458 } 459 460 return p2ProcessedImfileRowAlloc( 350 461 imfile->exp_id, 351 462 imfile->class_id, 352 463 uri, 353 "my recipe", // recipe 464 recipe, 465 bg, 466 bg_stdev, 467 bg_mean_stdev, 468 b1_uri, 469 b2_uri, 354 470 imfile->p1_version, 355 471 imfile->p2_version 356 472 ); 357 473 } 474 475 static p2ProcessedExpRow *p2PendingToProcessedExp(pxConfig *config, p2PendingExpRow *pendingExp) 476 { 477 PS_ASSERT_PTR_NON_NULL(pendingExp, NULL); 478 479 return p2ProcessedExpRowAlloc( 480 pendingExp->exp_id, 481 "my recipe", 482 pendingExp->p1_version, 483 pendingExp->p2_version 484 ); 485 } -
trunk/ippTools/src/pxframes.c
r8250 r8661 41 41 PX_FRAME_ALLOC(rawScienceFrame, rawScienceExp); 42 42 PX_FRAME_ALLOC(p2PendingFrame, p2PendingExp); 43 PX_FRAME_ALLOC(p2DoneFrame, p2DoneExp);44 43 45 44 #define PX_FRAME_PRINT(frametype, imfiletype) \ -
trunk/ippTools/src/pxtables.c
r8495 r8661 33 33 CREATE_TABLE(p2PendingExpCreateTable); 34 34 CREATE_TABLE(p2PendingImfileCreateTable); 35 CREATE_TABLE(p2 DoneExpCreateTable);36 CREATE_TABLE(p2 DoneImfileCreateTable);35 CREATE_TABLE(p2ProcessedExpCreateTable); 36 CREATE_TABLE(p2ProcessedImfileCreateTable); 37 37 CREATE_TABLE(p3PendingExpCreateTable); 38 38 CREATE_TABLE(detRunCreateTable); … … 88 88 DROP_TABLE(p2PendingExpDropTable); 89 89 DROP_TABLE(p2PendingImfileDropTable); 90 DROP_TABLE(p2 DoneExpDropTable);91 DROP_TABLE(p2 DoneImfileDropTable);90 DROP_TABLE(p2ProcessedExpDropTable); 91 DROP_TABLE(p2ProcessedImfileDropTable); 92 92 DROP_TABLE(p3PendingExpDropTable); 93 93 DROP_TABLE(detRunDropTable); -
trunk/ippTools/src/pxtools.h
r8175 r8661 91 91 ); 92 92 93 typedef struct {94 p2DoneExpRow *exposure;95 psArray *images;96 } p2DoneFrame;97 98 p2DoneFrame *p2DoneFrameAlloc(99 p2DoneExpRow *exposure,100 psArray *images101 );102 103 93 pxConfig *pxConfigAlloc(void); 104 94 … … 115 105 psArray *p2searchPendingImfiles(pxConfig *config); 116 106 psArray *p2searchPendingExp(pxConfig *config); 117 p2DoneExpRow *p2pendingToDoneExp(p2PendingExpRow *pendingExp);118 107 119 108 bool pzPendingFramePrint(FILE *stream, pxConfig *config, psArray *frames); -
trunk/ippTools/src/regtool.c
r8563 r8661 446 446 ); // WHERE class is generated from exp_id, class, & class_id 447 447 448 char *whereClaus = NULL;449 448 { 450 449 // build a query to search by exp_id, class, class_id … … 495 494 496 495 // there's not 497 whereClaus = psDBGenerateWhereSQL(where, NULL);496 psString whereClaus = psDBGenerateWhereSQL(where, NULL); 498 497 psFree(where); 499 498 if (whereClaus) {
Note:
See TracChangeset
for help on using the changeset viewer.
