Changeset 20903 for branches/bills_081204/ippTools/src/difftool.c
- Timestamp:
- Dec 4, 2008, 1:44:33 PM (18 years ago)
- File:
-
- 1 edited
-
branches/bills_081204/ippTools/src/difftool.c (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/bills_081204/ippTools/src/difftool.c
r20719 r20903 47 47 48 48 static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state); 49 static bool diffRunComplete(pxConfig *config); 49 50 50 51 # define MODECASE(caseName, func) \ … … 108 109 // required options 109 110 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); 110 PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false);111 111 PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", true, false); 112 112 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 113 113 PXOPT_LOOKUP_STR(reduction, config->args, "-reduction", false, false); 114 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", false, false); 114 115 115 116 // default … … 125 126 NULL, // dvodb 126 127 registered, 127 skycell_id,128 exp_id, 128 129 tess_id 129 130 ); … … 178 179 179 180 // optional 180 PXOPT_LOOKUP_S64(stack_id, config->args, "-stack_id", false, false); 181 PXOPT_LOOKUP_S64(warp_id, config->args, "-warp_id", false, false); 182 PXOPT_LOOKUP_STR(kind, config->args, "-kind", false, false); 183 184 // defaults to false 185 PXOPT_LOOKUP_BOOL(template, config->args, "-template", false); 186 187 // must provide either stack_id or warp_id but not BOTH 188 if (!(stack_id || warp_id)) { 189 psError(PS_ERR_UNKNOWN, true, "either -stack_id or -warp_id must be specified"); 190 return false; 191 } 192 if (stack_id && warp_id) { 193 psError(PS_ERR_UNKNOWN, true, "either -stack_id or -warp_id must be specified"); 194 return false; 195 } 196 197 // if a warp_id was provided we need to lookup the skycell_id and tess_id 198 // from the warpRun 199 psString skycell_id = NULL; 181 PXOPT_LOOKUP_S64(stack1, config->args, "-stack1", false, false); 182 PXOPT_LOOKUP_S64(stack2, config->args, "-stack2", false, false); 183 PXOPT_LOOKUP_S64(warp1, config->args, "-warp1", false, false); 184 PXOPT_LOOKUP_S64(warp2, config->args, "-warp2", false, false); 185 PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false); 186 187 // must provide either stack1 or warp1 but not BOTH 188 if (!(stack1 || warp1)) { 189 psError(PS_ERR_UNKNOWN, true, "either -stack1 or -warp1 must be specified"); 190 return false; 191 } 192 if (stack1 && warp1) { 193 psError(PS_ERR_UNKNOWN, true, "either -stack1 or -warp1 must be specified"); 194 return false; 195 } 196 // must provide either stack2 or warp2 but not BOTH 197 if (!(stack2 || warp2)) { 198 psError(PS_ERR_UNKNOWN, true, "either -stack2 or -warp2 must be specified"); 199 return false; 200 } 201 if (stack2 && warp2) { 202 psError(PS_ERR_UNKNOWN, true, "either -stack2 or -warp2 must be specified"); 203 return false; 204 } 205 206 // if a warp1 was provided we need to lookup the and tess_id from the diffRun 200 207 psString tess_id = NULL; 201 if (warp _id) {208 if (warp1) { 202 209 if (!p_psDBRunQuery(config->dbh, "SELECT * from diffRun WHERE diff_id = %" PRId64, diff_id)) { 203 210 psError(PS_ERR_UNKNOWN, false, "database error"); … … 217 224 218 225 diffRunRow *run = diffRunObjectFromMetadata(output->data[0]); 219 skycell_id = run->skycell_id;220 226 tess_id = run->tess_id; 221 227 } … … 228 234 if (!diffInputSkyfileInsert(config->dbh, 229 235 diff_id, 230 template, 231 stack_id ? stack_id : PS_MAX_S64, // defined or NULL 232 warp_id ? warp_id : PS_MAX_S64, // defined or NULL 236 warp1 ? warp1 : PS_MAX_S64, // defined or NULL 237 warp2 ? warp2 : PS_MAX_S64, // defined or NULL 238 stack1 ? stack1 : PS_MAX_S64, // defined or NULL 239 stack2 ? stack2 : PS_MAX_S64, // defined or NULL 233 240 skycell_id, 234 tess_id, 235 kind 241 tess_id 236 242 )) { 237 243 if (!psDBRollback(config->dbh)) { … … 300 306 PXOPT_COPY_STR(config->args, where, "-skycell_id", "skycell_id", "=="); 301 307 PXOPT_COPY_STR(config->args, where, "-tess_id", "tess_id", "=="); 302 PXOPT_COPY_STR(config->args, where, "-kind", "kind", "==");303 308 304 309 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); … … 349 354 } 350 355 351 if (!p_psDBRunQuery(config->dbh, query, whereClause, whereClause )) {356 if (!p_psDBRunQuery(config->dbh, query, whereClause, whereClause, whereClause, whereClause)) { 352 357 psError(PS_ERR_UNKNOWN, false, "database error"); 353 358 psFree(whereClause); … … 471 476 472 477 PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", true, false); // required 478 PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false); 473 479 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 474 480 PXOPT_LOOKUP_STR(uri, config->args, "-uri", (code == 0), false); … … 503 509 if (!diffSkyfileInsert(config->dbh, 504 510 diff_id, 511 skycell_id, 505 512 uri, 506 513 path_base, … … 533 540 } 534 541 535 if (! setdiffRunState(config, diff_id, "full")) {542 if (!diffRunComplete(config)) { 536 543 if (!psDBRollback(config->dbh)) { 537 544 psError(PS_ERR_UNKNOWN, false, "database error"); … … 546 553 return false; 547 554 } 555 548 556 549 557 return true; … … 762 770 psS64 template_warp_id, // Warp identifier for template image, PS_MAX_S64 for none 763 771 psS64 template_stack_id, // Stack identifier for template image, PS_MAX_S64 for none 772 psS64 exp_id, // exposure id for input_warp_id (if defined) 764 773 pxConfig *config // Configuration 765 774 ) … … 791 800 NULL, // dvodb 792 801 registered, 793 skycell_id,802 exp_id, 794 803 tess_id 795 804 ); … … 817 826 if (!diffInputSkyfileInsert(config->dbh, 818 827 run->diff_id, 819 true, 828 input_warp_id, 829 template_warp_id, 830 input_stack_id, 820 831 template_stack_id, 821 template_warp_id,822 832 skycell_id, 823 tess_id, 824 NULL // kind 825 )) { 826 if (!psDBRollback(config->dbh)) { 827 psError(PS_ERR_UNKNOWN, false, "database error"); 828 } 829 psError(PS_ERR_UNKNOWN, false, "database error"); 830 return false; 831 } 832 833 // Input 834 if (!diffInputSkyfileInsert(config->dbh, 835 run->diff_id, 836 false, 837 input_stack_id, 838 input_warp_id, 839 skycell_id, 840 tess_id, 841 NULL // kind 833 tess_id 842 834 )) { 843 835 if (!psDBRollback(config->dbh)) { … … 887 879 PXOPT_LOOKUP_S64(input_warp_id, config->args, "-input_warp_id", false, false); 888 880 PXOPT_LOOKUP_S64(input_stack_id, config->args, "-input_stack_id", false, false); 881 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", false, false); 889 882 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 890 883 … … 906 899 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 907 900 "No input has been defined (-input_stack_id or -input_warp_id)"); 901 return false; 902 } 903 if (input_warp_id && !exp_id) { 904 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 905 "-exp_id is required with -input_warp_id."); 908 906 return false; 909 907 } … … 916 914 template_warp_id ? template_warp_id : PS_MAX_S64, 917 915 template_stack_id ? template_stack_id : PS_MAX_S64, 916 exp_id, 918 917 config)) { 919 918 psError(PS_ERR_UNKNOWN, false, "failed to create populated diffRun"); … … 945 944 PXOPT_COPY_STR(config->args, warpWhere, "-filter", "rawExp.filter", "=="); 946 945 PXOPT_COPY_STR(config->args, warpWhere, "-warp_label", "warpRun.label", "=="); 947 PXOPT_COPY_STR(config->args, warpWhere, "-kind", "warpsToDiff.kind", "==");948 946 PXOPT_COPY_F32(config->args, warpWhere, "-good_frac", "warpSkyfile.good_frac", ">="); 949 947 PXOPT_COPY_STR(config->args, stackWhere, "-stack_label", "stackRun.label", "=="); … … 1048 1046 continue; 1049 1047 } 1048 psS64 exp_id = psMetadataLookupS64(&mdok, row, "exp_id"); 1049 if (!mdok) { 1050 psWarning("exp_id not found --- ignoring row %ld", i); 1051 continue; 1052 } 1050 1053 1051 1054 if (!populatedrun(list, workdir, skycell_id, tess_id, label, reduction, warp_id, 1052 PS_MAX_S64, PS_MAX_S64, stack_id, config)) {1055 PS_MAX_S64, PS_MAX_S64, stack_id, exp_id, config)) { 1053 1056 psWarning("Unable to add run for %s,%s,%" PRId64 ",%" PRId64, skycell_id, tess_id, 1054 1057 warp_id, stack_id); … … 1274 1277 } 1275 1278 1279 static bool diffRunComplete(pxConfig *config) 1280 { 1281 PS_ASSERT_PTR_NON_NULL(config, false); 1282 1283 // look for completed diffRuns 1284 psString query = pxDataGet("difftool_completed_runs.sql"); 1285 if (!query) { 1286 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1287 return false; 1288 } 1289 1290 if (!p_psDBRunQuery(config->dbh, query)) { 1291 psError(PS_ERR_UNKNOWN, false, "database error"); 1292 psFree(query); 1293 return false; 1294 } 1295 psFree(query); 1296 1297 psArray *output = p_psDBFetchResult(config->dbh); 1298 if (!output) { 1299 psError(PS_ERR_UNKNOWN, false, "database error"); 1300 return false; 1301 } 1302 if (!psArrayLength(output)) { 1303 psTrace("difftool", PS_LOG_INFO, "no rows found"); 1304 psFree(output); 1305 return true; 1306 } 1307 for (long i = 0; i < psArrayLength(output); i++) { 1308 psMetadata *row = output->data[i]; 1309 1310 psS64 diff_id = psMetadataLookupS64(NULL, row, "diff_id"); 1311 1312 // set diffRun.state to 'stop' 1313 if (!setdiffRunState(config, diff_id, "full")) { 1314 psError(PS_ERR_UNKNOWN, false, "failed to change diffRun.state for diff_id: %" PRId64, 1315 diff_id); 1316 psFree(output); 1317 return false; 1318 } 1319 } 1320 1321 return true; 1322 } 1323
Note:
See TracChangeset
for help on using the changeset viewer.
