Changeset 27838 for branches/tap_branches/ippTools/src/camtool.c
- Timestamp:
- May 3, 2010, 8:41:49 AM (16 years ago)
- Location:
- branches/tap_branches
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
ippTools/src (modified) (1 prop)
-
ippTools/src/camtool.c (modified) (30 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/tap_branches
- Property svn:mergeinfo changed
-
branches/tap_branches/ippTools/src
- Property svn:ignore
-
old new 16 16 difftool 17 17 disttool 18 dqstatstool 18 19 faketool 19 20 flatcorr
-
- Property svn:ignore
-
branches/tap_branches/ippTools/src/camtool.c
r25851 r27838 109 109 psMetadata *where = psMetadataAlloc(); 110 110 pxcamGetSearchArgs (config, where); 111 pxAddLabelSearchArgs (config, where, "-label", "c amRun.label", "==");112 PXOPT_COPY_STR(config->args, where, "-reduction", "c amRun.reduction", "==");111 pxAddLabelSearchArgs (config, where, "-label", "chipRun.label", "=="); // define using chipRun label 112 PXOPT_COPY_STR(config->args, where, "-reduction", "chipRun.reduction", "=="); 113 113 114 114 if (!psListLength(where->list) && 115 115 !psMetadataLookupBool(NULL, config->args, "-all")) { 116 116 psFree(where); 117 psError(PXTOOLS_ERR_ DATA, false, "search parameters are required");117 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 118 118 return false; 119 119 } … … 133 133 psString query = pxDataGet("camtool_find_chip_id.sql"); 134 134 if (!query) { 135 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");135 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 136 136 psFree(where); 137 137 return false; … … 184 184 bool status; 185 185 char *end_stage = psMetadataLookupStr(&status, md, "end_stage"); 186 if (end_stage && strcasecmp(end_stage, "warp")) continue;186 if (end_stage && strcasecmp(end_stage, "warp")) continue; 187 187 188 188 char *raw_tess_id = psMetadataLookupStr(&status, md, "tess_id"); 189 if (raw_tess_id || tess_id) continue;189 if (raw_tess_id || tess_id) continue; 190 190 191 191 char *label = psMetadataLookupStr(&status, md, "label"); … … 193 193 194 194 if (!status) { 195 psError(PS_ERR_UNKNOWN, false, "cannot queue analysis to WARP without a defined tess id: label: %s, exp_id %" PRId64, label, exp_id);195 psError(PS_ERR_UNKNOWN, false, "cannot queue analysis to WARP without a defined tess id: label: %s, exp_id %" PRId64, label, exp_id); 196 196 psFree(output); 197 197 return false; … … 199 199 } 200 200 201 // loop over our list of c amRun rows201 // loop over our list of chipRun rows 202 202 for (long i = 0; i < psArrayLength(output); i++) { 203 203 psMetadata *md = output->data[i]; 204 204 205 c amRunRow *row = camRunObjectFromMetadata(md);205 chipRunRow *row = chipRunObjectFromMetadata(md); 206 206 if (!row) { 207 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into c amRun");207 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into chipRun"); 208 208 psFree(output); 209 209 return false; … … 222 222 tess_id ? tess_id : row->tess_id, 223 223 end_stage ? end_stage : row->end_stage, 224 row->magicked, 224 225 note 225 226 )) { … … 254 255 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 255 256 PXOPT_COPY_STR(config->args, where, "-label", "camRun.label", "=="); 257 PXOPT_COPY_STR(config->args, where, "-data_group","camRun.data_group", "=="); 256 258 PXOPT_COPY_STR(config->args, where, "-state", "camRun.state", "=="); 257 259 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); … … 259 261 if (!psListLength(where->list)) { 260 262 psFree(where); 261 psError(PXTOOLS_ERR_ DATA, false, "search parameters are required");263 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 262 264 return false; 263 265 } … … 265 267 266 268 // pxUpdateRun gets parameters from config->args and updates 267 bool result = pxUpdateRun(config, where, &query, "camRun", true);269 bool result = pxUpdateRun(config, where, &query, "camRun", "cam_id", "camProcessedExp", true); 268 270 if (!result) { 269 psError( PXTOOLS_ERR_DATA, false, "pxUpdateRun failed");271 psError(psErrorCodeLast(), false, "pxUpdateRun failed"); 270 272 } 271 273 … … 292 294 psString query = pxDataGet("camtool_find_pendingexp.sql"); 293 295 if (!query) { 294 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");296 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 295 297 return false; 296 298 } … … 357 359 psString query = pxDataGet("camtool_find_pendingimfile.sql"); 358 360 if (!query) { 359 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");361 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 360 362 return false; 361 363 } … … 479 481 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 480 482 PXOPT_LOOKUP_S16(quality, config->args, "-quality", false, false); 481 482 PXOPT_LOOKUP_S64(magicked, config->args, "-magicked", false, false); 483 484 // Get this from the chipRun 485 // PXOPT_LOOKUP_S64(magicked, config->args, "-magicked", false, false); 483 486 484 487 // generate restrictions … … 488 491 psString query = pxDataGet("camtool_find_pendingexp.sql"); 489 492 if (!query) { 490 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");493 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 491 494 return false; 492 495 } … … 523 526 return false; 524 527 } 528 529 bool status; 530 psS64 chip_magicked = psMetadataLookupS64(&status, output->data[0], "chip_magicked"); 525 531 526 532 camRunRow *pendingRow = camRunObjectFromMetadata(output->data[0]); … … 603 609 } 604 610 605 // since there is only one exp per 'new' set camRun.state = 'full' 606 if (!pxcamRunSetState(config, row->cam_id, "full", magicked)) { 607 psError(PS_ERR_UNKNOWN, false, "failed to change camRun.state for cam_id: %" PRId64, row->cam_id); 608 psFree(row); 609 psFree(pendingRow); 610 return false; 611 } 612 613 // NULL for end_stage means go as far as possible 614 // EAM : skip here if fault != 0 615 // Also, we can run fake even if tess_id is not defined 616 if (fault || (pendingRow->end_stage && psStrcasestr(pendingRow->end_stage, "cam"))) { 611 if (fault) { 617 612 psFree(row); 618 613 psFree(pendingRow); … … 623 618 return true; 624 619 } 620 // else continue on... 621 622 // since there is only one exp per 'new' set camRun.state = 'full' 623 // propagate magicked state from chipRun 624 if (!pxcamRunSetState(config, row->cam_id, "full", chip_magicked)) { 625 psError(PS_ERR_UNKNOWN, false, "failed to change camRun.state for cam_id: %" PRId64, row->cam_id); 626 psFree(row); 627 psFree(pendingRow); 628 return false; 629 } 625 630 psFree(row); 626 // else continue on... 631 632 // EAM: NULL for end_stage means go as far as possible 633 // Also, we can run fake even if tess_id is not defined 634 if (pendingRow->end_stage && psStrcasestr(pendingRow->end_stage, "cam")) { 635 psFree(pendingRow); 636 if (!psDBCommit(config->dbh)) { 637 psError(PS_ERR_UNKNOWN, false, "database error"); 638 return false; 639 } 640 return true; 641 } 627 642 628 643 if (!pxfakeQueueByCamID(config, … … 666 681 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 667 682 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false); 683 PXOPT_LOOKUP_BOOL(pstamp_order, config->args, "-pstamp_order", false); 668 684 669 685 // generate restrictions … … 672 688 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 673 689 pxAddLabelSearchArgs (config, where, "-label", "camRun.label", "=="); 690 pxAddLabelSearchArgs (config, where, "-data_group", "camRun.data_group", "LIKE"); 674 691 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 675 692 676 if (!psListLength(where->list) && 693 psString where2 = NULL; 694 if (!pxspaceAddWhere(config, &where2, "rawExp")) { 695 psError(psErrorCodeLast(), false, "pxSpaceAddWhere failed"); 696 return false; 697 } 698 if (!pxmagicAddWhere(config, &where2, "chipRun")) { 699 psError(psErrorCodeLast(), false, "pxSpaceAddWhere failed"); 700 return false; 701 } 702 if (!psListLength(where->list) && !where2 && 677 703 !psMetadataLookupBool(NULL, config->args, "-all")) { 678 704 psFree(where); 679 psError(PXTOOLS_ERR_ DATA, false, "search parameters (or -all) are required");705 psError(PXTOOLS_ERR_CONFIG, false, "search parameters (or -all) are required"); 680 706 return false; 681 707 } … … 683 709 psString query = pxDataGet("camtool_find_processedexp.sql"); 684 710 if (!query) { 685 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");711 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 686 712 return false; 687 713 } … … 691 717 psStringAppend(&query, " WHERE %s", whereClause); 692 718 psFree(whereClause); 693 } 719 } 694 720 695 721 // we either add AND (condition) or WHERE (condition): … … 697 723 // list only faulted rows 698 724 psStringAppend(&query, " %s", " AND camProcessedExp.fault != 0"); 699 } 725 } 700 726 if (where->list && !faulted) { 701 727 // don't list faulted rows … … 705 731 // list only faulted rows 706 732 psStringAppend(&query, " %s", " WHERE camProcessedExp.fault != 0"); 707 } 733 } 708 734 if (!where->list && !faulted) { 709 735 // don't list faulted rows … … 711 737 } 712 738 psFree(where); 713 714 // order by cam_id so that the postage stamp parser can easliy find the 'latest' astrometry 715 psStringAppend(&query, " ORDER BY cam_id"); 739 if (where2) { 740 psStringAppend(&query, " %s", where2); 741 psFree(where2); 742 } 743 744 745 if (pstamp_order) { 746 // put runs in order of exposure id with newest chip Runs first 747 // The postage stamp parser depends on this behavior 748 psStringAppend(&query, " ORDER BY exp_id, cam_id DESC"); 749 } 716 750 717 751 // treat limit == 0 as "no limit" … … 766 800 if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) { 767 801 psFree(where); 768 psError(PXTOOLS_ERR_ DATA, false, "search parameters are required");802 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 769 803 return false; 770 804 } … … 779 813 psString query = pxDataGet("camtool_reset_faulted_runs.sql"); 780 814 if (!query) { 781 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");815 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 782 816 psFree(where); 783 817 return false; … … 811 845 psError(PS_ERR_UNKNOWN, false, "database error"); 812 846 } 813 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");847 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 814 848 psFree(where); 815 849 return false; … … 951 985 psString query = pxDataGet("camtool_pendingcleanuprun.sql"); 952 986 if (!query) { 953 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");987 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 954 988 return false; 955 989 } … … 1016 1050 psString query = pxDataGet("camtool_pendingcleanupexp.sql"); 1017 1051 if (!query) { 1018 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");1052 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1019 1053 return false; 1020 1054 } … … 1077 1111 psString query = pxDataGet("camtool_donecleanup.sql"); 1078 1112 if (!query) { 1079 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");1113 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1080 1114 return false; 1081 1115 } … … 1163 1197 psString query = pxDataGet(tables[i].sqlFilename); 1164 1198 if (!query) { 1165 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");1199 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1166 1200 return false; 1167 1201 }
Note:
See TracChangeset
for help on using the changeset viewer.
