Changeset 18029 for trunk/ippTools/src/faketool.c
- Timestamp:
- Jun 9, 2008, 12:55:57 PM (18 years ago)
- Location:
- trunk/ippTools/src
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
faketool.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src
- Property svn:ignore
-
old new 23 23 difftool 24 24 stacktool 25 faketool 25 26 dettool 26 27 detselect
-
- Property svn:ignore
-
trunk/ippTools/src/faketool.c
r17357 r18029 32 32 33 33 #include "faketool.h" 34 #include "camtool.h"35 34 36 35 static bool queueMode(pxConfig *config); 37 36 static bool updaterunMode(pxConfig *config); 37 static bool pendingexpMode(pxConfig *config); 38 38 static bool pendingimfileMode(pxConfig *config); 39 39 static bool addprocessedimfileMode(pxConfig *config); … … 67 67 MODECASE(FAKETOOL_MODE_QUEUE, queueMode); 68 68 MODECASE(FAKETOOL_MODE_UPDATERUN, updaterunMode); 69 MODECASE(FAKETOOL_MODE_PENDINGEXP, pendingexpMode); 69 70 MODECASE(FAKETOOL_MODE_PENDINGIMFILE, pendingimfileMode); 70 71 MODECASE(FAKETOOL_MODE_ADDPROCESSEDIMFILE, addprocessedimfileMode); … … 171 172 172 173 // find the exp_id of all the exposures that we want to queue up. 173 psString query = pxDataGet("faketool_find_ rawexp.sql");174 psString query = pxDataGet("faketool_find_camrun.sql"); 174 175 if (!query) { 175 176 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); … … 179 180 180 181 if (where && psListLength(where->list)) { 181 psString whereClause = psDBGenerateWhere ConditionSQL(where, "rawExp");182 psStringAppend(&query, " AND%s", whereClause);182 psString whereClause = psDBGenerateWhereSQL(where, NULL); 183 psStringAppend(&query, " %s", whereClause); 183 184 psFree(whereClause); 184 185 } … … 219 220 } 220 221 221 // loop over our list of exp_ids222 // loop over our list of cam_ids 222 223 for (long i = 0; i < psArrayLength(output); i++) { 223 224 psMetadata *md = output->data[i]; 224 225 225 226 bool status; 226 psS64 exp_id = psMetadataLookupS64(&status, md, "exp_id");227 psS64 cam_id = psMetadataLookupS64(&status, md, "cam_id"); 227 228 if (!status) { 228 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for exp_id");229 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for cam_id"); 229 230 psFree(output); 230 231 return false; … … 232 233 233 234 // queue the exp 234 if (!pxfakeQueueBy ExpTag(config, exp_id, workdir, label, reduction, expgroup, dvodb, tess_id, end_stage)) {235 if (!pxfakeQueueByCamID(config, cam_id, workdir, label, reduction, expgroup, dvodb, tess_id, end_stage)) { 235 236 if (!psDBRollback(config->dbh)) { 236 237 psError(PS_ERR_UNKNOWN, false, "database error"); 237 238 } 238 239 psError(PS_ERR_UNKNOWN, false, 239 "failed to trying to queue exp_id: %" PRId64, exp_id);240 "failed to trying to queue cam_id: %" PRId64, cam_id); 240 241 psFree(output); 241 242 return false; … … 354 355 355 356 357 static bool pendingexpMode(pxConfig *config) 358 { 359 PS_ASSERT_PTR_NON_NULL(config, false); 360 361 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 362 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 363 364 psMetadata *where = psMetadataAlloc(); 365 PXOPT_COPY_STR(config->args, where, "-fake_id", "fake_id", "=="); 366 PXOPT_COPY_STR(config->args, where, "-cam_id", "cam_id", "=="); 367 PXOPT_COPY_STR(config->args, where, "-chip_id", "chip_id", "=="); 368 369 psString query = pxDataGet("faketool_find_pendingexp.sql"); 370 if (!query) { 371 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 372 psFree(where); 373 return false; 374 } 375 376 if (where && psListLength(where->list)) { 377 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 378 psStringAppend(&query, " AND %s", whereClause); 379 psFree(whereClause); 380 } 381 psFree(where); 382 383 // treat limit == 0 as "no limit" 384 if (limit) { 385 psString limitString = psDBGenerateLimitSQL(limit); 386 psStringAppend(&query, " %s", limitString); 387 psFree(limitString); 388 } 389 390 if (!p_psDBRunQuery(config->dbh, query)) { 391 psError(PS_ERR_UNKNOWN, false, "database error"); 392 psFree(query); 393 return false; 394 } 395 psFree(query); 396 397 psArray *output = p_psDBFetchResult(config->dbh); 398 if (!output) { 399 psError(PS_ERR_UNKNOWN, false, "database error"); 400 return false; 401 } 402 if (!psArrayLength(output)) { 403 psTrace("camtool", PS_LOG_INFO, "no rows found"); 404 psFree(output); 405 return true; 406 } 407 408 if (!convertIdToStr(output)) { 409 psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings"); 410 psFree(output); 411 return false; 412 } 413 414 // negate simple so the default is true 415 if (!ippdbPrintMetadatas(stdout, output, "fakePendingExp", !simple)) { 416 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 417 psFree(output); 418 return false; 419 } 420 421 psFree(output); 422 423 return true; 424 } 425 426 356 427 static bool pendingimfileMode(pxConfig *config) 357 428 { … … 448 519 449 520 // fake_id, ext_tag, class_id are required 450 PXOPT_LOOKUP_STR(fake_id, config->args, "-fake_id", true, false);451 PXOPT_LOOKUP_STR(exp_id, config->args, "-exp_id", true, false);452 PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", true, false);521 PXOPT_LOOKUP_STR(fake_id, config->args, "-fake_id", true, false); 522 PXOPT_LOOKUP_STR(exp_id, config->args, "-exp_id", true, false); 523 PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", true, false); 453 524 454 525 // optional 455 PXOPT_LOOKUP_STR(uri, config->args, "-uri", false, false); 456 PXOPT_LOOKUP_F32(bg, config->args, "-bg", false, false); 457 PXOPT_LOOKUP_F32(bg_stdev, config->args, "-bg_stdev", false, false); 458 PXOPT_LOOKUP_F32(bg_mean_stdev, config->args, "-bg_mean_stdev", false, false); 459 PXOPT_LOOKUP_F32(bias, config->args, "-bias", false, false); 460 PXOPT_LOOKUP_F32(bias_stdev, config->args, "-bias_stdev", false, false); 461 PXOPT_LOOKUP_F32(fringe_0, config->args, "-fringe_0", false, false); 462 PXOPT_LOOKUP_F32(fringe_1, config->args, "-fringe_1", false, false); 463 PXOPT_LOOKUP_F32(fringe_2, config->args, "-fringe_2", false, false); 464 PXOPT_LOOKUP_F32(sigma_ra, config->args, "-sigma_ra", false, false); 465 PXOPT_LOOKUP_F32(sigma_dec, config->args, "-sigma_dec", false, false); 466 PXOPT_LOOKUP_F32(ap_resid, config->args, "-ap_resid", false, false); 467 PXOPT_LOOKUP_F32(ap_resid_stdev, config->args, "-ap_resid_stdev", false, false); 468 PXOPT_LOOKUP_F32(zp_mean, config->args, "-zp_mean", false, false); 469 PXOPT_LOOKUP_F32(zp_stdev, config->args, "-zp_stdev", false, false); 470 PXOPT_LOOKUP_F32(fwhm_major, config->args, "-fwhm_major", false, false); 471 PXOPT_LOOKUP_F32(fwhm_minor, config->args, "-fwhm_minor", false, false); 472 PXOPT_LOOKUP_F32(dtime_detrend, config->args, "-dtime_detrend", false, false); 473 PXOPT_LOOKUP_F32(dtime_photom, config->args, "-dtime_photom", false, false); 474 PXOPT_LOOKUP_F32(dtime_astrom, config->args, "-dtime_astrom", false, false); 475 PXOPT_LOOKUP_STR(hostname, config->args, "-hostname", false, false); 476 PXOPT_LOOKUP_F32(n_stars, config->args, "-n_stars", false, false); 477 PXOPT_LOOKUP_F32(n_extended, config->args, "-n_extended", false, false); 478 PXOPT_LOOKUP_F32(n_cr, config->args, "-n_cr", false, false); 479 PXOPT_LOOKUP_F32(n_astrom, config->args, "-n_astrom", false, false); 480 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false); 526 PXOPT_LOOKUP_STR(uri, config->args, "-uri", false, false); 527 528 PXOPT_LOOKUP_F32(dtime_fake, config->args, "-dtime_fake", false, false); 529 PXOPT_LOOKUP_STR(hostname, config->args, "-hostname", false, false); 530 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false); 481 531 482 532 // default values 483 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);533 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 484 534 485 535 if (!psDBTransaction(config->dbh)) { … … 493 543 class_id, 494 544 uri, 495 bg, 496 bg_stdev, 497 bg_mean_stdev, 498 bias, 499 bias_stdev, 500 fringe_0, 501 fringe_1, 502 fringe_2, 503 sigma_ra, 504 sigma_dec, 505 ap_resid, 506 ap_resid_stdev, 507 zp_mean, 508 zp_stdev, 509 fwhm_major, 510 fwhm_minor, 511 dtime_detrend, 512 dtime_photom, 513 dtime_astrom, 545 dtime_fake, 514 546 hostname, 515 n_stars,516 n_extended,517 n_cr,518 n_astrom,519 547 path_base, 520 code 548 code, 549 NULL // epoch 521 550 )) { 522 551 // rollback … … 748 777 PXOPT_LOOKUP_S16(code, config->args, "-code", true, false); 749 778 750 if (!pxSetFaultCode(config->dbh, "fakeProcessedImfile", config->where, code)) { 779 psMetadata *where = psMetadataAlloc(); 780 PXOPT_LOOKUP_STR(fake_id, config->args, "-fake_id", false, false); 781 // convert fake_id into a psS64 782 if (fake_id) { 783 if (!psMetadataAddS64(where, PS_LIST_TAIL, "fake_id", 0, "==", (psS64)atoll(fake_id))) { 784 psError(PS_ERR_UNKNOWN, false, "failed to add item fake_id"); 785 psFree(where); 786 return false; 787 } 788 } 789 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); 790 791 if (!pxSetFaultCode(config->dbh, "fakeProcessedImfile", where, code)) { 751 792 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); 752 return false; 753 } 793 psFree(where); 794 return false; 795 } 796 psFree(where); 754 797 755 798 return true; … … 984 1027 // camQueueFakeID() can only be run after fakeRun.state has been set to 985 1028 // stop 986 if (!px camQueueByFakeID(config,1029 if (!pxwarpQueueByFakeID(config, 987 1030 fakeRun->fake_id, 988 1031 fakeRun->workdir, 989 1032 fakeRun->label, 990 fakeRun->reduction,991 fakeRun->expgroup,992 1033 fakeRun->dvodb, 993 1034 fakeRun->tess_id,
Note:
See TracChangeset
for help on using the changeset viewer.
