IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 12, 2010, 2:07:51 PM (16 years ago)
Author:
bills
Message:

Make update processing compatible with magic. Fix some bugs in update for the warp stage
Make script changes to implement update for diff stage.
Change value of 'magicked' in the various runs and files to contain the value
the magic_id of the magicRun that corresponds to the streaks file used for desreaking.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/magicdstool.c

    r26495 r26567  
    4444static bool tocleanupMode(pxConfig *config);
    4545
    46 static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, psMetadata *where, const char *state);
     46static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, psString extraSetString, psMetadata *where, const char *state);
    4747
    4848# define MODECASE(caseName, func) \
     
    326326    PXOPT_LOOKUP_STR(state, config->args, "-set_state", true, false);
    327327
     328    // optional
     329    PXOPT_LOOKUP_STR(set_label, config->args, "-set_label", false, false);
     330    psString setString = NULL;
     331    if (set_label) {
     332        psStringAppend(&setString, ", label = '%s'", set_label);
     333    }
     334
    328335    PXOPT_LOOKUP_S64(magic_ds_id, config->args, "-magic_ds_id", false, false);
    329336    if (magic_ds_id) {
    330337
    331         return setmagicDSRunState(config, magic_ds_id, NULL, state);
     338        return setmagicDSRunState(config, magic_ds_id, setString, NULL, state);
    332339
    333340    } else if (!strcmp(state, "full")) {
     
    336343    }
    337344    // we can transition by query as well
     345
    338346
    339347    psMetadata *where = psMetadataAlloc();
     
    342350    PXOPT_COPY_STR(config->args, where, "-stage", "stage", "==");
    343351
    344 
    345352    if (psListLength(where->list) < 2) {
    346353        psError(PS_ERR_UNKNOWN, true, "at least 2 search arguments are required");
     
    353360        psMetadataAddS32(where, PS_LIST_TAIL, "re_place", 0, ">", 0);
    354361    }
    355     bool result = setmagicDSRunState(config, magic_ds_id, where, state);
     362    bool result = setmagicDSRunState(config, magic_ds_id, setString, where, state);
    356363    psFree(where);
    357364
     
    445452{
    446453    // first query the magicDSRun to find the stage and the stage_id
    447     psString query = "SELECT stage, stage_id from magicDSRun where magic_ds_id = %" PRId64;
     454    psString query = "SELECT stage, stage_id, magic_id from magicDSRun where magic_ds_id = %" PRId64;
    448455
    449456    if (!p_psDBRunQueryF(config->dbh, query, magic_ds_id)) {
     
    472479    psString stage= psMetadataLookupStr(NULL, row, "stage");
    473480    psS64 stage_id = psMetadataLookupS64(NULL, row, "stage_id");
     481    psS64 magic_id = psMetadataLookupS64(NULL, row, "magic_id");
    474482
    475483    ippStage stageNum = ippStringToStage(stage);
     
    499507    }
    500508
    501     if (!p_psDBRunQueryF(config->dbh, query, magic_ds_id, stage_id, component)) {
     509    if (!p_psDBRunQueryF(config->dbh, query, magic_id, stage_id, component)) {
    502510        psError(PS_ERR_UNKNOWN, false, "database error");
    503511        return false;
     
    518526{
    519527    // first query the magicDSRun to find the stage and the stage_id
    520     psString query = "SELECT stage, stage_id from magicDSRun where magic_ds_id = %" PRId64;
     528    psString query = "SELECT stage, stage_id, magic_id from magicDSRun where magic_ds_id = %" PRId64;
    521529
    522530    if (!p_psDBRunQueryF(config->dbh, query, magic_ds_id)) {
     
    545553    psString stage = psMetadataLookupStr(NULL, row, "stage");
    546554    psS64 stage_id = psMetadataLookupS64(NULL, row, "stage_id");
     555    psS64 magic_id = psMetadataLookupS64(NULL, row, "magic_id");
    547556
    548557    ippStage stageNum = ippStringToStage(stage);
     
    570579        return false;
    571580    }
    572     if (!p_psDBRunQueryF(config->dbh, query, magic_ds_id, stage_id)) {
     581    if (!p_psDBRunQueryF(config->dbh, query, magic_id, stage_id)) {
    573582        psError(PS_ERR_UNKNOWN, false, "database error");
    574583        return false;
     
    710719
    711720        // set magicDSRun.state to 'full'
    712         if (!setmagicDSRunState(config, magic_ds_id, NULL, "full")) {
     721        if (!setmagicDSRunState(config, magic_ds_id, NULL, NULL, "full")) {
    713722            psError(PS_ERR_UNKNOWN, false, "failed to change magicDSRun.state for magic_ds_id: %" PRId64,
    714723                magic_ds_id);
     
    927936}
    928937
    929 static bool setmagicDSRunState(pxConfig *config, psS64 magic_ds_id, psMetadata *where, const char *state)
     938static bool setmagicDSRunState(pxConfig *config, psS64 magic_ds_id, psString extraSetStr, psMetadata *where, const char *state)
    930939{
    931940    PS_ASSERT_PTR_NON_NULL(state, false);
     
    937946    }
    938947
    939     psString query = psStringCopy("UPDATE magicDSRun SET state = '%s'");
     948    psString query = NULL;
     949    psStringAppend(&query, "UPDATE magicDSRun SET state = '%s' %s\n", state, extraSetStr ? extraSetStr : "");
    940950    if (magic_ds_id) {
    941951        psStringAppend(&query, " WHERE magic_ds_id = %" PRId64, magic_ds_id);
     
    949959    }
    950960
    951     if (!p_psDBRunQueryF(config->dbh, query, state)) {
     961    if (!p_psDBRunQuery(config->dbh, query)) {
    952962        psError(PS_ERR_UNKNOWN, false,
    953963                "failed to change state for magic_id %" PRId64, magic_ds_id);
Note: See TracChangeset for help on using the changeset viewer.