IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 22, 2008, 10:23:58 AM (18 years ago)
Author:
eugene
Message:

added -unmasked mode to chiptool; added various restrictions to dettool -runs

File:
1 edited

Legend:

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

    r16504 r16613  
    10111011
    10121012    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    1013 
     1013    PXOPT_LOOKUP_BOOL(active, config->args, "-active", false);
     1014    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     1015
     1016    PXOPT_COPY_STR(config->args, config->where, "-inst", "camera", "==");
     1017    PXOPT_COPY_STR(config->args, config->where, "-telescope", "telescope", "==");
     1018    PXOPT_COPY_STR(config->args, config->where, "-filter", "filter", "==");
     1019
     1020    // airmass_min  < airmass  < airmass_max
     1021    PXOPT_COPY_F32(config->args, config->where, "-airmass", "airmass_min", "<=");
     1022    PXOPT_COPY_F32(config->args, config->where, "-airmass", "airmass_max", ">=");
     1023
     1024    // exp_time_min < exp_time < exp_time_max
     1025    PXOPT_COPY_F32(config->args, config->where, "-exp_time", "exp_time_min", "<=");
     1026    PXOPT_COPY_F32(config->args, config->where, "-exp_time", "exp_time_max", ">=");
     1027
     1028    // ccd_temp_min < ccd_temp < ccd_temp_max
     1029    PXOPT_COPY_F32(config->args, config->where, "-ccd_temp", "ccd_temp_min", "<=");
     1030    PXOPT_COPY_F32(config->args, config->where, "-ccd_temp", "ccd_temp_max", ">=");
     1031
     1032    PXOPT_COPY_F64(config->args, config->where, "-posang", "posang_min", "<=");
     1033    PXOPT_COPY_F64(config->args, config->where, "-posang", "posang_max", ">=");
     1034
     1035    psString query = pxDataGet("dettool_runs.sql");
     1036    if (!query) {
     1037        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     1038        return false;
     1039    }
     1040   
     1041    if (config->where && active) {
     1042        psString whereClause = psDBGenerateWhereSQL(config->where, "detRun");
     1043        psStringAppend(&query, " %s AND (detRun.state = 'run' OR detRun.state = 'stop' OR detRun.state = 'register')", whereClause);
     1044        psFree(whereClause);
     1045    }
     1046    if (config->where && !active) {
     1047        psString whereClause = psDBGenerateWhereSQL(config->where, "detRun");
     1048        psStringAppend(&query, " %s", whereClause);
     1049        psFree(whereClause);
     1050    }
     1051    if (!config->where && active) {
     1052        psStringAppend(&query, " WHERE (detRun.state = 'run' OR detRun.state = 'stop' OR detRun.state = 'register')");
     1053    }
     1054
     1055    // treat limit == 0 as "no limit"
     1056    if (limit) {
     1057        psString limitString = psDBGenerateLimitSQL(limit);
     1058        psStringAppend(&query, " %s", limitString);
     1059        psFree(limitString);
     1060    }
     1061
     1062    if (!p_psDBRunQuery(config->dbh, query)) {
     1063        psError(PS_ERR_UNKNOWN, false, "database error");
     1064        psFree(query);
     1065        return false;
     1066    }
     1067    psFree(query);
     1068
     1069    psArray *runs = p_psDBFetchResult(config->dbh);
     1070    if (!runs) {
     1071        psError(PS_ERR_UNKNOWN, false, "database error");
     1072        return false;
     1073    }
     1074
     1075// XXX old version
     1076# if 0
    10141077    // XXX fix the hard coding of the table name
    10151078    psArray *runs = psDBSelectRows(config->dbh, "detRun", config->where, 0);
     
    10181081        return false;
    10191082    }
     1083# endif
    10201084
    10211085    if (!psArrayLength(runs)) {
Note: See TracChangeset for help on using the changeset viewer.