IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 11, 2011, 4:29:48 PM (15 years ago)
Author:
watersc1
Message:

Trying to merge back into trunk.

Location:
branches/czw_branch/20101203
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20101203

  • branches/czw_branch/20101203/ippTools/src/pztool.c

    r29982 r30586  
    4747static bool advanceMode(pxConfig *config);
    4848
     49static bool updatepzexpMode(pxConfig *config);
     50static bool updatenewexpMode(pxConfig *config);
     51
    4952// static bool copydoneCompleteExp(pxConfig *config);
    5053static psArray *pzGetPendingCameras(pxConfig *config);
     
    8386        MODECASE(PZTOOL_MODE_TOADVANCE, toadvanceMode);
    8487        MODECASE(PZTOOL_MODE_ADVANCE, advanceMode);
     88        MODECASE(PZTOOL_MODE_UPDATEPZEXP, updatepzexpMode);
     89        MODECASE(PZTOOL_MODE_UPDATENEWEXP, updatenewexpMode);
    8590        default:
    8691            psAbort("invalid option (this should not happen)");
     
    294299
    295300    psMetadata *where = psMetadataAlloc();
    296     PXOPT_COPY_STR(config->args, where,  "-exp_name",     "exp_name", "==");
    297     PXOPT_COPY_STR(config->args, where,  "-inst",         "camera", "==");
    298     PXOPT_COPY_STR(config->args, where,  "-telescope",    "telescope", "==");
    299     PXOPT_COPY_STR(config->args, where,  "-exp_type",     "exp_type", "==");
     301    PXOPT_COPY_STR(config->args, where,  "-exp_name",      "exp_name",  "==");
     302    PXOPT_COPY_STR(config->args, where,  "-inst",          "camera",    "==");
     303    PXOPT_COPY_STR(config->args, where,  "-telescope",     "telescope", "==");
     304    PXOPT_COPY_STR(config->args, where,  "-exp_type",      "exp_type",  "==");
     305    PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "dateobs",   ">=");
     306    PXOPT_COPY_TIME(config->args, where, "-dateobs_end",   "dateobs",   "<=");
    300307
    301308    PXOPT_LOOKUP_BOOL(desc, config->args, "-desc", false);
     
    325332
    326333        if (psListLength(where->list)) {
    327             psString whereClause = psDBGenerateWhereConditionSQL(where, "pzDownloadImfile");
     334            psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    328335            psStringAppend(&query, " AND %s", whereClause);
    329336            psFree(whereClause);
     
    889896            || (strncmp(state, "stop", 5) == 0)
    890897            || (strncmp(state, "reg", 4) == 0)
     898            || (strncmp(state, "drop", 5) == 0)
    891899        )
    892900    ) {
     
    905913}
    906914
     915static bool updatepzexpMode(pxConfig *config)
     916{
     917  PS_ASSERT_PTR_NON_NULL(config, false);
     918  PXOPT_LOOKUP_STR(exp_name, config->args, "-exp_name", true, false);
     919  PXOPT_LOOKUP_STR(camera,   config->args, "-inst",   true, false);
     920  PXOPT_LOOKUP_STR(telescope,config->args, "-telescope",true, false);
     921  PXOPT_LOOKUP_STR(state,    config->args, "-set_state",true, false);
     922
     923  if (!pzDownloadExpSetState(config,exp_name,camera,telescope,state)) {
     924    psError(PS_ERR_UNKNOWN, false, "failed to change state for %s:%s:%s", exp_name, camera, telescope);
     925    return false;
     926  }
     927  return true;
     928}
     929 
     930 
     931static bool updatenewexpMode(pxConfig *config)
     932{
     933    PS_ASSERT_PTR_NON_NULL(config, false);
     934
     935    psMetadata *where = psMetadataAlloc();
     936    PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "==");
     937    PXOPT_COPY_STR(config->args, where,  "-exp_name", "tmp_exp_name", "==");
     938
     939    PXOPT_LOOKUP_STR(new_state, config->args, "-set_state", true, false);
     940
     941    if (strcmp(new_state, "drop") && strcmp(new_state, "run") && strcmp(new_state, "wait")) {
     942        psError(PXTOOLS_ERR_ARGUMENTS, true, "%s is not a valid value for -set_state", new_state);
     943        psFree(where);
     944        return false;
     945    }
     946
     947    if (psListLength(where->list) < 1) {
     948        psFree(where);
     949        psError(PXTOOLS_ERR_CONFIG, false, "-exp_name or -exp_id is required");
     950        return false;
     951    }
     952
     953    psString query = NULL;
     954    psStringAppend(&query, "UPDATE newExp SET state = '%s'", new_state);
     955
     956    psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     957    psStringAppend(&query, "\nWHERE %s", whereClause);
     958
     959    psFree(whereClause);
     960    psFree(where);
     961
     962    if (!p_psDBRunQuery(config->dbh, query)) {
     963        psError(PS_ERR_UNKNOWN, false, "database error");
     964        psFree(query);
     965        return false;
     966    }
     967    psFree(query);
     968
     969    return true;
     970}
     971
     972
     973
    907974
    908975#if 0
Note: See TracChangeset for help on using the changeset viewer.