IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11002


Ignore:
Timestamp:
Jan 9, 2007, 3:59:08 PM (19 years ago)
Author:
jhoblitt
Message:

rename setFaultCode() -> pxSetFaultCode() and move it into it's own file
add p2tool -faultimfile & -pendingimfile -faulted & -pendingimfile -limit

Location:
trunk/ippTools/src
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/Makefile.am

    r10642 r11002  
    3232libpxtools_la_SOURCES   = \
    3333        pxconfig.c \
     34        pxfault.c \
    3435        pxframes.c \
    3536        pxtables.c \
  • trunk/ippTools/src/chiptool.c

    r10943 r11002  
    3333static bool pendingimfileMode(pxConfig *config);
    3434static bool addprocessedimfileMode(pxConfig *config);
     35static bool faultimfileMode(pxConfig *config);
    3536static bool blockMode(pxConfig *config);
    3637static bool maskedMode(pxConfig *config);
     
    5859        MODECASE(P2TOOL_MODE_PENDINGIMFILE,         pendingimfileMode);
    5960        MODECASE(P2TOOL_MODE_ADDPROCESSEDIMFILE,    addprocessedimfileMode);
     61        MODECASE(P2TOOL_MODE_FAULTIMFILE,           faultimfileMode);
    6062        MODECASE(P2TOOL_MODE_BLOCK,                 blockMode);
    6163        MODECASE(P2TOOL_MODE_MASKED,                maskedMode);
     
    174176    PS_ASSERT_PTR_NON_NULL(config, NULL);
    175177
     178    bool status = false;
     179    psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
     180    if (!status) {
     181        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit");
     182        return false;
     183    }
     184
     185    bool faulted = psMetadataLookupU64(&status, config->args, "-faulted");
     186    if (!status) {
     187        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -faulted");
     188        return false;
     189    }
     190
    176191    // XXX does this need to be constrained so that it won't return any results
    177192    // if a match p2PendingExp hasn't been registered?
     
    197212    }
    198213
     214    if (faulted) {
     215        // list only faulted rows
     216        psStringAppend(&query, " %s", "AND p2PendingImfile.fault != 0");
     217    } else {
     218        // don't list faulted rows
     219        psStringAppend(&query, " %s", "AND p2PendingImfile.fault = 0");
     220    }
     221
     222    // treat limit == 0 as "no limit"
     223    if (limit) {
     224        psString limitString = psDBGenerateLimitSQL(limit);
     225        psStringAppend(&query, " %s", limitString);
     226        psFree(limitString);
     227    }
     228
    199229    if (!p_psDBRunQuery(config->dbh, query)) {
    200230        psError(PS_ERR_UNKNOWN, false, "database error");
     
    401431    return true;
    402432}
     433
     434
     435static bool faultimfileMode(pxConfig *config)
     436{
     437    PS_ASSERT_PTR_NON_NULL(config, false);
     438
     439    bool status = false;
     440    psS8 code = psMetadataLookupS8(&status, config->args, "-code");
     441    if (!status) {
     442        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code");
     443        return false;
     444    }
     445
     446    if (!pxSetFaultCode(config->dbh, "p2PendingImfile", config->where, code)) {
     447        psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
     448        return false;
     449    }
     450
     451    return true;
     452}
     453
    403454
    404455static bool blockMode(pxConfig *config)
  • trunk/ippTools/src/chiptool.h

    r9765 r11002  
    2929    P2TOOL_MODE_PENDINGIMFILE,
    3030    P2TOOL_MODE_ADDPROCESSEDIMFILE,
     31    P2TOOL_MODE_FAULTIMFILE,
    3132    P2TOOL_MODE_BLOCK,
    3233    P2TOOL_MODE_MASKED,
  • trunk/ippTools/src/chiptoolConfig.c

    r10440 r11002  
    5959    psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-uri",  0,
    6060            "define URL", NULL);
     61    psMetadataAddU64(pendingimfileArgs, PS_LIST_TAIL, "-limit",  0,
     62        "limit result set to N items", 0);
     63    psMetadataAddBool(pendingimfileArgs, PS_LIST_TAIL, "-faulted",  0,
     64        "only return imfiles with a fault status set", false);
    6165    psMetadataAddBool(pendingimfileArgs, PS_LIST_TAIL, "-simple",  0,
    6266            "use the simple output format", false);
     
    8387            "define banana 2", NULL);
    8488
     89    // -faultimfile
     90    psMetadata *faultimfileArgs = psMetadataAlloc();
     91    psMetadataAddStr(faultimfileArgs, PS_LIST_TAIL, "-exp_tag",  0,
     92        "search by exposure ID", NULL);
     93    psMetadataAddStr(faultimfileArgs, PS_LIST_TAIL, "-class",  0,
     94        "search by class", NULL);
     95    psMetadataAddStr(faultimfileArgs, PS_LIST_TAIL, "-class_id",  0,
     96        "search by class ID", NULL);
     97    psMetadataAddS8(faultimfileArgs, PS_LIST_TAIL, "-code",  0,
     98        "set fault code (required)", 0);
     99
     100
    85101    // -block
    86102    psMetadata *blockArgs = psMetadataAlloc();
     
    121137    PXTOOL_MODE("-pendingimfile", P2TOOL_MODE_PENDINGIMFILE, pendingimfileArgs);
    122138    PXTOOL_MODE("-addprocessedimfile",P2TOOL_MODE_ADDPROCESSEDIMFILE,addprocessedimfileArgs);
     139    PXTOOL_MODE("-faultimfile",  P2TOOL_MODE_FAULTIMFILE,   faultimfileArgs);
    123140    PXTOOL_MODE("-block",        P2TOOL_MODE_BLOCK,          blockArgs);
    124141    PXTOOL_MODE("-masked",       P2TOOL_MODE_MASKED,         maskedArgs);
  • trunk/ippTools/src/pxtools.h

    r10953 r11002  
    6969bool rawScienceFrameInsert(pxConfig *config, rawScienceFrame *frame);
    7070
     71bool pxSetFaultCode(psDB *dbh, const char *tableName, psMetadata *where, psS8 code);
     72
    7173#endif // PXTOOLS_H
  • trunk/ippTools/src/regtool.c

    r10988 r11002  
    4141static rawImfileRow *newToRawImfile(pxConfig *config, newImfileRow *exp);
    4242//static psU32 mapCodeStrToInt(const char *codeStr);
    43 static bool setFaultCode(psDB *dbh, const char *tableName, psMetadata *where, psS8 code);
    4443
    4544
     
    281280    }
    282281
    283     if (!setFaultCode(config->dbh, "newExp", config->where, code)) {
     282    if (!pxSetFaultCode(config->dbh, "newExp", config->where, code)) {
    284283        psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
    285284        return false;
     
    300299    }
    301300
    302     if (!setFaultCode(config->dbh, "newImfile", config->where, code)) {
     301    if (!pxSetFaultCode(config->dbh, "newImfile", config->where, code)) {
    303302        psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
    304         return false;
    305     }
    306 
    307     return true;
    308 }
    309 
    310 
    311 static bool setFaultCode(psDB *dbh, const char *tableName, psMetadata *where, psS8 code)
    312 {
    313     PS_ASSERT_PTR_NON_NULL(dbh, false);
    314     PS_ASSERT_PTR_NON_NULL(tableName, false);
    315     PS_ASSERT_PTR_NON_NULL(where, false);
    316 
    317 #if 0
    318     // map code string to numeric fault code
    319     psU32 code = mapCodeStrToInt(codeStr);
    320     if (code == (psU32)-1) {
    321         psError(PS_ERR_UNKNOWN, false, "error resolving error code");
    322         return false;
    323     }
    324 #endif
    325 
    326     // update the database
    327     psMetadata *values = psMetadataAlloc();
    328     if (!psMetadataAddS8(values, PS_LIST_HEAD, "fault", 0, NULL, code)) {
    329         psError(PS_ERR_UNKNOWN, false, "failed to add metadata item fault");
    330         psFree(values);
    331         return false;
    332     }
    333     psFree(values);
    334 
    335     long rowsAffected = psDBUpdateRows(dbh, tableName, where, values);
    336     if (rowsAffected < 0) {
    337         // database error
    338         psError(PS_ERR_UNKNOWN, false, "database error");
    339         return false;
    340     }
    341     if (rowsAffected < 1) {
    342         // we didn't do anything
    343         psError(PS_ERR_UNKNOWN, false, "zero rows were affected - either the search criteria didn't match any rows or the field already had the value being set.");
    344303        return false;
    345304    }
     
    839798        exp->exp_tag,
    840799        "my recipe",
    841         0xff, // XXX calc version number
    842         0xff, // XXX calc version number
    843         label
     800        0xff,   // XXX calc version number
     801        0xff,   // XXX calc version number
     802        label,
     803        0       // fault code
    844804    );
    845805
     
    855815        "my recipe",
    856816        0xff, // XXX calc version number
    857         0xff // XXX calc version number
     817        0xff, // XXX calc version number
     818        0       // fault code
    858819    );
    859820}
Note: See TracChangeset for help on using the changeset viewer.