Changeset 31385 for branches/czw_branch/20110406/ippTools/src/laptool.c
- Timestamp:
- Apr 26, 2011, 6:38:11 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20110406/ippTools/src/laptool.c
r31338 r31385 1 1 /* 2 * reproctool.c2 * laptool.c 3 3 */ 4 4 … … 13 13 #include "pxtools.h" 14 14 #include "pxdata.h" 15 #include " reproctool.h"15 #include "laptool.h" 16 16 17 17 … … 38 38 psLibInit(NULL); 39 39 40 pxConfig *config = reproctoolConfig(NULL, argc, argv);40 pxConfig *config = laptoolConfig(NULL, argc, argv); 41 41 if (!config) { 42 42 psError(PXTOOLS_ERR_CONFIG, false, "failed to configure"); … … 45 45 46 46 switch (config->mode) { 47 MODECASE( REPROCTOOL_MODE_DEFINERUN, definerunMode);48 MODECASE( REPROCTOOL_MODE_PENDINGRUN, pendingrunMode);49 MODECASE( REPROCTOOL_MODE_UPDATERUN, updaterunMode);50 51 MODECASE( REPROCTOOL_MODE_PENDINGCHIPEXP, pendingchipexpMode);52 MODECASE( REPROCTOOL_MODE_PENDINGQUICKSTACK,pendingquickstackMode);53 MODECASE( REPROCTOOL_MODE_PENDINGDIFF, pendingdiffMode);54 MODECASE( REPROCTOOL_MODE_PENDINGFINALSTACK,pendingfinalstackMode);55 MODECASE( REPROCTOOL_MODE_UPDATEEXP, updateexpMode);47 MODECASE(LAPTOOL_MODE_DEFINERUN, definerunMode); 48 MODECASE(LAPTOOL_MODE_PENDINGRUN, pendingrunMode); 49 MODECASE(LAPTOOL_MODE_UPDATERUN, updaterunMode); 50 51 MODECASE(LAPTOOL_MODE_PENDINGCHIPEXP, pendingchipexpMode); 52 MODECASE(LAPTOOL_MODE_PENDINGQUICKSTACK,pendingquickstackMode); 53 MODECASE(LAPTOOL_MODE_PENDINGDIFF, pendingdiffMode); 54 MODECASE(LAPTOOL_MODE_PENDINGFINALSTACK,pendingfinalstackMode); 55 MODECASE(LAPTOOL_MODE_UPDATEEXP, updateexpMode); 56 56 default: 57 57 psAbort("invalid option (this should not happen)"); 58 58 } 59 psTrace(" reproctool", 9, "Attempting to free config\n");59 psTrace("laptool", 9, "Attempting to free config\n"); 60 60 psFree(config); 61 61 pmConfigDone(); … … 86 86 87 87 // Insert the run 88 if (! reprocRunInsert(config->dbh,89 NULL, // re_id88 if (!lapRunInsert(config->dbh, 89 NULL, // lap_id 90 90 projection_cell, 91 91 tess_id, … … 105 105 return false; 106 106 } 107 psS64 re_id = psDBLastInsertID(config->dbh);107 psS64 lap_id = psDBLastInsertID(config->dbh); 108 108 109 109 110 110 // Find the input exposures 111 psString query = pxDataGet(" reproctool_definerun.sql");111 psString query = pxDataGet("laptool_definerun.sql"); 112 112 if (!query) { 113 113 psError(PXTOOL_ERR_SYS, false, "failed to retrieve SQL statement"); … … 135 135 } 136 136 if (!psArrayLength(output)) { 137 psTrace(" reproctool", PS_LOG_INFO, "no rows found");137 psTrace("laptool", PS_LOG_INFO, "no rows found"); 138 138 psFree(output); 139 139 return(true); … … 145 145 psMetadata *row = output->data[i]; // Row from select 146 146 bool status; 147 reprocExpRow *reExp = reprocExpObjectFromMetadata(row);148 reExp-> re_id = re_id;149 150 if (! reprocExpInsertObject(config->dbh,reExp)) {147 lapExpRow *reExp = lapExpObjectFromMetadata(row); 148 reExp->lap_id = lap_id; 149 150 if (!lapExpInsertObject(config->dbh,reExp)) { 151 151 if (!psDBRollback(config->dbh)) { 152 152 psError(PS_ERR_UNKNOWN, false, "database error"); … … 169 169 170 170 psmetadata *where = psMetadataAlloc(); 171 PXOPT_COPY_S64(config->args, where, "- re_id", "re_id", "==");171 PXOPT_COPY_S64(config->args, where, "-lap_id", "lap_id", "=="); 172 172 PXOPT_COPY_STR(config->args, where, "-projection_cell", "projection_cell", "=="); 173 173 174 psString query = pxDataGet(" reproctool_pendingrun.sql");174 psString query = pxDataGet("laptool_pendingrun.sql"); 175 175 if (!query) { 176 176 psError(PXTOOL_ERR_SYS, false, "failed to retrieve SQL statement"); … … 205 205 } 206 206 if (!psArrayLength(output)) { 207 psTrace(" reproctool", PS_LOG_INFO, "no rows found");208 psFree(output); 209 return(true); 210 } 211 212 if (!ippdbPrintMetadatas(stdout, output, " reprocExp", !simple)) {207 psTrace("laptool", PS_LOG_INFO, "no rows found"); 208 psFree(output); 209 return(true); 210 } 211 212 if (!ippdbPrintMetadatas(stdout, output, "lapExp", !simple)) { 213 213 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 214 214 psFree(output); … … 225 225 226 226 psMetadata *where = psMetadataAlloc(); 227 PXOPT_LOOKUP_S64( re_id, config->args, "-re_id", true, false);227 PXOPT_LOOKUP_S64(lap_id, config->args, "-lap_id", true, false); 228 228 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 229 229 PXOPT_LOOKUP_STR(set_state, config->args, "-set_state", false, false); … … 235 235 236 236 psMetadata *where = psMetadataAlloc(); 237 PXOPT_COPY_S64(config->args, where, "- re_id", "re_id", "==");237 PXOPT_COPY_S64(config->args, where, "-lap_id", "lap_id", "=="); 238 238 239 239 // Set a fault 240 240 if (fault != INT16_MAX) { 241 241 // this is fairly dangerous : can set all if the where is not set... 242 if (!pxSetFaultCode(config->dbh, " reprocRun", where, fault, 0)) {242 if (!pxSetFaultCode(config->dbh, "lapRun", where, fault, 0)) { 243 243 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); 244 244 psFree (where); … … 255 255 // Deactivate exposures 256 256 257 psString query = pxDataGet(" reproctool_updaterun_deactivate.sql");257 psString query = pxDataGet("laptool_updaterun_deactivate.sql"); 258 258 if (!query) { 259 259 psError(PXTOOL_ERR_SYS, false, "failed to retrieve SQL statement"); … … 270 270 } 271 271 272 char *query = "UPDATE reprocRun SET state = '%s' WHERE re_id = %"PRId64;273 if (!p_psDBRunQueryF(config->dbh, query, state, re_id)) {272 char *query = "UPDATE lapRun SET state = '%s' WHERE lap_id = %"PRId64; 273 if (!p_psDBRunQueryF(config->dbh, query, state, lap_id)) { 274 274 psError(PS_ERR_UNKNOWN, false, 275 "failed to change state for re_id %"PRId64, re_id);275 "failed to change state for lap_id %"PRId64, lap_id); 276 276 return(false); 277 277 } … … 280 280 } 281 281 // Exposure level 282 static bool pendingchipexpMode(pxConfig *config) 283 { 284 PS_ASSERT_PTR_NON_NULL(config, false); 285 282 283 static bool exposuresMode(pxConfig *config) 284 { 285 PS_ASSERT_PTR_NON_NULL(config, false); 286 286 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 287 287 288 288 psmetadata *where = psMetadataAlloc(); 289 PXOPT_COPY_S64(config->args, where, "-re_id", "re_id", "=="); 290 PXOPT_COPY_STR(config->args, where, "-filter", "filter", "=="); 291 292 psString query = pxDataGet("reproctool_pendingchipexp.sql"); 289 PXOPT_COPY_S64(config->args, where, "-lap_id", "lap_id", "=="); 290 291 psString query = pxDataGet("laptool_exposures.sql"); 293 292 if (!query) { 294 293 psError(PXTOOL_ERR_SYS, false, "failed to retrieve SQL statement"); … … 323 322 } 324 323 if (!psArrayLength(output)) { 325 psTrace(" reproctool", PS_LOG_INFO, "no rows found");326 psFree(output); 327 return(true); 328 } 329 330 if (!ippdbPrintMetadatas(stdout, output, " reprocExp", !simple)) {324 psTrace("laptool", PS_LOG_INFO, "no rows found"); 325 psFree(output); 326 return(true); 327 } 328 329 if (!ippdbPrintMetadatas(stdout, output, "lapExp", !simple)) { 331 330 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 332 331 psFree(output); … … 337 336 return(true); 338 337 339 340 } 341 static bool pendingquickstackMode(pxConfig *config) 342 { 343 PS_ASSERT_PTR_NON_NULL(config, false); 338 } 339 340 341 static bool pendingchipexpMode(pxConfig *config) 342 { 343 PS_ASSERT_PTR_NON_NULL(config, false); 344 344 345 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 345 346 346 347 psmetadata *where = psMetadataAlloc(); 347 PXOPT_COPY_S64(config->args, where, "- re_id", "re_id", "==");348 PXOPT_COPY_S64(config->args, where, "-lap_id", "lap_id", "=="); 348 349 PXOPT_COPY_STR(config->args, where, "-filter", "filter", "=="); 349 350 350 psString query = pxDataGet(" reproctool_pendingquickstack.sql");351 psString query = pxDataGet("laptool_pendingchipexp.sql"); 351 352 if (!query) { 352 353 psError(PXTOOL_ERR_SYS, false, "failed to retrieve SQL statement"); … … 381 382 } 382 383 if (!psArrayLength(output)) { 383 psTrace(" reproctool", PS_LOG_INFO, "no rows found");384 psFree(output); 385 return(true); 386 } 387 388 if (!ippdbPrintMetadatas(stdout, output, " reprocExp", !simple)) {384 psTrace("laptool", PS_LOG_INFO, "no rows found"); 385 psFree(output); 386 return(true); 387 } 388 389 if (!ippdbPrintMetadatas(stdout, output, "lapExp", !simple)) { 389 390 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 390 391 psFree(output); … … 397 398 398 399 } 399 static bool pending diffMode(pxConfig *config)400 static bool pendingquickstackMode(pxConfig *config) 400 401 { 401 402 PS_ASSERT_PTR_NON_NULL(config, false); … … 403 404 404 405 psmetadata *where = psMetadataAlloc(); 405 PXOPT_COPY_S64(config->args, where, "- re_id", "re_id", "==");406 PXOPT_COPY_S64(config->args, where, "-lap_id", "lap_id", "=="); 406 407 PXOPT_COPY_STR(config->args, where, "-filter", "filter", "=="); 407 408 408 psString query = pxDataGet(" reproctool_pendingdiff.sql");409 psString query = pxDataGet("laptool_pendingquickstack.sql"); 409 410 if (!query) { 410 411 psError(PXTOOL_ERR_SYS, false, "failed to retrieve SQL statement"); … … 439 440 } 440 441 if (!psArrayLength(output)) { 441 psTrace(" reproctool", PS_LOG_INFO, "no rows found");442 psFree(output); 443 return(true); 444 } 445 446 if (!ippdbPrintMetadatas(stdout, output, " reprocExp", !simple)) {442 psTrace("laptool", PS_LOG_INFO, "no rows found"); 443 psFree(output); 444 return(true); 445 } 446 447 if (!ippdbPrintMetadatas(stdout, output, "lapExp", !simple)) { 447 448 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 448 449 psFree(output); … … 455 456 456 457 } 457 static bool pending finalstackMode(pxConfig *config)458 static bool pendingdiffMode(pxConfig *config) 458 459 { 459 460 PS_ASSERT_PTR_NON_NULL(config, false); … … 461 462 462 463 psmetadata *where = psMetadataAlloc(); 463 PXOPT_COPY_S64(config->args, where, "- re_id", "re_id", "==");464 PXOPT_COPY_S64(config->args, where, "-lap_id", "lap_id", "=="); 464 465 PXOPT_COPY_STR(config->args, where, "-filter", "filter", "=="); 465 466 466 psString query = pxDataGet(" reproctool_pendingfinalstack.sql");467 psString query = pxDataGet("laptool_pendingdiff.sql"); 467 468 if (!query) { 468 469 psError(PXTOOL_ERR_SYS, false, "failed to retrieve SQL statement"); … … 497 498 } 498 499 if (!psArrayLength(output)) { 499 psTrace(" reproctool", PS_LOG_INFO, "no rows found");500 psFree(output); 501 return(true); 502 } 503 504 if (!ippdbPrintMetadatas(stdout, output, " reprocExp", !simple)) {500 psTrace("laptool", PS_LOG_INFO, "no rows found"); 501 psFree(output); 502 return(true); 503 } 504 505 if (!ippdbPrintMetadatas(stdout, output, "lapExp", !simple)) { 505 506 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 506 507 psFree(output); … … 513 514 514 515 } 516 static bool pendingfinalstackMode(pxConfig *config) 517 { 518 PS_ASSERT_PTR_NON_NULL(config, false); 519 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 520 521 psmetadata *where = psMetadataAlloc(); 522 PXOPT_COPY_S64(config->args, where, "-lap_id", "lap_id", "=="); 523 PXOPT_COPY_STR(config->args, where, "-filter", "filter", "=="); 524 525 psString query = pxDataGet("laptool_pendingfinalstack.sql"); 526 if (!query) { 527 psError(PXTOOL_ERR_SYS, false, "failed to retrieve SQL statement"); 528 return(false); 529 } 530 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 531 if (whereClause) { 532 psStringPrepend(&whereClause, "\n AND "); 533 } 534 535 psString limitString = NULL; 536 if (limit) { 537 limitString = psDBGenerateLimitSQL(limit); 538 psStringPrepend(&limitString, "\n"); 539 } 540 541 if (!p_psDBRunQueryF(config->dbh, query, whereClause, limitString ? limitString : "")) { 542 psError(PXTOOLS_ERR_PROG, false, "database error"); 543 psFree(limitString); 544 psFree(query); 545 psFree(whereClause); 546 return(false); 547 } 548 psFree(limitString); 549 psFree(query); 550 psFree(whereClause); 551 552 psArray *output = p_psDBFetchResult(config->dbh); 553 if (!output) { 554 psError(PS_ERR_UNKNOWN, false, "database error"); 555 return(false); 556 } 557 if (!psArrayLength(output)) { 558 psTrace("laptool", PS_LOG_INFO, "no rows found"); 559 psFree(output); 560 return(true); 561 } 562 563 if (!ippdbPrintMetadatas(stdout, output, "lapExp", !simple)) { 564 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 565 psFree(output); 566 return(false); 567 } 568 569 psFree(output); 570 return(true); 571 572 573 } 515 574 static bool updateexpMode(pxConfig *config) 516 575 { … … 518 577 519 578 psMetadata *where = psMetadataAlloc(); 520 PXOPT_LOOKUP_S64( re_id, config->args, "-re_id", true, false);579 PXOPT_LOOKUP_S64(lap_id, config->args, "-lap_id", true, false); 521 580 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", true, false); 522 581 PXOPT_LOOKUP_S64(chip_id, config->args, "-chip_id", false, false); … … 532 591 533 592 psMetadata *where = psMetadataAlloc(); 534 PXOPT_COPY_S64(config->args, where, "- re_id", "re_id", "==");593 PXOPT_COPY_S64(config->args, where, "-lap_id", "lap_id", "=="); 535 594 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 536 595 PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "=="); … … 550 609 } 551 610 552 long rows = psDBUpdateRows(config->dbh," reprocExp",where,values);611 long rows = psDBUpdateRows(config->dbh,"lapExp",where,values); 553 612 if (rows) { 554 613 return(true);
Note:
See TracChangeset
for help on using the changeset viewer.
