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/stacktool.c

    r11997 r12024  
    3939static bool sumskyfileMode(pxConfig *config);
    4040
    41 static bool setp6RunState(pxConfig *config, const char *p6_id, const char *state);
     41static bool setstackRunState(pxConfig *config, const char *stack_id, const char *state);
    4242
    4343# define MODECASE(caseName, func) \
     
    125125
    126126    // we have to support multipe exp_tags
    127     psMetadataItem *p4_ids = psMetadataLookup(config->args, "-p4_id");
    128     if (!p4_ids) {
     127    psMetadataItem *warp_ids = psMetadataLookup(config->args, "-warp_id");
     128    if (!warp_ids) {
    129129        // this shouldn't actually happen when using psArgs
    130         psError(PS_ERR_UNKNOWN, true, "-p4_id is required");
     130        psError(PS_ERR_UNKNOWN, true, "-warp_id is required");
    131131        return false;
    132132    }
     
    147147    }
    148148
    149     p6RunRow *run = p6RunRowAlloc(
     149    stackRunRow *run = stackRunRowAlloc(
    150150            0,          // ID
    151151            "run",      // state
     
    158158    psFree(registered);
    159159    if (!run) {
    160         psError(PS_ERR_UNKNOWN, false, "failed to alloc p6Run object");
     160        psError(PS_ERR_UNKNOWN, false, "failed to alloc stackRun object");
    161161        return true;
    162162    }
     
    167167    }
    168168
    169     if (!p6RunInsertObject(config->dbh, run)) {
     169    if (!stackRunInsertObject(config->dbh, run)) {
    170170        if (!psDBRollback(config->dbh)) {
    171171            psError(PS_ERR_UNKNOWN, false, "database error");
     
    176176    }
    177177
    178     // get the assigned p4_id
    179     run->p6_id = psDBLastInsertID(config->dbh);
    180 
    181     // insert the p6InputSkyfile rows
    182     psListIterator *iter = psListIteratorAlloc(p4_ids->data.list, 0, false);
     178    // get the assigned warp_id
     179    run->stack_id = psDBLastInsertID(config->dbh);
     180
     181    // insert the stackInputSkyfile rows
     182    psListIterator *iter = psListIteratorAlloc(warp_ids->data.list, 0, false);
    183183    psMetadataItem *item = NULL;
    184184    while ((item = psListGetAndIncrement(iter))) {
    185         if (!p6InputSkyfileInsert(config->dbh, run->p6_id, atoi((char *)item->data.V))) {
     185        if (!stackInputSkyfileInsert(config->dbh, run->stack_id, atoi((char *)item->data.V))) {
    186186            if (!psDBRollback(config->dbh)) {
    187187                psError(PS_ERR_UNKNOWN, false, "database error");
    188188            }
    189             psError(PS_ERR_UNKNOWN, false, "failed to insert p6InputSkyfile rows");
     189            psError(PS_ERR_UNKNOWN, false, "failed to insert stackInputSkyfile rows");
    190190            return false;
    191191        }
     
    210210    }
    211211
    212     if (!p6RunPrintObject(stdout, run, !simple)) {
     212    if (!stackRunPrintObject(stdout, run, !simple)) {
    213213            psError(PS_ERR_UNKNOWN, false, "failed to print object");
    214214            psFree(run);
     
    227227
    228228    bool status = false;
    229     psString p6_id = psMetadataLookupStr(&status, config->args, "-p6_id");
    230     if (!status) {
    231         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p6_id");
    232         return false;
    233     }
    234     if (!p6_id) {
    235         psError(PS_ERR_UNKNOWN, true, "-p6_id is required");
     229    psString stack_id = psMetadataLookupStr(&status, config->args, "-stack_id");
     230    if (!status) {
     231        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -stack_id");
     232        return false;
     233    }
     234    if (!stack_id) {
     235        psError(PS_ERR_UNKNOWN, true, "-stack_id is required");
    236236        return false;
    237237    }
     
    249249    if (state) {
    250250        // set detRun.state to state
    251         return setp6RunState(config, p6_id, state);
     251        return setstackRunState(config, stack_id, state);
    252252    }
    253253
     
    261261
    262262    bool status = false;
    263     psString p6_id = psMetadataLookupStr(&status, config->args, "-p6_id");
    264     if (!status) {
    265         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p6_id");
    266         return false;
    267     }
    268     if (!p6_id) {
    269         psError(PS_ERR_UNKNOWN, true, "-p6_id is required");
    270         return false;
    271 
    272     }
    273 
    274     psString p4_id = psMetadataLookupStr(&status, config->args, "-p4_id");
    275     if (!status) {
    276         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p4_id");
    277         return false;
    278     }
    279     if (!p4_id) {
    280         psError(PS_ERR_UNKNOWN, true, "-p4_id is required");
    281         return false;
    282     }
    283 
    284 
    285     // XXX need to validate the p4_id here
     263    psString stack_id = psMetadataLookupStr(&status, config->args, "-stack_id");
     264    if (!status) {
     265        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -stack_id");
     266        return false;
     267    }
     268    if (!stack_id) {
     269        psError(PS_ERR_UNKNOWN, true, "-stack_id is required");
     270        return false;
     271
     272    }
     273
     274    psString warp_id = psMetadataLookupStr(&status, config->args, "-warp_id");
     275    if (!status) {
     276        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -warp_id");
     277        return false;
     278    }
     279    if (!warp_id) {
     280        psError(PS_ERR_UNKNOWN, true, "-warp_id is required");
     281        return false;
     282    }
     283
     284
     285    // XXX need to validate the warp_id here
    286286    // XXX instead of validiting it here we should just use forgein key
    287287    // constrants
    288     if (!p6InputSkyfileInsert(config->dbh,
    289             (psS32)atoi(p6_id),
    290             (psS32)atoi(p4_id)
     288    if (!stackInputSkyfileInsert(config->dbh,
     289            (psS32)atoi(stack_id),
     290            (psS32)atoi(warp_id)
    291291        )) {
    292292        psError(PS_ERR_UNKNOWN, false, "database error");
     
    312312    psString query = psStringCopy(
    313313        "SELECT\n"
    314         "   p4Skyfile.*\n"
    315         " FROM p6Run\n"
    316         " JOIN p6InputSkyfile\n"
    317         "   USING(p6_id)\n"
    318         " JOIN p4Skyfile\n"
    319         "   ON  p6InputSkyfile.p4_id = p4Skyfile.p4_id\n"
    320         "   AND p6Run.skycell_id    = p4Skyfile.skycell_id\n"
    321         "   AND p6Run.tess_id       = p4Skyfile.tess_id\n"
     314        "   warpSkyfile.*\n"
     315        " FROM stackRun\n"
     316        " JOIN stackInputSkyfile\n"
     317        "   USING(stack_id)\n"
     318        " JOIN warpSkyfile\n"
     319        "   ON  stackInputSkyfile.warp_id = warpSkyfile.warp_id\n"
     320        "   AND stackRun.skycell_id    = warpSkyfile.skycell_id\n"
     321        "   AND stackRun.tess_id       = warpSkyfile.tess_id\n"
    322322        " WHERE\n"
    323         "   p6Run.state = 'run'\n"
     323        "   stackRun.state = 'run'\n"
    324324    );
    325325    if (config->where) {
    326         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p6InputSkyfile");
     326        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "stackInputSkyfile");
    327327        psStringAppend(&query, " AND %s", whereClause);
    328328        psFree(whereClause);
     
    358358    }
    359359    if (!psArrayLength(output)) {
    360         psError(PS_ERR_UNKNOWN, false, "no p6InputSkyfile rows found");
     360        psError(PS_ERR_UNKNOWN, false, "no stackInputSkyfile 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, "p6InputSkyfile", !simple)) {
     377        if (!ippdbPrintMetadatas(stdout, output, "stackInputSkyfile", !simple)) {
    378378            psError(PS_ERR_UNKNOWN, false, "failed to print array");
    379379            psFree(output);
     
    402402    psString query = psStringCopy(
    403403        "SELECT\n"
    404         "   p6Run.p6_id\n"
    405         " FROM p6Run\n"
    406         " LEFT JOIN p6SumSkyfile\n"
    407         "   USING(p6_id)\n"
     404        "   stackRun.stack_id\n"
     405        " FROM stackRun\n"
     406        " LEFT JOIN stackSumSkyfile\n"
     407        "   USING(stack_id)\n"
    408408        " WHERE\n"
    409         "   p6Run.state = 'run'\n"
    410         "   AND p6SumSkyfile.p6_id IS NULL\n"
     409        "   stackRun.state = 'run'\n"
     410        "   AND stackSumSkyfile.stack_id IS NULL\n"
    411411    );
    412412
    413413    if (config->where) {
    414         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p6SumSkyfile");
     414        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "stackSumSkyfile");
    415415        psStringAppend(&query, " AND %s", whereClause);
    416416        psFree(whereClause);
     
    446446    }
    447447    if (!psArrayLength(output)) {
    448         psError(PS_ERR_UNKNOWN, false, "no p6SumSkyfile rows found");
     448        psError(PS_ERR_UNKNOWN, false, "no stackSumSkyfile rows found");
    449449        psFree(output);
    450450        return true;
     
    463463    if (psArrayLength(output)) {
    464464        // negative simple so the default is true
    465         if (!ippdbPrintMetadatas(stdout, output, "p6SumSkyfile", !simple)) {
     465        if (!ippdbPrintMetadatas(stdout, output, "stackSumSkyfile", !simple)) {
    466466            psError(PS_ERR_UNKNOWN, false, "failed to print array");
    467467            psFree(output);
     
    481481
    482482    bool status = false;
    483     psString p6_id = psMetadataLookupStr(&status, config->args, "-p6_id");
    484     if (!status) {
    485         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p6_id");
    486         return false;
    487     }
    488     if (!p6_id) {
    489         psError(PS_ERR_UNKNOWN, true, "-p6_id is required");
     483    psString stack_id = psMetadataLookupStr(&status, config->args, "-stack_id");
     484    if (!status) {
     485        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -stack_id");
     486        return false;
     487    }
     488    if (!stack_id) {
     489        psError(PS_ERR_UNKNOWN, true, "-stack_id is required");
    490490        return false;
    491491
     
    520520    }
    521521
    522     // XXX need to validate the p6_id here
     522    // XXX need to validate the stack_id here
    523523    // XXX instead of validiting it here we should just use forgein key
    524524    // constrants
    525     if (!p6SumSkyfileInsert(config->dbh,
    526             (psS32)atoi(p6_id),
     525    if (!stackSumSkyfileInsert(config->dbh,
     526            (psS32)atoi(stack_id),
    527527            uri,
    528528            bg,
     
    536536    }
    537537
    538     if (setp6RunState(config, p6_id, "stop")) {
     538    if (setstackRunState(config, stack_id, "stop")) {
    539539        if (!psDBRollback(config->dbh)) {
    540540            psError(PS_ERR_UNKNOWN, false, "database error");
    541541        }
    542         psError(PS_ERR_UNKNOWN, false, "failed to change p6Run's state");
     542        psError(PS_ERR_UNKNOWN, false, "failed to change stackRun's state");
    543543        return false;
    544544    }
     
    568568    psString query = psStringCopy(
    569569        "SELECT\n"
    570         "   p6SumSkyfile.*\n"
    571         " FROM p6Run\n"
    572         " JOIN p6SumSkyfile\n"
    573         "   USING(p6_id)\n"
     570        "   stackSumSkyfile.*\n"
     571        " FROM stackRun\n"
     572        " JOIN stackSumSkyfile\n"
     573        "   USING(stack_id)\n"
    574574        " WHERE\n"
    575         "   p6Run.state = 'run'\n"
     575        "   stackRun.state = 'run'\n"
    576576    );
    577577
    578578    if (config->where) {
    579         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p6SumSkyfile");
     579        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "stackSumSkyfile");
    580580        psStringAppend(&query, " AND %s", whereClause);
    581581        psFree(whereClause);
     
    611611    }
    612612    if (!psArrayLength(output)) {
    613         psError(PS_ERR_UNKNOWN, false, "no p4Skyfile rows found");
     613        psError(PS_ERR_UNKNOWN, false, "no warpSkyfile rows found");
    614614        psFree(output);
    615615        return true;
     
    627627
    628628    if (psArrayLength(output)) {
    629         if (!ippdbPrintMetadatas(stdout, output, "p6SumSkyfile", !simple)) {
     629        if (!ippdbPrintMetadatas(stdout, output, "stackSumSkyfile", !simple)) {
    630630            psError(PS_ERR_UNKNOWN, false, "failed to print array");
    631631            psFree(output);
     
    640640
    641641
    642 static bool setp6RunState(pxConfig *config, const char *p6_id, const char *state)
    643 {
    644     PS_ASSERT_PTR_NON_NULL(p6_id, false);
     642static bool setstackRunState(pxConfig *config, const char *stack_id, const char *state)
     643{
     644    PS_ASSERT_PTR_NON_NULL(stack_id, false);
    645645    PS_ASSERT_PTR_NON_NULL(state, false);
    646646
     
    653653    ) {
    654654        psError(PS_ERR_UNKNOWN, false,
    655                 "invalid p4Run state: %s", state);
    656         return false;
    657     }
    658 
    659     char *query = "UPDATE p6Run SET state = '%s' WHERE p6_id = '%s'";
    660     if (!p_psDBRunQuery(config->dbh, query, state, p6_id)) {
     655                "invalid warpRun state: %s", state);
     656        return false;
     657    }
     658
     659    char *query = "UPDATE stackRun SET state = '%s' WHERE stack_id = '%s'";
     660    if (!p_psDBRunQuery(config->dbh, query, state, stack_id)) {
    661661        psError(PS_ERR_UNKNOWN, false,
    662                 "failed to change state for p6_id %s", p6_id);
    663         return false;
    664     }
    665 
    666     return true;
    667 }
     662                "failed to change state for stack_id %s", stack_id);
     663        return false;
     664    }
     665
     666    return true;
     667}
Note: See TracChangeset for help on using the changeset viewer.