IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 20, 2006, 5:13:14 PM (20 years ago)
Author:
jhoblitt
Message:

add -selectruns

File:
1 edited

Legend:

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

    r7600 r7602  
    1111static bool defineMode(pxConfig *config);
    1212static bool runsMode(pxConfig *config);
     13static bool selectrunsMode(pxConfig *config);
    1314static bool inputMode(pxConfig *config);
    1415static bool rawMode(pxConfig *config);
     
    5051        MODECASE(DETTOOL_MODE_DEFINE, defineMode);
    5152        MODECASE(DETTOOL_MODE_RUNS, runsMode);
     53        MODECASE(DETTOOL_MODE_SELECTRUNS, selectrunsMode);
    5254        MODECASE(DETTOOL_MODE_INPUT, inputMode);
    5355        MODECASE(DETTOOL_MODE_RAW, rawMode);
     
    269271
    270272    psFree(runs);
     273
     274    return true;
     275}
     276
     277static bool selectrunsMode(pxConfig *config)
     278{
     279    PS_ASSERT_PTR_NON_NULL(config, 0);
     280
     281    // -inst & -dete_type are required
     282    bool status = false;
     283    psString camera = psMetadataLookupStr(&status, config->args, "-inst");
     284    if (!status) {
     285        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -inst");
     286        return false;
     287    }
     288    if (!camera) {
     289        psError(PS_ERR_UNKNOWN, true, "-inst is required");
     290        return false;
     291    }
     292    psString det_type = psMetadataLookupStr(&status, config->args, "-det_type");
     293    if (!status) {
     294        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_type");
     295        return false;
     296    }
     297    if (!det_type) {
     298        psError(PS_ERR_UNKNOWN, true, "-det_type is required");
     299        return false;
     300    }
     301
     302    char *query = "SELECT detRun.position, det_type, camera FROM detRun JOIN detInputExp where camera = '%s' and det_type = '%s' LIMIT 1";
     303
     304    if (!p_psDBRunQuery(config->dbh, query, camera, det_type)) {
     305        psError(PS_ERR_UNKNOWN, false, "database error");
     306        return false;
     307    }
     308
     309    psArray *result = p_psDBFetchResult(config->dbh);
     310    if (!result) {
     311    }
     312
     313    // sanity check the result
     314    if (psArrayLength(result) != 1) {
     315    }
     316
     317    // just a view... doesn't need to be free'd
     318    psMetadata *run = result->data[0];
     319
     320    psS32 det_id = psMetadataLookupS32(&status, run, "position");
     321    if (!status) {
     322        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for position");
     323        psFree(result);
     324        return false;
     325    }
     326
     327    psFree(result);
     328
     329    fprintf(stdout, "FLAT CHIP %d DONE\n", det_id);
    271330
    272331    return true;
     
    19872046    return newIteration;
    19882047}
     2048
Note: See TracChangeset for help on using the changeset viewer.