Changeset 11075 for trunk/ippTools/src
- Timestamp:
- Jan 12, 2007, 12:24:34 PM (19 years ago)
- Location:
- trunk/ippTools/src
- Files:
-
- 5 edited
-
camtool.c (modified) (11 diffs)
-
camtool.h (modified) (1 diff)
-
camtoolConfig.c (modified) (3 diffs)
-
chiptool.c (modified) (5 diffs)
-
detselect.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/camtool.c
r11024 r11075 30 30 static bool pendingimfileMode(pxConfig *config); 31 31 static bool addprocessedexpMode(pxConfig *config); 32 static bool faultexpMode(pxConfig *config); 32 static bool processedexpMode(pxConfig *config); 33 static bool updateprocessedexpMode(pxConfig *config); 33 34 static bool blockMode(pxConfig *config); 34 35 static bool maskedMode(pxConfig *config); … … 52 53 MODECASE(P3TOOL_MODE_PENDINGIMFILE, pendingimfileMode); 53 54 MODECASE(P3TOOL_MODE_ADDPROCESSEDEXP, addprocessedexpMode); 54 MODECASE(P3TOOL_MODE_FAULTEXP, faultexpMode); 55 MODECASE(P3TOOL_MODE_PROCESSEDEXP, processedexpMode); 56 MODECASE(P3TOOL_MODE_UPDATEPROCESSEDEXP,updateprocessedexpMode); 55 57 MODECASE(P3TOOL_MODE_BLOCK, blockMode); 56 58 MODECASE(P3TOOL_MODE_MASKED, maskedMode); … … 86 88 } 87 89 88 bool faulted = psMetadataLookupU64(&status, config->args, "-faulted");89 if (!status) {90 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -faulted");91 return false;92 }93 94 90 psString query = psStringCopy( 95 91 "SELECT" 96 92 " p3PendingExp.*," 97 " raw ScienceExp.camera"93 " rawExp.camera" 98 94 " FROM p3PendingExp" 99 " JOIN raw ScienceExp"95 " JOIN rawExp" 100 96 " USING(exp_tag)" 101 97 " LEFT JOIN p3ProcessedExp" … … 114 110 } 115 111 116 if (faulted) {117 // list only faulted rows118 psStringAppend(&query, " %s", "AND p3PendingExp.fault != 0");119 } else {120 // don't list faulted rows121 psStringAppend(&query, " %s", "AND p3PendingExp.fault = 0");122 }123 124 112 // treat limit == 0 as "no limit" 125 113 if (limit) { … … 177 165 "SELECT" 178 166 " p2ProcessedImfile.*," 179 " raw ScienceExp.camera"167 " rawExp.camera" 180 168 " FROM p3PendingExp" 181 " JOIN raw ScienceExp"169 " JOIN rawExp" 182 170 " USING(exp_tag)" 183 171 " JOIN p2ProcessedImfile" … … 345 333 return false; 346 334 } 335 347 336 // optional 348 337 psString b1_uri = psMetadataLookupStr(&status, config->args, "-b1_uri"); … … 354 343 if (!status) { 355 344 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -b2_uri"); 345 return false; 346 } 347 348 // default 349 psS8 code = psMetadataLookupS8(&status, config->args, "-code"); 350 if (!status) { 351 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code"); 356 352 return false; 357 353 } … … 380 376 } 381 377 if (!psArrayLength(output)) { 382 // XXX check psError here383 378 psError(PS_ERR_UNKNOWN, false, "no p3PendingExp rows found"); 379 psFree(output); 384 380 return true; 381 } 382 383 // start a transaction so we don't end up with an exp_tag is both 384 // p3PendingExp & p3ProcessedExp 385 if (!psDBTransaction(config->dbh)) { 386 psError(PS_ERR_UNKNOWN, false, "database error"); 387 psFree(output); 388 return false; 385 389 } 386 390 … … 404 408 pendingRow->p2_version, 405 409 pendingRow->p3_version, 406 pendingRow->label 410 pendingRow->label, 411 code 407 412 ); 408 psFree(pendingRow);409 413 410 414 // insert the new row into the p3ProcessedImfile table 411 415 if (!p3ProcessedExpInsertObject(config->dbh, row)) { 416 // rollback 417 if (!psDBRollback(config->dbh)) { 418 psError(PS_ERR_UNKNOWN, false, "database error"); 419 } 412 420 psError(PS_ERR_UNKNOWN, false, "database error"); 413 421 psFree(row); 414 return false;415 }416 422 psFree(pendingRow); 423 return false; 424 } 417 425 psFree(row); 418 426 419 return true; 420 } 421 422 423 static bool faultexpMode(pxConfig *config) 427 // delete the p3PendingExp row from the database 428 if (!p3PendingExpDeleteObject(config->dbh, pendingRow)) { 429 // rollback 430 if (!psDBRollback(config->dbh)) { 431 psError(PS_ERR_UNKNOWN, false, "database error"); 432 } 433 psError(PS_ERR_UNKNOWN, false, "database error"); 434 psFree(pendingRow); 435 return false; 436 } 437 438 psFree(pendingRow); 439 440 // point of no return for p3PendingExp -> p3ProcessedExp 441 if (!psDBCommit(config->dbh)) { 442 psError(PS_ERR_UNKNOWN, false, "database error"); 443 return false; 444 } 445 446 return true; 447 } 448 449 static bool processedexpMode(pxConfig *config) 424 450 { 425 451 PS_ASSERT_PTR_NON_NULL(config, false); 426 452 427 453 bool status = false; 428 ps S8 code = psMetadataLookupS8(&status, config->args, "-code");429 if (!status) { 430 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for - code");431 return false; 432 } 433 434 if (!pxSetFaultCode(config->dbh, "p3PendingExp", config->where, code)) {435 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");436 return false;437 }438 439 return true; 440 } 441 442 443 static bool blockMode(pxConfig *config) 444 { 445 PS_ASSERT_PTR_NON_NULL(config, false);446 447 bool status = false;448 psString label = psMetadataLookupStr(&status, config->args, "-label");449 if (!status) {450 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -label"); 451 return false;452 }453 if (!label) {454 ps Error(PS_ERR_UNKNOWN, true, "-label is required");455 return false;456 } 457 458 if (!p3MaskInsert(config->dbh, label)) {459 ps Error(PS_ERR_UNKNOWN, false, "database error");460 return false;461 }462 463 return true;464 } 465 466 static bool maskedMode(pxConfig *config) 467 { 468 PS_ASSERT_PTR_NON_NULL(config, false);469 470 psString query = psStringCopy("SELECT * FROM p3Mask");454 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 455 if (!status) { 456 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 457 return false; 458 } 459 460 bool faulted = psMetadataLookupU64(&status, config->args, "-faulted"); 461 if (!status) { 462 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -faulted"); 463 return false; 464 } 465 466 psString query = psStringCopy( 467 "SELECT" 468 " p3ProcessedExp.*," 469 " rawExp.camera" 470 " FROM p3ProcessedExp" 471 " JOIN rawExp" 472 " USING(exp_tag)" 473 " WHERE" 474 " p3ProcessedExp.exp_tag IS NOT NULL" 475 ); 476 477 if (config->where) { 478 psString whereClause = psDBGenerateWhereConditionSQL(config->where, NULL); 479 psStringAppend(&query, " %s", whereClause); 480 psFree(whereClause); 481 } 482 483 if (faulted) { 484 // list only faulted rows 485 psStringAppend(&query, " %s", "AND p3ProcessedExp.fault != 0"); 486 } else { 487 // don't list faulted rows 488 psStringAppend(&query, " %s", "AND p3ProcessedExp.fault = 0"); 489 } 490 491 // treat limit == 0 as "no limit" 492 if (limit) { 493 psString limitString = psDBGenerateLimitSQL(limit); 494 psStringAppend(&query, " %s", limitString); 495 psFree(limitString); 496 } 471 497 472 498 if (!p_psDBRunQuery(config->dbh, query)) { … … 484 510 if (!psArrayLength(output)) { 485 511 // XXX check psError here 486 psError(PS_ERR_UNKNOWN, false, "no p3 Maskrows found");512 psError(PS_ERR_UNKNOWN, false, "no p3ProcessedExp rows found"); 487 513 psFree(output); 488 514 return true; … … 499 525 } 500 526 527 // negate simple so the default is true 528 if (!ippdbPrintMetadatas(stdout, output, "p3ProcessedExp", !simple)) { 529 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 530 psFree(output); 531 return false; 532 } 533 534 psFree(output); 535 536 return true; 537 } 538 539 540 static bool updateprocessedexpMode(pxConfig *config) 541 { 542 PS_ASSERT_PTR_NON_NULL(config, false); 543 544 bool status = false; 545 psS8 code = psMetadataLookupS8(&status, config->args, "-code"); 546 if (!status) { 547 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code"); 548 return false; 549 } 550 551 if (!pxSetFaultCode(config->dbh, "p3ProcessedExp", config->where, code)) { 552 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); 553 return false; 554 } 555 556 return true; 557 } 558 559 560 static bool blockMode(pxConfig *config) 561 { 562 PS_ASSERT_PTR_NON_NULL(config, false); 563 564 bool status = false; 565 psString label = psMetadataLookupStr(&status, config->args, "-label"); 566 if (!status) { 567 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -label"); 568 return false; 569 } 570 if (!label) { 571 psError(PS_ERR_UNKNOWN, true, "-label is required"); 572 return false; 573 } 574 575 if (!p3MaskInsert(config->dbh, label)) { 576 psError(PS_ERR_UNKNOWN, false, "database error"); 577 return false; 578 } 579 580 return true; 581 } 582 583 static bool maskedMode(pxConfig *config) 584 { 585 PS_ASSERT_PTR_NON_NULL(config, false); 586 587 psString query = psStringCopy("SELECT * FROM p3Mask"); 588 589 if (!p_psDBRunQuery(config->dbh, query)) { 590 psError(PS_ERR_UNKNOWN, false, "database error"); 591 psFree(query); 592 return false; 593 } 594 psFree(query); 595 596 psArray *output = p_psDBFetchResult(config->dbh); 597 if (!output) { 598 psError(PS_ERR_UNKNOWN, false, "database error"); 599 return false; 600 } 601 if (!psArrayLength(output)) { 602 // XXX check psError here 603 psError(PS_ERR_UNKNOWN, false, "no p3Mask rows found"); 604 psFree(output); 605 return true; 606 } 607 608 bool simple = false; 609 { 610 bool status = false; 611 simple = psMetadataLookupBool(&status, config->args, "-simple"); 612 if (!status) { 613 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple"); 614 return false; 615 } 616 } 617 501 618 // negative simple so the default is true 502 619 if (!ippdbPrintMetadatas(stdout, output, "p3Mask", !simple)) { -
trunk/ippTools/src/camtool.h
r11024 r11075 28 28 P3TOOL_MODE_PENDINGIMFILE, 29 29 P3TOOL_MODE_ADDPROCESSEDEXP, 30 P3TOOL_MODE_FAULTEXP, 30 P3TOOL_MODE_PROCESSEDEXP, 31 P3TOOL_MODE_UPDATEPROCESSEDEXP, 31 32 P3TOOL_MODE_BLOCK, 32 33 P3TOOL_MODE_MASKED, -
trunk/ippTools/src/camtoolConfig.c
r11024 r11075 51 51 psMetadataAddU64(pendingexpArgs, PS_LIST_TAIL, "-limit", 0, 52 52 "limit result set to N items", 0); 53 psMetadataAddBool(pendingexpArgs, PS_LIST_TAIL, "-faulted", 0,54 "only return imfiles with a fault status set", false);55 53 psMetadataAddBool(pendingexpArgs, PS_LIST_TAIL, "-simple", 0, 56 54 "use the simple output format", false); … … 97 95 psMetadataAddStr(addprocessedexpArgs, PS_LIST_TAIL, "-b2_uri", 0, 98 96 "define banana 2", NULL); 99 100 // -faultexp 101 psMetadata *faultexpArgs = psMetadataAlloc(); 102 psMetadataAddStr(faultexpArgs, PS_LIST_TAIL, "-exp_tag", 0, 97 psMetadataAddS8(addprocessedexpArgs, PS_LIST_TAIL, "-code", 0, 98 "set fault code (required)", 0); 99 psMetadataAddBool(pendingexpArgs, PS_LIST_TAIL, "-faulted", 0, 100 "only return imfiles with a fault status set", false); 101 102 // -processedexp 103 psMetadata *processedexpArgs = psMetadataAlloc(); 104 psMetadataAddStr(processedexpArgs, PS_LIST_TAIL, "-exp_tag", 0, 105 "search by exposure ID", NULL); 106 psMetadataAddS32(processedexpArgs, PS_LIST_TAIL, "-p2_version", 0, 107 "search for exposures with this p2 version", -1); 108 psMetadataAddS32(processedexpArgs, PS_LIST_TAIL, "-p3_version", 0, 109 "search for exposures with this p3 version", -1); 110 psMetadataAddU64(processedexpArgs, PS_LIST_TAIL, "-limit", 0, 111 "limit result set to N items", 0); 112 psMetadataAddBool(processedexpArgs, PS_LIST_TAIL, "-simple", 0, 113 "use the simple output format", false); 114 115 // -updateprocessedexp 116 psMetadata *updateprocessedexpArgs = psMetadataAlloc(); 117 psMetadataAddStr(updateprocessedexpArgs, PS_LIST_TAIL, "-exp_tag", 0, 103 118 "search by exposure ID", NULL); 104 psMetadataAddStr( faultexpArgs, PS_LIST_TAIL, "-class", 0,119 psMetadataAddStr(updateprocessedexpArgs, PS_LIST_TAIL, "-class", 0, 105 120 "search by class", NULL); 106 psMetadataAddStr( faultexpArgs, PS_LIST_TAIL, "-class_id", 0,121 psMetadataAddStr(updateprocessedexpArgs, PS_LIST_TAIL, "-class_id", 0, 107 122 "search by class ID", NULL); 108 psMetadataAddS8( faultexpArgs, PS_LIST_TAIL, "-code", 0,123 psMetadataAddS8(updateprocessedexpArgs, PS_LIST_TAIL, "-code", 0, 109 124 "set fault code (required)", 0); 110 125 … … 146 161 PXTOOL_MODE("-pendingexp", P3TOOL_MODE_PENDINGEXP, pendingexpArgs); 147 162 PXTOOL_MODE("-pendingimfile",P3TOOL_MODE_PENDINGIMFILE, pendingimfileArgs); 148 PXTOOL_MODE("-faultexp", P3TOOL_MODE_FAULTEXP, faultexpArgs);149 163 PXTOOL_MODE("-addprocessedexp", P3TOOL_MODE_ADDPROCESSEDEXP, addprocessedexpArgs); 164 PXTOOL_MODE("-processedexp", P3TOOL_MODE_PROCESSEDEXP, processedexpArgs); 165 PXTOOL_MODE("-updateprocessedexp", P3TOOL_MODE_UPDATEPROCESSEDEXP,updateprocessedexpArgs); 150 166 PXTOOL_MODE("-block", P3TOOL_MODE_BLOCK, blockArgs); 151 167 PXTOOL_MODE("-masked", P3TOOL_MODE_MASKED, maskedArgs); -
trunk/ippTools/src/chiptool.c
r11034 r11075 99 99 "SELECT" 100 100 " p2PendingImfile.*," 101 " raw ScienceExp.camera"101 " rawExp.camera" 102 102 " FROM p2PendingImfile" 103 103 " JOIN p2PendingExp" 104 104 " USING(exp_tag)" 105 " JOIN raw ScienceExp"105 " JOIN rawExp" 106 106 " USING(exp_tag)" 107 107 " LEFT JOIN p2Mask" … … 353 353 "SELECT" 354 354 " p2ProcessedImfile.*," 355 " raw ScienceExp.camera"355 " rawExp.camera" 356 356 " FROM p2ProcessedImfile" 357 " JOIN raw ScienceExp"357 " JOIN rawExp" 358 358 " USING(exp_tag)" 359 359 " WHERE " … … 554 554 // where exp_tag is not in p2PendingImfile 555 555 // where the number of entries in p2ProccessedImfile matches the .imfiles 556 // entry in raw ScienceExp556 // entry in rawExp 557 557 psString query = psStringCopy( 558 558 "SELECT DISTINCT" 559 559 " p2PendingExp.*," 560 " raw ScienceExp.imfiles,"560 " rawExp.imfiles," 561 561 " p2ProcessedImfile.class_id" 562 562 " FROM p2PendingExp" 563 " JOIN raw ScienceExp"564 " ON p2PendingExp.exp_tag = raw ScienceExp.exp_tag"563 " JOIN rawExp" 564 " ON p2PendingExp.exp_tag = rawExp.exp_tag" 565 565 " LEFT JOIN p2ProcessedExp" 566 566 " ON p2PendingExp.exp_tag = p2ProcessedExp.exp_tag" … … 575 575 " GROUP BY" 576 576 " p2PendingExp.exp_tag" 577 " HAVING raw ScienceExp.imfiles = COUNT(p2ProcessedImfile.class_id)"577 " HAVING rawExp.imfiles = COUNT(p2ProcessedImfile.class_id)" 578 578 ); 579 579 … … 773 773 pendingExp->p1_version, 774 774 pendingExp->p2_version, 775 pendingExp->label, 776 0 // fault code 775 pendingExp->label 777 776 ); 778 777 } -
trunk/ippTools/src/detselect.c
r10161 r11075 90 90 // " detRun.state," 91 91 // " detRunSummary.accept," 92 // " raw DetrendExp.camera"92 // " rawExp.camera" 93 93 " FROM detRun" 94 94 " JOIN detRunSummary " … … 97 97 " ON detRunSummary.det_id = detInputExp.det_id" 98 98 " AND detRunSummary.iteration = detInputExp.iteration" 99 " JOIN raw DetrendExp"100 " ON detInputExp.exp_tag = raw DetrendExp.exp_tag"99 " JOIN rawExp" 100 " ON detInputExp.exp_tag = rawExp.exp_tag" 101 101 " JOIN rawImfile" 102 " ON raw DetrendExp.exp_tag = rawImfile.exp_tag"102 " ON rawExp.exp_tag = rawImfile.exp_tag" 103 103 " WHERE" 104 104 " detRun.state = 'stop'" … … 106 106 // XXX the following entry is needed to exclude db mismatched 107 107 // XXX these are caused by an error upstream and should be fixed 108 // " AND detRun.det_type = raw DetrendExp.object"108 // " AND detRun.det_type = rawExp.object" 109 109 ); 110 110 # endif
Note:
See TracChangeset
for help on using the changeset viewer.
