IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 23, 2007, 3:41:56 PM (19 years ago)
Author:
jhoblitt
Message:

s/p0/reg/g
s/p1/guide/g
s/p2/chip/g
s/p6/stack/g
s/p5/diff/g
s/p4/warp/g
s/p3/cam/g

File:
1 edited

Legend:

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

    r11997 r12024  
    3939static bool diffskyfileMode(pxConfig *config);
    4040
    41 static bool setp5RunState(pxConfig *config, const char *p4_id, const char *state);
     41static bool setdiffRunState(pxConfig *config, const char *warp_id, const char *state);
    4242
    4343# define MODECASE(caseName, func) \
     
    139139    }
    140140
    141     p5RunRow *run = p5RunRowAlloc(
     141    diffRunRow *run = diffRunRowAlloc(
    142142            0,          // ID
    143143            "reg",      // state
     
    150150    psFree(registered);
    151151    if (!run) {
    152         psError(PS_ERR_UNKNOWN, false, "failed to alloc p5Run object");
     152        psError(PS_ERR_UNKNOWN, false, "failed to alloc diffRun object");
    153153        return true;
    154154    }
    155     if (!p5RunInsertObject(config->dbh, run)) {
     155    if (!diffRunInsertObject(config->dbh, run)) {
    156156        psError(PS_ERR_UNKNOWN, false, "database error");
    157157        psFree(run);
     
    159159    }
    160160
    161     // get the assigned p5_id
    162     run->p5_id = psDBLastInsertID(config->dbh);
     161    // get the assigned diff_id
     162    run->diff_id = psDBLastInsertID(config->dbh);
    163163
    164164    bool simple = false;
     
    173173    }
    174174
    175     if (!p5RunPrintObject(stdout, run, !simple)) {
     175    if (!diffRunPrintObject(stdout, run, !simple)) {
    176176            psError(PS_ERR_UNKNOWN, false, "failed to print object");
    177177            psFree(run);
     
    190190
    191191    bool status = false;
    192     psString p5_id = psMetadataLookupStr(&status, config->args, "-p5_id");
    193     if (!status) {
    194         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p5_id");
    195         return false;
    196     }
    197     if (!p5_id) {
    198         psError(PS_ERR_UNKNOWN, true, "-p5_id is required");
     192    psString diff_id = psMetadataLookupStr(&status, config->args, "-diff_id");
     193    if (!status) {
     194        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -diff_id");
     195        return false;
     196    }
     197    if (!diff_id) {
     198        psError(PS_ERR_UNKNOWN, true, "-diff_id is required");
    199199        return false;
    200200    }
     
    212212    if (state) {
    213213        // set detRun.state to state
    214         return setp5RunState(config, p5_id, state);
     214        return setdiffRunState(config, diff_id, state);
    215215    }
    216216
     
    224224
    225225    bool status = false;
    226     psString p5_id = psMetadataLookupStr(&status, config->args, "-p5_id");
    227     if (!status) {
    228         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p5_id");
    229         return false;
    230     }
    231     if (!p5_id) {
    232         psError(PS_ERR_UNKNOWN, true, "-p5_id is required");
    233         return false;
    234     }
    235 
    236     psString p4_id = psMetadataLookupStr(&status, config->args, "-p4_id");
    237     if (!status) {
    238         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p4_id");
    239         return false;
    240     }
    241     if (!p5_id) {
    242         psError(PS_ERR_UNKNOWN, true, "-p5_id is required");
     226    psString diff_id = psMetadataLookupStr(&status, config->args, "-diff_id");
     227    if (!status) {
     228        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -diff_id");
     229        return false;
     230    }
     231    if (!diff_id) {
     232        psError(PS_ERR_UNKNOWN, true, "-diff_id is required");
     233        return false;
     234    }
     235
     236    psString warp_id = psMetadataLookupStr(&status, config->args, "-warp_id");
     237    if (!status) {
     238        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -warp_id");
     239        return false;
     240    }
     241    if (!diff_id) {
     242        psError(PS_ERR_UNKNOWN, true, "-diff_id is required");
    243243        return false;
    244244    }
     
    277277    }
    278278
    279     // XXX need to validate the p4_id here
     279    // XXX need to validate the warp_id here
    280280    // XXX instead of validiting it here we should just use forgein key
    281281    // constrants
    282     if (!p5InputSkyfileInsert(config->dbh,
    283             (psS32)atoi(p5_id),
    284             (psS32)atoi(p4_id),
     282    if (!diffInputSkyfileInsert(config->dbh,
     283            (psS32)atoi(diff_id),
     284            (psS32)atoi(warp_id),
    285285            skycell_id,
    286286            tess_id,
     
    310310    psString query = psStringCopy(
    311311        "SELECT\n"
    312         "   p4Skyfile.*,\n"
    313         "   p5InputSkyfile.template\n"
    314         " FROM p5Run\n"
    315         " JOIN p5InputSkyfile\n"
    316         "   USING(p5_id)\n"
    317         " JOIN p4Skyfile\n"
    318         "   ON p5InputSkyfile.p4_id      = p4Skyfile.p4_id\n"
    319         "  AND p5InputSkyfile.skycell_id = p4Skyfile.skycell_id\n"
    320         "  AND p5InputSkyfile.tess_id    = p4Skyfile.tess_id\n"
     312        "   warpSkyfile.*,\n"
     313        "   diffInputSkyfile.template\n"
     314        " FROM diffRun\n"
     315        " JOIN diffInputSkyfile\n"
     316        "   USING(diff_id)\n"
     317        " JOIN warpSkyfile\n"
     318        "   ON diffInputSkyfile.warp_id      = warpSkyfile.warp_id\n"
     319        "  AND diffInputSkyfile.skycell_id = warpSkyfile.skycell_id\n"
     320        "  AND diffInputSkyfile.tess_id    = warpSkyfile.tess_id\n"
    321321        " WHERE\n"
    322         "   p5Run.state = 'run'\n"
     322        "   diffRun.state = 'run'\n"
    323323    );
    324324
    325325    if (config->where) {
    326         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p5InputSkyfile");
     326        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "diffInputSkyfile");
    327327        psStringAppend(&query, " AND %s", whereClause);
    328328        psFree(whereClause);
     
    358358    }
    359359    if (!psArrayLength(output)) {
    360         psError(PS_ERR_UNKNOWN, false, "no p5InputSkyfile rows found");
     360        psError(PS_ERR_UNKNOWN, false, "no diffInputSkyfile rows found");
    361361        psFree(output);
    362362        return true;
     
    375375    if (psArrayLength(output)) {
    376376        // negative simple so the default is true
    377         if (!ippdbPrintMetadatas(stdout, output, "p5InputSkyfile", !simple)) {
     377        if (!ippdbPrintMetadatas(stdout, output, "diffInputSkyfile", !simple)) {
    378378            psError(PS_ERR_UNKNOWN, false, "failed to print array");
    379379            psFree(output);
     
    402402    psString query = psStringCopy(
    403403        "SELECT DISTINCT\n"
    404         "   p5Run.p5_id\n"
    405         " FROM p5Run\n"
    406         " JOIN p5InputSkyfile\n"
    407         "   USING(p5_id)\n"
    408         " JOIN p4Skyfile\n"
    409         "   ON p5InputSkyfile.p4_id      = p4Skyfile.p4_id\n"
    410         "  AND p5InputSkyfile.skycell_id = p4Skyfile.skycell_id\n"
    411         "  AND p5InputSkyfile.tess_id    = p4Skyfile.tess_id\n"
    412         " LEFT JOIN p5DiffSkyfile\n"
    413         "   ON p5InputSkyfile.p5_id      = p5DiffSkyfile.p5_id\n"
     404        "   diffRun.diff_id\n"
     405        " FROM diffRun\n"
     406        " JOIN diffInputSkyfile\n"
     407        "   USING(diff_id)\n"
     408        " JOIN warpSkyfile\n"
     409        "   ON diffInputSkyfile.warp_id      = warpSkyfile.warp_id\n"
     410        "  AND diffInputSkyfile.skycell_id = warpSkyfile.skycell_id\n"
     411        "  AND diffInputSkyfile.tess_id    = warpSkyfile.tess_id\n"
     412        " LEFT JOIN diffSkyfile\n"
     413        "   ON diffInputSkyfile.diff_id      = diffSkyfile.diff_id\n"
    414414        " WHERE\n"
    415         "   p5Run.state = 'run'\n"
    416         "   AND p5DiffSkyfile.p5_id IS NULL\n"
     415        "   diffRun.state = 'run'\n"
     416        "   AND diffSkyfile.diff_id IS NULL\n"
    417417    );
    418418
    419419    if (config->where) {
    420         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p5Skyfile");
     420        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "diffSkyfile");
    421421        psStringAppend(&query, " AND %s", whereClause);
    422422        psFree(whereClause);
     
    452452    }
    453453    if (!psArrayLength(output)) {
    454         psError(PS_ERR_UNKNOWN, false, "no p5Skyfile rows found");
     454        psError(PS_ERR_UNKNOWN, false, "no diffSkyfile rows found");
    455455        psFree(output);
    456456        return true;
     
    469469    if (psArrayLength(output)) {
    470470        // negative simple so the default is true
    471         if (!ippdbPrintMetadatas(stdout, output, "p5Skyfile", !simple)) {
     471        if (!ippdbPrintMetadatas(stdout, output, "diffSkyfile", !simple)) {
    472472            psError(PS_ERR_UNKNOWN, false, "failed to print array");
    473473            psFree(output);
     
    487487
    488488    bool status = false;
    489     psString p5_id = psMetadataLookupStr(&status, config->args, "-p5_id");
    490     if (!status) {
    491         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p5_id");
    492         return false;
    493     }
    494     if (!p5_id) {
    495         psError(PS_ERR_UNKNOWN, true, "-p5_id is required");
     489    psString diff_id = psMetadataLookupStr(&status, config->args, "-diff_id");
     490    if (!status) {
     491        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -diff_id");
     492        return false;
     493    }
     494    if (!diff_id) {
     495        psError(PS_ERR_UNKNOWN, true, "-diff_id is required");
    496496        return false;
    497497    }
     
    525525    }
    526526
    527     if (!p5DiffSkyfileInsert(config->dbh,
    528             (psS32)atoi(p5_id),
     527    if (!diffSkyfileInsert(config->dbh,
     528            (psS32)atoi(diff_id),
    529529            uri,
    530530            bg,
     
    538538    }
    539539
    540     if (!setp5RunState(config, p5_id, "stop")) {
     540    if (!setdiffRunState(config, diff_id, "stop")) {
    541541        if (!psDBRollback(config->dbh)) {
    542542            psError(PS_ERR_UNKNOWN, false, "database error");
     
    570570    psString query = psStringCopy(
    571571        "SELECT\n"
    572         "   p5Run.skycell_id,\n"
    573         "   p5Run.tess_id,\n"
    574         "   p5DiffSkyfile.*\n"
    575         " FROM p5Run\n"
    576         " JOIN p5DiffSkyfile\n"
    577         "   USING(p5_id)\n"
     572        "   diffRun.skycell_id,\n"
     573        "   diffRun.tess_id,\n"
     574        "   diffSkyfile.*\n"
     575        " FROM diffRun\n"
     576        " JOIN diffSkyfile\n"
     577        "   USING(diff_id)\n"
    578578        " WHERE\n"
    579         "   p5Run.state = 'run'\n"
     579        "   diffRun.state = 'run'\n"
    580580    );
    581581
    582582    if (config->where) {
    583         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p5DiffSkyfile");
     583        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "diffSkyfile");
    584584        psStringAppend(&query, " AND %s", whereClause);
    585585        psFree(whereClause);
     
    615615    }
    616616    if (!psArrayLength(output)) {
    617         psError(PS_ERR_UNKNOWN, false, "no p5DiffSkyfile rows found");
     617        psError(PS_ERR_UNKNOWN, false, "no diffSkyfile rows found");
    618618        psFree(output);
    619619        return true;
     
    632632    if (psArrayLength(output)) {
    633633        // negative simple so the default is true
    634         if (!ippdbPrintMetadatas(stdout, output, "p5DiffSkyfile", !simple)) {
     634        if (!ippdbPrintMetadatas(stdout, output, "diffSkyfile", !simple)) {
    635635            psError(PS_ERR_UNKNOWN, false, "failed to print array");
    636636            psFree(output);
     
    644644}
    645645
    646 static bool setp5RunState(pxConfig *config, const char *p5_id, const char *state)
    647 {
    648     PS_ASSERT_PTR_NON_NULL(p5_id, false);
     646static bool setdiffRunState(pxConfig *config, const char *diff_id, const char *state)
     647{
     648    PS_ASSERT_PTR_NON_NULL(diff_id, false);
    649649    PS_ASSERT_PTR_NON_NULL(state, false);
    650650
     
    657657    ) {
    658658        psError(PS_ERR_UNKNOWN, false,
    659                 "invalid p5Run state: %s", state);
    660         return false;
    661     }
    662 
    663     char *query = "UPDATE p5Run SET state = '%s' WHERE p5_id = '%s'";
    664     if (!p_psDBRunQuery(config->dbh, query, state, p5_id)) {
     659                "invalid diffRun state: %s", state);
     660        return false;
     661    }
     662
     663    char *query = "UPDATE diffRun SET state = '%s' WHERE diff_id = '%s'";
     664    if (!p_psDBRunQuery(config->dbh, query, state, diff_id)) {
    665665        psError(PS_ERR_UNKNOWN, false,
    666                 "failed to change state for p5_id %s", p5_id);
    667         return false;
    668     }
    669 
    670     return true;
    671 }
     666                "failed to change state for diff_id %s", diff_id);
     667        return false;
     668    }
     669
     670    return true;
     671}
Note: See TracChangeset for help on using the changeset viewer.