IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 16, 2007, 11:56:49 AM (19 years ago)
Author:
jhoblitt
Message:

update camtool -queue

File:
1 edited

Legend:

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

    r14147 r14227  
    8989}
    9090
    91 
    92 #define ADDPARAMSTR(from, to, name) \
     91#define ADDRENAMEPARAMSTR(from, to, oldname, newname, comment) \
    9392{ \
    9493    bool status = false; \
    95     psString str = psMetadataLookupStr(&status, from, "-" name); \
     94    psString str = psMetadataLookupStr(&status, from, "-" oldname); \
    9695    if (!status) { \
    97         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -" name); \
     96        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -" oldname); \
    9897        return false; \
    9998    } \
    10099    if (str) { \
    101         if (!psMetadataAddStr(to, PS_LIST_TAIL, name, 0, "==", str)) { \
    102             psError(PS_ERR_UNKNOWN, false, "failed to add item " name); \
     100        if (!psMetadataAddStr(to, PS_LIST_TAIL, newname, PS_META_DUPLICATE_OK, comment, str)) { \
     101            psError(PS_ERR_UNKNOWN, false, "failed to add item " newname); \
    103102            psFree(to); \
    104103            return false; \
     
    107106}
    108107
    109 
    110 #define ADDPARAMF(from, to, type, name) \
     108#define ADDPARAMSTR(from, to, name) \
     109  ADDRENAMEPARAMSTR(from, to, name, name, "==")
     110
     111#define ADDRENAMEPARAMF(from, to, type, oldname, newname, comment) \
    111112{ \
    112113    bool status = false; \
    113     ps##type var = psMetadataLookup##type(&status, from, "-" name); \
     114    ps##type var = psMetadataLookup##type(&status, from, "-" oldname); \
    114115    if (!status) { \
    115         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -" name); \
     116        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -" oldname); \
    116117        return false; \
    117118    } \
    118119    if (!isnan(var)) { \
    119         if (!psMetadataAdd##type(to, PS_LIST_TAIL, #name, 0, "==", var)) { \
    120             psError(PS_ERR_UNKNOWN, false, "failed to add item " name); \
     120        if (!psMetadataAdd##type(to, PS_LIST_TAIL, newname, PS_META_DUPLICATE_OK, comment, var)) { \
     121            psError(PS_ERR_UNKNOWN, false, "failed to add item " newname); \
    121122            psFree(to); \
    122123            return false; \
     
    125126}
    126127
     128#define ADDPARAMF(from, to, type, name) \
     129  ADDRENAMEPARAMF(from, to, type, name, name, "==")
     130
    127131static bool queueMode(pxConfig *config)
    128132{
     
    130134
    131135    psMetadata *where = psMetadataAlloc();
     136    // convert chip_id into a psS64
    132137{
    133138    bool status = false;
     
    145150    }
    146151}
    147 
    148     ADDPARAMSTR(config->args, where, "exp_id");
     152    // convert exp_id into a psS64
     153{
     154    bool status = false;
     155    psString var = psMetadataLookupStr(&status, config->args, "-exp_id");
     156    if (!status) {
     157        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
     158        return false;
     159    }
     160    if (var) {
     161        if (!psMetadataAddS64(where, PS_LIST_TAIL, "exp_id", 0, "==", (psS64)atoll(var))) {
     162            psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
     163            psFree(where);
     164            return false;
     165        }
     166    }
     167}
    149168    ADDPARAMSTR(config->args, where, "exp_name");
    150     ADDPARAMSTR(config->args, where, "inst");
     169    ADDRENAMEPARAMSTR(config->args, where, "inst", "camera", "==");
    151170    ADDPARAMSTR(config->args, where, "telescope");
    152     ADDPARAMSTR(config->args, where, "dateobs");
     171    ADDPARAMSTR(config->args, where, "dateobs_begin");
     172    ADDPARAMSTR(config->args, where, "dateobs_end");
     173    ADDPARAMSTR(config->args, where, "exp_tag");
    153174    ADDPARAMSTR(config->args, where, "exp_type");
    154     ADDPARAMSTR(config->args, where, "imfiles");
    155     ADDPARAMSTR(config->args, where, "workdir");
     175    ADDPARAMSTR(config->args, where, "filelevel");
     176    ADDPARAMSTR(config->args, where, "reduction");
    156177    ADDPARAMSTR(config->args, where, "filter");
    157     ADDPARAMF(config->args, where, F32, "airmass");
    158     ADDPARAMF(config->args, where, F32, "ra");
    159     ADDPARAMF(config->args, where, F32, "decl");
    160     ADDPARAMF(config->args, where, F32, "exp_time");
    161     ADDPARAMF(config->args, where, F64, "bg");
    162     ADDPARAMF(config->args, where, F64, "bg_stdev");
    163     ADDPARAMF(config->args, where, F64, "bg_mean_stdev");
    164     ADDPARAMF(config->args, where, F64, "alt");
    165     ADDPARAMF(config->args, where, F64, "az");
    166     ADDPARAMF(config->args, where, F32, "ccd_temp");
    167     ADDPARAMF(config->args, where, F64, "posang");
     178    ADDRENAMEPARAMF(config->args, where, F64, "airmass_min", "airmass", ">=");
     179    ADDRENAMEPARAMF(config->args, where, F64, "airmass_max", "airmass", "<");
     180    ADDRENAMEPARAMF(config->args, where, F64, "ra_min", "ra", ">=");
     181    ADDRENAMEPARAMF(config->args, where, F64, "ra_max", "ra", "<");
     182    ADDRENAMEPARAMF(config->args, where, F64, "decl_min", "decl", ">=");
     183    ADDRENAMEPARAMF(config->args, where, F64, "decl_max", "decl", "<");
     184    ADDRENAMEPARAMF(config->args, where, F32, "exp_time_min", "exp_time", ">=");
     185    ADDRENAMEPARAMF(config->args, where, F32, "exp_time_max", "exp_time", "<");
     186    ADDRENAMEPARAMF(config->args, where, F32, "sat_pixel_frac_min", "sat_pixel_frac", ">=");
     187    ADDRENAMEPARAMF(config->args, where, F32, "sat_pixel_frac_max", "sat_pixel_frac", "<");
     188    ADDRENAMEPARAMF(config->args, where, F64, "bg_min", "bt", ">=");
     189    ADDRENAMEPARAMF(config->args, where, F64, "bg_max", "bt", "<");
     190    ADDRENAMEPARAMF(config->args, where, F64, "bg_stdev_min", "bg_stdev", ">=");
     191    ADDRENAMEPARAMF(config->args, where, F64, "bg_stdev_max", "bg_stdev", "<");
     192    ADDRENAMEPARAMF(config->args, where, F64, "bg_mean_stdev_min", "bg_mean_stdev", ">=");
     193    ADDRENAMEPARAMF(config->args, where, F64, "bg_mean_stdev_max", "bg_mean_stdev", "<");
     194    ADDRENAMEPARAMF(config->args, where, F64, "alt_min", "alt", ">=");
     195    ADDRENAMEPARAMF(config->args, where, F64, "alt_max", "alt", "<");
     196    ADDRENAMEPARAMF(config->args, where, F64, "az_min", "az", ">=");
     197    ADDRENAMEPARAMF(config->args, where, F64, "az_max", "az", "<");
     198    ADDRENAMEPARAMF(config->args, where, F32, "ccd_temp_min", "ccd_temp", ">=");
     199    ADDRENAMEPARAMF(config->args, where, F32, "ccd_temp_max", "ccd_temp", "<");
     200    ADDRENAMEPARAMF(config->args, where, F64, "posang_min", "posang", ">=");
     201    ADDRENAMEPARAMF(config->args, where, F64, "posang_max", "posang", "<");
    168202    ADDPARAMSTR(config->args, where, "object");
     203    ADDRENAMEPARAMF(config->args, where, F32, "solang_min", "solang", ">=");
     204    ADDRENAMEPARAMF(config->args, where, F32, "solang_max", "solang", "<");
    169205
    170206    if (where->list->n < 1) {
     
    204240    }
    205241
    206     // find the chipProcessedExp exposures that we want to queue up.
    207 //    psString query = psStringCopy("SELECT * FROM chipRun WHERE chipRun.state = 'stop'");
     242    // find the exp_id of all the exposures that we want to queue up.
    208243    psString query = pxDataGet("camtool_find_chip_id.sql");
    209244    if (!query) {
     
    213248
    214249    if (where) {
    215         psString whereClause = psDBGenerateWhereSQL(where, "");
     250        psString whereClause = psDBGenerateWhereConditionSQL(where, "");
    216251        psFree(where);
    217         psStringAppend(&query, " %s", whereClause);
     252        psStringAppend(&query, " AND %s", whereClause);
    218253        psFree(whereClause);
    219254    }
     
    232267    }
    233268    if (!psArrayLength(output)) {
    234         psTrace("chiptool", PS_LOG_INFO, "no rows found");
     269        psTrace("camtool", PS_LOG_INFO, "no rows found");
    235270        psFree(output);
    236271        return true;
    237272    }
    238273
     274    // start a transaction so we don't end up with an exp without any associted
     275    // imfiles
    239276    if (!psDBTransaction(config->dbh)) {
    240277        psError(PS_ERR_UNKNOWN, false, "database error");
     
    248285    // old values in place (i.e., passing the values through).
    249286
    250     // loop over our list of chipProcessedExp rows
     287    // loop over our list of chipRun rows
    251288    for (long i = 0; i < psArrayLength(output); i++) {
    252289        psMetadata *md = output->data[i];
Note: See TracChangeset for help on using the changeset viewer.