Changeset 23786
- Timestamp:
- Apr 9, 2009, 4:01:21 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/flatcorr.c (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/flatcorr.c
r23688 r23786 117 117 } 118 118 119 // require the camera to be defined: this analysis does not make sense 119 // require the camera to be defined: this analysis does not make sense 120 120 // across multiple cameras 121 121 PXOPT_LOOKUP_STR(camera, config->args, "-inst", true, false); … … 169 169 170 170 if (pretend) { 171 for (long i = 0; i < psArrayLength(output); i++) {172 // negative simple so the default is true173 if (!ippdbPrintMetadataRaw(stdout, output->data[i], !simple)) {174 psError(PS_ERR_UNKNOWN, false, "failed to print array");175 psFree(output);176 return false;177 }178 }171 for (long i = 0; i < psArrayLength(output); i++) { 172 // negative simple so the default is true 173 if (!ippdbPrintMetadataRaw(stdout, output->data[i], !simple)) { 174 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 175 psFree(output); 176 return false; 177 } 178 } 179 179 psFree(output); 180 180 return true; … … 191 191 // create a new flatcorrRun 192 192 if (!flatcorrRunInsert( 193 config->dbh,193 config->dbh, 194 194 0, // corr_id 195 det_type,195 det_type, 196 196 dvodb, 197 camera,198 telescope,199 NULL,197 camera, 198 telescope, 199 NULL, 200 200 filter, 201 201 "reg", // state … … 203 203 label, 204 204 reduction, 205 region,206 NULL,207 0205 region, 206 NULL, 207 0 208 208 )) { 209 209 if (!psDBRollback(config->dbh)) { … … 304 304 // create a new flatcorrRun 305 305 flatcorrRunRow *row = flatcorrRunRowAlloc( 306 0, // corr_id307 det_type,308 dvodb,309 camera,310 telescope,311 NULL,312 filter,313 "reg", // state314 workdir,315 label,316 reduction,317 region,318 NULL, // hostname319 0 // fault306 0, // corr_id 307 det_type, 308 dvodb, 309 camera, 310 telescope, 311 NULL, 312 filter, 313 "reg", // state 314 workdir, 315 label, 316 reduction, 317 region, 318 NULL, // hostname 319 0 // fault 320 320 ); 321 321 … … 328 328 return false; 329 329 } 330 330 331 331 // figure out the ID of the flatcorrRun we just created 332 332 psS64 corr_id = psDBLastInsertID(config->dbh); … … 365 365 psString query = pxDataGet("flatcorr_dropchip.sql"); 366 366 if (!query) { 367 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");368 return false;367 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 368 return false; 369 369 } 370 370 … … 390 390 psString query = pxDataGet("flatcorr_chiprundone.sql"); 391 391 if (!query) { 392 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");393 return false;392 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 393 return false; 394 394 } 395 395 396 396 // treat limit == 0 as "no limit" 397 397 if (limit) { 398 psString limitString = psDBGenerateLimitSQL(limit);399 psStringAppend(&query, " %s", limitString);400 psFree(limitString);398 psString limitString = psDBGenerateLimitSQL(limit); 399 psStringAppend(&query, " %s", limitString); 400 psFree(limitString); 401 401 } 402 402 … … 459 459 // queue the exp 460 460 if (!pxcamQueueByChipID( 461 config,462 row->chip_id,463 row->workdir,464 row->label,465 row->reduction,466 row->expgroup,467 row->dvodb,468 row->tess_id,469 "camera")) {461 config, 462 row->chip_id, 463 row->workdir, 464 row->label, 465 row->reduction, 466 row->expgroup, 467 row->dvodb, 468 row->tess_id, 469 "camera")) { 470 470 if (!psDBRollback(config->dbh)) { 471 471 psError(PS_ERR_UNKNOWN, false, "database error"); … … 478 478 } 479 479 480 // figure out the ID of the flatcorrRun we just created481 psS64 cam_id = psDBLastInsertID(config->dbh);482 483 // add the camRun entry to the flatcorrCamLink table (include is TRUE)480 // figure out the ID of the flatcorrRun we just created 481 psS64 cam_id = psDBLastInsertID(config->dbh); 482 483 // add the camRun entry to the flatcorrCamLink table (include is TRUE) 484 484 if (!flatcorrCamLinkInsert(config->dbh, corr_id, row->chip_id, cam_id, 1)) { 485 485 if (!psDBRollback(config->dbh)) { … … 489 489 return false; 490 490 } 491 491 492 492 psFree(row); 493 493 } … … 513 513 psString query = pxDataGet("flatcorr_dropcamera.sql"); 514 514 if (!query) { 515 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");516 return false;515 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 516 return false; 517 517 } 518 518 … … 537 537 psString query = pxDataGet("flatcorr_pendingprocess.sql"); 538 538 if (!query) { 539 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");540 return false;539 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 540 return false; 541 541 } 542 542 543 543 // treat limit == 0 as "no limit" 544 544 if (limit) { 545 psString limitString = psDBGenerateLimitSQL(limit);546 psStringAppend(&query, " %s", limitString);547 psFree(limitString);545 psString limitString = psDBGenerateLimitSQL(limit); 546 psStringAppend(&query, " %s", limitString); 547 psFree(limitString); 548 548 } 549 549 … … 566 566 567 567 if (!ippdbPrintMetadatas(stdout, output, "flatcorrPending", !simple)) { 568 psError(PS_ERR_UNKNOWN, false, "failed to print array");569 psFree(output);570 return false;568 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 569 psFree(output); 570 return false; 571 571 } 572 572 … … 588 588 // treat limit == 0 as "no limit" 589 589 if (limit) { 590 psString limitString = psDBGenerateLimitSQL(limit);591 psStringAppend(&query, " %s", limitString);592 psFree(limitString);590 psString limitString = psDBGenerateLimitSQL(limit); 591 psStringAppend(&query, " %s", limitString); 592 psFree(limitString); 593 593 } 594 594 … … 611 611 612 612 if (!ippdbPrintMetadatas(stdout, output, "flatcorrPending", !simple)) { 613 psError(PS_ERR_UNKNOWN, false, "failed to print array");614 psFree(output);615 return false;613 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 614 psFree(output); 615 return false; 616 616 } 617 617 … … 628 628 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 629 629 PXOPT_LOOKUP_BOOL(limit, config->args, "-limit", false); 630 630 631 631 psMetadata *where = psMetadataAlloc(); 632 632 PXOPT_COPY_S64(config->args, where, "-chip_id", "chipProcessedImfile.chip_id", "=="); … … 647 647 // treat limit == 0 as "no limit" 648 648 if (limit) { 649 psString limitString = psDBGenerateLimitSQL(limit);650 psStringAppend(&query, " %s", limitString);651 psFree(limitString);649 psString limitString = psDBGenerateLimitSQL(limit); 650 psStringAppend(&query, " %s", limitString); 651 psFree(limitString); 652 652 } 653 653 … … 670 670 671 671 if (!ippdbPrintMetadatas(stdout, output, "flatcorrPending", !simple)) { 672 psError(PS_ERR_UNKNOWN, false, "failed to print array");673 psFree(output);674 return false;672 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 673 psFree(output); 674 return false; 675 675 } 676 676 … … 685 685 PXOPT_LOOKUP_S64(corr_id, config->args, "-corr_id", true, false); 686 686 PXOPT_LOOKUP_STR(hostname, config->args, "-hostname", false, false); 687 PXOPT_LOOKUP_S16( fault, config->args, "-fault", false, false);687 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 688 688 689 689 char *query = "UPDATE flatcorrRun SET state = 'full', hostname = '%s', fault = '%hd' WHERE corr_id = %" PRId64; 690 690 691 if (!p_psDBRunQueryF(config->dbh, query, hostname, fault, corr_id)) {691 if (!p_psDBRunQueryF(config->dbh, query, hostname, code, corr_id)) { 692 692 psError(PS_ERR_UNKNOWN, false, "failed to change state for corr_id %" PRId64, corr_id); 693 693 return false; … … 721 721 722 722 // check that state is a valid string value 723 if (!strcmp(state, "reg") && 724 !strcmp(state, "new") && 725 !strcmp(state, "full"))723 if (!strcmp(state, "reg") && 724 !strcmp(state, "new") && 725 !strcmp(state, "full")) 726 726 { 727 727 psError(PS_ERR_UNKNOWN, false, "invalid state: %s", state); … … 745 745 char sqlFilename[80]; 746 746 } ExportTable; 747 747 748 748 int numExportTables = 3; 749 749 … … 761 761 762 762 psMetadata *where = psMetadataAlloc(); 763 PXOPT_COPY_S64(config->args, where, "-co or_id", "corr_id", "==");763 PXOPT_COPY_S64(config->args, where, "-corr_id", "corr_id", "=="); 764 764 765 765 ExportTable tables [] = { … … 825 825 unsigned int nFail; 826 826 psMetadataItem *item, *entry; 827 827 828 828 int numImportTables = 3; 829 829 830 830 char tables[3] [80] = {"flatcorrRun", "flatcorrCamLink", "flatcorrChipLink"}; 831 831 832 832 PS_ASSERT_PTR_NON_NULL(config, NULL); 833 833 834 834 PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false); 835 835 … … 843 843 psAssert (item, "entry not in input?"); 844 844 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 845 845 846 846 entry = psListGet (item->data.list, 0); 847 847 assert (entry); 848 848 assert (entry->type == PS_DATA_METADATA); 849 849 850 850 switch (i) { 851 851 case 0: … … 857 857 // psMetadataPrint (stderr, entry->data.md, 1); 858 858 break; 859 } 859 } 860 860 case 1: 861 861 {
Note:
See TracChangeset
for help on using the changeset viewer.
