IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11075 for trunk/ippTools/src


Ignore:
Timestamp:
Jan 12, 2007, 12:24:34 PM (19 years ago)
Author:
jhoblitt
Message:

catch renaming raw*Exp -> rawExp conversions
update p3tool to the 'new' fault handling semantics

Location:
trunk/ippTools/src
Files:
5 edited

Legend:

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

    r11024 r11075  
    3030static bool pendingimfileMode(pxConfig *config);
    3131static bool addprocessedexpMode(pxConfig *config);
    32 static bool faultexpMode(pxConfig *config);
     32static bool processedexpMode(pxConfig *config);
     33static bool updateprocessedexpMode(pxConfig *config);
    3334static bool blockMode(pxConfig *config);
    3435static bool maskedMode(pxConfig *config);
     
    5253        MODECASE(P3TOOL_MODE_PENDINGIMFILE,     pendingimfileMode);
    5354        MODECASE(P3TOOL_MODE_ADDPROCESSEDEXP,   addprocessedexpMode);
    54         MODECASE(P3TOOL_MODE_FAULTEXP,          faultexpMode);
     55        MODECASE(P3TOOL_MODE_PROCESSEDEXP,      processedexpMode);
     56        MODECASE(P3TOOL_MODE_UPDATEPROCESSEDEXP,updateprocessedexpMode);
    5557        MODECASE(P3TOOL_MODE_BLOCK,             blockMode);
    5658        MODECASE(P3TOOL_MODE_MASKED,            maskedMode);
     
    8688    }
    8789
    88     bool faulted = psMetadataLookupU64(&status, config->args, "-faulted");
    89     if (!status) {
    90         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -faulted");
    91         return false;
    92     }
    93 
    9490    psString query = psStringCopy(
    9591            "SELECT"
    9692            "   p3PendingExp.*,"
    97             "   rawScienceExp.camera"
     93            "   rawExp.camera"
    9894            " FROM p3PendingExp"
    99             " JOIN rawScienceExp"
     95            " JOIN rawExp"
    10096            "   USING(exp_tag)"
    10197            " LEFT JOIN p3ProcessedExp"
     
    114110    }
    115111
    116     if (faulted) {
    117         // list only faulted rows
    118         psStringAppend(&query, " %s", "AND p3PendingExp.fault != 0");
    119     } else {
    120         // don't list faulted rows
    121         psStringAppend(&query, " %s", "AND p3PendingExp.fault = 0");
    122     }
    123 
    124112    // treat limit == 0 as "no limit"
    125113    if (limit) {
     
    177165            "SELECT"
    178166            "   p2ProcessedImfile.*,"
    179             "   rawScienceExp.camera"   
     167            "   rawExp.camera"   
    180168            " FROM p3PendingExp"
    181             " JOIN rawScienceExp"
     169            " JOIN rawExp"
    182170            "   USING(exp_tag)"
    183171            " JOIN p2ProcessedImfile"
     
    345333        return false;
    346334    }
     335
    347336    // optional
    348337    psString b1_uri = psMetadataLookupStr(&status, config->args, "-b1_uri");
     
    354343    if (!status) {
    355344        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -b2_uri");
     345        return false;
     346    }
     347
     348    // default
     349    psS8 code = psMetadataLookupS8(&status, config->args, "-code");
     350    if (!status) {
     351        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code");
    356352        return false;
    357353    }
     
    380376    }
    381377    if (!psArrayLength(output)) {
    382         // XXX check psError here
    383378        psError(PS_ERR_UNKNOWN, false, "no p3PendingExp rows found");
     379        psFree(output);
    384380        return true;
     381    }
     382
     383    // start a transaction so we don't end up with an exp_tag is both
     384    // p3PendingExp & p3ProcessedExp
     385    if (!psDBTransaction(config->dbh)) {
     386        psError(PS_ERR_UNKNOWN, false, "database error");
     387        psFree(output);
     388        return false;
    385389    }
    386390
     
    404408        pendingRow->p2_version,
    405409        pendingRow->p3_version,
    406         pendingRow->label
     410        pendingRow->label,
     411        code
    407412    );
    408     psFree(pendingRow);
    409413
    410414    // insert the new row into the p3ProcessedImfile table
    411415    if (!p3ProcessedExpInsertObject(config->dbh, row)) {
     416        // rollback
     417        if (!psDBRollback(config->dbh)) {
     418            psError(PS_ERR_UNKNOWN, false, "database error");
     419        }
    412420        psError(PS_ERR_UNKNOWN, false, "database error");
    413421        psFree(row);
    414         return false;
    415     }
    416 
     422        psFree(pendingRow);
     423        return false;
     424    }
    417425    psFree(row);
    418426
    419     return true;
    420 }
    421 
    422 
    423 static bool faultexpMode(pxConfig *config)
     427    // delete the p3PendingExp row from the database
     428    if (!p3PendingExpDeleteObject(config->dbh, pendingRow)) {
     429        // rollback
     430        if (!psDBRollback(config->dbh)) {
     431            psError(PS_ERR_UNKNOWN, false, "database error");
     432        }
     433        psError(PS_ERR_UNKNOWN, false, "database error");
     434        psFree(pendingRow);
     435        return false;
     436    }
     437
     438    psFree(pendingRow);
     439
     440    // point of no return for p3PendingExp -> p3ProcessedExp
     441    if (!psDBCommit(config->dbh)) {
     442        psError(PS_ERR_UNKNOWN, false, "database error");
     443        return false;
     444    }
     445
     446    return true;
     447}
     448
     449static bool processedexpMode(pxConfig *config)
    424450{
    425451    PS_ASSERT_PTR_NON_NULL(config, false);
    426452
    427453    bool status = false;
    428     psS8 code = psMetadataLookupS8(&status, config->args, "-code");
    429     if (!status) {
    430         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code");
    431         return false;
    432     }
    433 
    434     if (!pxSetFaultCode(config->dbh, "p3PendingExp", config->where, code)) {
    435         psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
    436         return false;
    437     }
    438 
    439     return true;
    440 }
    441 
    442 
    443 static bool blockMode(pxConfig *config)
    444 {
    445     PS_ASSERT_PTR_NON_NULL(config, false);
    446 
    447     bool status = false;
    448     psString label = psMetadataLookupStr(&status, config->args, "-label");
    449     if (!status) {
    450         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -label");
    451         return false;
    452     }
    453     if (!label) {
    454         psError(PS_ERR_UNKNOWN, true, "-label is required");
    455         return false;
    456     }
    457 
    458     if (!p3MaskInsert(config->dbh, label)) {
    459         psError(PS_ERR_UNKNOWN, false, "database error");
    460         return false;
    461     }
    462 
    463     return true;
    464 }
    465 
    466 static bool maskedMode(pxConfig *config)
    467 {
    468     PS_ASSERT_PTR_NON_NULL(config, false);
    469 
    470     psString query = psStringCopy("SELECT * FROM p3Mask");
     454    psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
     455    if (!status) {
     456        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit");
     457        return false;
     458    }
     459
     460    bool faulted = psMetadataLookupU64(&status, config->args, "-faulted");
     461    if (!status) {
     462        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -faulted");
     463        return false;
     464    }
     465
     466    psString query = psStringCopy(
     467            "SELECT"
     468            "   p3ProcessedExp.*,"
     469            "   rawExp.camera"
     470            " FROM p3ProcessedExp"
     471            " JOIN rawExp"
     472            "   USING(exp_tag)"   
     473            " WHERE"
     474            "   p3ProcessedExp.exp_tag IS NOT NULL"
     475    );
     476
     477    if (config->where) {
     478        psString whereClause = psDBGenerateWhereConditionSQL(config->where, NULL);
     479        psStringAppend(&query, " %s", whereClause);
     480        psFree(whereClause);
     481    }
     482
     483    if (faulted) {
     484        // list only faulted rows
     485        psStringAppend(&query, " %s", "AND p3ProcessedExp.fault != 0");
     486    } else {
     487        // don't list faulted rows
     488        psStringAppend(&query, " %s", "AND p3ProcessedExp.fault = 0");
     489    }
     490
     491    // treat limit == 0 as "no limit"
     492    if (limit) {
     493        psString limitString = psDBGenerateLimitSQL(limit);
     494        psStringAppend(&query, " %s", limitString);
     495        psFree(limitString);
     496    }
    471497
    472498    if (!p_psDBRunQuery(config->dbh, query)) {
     
    484510    if (!psArrayLength(output)) {
    485511        // XXX check psError here
    486         psError(PS_ERR_UNKNOWN, false, "no p3Mask rows found");
     512        psError(PS_ERR_UNKNOWN, false, "no p3ProcessedExp rows found");
    487513        psFree(output);
    488514        return true;
     
    499525    }
    500526
     527    // negate simple so the default is true
     528    if (!ippdbPrintMetadatas(stdout, output, "p3ProcessedExp", !simple)) {
     529        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     530        psFree(output);
     531        return false;
     532    }
     533
     534    psFree(output);
     535
     536    return true;
     537}
     538
     539
     540static bool updateprocessedexpMode(pxConfig *config)
     541{
     542    PS_ASSERT_PTR_NON_NULL(config, false);
     543
     544    bool status = false;
     545    psS8 code = psMetadataLookupS8(&status, config->args, "-code");
     546    if (!status) {
     547        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code");
     548        return false;
     549    }
     550
     551    if (!pxSetFaultCode(config->dbh, "p3ProcessedExp", config->where, code)) {
     552        psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
     553        return false;
     554    }
     555
     556    return true;
     557}
     558
     559
     560static bool blockMode(pxConfig *config)
     561{
     562    PS_ASSERT_PTR_NON_NULL(config, false);
     563
     564    bool status = false;
     565    psString label = psMetadataLookupStr(&status, config->args, "-label");
     566    if (!status) {
     567        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -label");
     568        return false;
     569    }
     570    if (!label) {
     571        psError(PS_ERR_UNKNOWN, true, "-label is required");
     572        return false;
     573    }
     574
     575    if (!p3MaskInsert(config->dbh, label)) {
     576        psError(PS_ERR_UNKNOWN, false, "database error");
     577        return false;
     578    }
     579
     580    return true;
     581}
     582
     583static bool maskedMode(pxConfig *config)
     584{
     585    PS_ASSERT_PTR_NON_NULL(config, false);
     586
     587    psString query = psStringCopy("SELECT * FROM p3Mask");
     588
     589    if (!p_psDBRunQuery(config->dbh, query)) {
     590        psError(PS_ERR_UNKNOWN, false, "database error");
     591        psFree(query);
     592        return false;
     593    }
     594    psFree(query);
     595
     596    psArray *output = p_psDBFetchResult(config->dbh);
     597    if (!output) {
     598        psError(PS_ERR_UNKNOWN, false, "database error");
     599        return false;
     600    }
     601    if (!psArrayLength(output)) {
     602        // XXX check psError here
     603        psError(PS_ERR_UNKNOWN, false, "no p3Mask rows found");
     604        psFree(output);
     605        return true;
     606    }
     607
     608    bool simple = false;
     609    {
     610        bool status = false;
     611        simple = psMetadataLookupBool(&status, config->args, "-simple");
     612        if (!status) {
     613            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
     614            return false;
     615        }
     616    }
     617
    501618    // negative simple so the default is true
    502619    if (!ippdbPrintMetadatas(stdout, output, "p3Mask", !simple)) {
  • trunk/ippTools/src/camtool.h

    r11024 r11075  
    2828    P3TOOL_MODE_PENDINGIMFILE,
    2929    P3TOOL_MODE_ADDPROCESSEDEXP,
    30     P3TOOL_MODE_FAULTEXP,
     30    P3TOOL_MODE_PROCESSEDEXP,
     31    P3TOOL_MODE_UPDATEPROCESSEDEXP,
    3132    P3TOOL_MODE_BLOCK,
    3233    P3TOOL_MODE_MASKED,
  • trunk/ippTools/src/camtoolConfig.c

    r11024 r11075  
    5151    psMetadataAddU64(pendingexpArgs, PS_LIST_TAIL, "-limit",  0,
    5252        "limit result set to N items", 0);
    53     psMetadataAddBool(pendingexpArgs, PS_LIST_TAIL, "-faulted",  0,
    54         "only return imfiles with a fault status set", false);
    5553    psMetadataAddBool(pendingexpArgs, PS_LIST_TAIL, "-simple", 0,
    5654            "use the simple output format", false);
     
    9795    psMetadataAddStr(addprocessedexpArgs, PS_LIST_TAIL, "-b2_uri", 0,
    9896            "define banana 2", NULL);
    99 
    100     // -faultexp
    101     psMetadata *faultexpArgs = psMetadataAlloc();
    102     psMetadataAddStr(faultexpArgs, PS_LIST_TAIL, "-exp_tag",  0,
     97    psMetadataAddS8(addprocessedexpArgs, PS_LIST_TAIL, "-code",  0,
     98        "set fault code (required)", 0);
     99    psMetadataAddBool(pendingexpArgs, PS_LIST_TAIL, "-faulted",  0,
     100        "only return imfiles with a fault status set", false);
     101
     102    // -processedexp
     103    psMetadata *processedexpArgs = psMetadataAlloc();
     104    psMetadataAddStr(processedexpArgs, PS_LIST_TAIL, "-exp_tag", 0,
     105            "search by exposure ID", NULL);
     106    psMetadataAddS32(processedexpArgs, PS_LIST_TAIL, "-p2_version", 0,
     107            "search for exposures with this p2 version", -1);
     108    psMetadataAddS32(processedexpArgs, PS_LIST_TAIL, "-p3_version", 0,
     109            "search for exposures with this p3 version", -1);
     110    psMetadataAddU64(processedexpArgs, PS_LIST_TAIL, "-limit",  0,
     111        "limit result set to N items", 0);
     112    psMetadataAddBool(processedexpArgs, PS_LIST_TAIL, "-simple", 0,
     113            "use the simple output format", false);
     114
     115    // -updateprocessedexp
     116    psMetadata *updateprocessedexpArgs = psMetadataAlloc();
     117    psMetadataAddStr(updateprocessedexpArgs, PS_LIST_TAIL, "-exp_tag",  0,
    103118        "search by exposure ID", NULL);
    104     psMetadataAddStr(faultexpArgs, PS_LIST_TAIL, "-class",  0,
     119    psMetadataAddStr(updateprocessedexpArgs, PS_LIST_TAIL, "-class",  0,
    105120        "search by class", NULL);
    106     psMetadataAddStr(faultexpArgs, PS_LIST_TAIL, "-class_id",  0,
     121    psMetadataAddStr(updateprocessedexpArgs, PS_LIST_TAIL, "-class_id",  0,
    107122        "search by class ID", NULL);
    108     psMetadataAddS8(faultexpArgs, PS_LIST_TAIL, "-code",  0,
     123    psMetadataAddS8(updateprocessedexpArgs, PS_LIST_TAIL, "-code",  0,
    109124        "set fault code (required)", 0);
    110125
     
    146161    PXTOOL_MODE("-pendingexp",   P3TOOL_MODE_PENDINGEXP,    pendingexpArgs);
    147162    PXTOOL_MODE("-pendingimfile",P3TOOL_MODE_PENDINGIMFILE, pendingimfileArgs);
    148     PXTOOL_MODE("-faultexp",     P3TOOL_MODE_FAULTEXP,      faultexpArgs);
    149163    PXTOOL_MODE("-addprocessedexp", P3TOOL_MODE_ADDPROCESSEDEXP, addprocessedexpArgs);
     164    PXTOOL_MODE("-processedexp", P3TOOL_MODE_PROCESSEDEXP,  processedexpArgs);
     165    PXTOOL_MODE("-updateprocessedexp", P3TOOL_MODE_UPDATEPROCESSEDEXP,updateprocessedexpArgs);
    150166    PXTOOL_MODE("-block",        P3TOOL_MODE_BLOCK,         blockArgs);
    151167    PXTOOL_MODE("-masked",       P3TOOL_MODE_MASKED,        maskedArgs);
  • trunk/ippTools/src/chiptool.c

    r11034 r11075  
    9999            "SELECT"
    100100            "   p2PendingImfile.*,"
    101             "   rawScienceExp.camera"
     101            "   rawExp.camera"
    102102            " FROM p2PendingImfile"
    103103            " JOIN p2PendingExp"
    104104            "   USING(exp_tag)"
    105             " JOIN rawScienceExp"
     105            " JOIN rawExp"
    106106            "   USING(exp_tag)"
    107107            " LEFT JOIN p2Mask"
     
    353353            "SELECT"
    354354            "   p2ProcessedImfile.*,"
    355             "   rawScienceExp.camera"
     355            "   rawExp.camera"
    356356            " FROM p2ProcessedImfile"
    357             " JOIN rawScienceExp"
     357            " JOIN rawExp"
    358358            "   USING(exp_tag)"
    359359            " WHERE "
     
    554554    // where exp_tag is not in p2PendingImfile
    555555    // where the number of entries in p2ProccessedImfile matches the .imfiles
    556     // entry in rawScienceExp
     556    // entry in rawExp
    557557    psString query = psStringCopy(
    558558        "SELECT DISTINCT"
    559559        "   p2PendingExp.*,"
    560         "   rawScienceExp.imfiles,"
     560        "   rawExp.imfiles,"
    561561        "   p2ProcessedImfile.class_id"
    562562        " FROM p2PendingExp"
    563         " JOIN rawScienceExp"
    564         "   ON p2PendingExp.exp_tag = rawScienceExp.exp_tag"
     563        " JOIN rawExp"
     564        "   ON p2PendingExp.exp_tag = rawExp.exp_tag"
    565565        " LEFT JOIN p2ProcessedExp"
    566566        "   ON p2PendingExp.exp_tag = p2ProcessedExp.exp_tag"
     
    575575        " GROUP BY"
    576576        "   p2PendingExp.exp_tag"
    577         " HAVING rawScienceExp.imfiles = COUNT(p2ProcessedImfile.class_id)"
     577        " HAVING rawExp.imfiles = COUNT(p2ProcessedImfile.class_id)"
    578578        );
    579579
     
    773773        pendingExp->p1_version,
    774774        pendingExp->p2_version,
    775         pendingExp->label,
    776         0   // fault code
     775        pendingExp->label
    777776    );
    778777}
  • trunk/ippTools/src/detselect.c

    r10161 r11075  
    9090        // "   detRun.state,"
    9191        // "   detRunSummary.accept,"
    92         // "   rawDetrendExp.camera"
     92        // "   rawExp.camera"
    9393        " FROM detRun"
    9494        " JOIN detRunSummary "
     
    9797        "   ON detRunSummary.det_id = detInputExp.det_id"
    9898        "   AND detRunSummary.iteration = detInputExp.iteration"
    99         " JOIN rawDetrendExp"
    100         "   ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
     99        " JOIN rawExp"
     100        "   ON detInputExp.exp_tag = rawExp.exp_tag"
    101101        " JOIN rawImfile"
    102         "   ON rawDetrendExp.exp_tag = rawImfile.exp_tag"
     102        "   ON rawExp.exp_tag = rawImfile.exp_tag"
    103103        " WHERE"
    104104        "   detRun.state = 'stop'"
     
    106106        // XXX the following entry is needed to exclude db mismatched
    107107        // XXX these are caused by an error upstream and should be fixed
    108 //        "   AND detRun.det_type = rawDetrendExp.object"
     108//        "   AND detRun.det_type = rawExp.object"
    109109    );
    110110# endif
Note: See TracChangeset for help on using the changeset viewer.