Changeset 25870 for branches/eam_branches/20090820/ippTools/src/difftool.c
- Timestamp:
- Oct 18, 2009, 10:23:28 AM (17 years ago)
- Location:
- branches/eam_branches/20090820
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippTools/src/difftool.c (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090820
-
branches/eam_branches/20090820/ippTools/src/difftool.c
r25766 r25870 51 51 52 52 static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state, psS64 magicked); 53 static bool change_skyfile_data_state(pxConfig *config, psString data_state, psString run_state); 54 static bool tocleanedskyfileMode(pxConfig *config); 55 static bool topurgedskyfileMode(pxConfig *config); 56 static bool toscrubbedskyfileMode(pxConfig *config); 57 58 53 59 54 60 # define MODECASE(caseName, func) \ … … 88 94 MODECASE(DIFFTOOL_MODE_EXPORTRUN, exportrunMode); 89 95 MODECASE(DIFFTOOL_MODE_IMPORTRUN, importrunMode); 96 MODECASE(DIFFTOOL_MODE_TOCLEANEDSKYFILE, tocleanedskyfileMode); 97 MODECASE(DIFFTOOL_MODE_TOPURGEDSKYFILE, topurgedskyfileMode); 98 MODECASE(DIFFTOOL_MODE_TOSCRUBBEDSKYFILE, toscrubbedskyfileMode); 99 90 100 default: 91 101 psAbort("invalid option (this should not happen)"); … … 115 125 116 126 // required options 117 PXOPT_LOOKUP_STR(workdir, config->args, "- workdir", true, false);127 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", true, false); 118 128 PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", true, false); 119 129 PXOPT_LOOKUP_BOOL(bothways, config->args, "-bothways", false); 120 130 PXOPT_LOOKUP_BOOL(exposure, config->args, "-exposure", false); 121 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 122 PXOPT_LOOKUP_STR(reduction, config->args, "-reduction", false, false); 131 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 132 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); 133 PXOPT_LOOKUP_STR(dist_group, config->args, "-set_dist_group", false, false); 134 PXOPT_LOOKUP_STR(reduction, config->args, "-rset_eduction", false, false); 135 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 123 136 124 137 // default … … 131 144 workdir, 132 145 label, 146 data_group ? data_group : label, 147 dist_group, 133 148 reduction, 134 149 NULL, // dvodb … … 137 152 bothways, 138 153 exposure, 139 false 154 false, 155 note 140 156 ); 141 157 if (!run) { … … 168 184 PS_ASSERT_PTR_NON_NULL(config, false); 169 185 186 psMetadata *where = psMetadataAlloc(); 187 188 PXOPT_COPY_S64(config->args, where, "-diff_id", "stack_id", "=="); 189 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 190 PXOPT_COPY_STR(config->args, where, "-state", "state", "=="); 191 if (!psListLength(where->list)) { 192 psFree(where); 193 psError(PXTOOLS_ERR_DATA, false, "search parameters are required"); 194 return false; 195 } 196 197 psString query = psStringCopy("UPDATE diffRun"); 198 199 // pxUpdateRun gets parameters from config->args and updates 200 bool result = pxUpdateRun(config, where, &query, "diffRun", true); 201 202 psFree(query); 203 psFree(where); 204 205 return result; 206 207 #ifdef notdef 170 208 // required options 171 PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", true, false);209 PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", false, false); 172 210 PXOPT_LOOKUP_STR(state, config->args, "-state", true, false); 173 174 if (state) { 211 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 212 213 // Copy of my hacky work around from stacktool.c 214 if ((state)&&(diff_id)) { 175 215 // set detRun.state to state 176 216 return setdiffRunState(config, diff_id, state, false); 177 217 } 178 218 179 return true; 219 if ((state)&&(label)) { 220 return setdiffRunStateByLabel(config, label, state); 221 } 222 223 psError(PS_ERR_UNKNOWN, false, "Required options not found."); 224 225 return false; 226 #endif 180 227 } 181 228 … … 692 739 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 693 740 694 PXOPT_LOOKUP_U64(magicked, config->args, "-magicked", false, false); 695 PXOPT_LOOKUP_BOOL(destreaked, config->args, "-destreaked", false);696 PXOPT_LOOKUP_BOOL(not_destreaked, config->args, "-not_destreaked", false);697 741 742 psString where2 = NULL; 743 pxmagicAddWhere(config, &where2, "diffSkyfile"); 744 pxspaceAddWhere(config, &where2, template ? "rawTemplate" : "rawInput"); 698 745 psString query = pxDataGet("difftool_skyfile.sql"); 699 746 if (!query) { … … 706 753 psStringAppend(&query, " WHERE %s", whereClause); 707 754 psFree(whereClause); 755 } else if (where2) { 756 psStringAppend(&query, " WHERE diffRun.diff_id is not null %s", where2); 708 757 } else if (!all) { 709 758 psError(PXTOOLS_ERR_DATA, true, "search parameters or -all are required"); 759 return false; 710 760 } 711 761 psFree(where); 712 713 if (not_destreaked) {714 if (destreaked) {715 psError(PXTOOLS_ERR_DATA, true, "providing -not_destreaked and -destreaked makes no sense");716 return false;717 }718 if (magicked) {719 psError(PXTOOLS_ERR_DATA, true, "providing -not_destreaked and -magicked makes no sense");720 return false;721 }722 psStringAppend(&query, " AND diffSkyfile.magicked = 0");723 }724 if (destreaked) {725 psStringAppend(&query, " AND diffSkyfile.magicked != 0");726 }727 728 762 729 763 // treat limit == 0 as "no limit" … … 878 912 } 879 913 880 char *query = "UPDATE diffRun SET state = '%s', magicked = %" PRId64 " WHERE diff_id = %"PRId64; 881 882 if (!p_psDBRunQueryF(config->dbh, query, state, magicked, diff_id)) { 914 if (magicked) { 915 char *query = "UPDATE diffRun SET state = '%s', magicked = %" PRId64 " WHERE diff_id = %"PRId64; 916 917 if (!p_psDBRunQueryF(config->dbh, query, state, magicked, diff_id)) { 883 918 psError(PS_ERR_UNKNOWN, false, 884 919 "failed to change state for diff_id %"PRId64, diff_id); 885 920 return false; 886 } 887 921 } 922 } 923 else { 924 char *query = "UPDATE diffRun SET state = '%s' WHERE diff_id = %"PRId64; 925 926 if (!p_psDBRunQueryF(config->dbh, query, state, diff_id)) { 927 psError(PS_ERR_UNKNOWN, false, 928 "failed to change state for diff_id %"PRId64, diff_id); 929 return false; 930 } 931 } 932 888 933 return true; 889 934 } 935 936 937 #ifdef notdef 938 static bool setdiffRunStateByLabel(pxConfig *config, const char *label, const char *state) { 939 PS_ASSERT_PTR_NON_NULL(state,false); 940 941 // check that state is a valid string value 942 if (!pxIsValidState(state)) { 943 psError(PS_ERR_UNKNOWN, false, "invalid diffRun state: %s", state); 944 return false; 945 } 946 947 char *query = "UPDATE diffRun SET state = '%s' WHERE label = '%s'"; 948 if (!p_psDBRunQueryF(config->dbh,query,state,label)) { 949 psError(PS_ERR_UNKNOWN, false, 950 "failed to change state for label %s", label); 951 return(false); 952 } 953 954 return true; 955 } 956 #endif 890 957 891 958 // Generate a single populated run … … 895 962 const char *tess_id, // Tessellation identifier 896 963 const char *label, // label 964 const char *data_group, // data_group 965 const char *dist_group, // dist_group 897 966 const char *reduction, // reduction 967 const char *note, // note 898 968 psS64 input_warp_id, // Warp identifier for input image, PS_MAX_S64 for none 899 969 psS64 input_stack_id, // Stack identifier for input image, PS_MAX_S64 for none … … 926 996 workdir, 927 997 label, 998 data_group ? data_group : label, 999 dist_group, 928 1000 reduction, 929 1001 NULL, // dvodb … … 932 1004 false, 933 1005 false, 934 0 // magicked 1006 0, // magicked 1007 note 935 1008 ); 936 1009 … … 1006 1079 PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", true, false); // required options 1007 1080 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 1081 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); 1082 PXOPT_LOOKUP_STR(dist_group, config->args, "-set_dist_group", false, false); 1008 1083 PXOPT_LOOKUP_STR(reduction, config->args, "-reduction", false, false); 1009 1084 PXOPT_LOOKUP_S64(template_warp_id, config->args, "-template_warp_id", false, false); … … 1012 1087 PXOPT_LOOKUP_S64(input_stack_id, config->args, "-input_stack_id", false, false); 1013 1088 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1089 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 1014 1090 1015 1091 if (template_stack_id && template_warp_id) { … … 1035 1111 psArray *list = psArrayAllocEmpty(16); // List of runs, to print 1036 1112 1037 if (!populatedrun(list, workdir, skycell_id, tess_id, label, reduction,1113 if (!populatedrun(list, workdir, skycell_id, tess_id, label, data_group ? data_group : label, dist_group, reduction, note, 1038 1114 input_warp_id ? input_warp_id : PS_MAX_S64, 1039 1115 input_stack_id ? input_stack_id : PS_MAX_S64, … … 1074 1150 PXOPT_COPY_STR(config->args, stackWhere, "-stack_label", "stackRun.label", "=="); 1075 1151 1076 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); // required options 1077 PXOPT_LOOKUP_STR(reduction, config->args, "-reduction", false, false); // option 1078 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); // option 1079 PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false); 1152 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", true, false); // required option 1153 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false); // option 1154 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); // option 1155 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); 1156 PXOPT_LOOKUP_STR(dist_group, config->args, "-set_dist_group", false, false); 1157 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 1158 PXOPT_LOOKUP_TIME(registered, config->args, "-set_registered", false, false); 1159 1080 1160 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1081 1161 PXOPT_LOOKUP_BOOL(newTemplates, config->args, "-new-templates", false); … … 1313 1393 workdir, 1314 1394 label, 1395 data_group ? data_group : label, 1396 dist_group, 1315 1397 reduction, 1316 1398 NULL, // dvodb … … 1319 1401 false, // bothways 1320 1402 true, // exposure 1321 0 // magicked 1403 0, // magicked 1404 note 1322 1405 ); 1323 1406 … … 1388 1471 } 1389 1472 1390 if ( !diffRunPrintObjects(stdout, list, !simple)) {1473 if (numGood && !diffRunPrintObjects(stdout, list, !simple)) { 1391 1474 psError(PS_ERR_UNKNOWN, false, "failed to print object"); 1392 1475 psFree(list); … … 1469 1552 1470 1553 // Settings to apply to defined run 1471 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); // required options 1472 PXOPT_LOOKUP_STR(reduction, config->args, "-reduction", false, false); // option 1473 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); // option 1474 PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false); 1554 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", true, false); // required options 1555 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false); // option 1556 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); // option 1557 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); // option 1558 PXOPT_LOOKUP_STR(dist_group, config->args, "-set_dist_group", false, false); // option 1559 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); // option 1560 PXOPT_LOOKUP_TIME(registered, config->args, "-set_registered", false, false); 1561 1475 1562 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1476 1563 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); … … 1656 1743 } 1657 1744 1658 diffRunRow *run = diffRunRowAlloc(0, "reg", workdir, label, reduction, NULL, registered,1659 tess_id, true, true, false ); // Run to insert1745 diffRunRow *run = diffRunRowAlloc(0, "reg", workdir, label, data_group ? data_group : label, dist_group, reduction, NULL, registered, 1746 tess_id, true, true, false, note); // Run to insert 1660 1747 if (!diffRunInsertObject(config->dbh, run)) { 1661 1748 psError(PS_ERR_UNKNOWN, false, "database error"); … … 1738 1825 1739 1826 psMetadata *where = psMetadataAlloc(); 1740 pxAddLabelSearchArgs (config, where, "-label", " diffRun.label", "==");1827 pxAddLabelSearchArgs (config, where, "-label", "label", "=="); 1741 1828 1742 1829 psString query = pxDataGet("difftool_pendingcleanuprun.sql"); … … 1760 1847 } 1761 1848 1849 // fprintf(stderr,"%s",query); 1762 1850 if (!p_psDBRunQuery(config->dbh, query)) { 1763 1851 psError(PS_ERR_UNKNOWN, false, "database error"); … … 1931 2019 1932 2020 return true; 2021 } 2022 2023 static bool change_skyfile_data_state(pxConfig *config, psString data_state, psString run_state) { 2024 PS_ASSERT_PTR_NON_NULL(config, false); 2025 2026 // diff_id, skycell_id are required 2027 PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", true, false); 2028 PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false); 2029 2030 psString query = pxDataGet("difftool_change_skyfile_data_state.sql"); 2031 2032 if (!psDBTransaction(config->dbh)) { 2033 psError(PS_ERR_UNKNOWN, false, "database error"); 2034 return(false); 2035 } 2036 2037 // Uses the unconstrained (diffRun.state [NEED NOT EQUAL] run_state) version from warptool.c 2038 2039 if (!p_psDBRunQueryF(config->dbh, query, data_state, diff_id, skycell_id)) { 2040 psError(PS_ERR_UNKNOWN, false, "database error"); 2041 // rollback 2042 if (!psDBRollback(config->dbh)) { 2043 psError(PS_ERR_UNKNOWN, false, "database error"); 2044 } 2045 psError(PS_ERR_UNKNOWN, false, "database error"); 2046 return(false); 2047 } 2048 psFree(query); 2049 2050 query = pxDataGet("difftool_change_run_state.sql"); 2051 if (!p_psDBRunQueryF(config->dbh, query, data_state, diff_id, data_state)) { 2052 // rollback 2053 if (!psDBRollback(config->dbh)) { 2054 psError(PS_ERR_UNKNOWN, false, "database error"); 2055 } 2056 psError(PS_ERR_UNKNOWN, false, "database error"); 2057 return(false); 2058 } 2059 2060 if (!psDBCommit(config->dbh)) { 2061 psError(PS_ERR_UNKNOWN, false, "database error"); 2062 return(false); 2063 } 2064 2065 return(true); 2066 } 2067 2068 static bool tocleanedskyfileMode(pxConfig *config) { 2069 return change_skyfile_data_state(config, "cleaned","goto_cleaned"); 2070 } 2071 static bool topurgedskyfileMode(pxConfig *config) { 2072 return change_skyfile_data_state(config, "purged", "goto_purged"); 2073 } 2074 static bool toscrubbedskyfileMode(pxConfig *config) { 2075 return change_skyfile_data_state(config, "scrubbed", "goto_scrubbed"); 1933 2076 } 1934 2077 … … 1956 2099 } 1957 2100 2101 if (!pxExportVersion(config, f)) { 2102 psError(PS_ERR_UNKNOWN, false, "failed to write dbversion output file"); 2103 return false; 2104 } 1958 2105 psMetadata *where = psMetadataAlloc(); 1959 2106 PXOPT_COPY_S64(config->args, where, "-diff_id", "diff_id", "=="); … … 2047 2194 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 2048 2195 2049 fprintf (stdout, "---- input ----\n"); 2196 #ifdef notdef 2197 fprintf (stderr, "---- input ----\n"); 2050 2198 psMetadataPrint (stderr, input, 1); 2051 2199 #endif 2200 2201 if (!pxCheckImportVersion(config, input)) { 2202 psError(PS_ERR_UNKNOWN, false, "pxCheckImportVersion failed"); 2203 return false; 2204 } 2052 2205 psMetadataItem *item = psMetadataLookup (input, "diffRun"); 2053 2206 psAssert (item, "entry not in input?");
Note:
See TracChangeset
for help on using the changeset viewer.
