IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 28, 2008, 11:17:03 AM (18 years ago)
Author:
jhoblitt
Message:

add camtool -updaterun

File:
1 edited

Legend:

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

    r16170 r17171  
    3131bool pxcamRunSetState(pxConfig *config, psS64 cam_id, const char *state)
    3232{
     33    PS_ASSERT_PTR_NON_NULL(config, false);
    3334    PS_ASSERT_PTR_NON_NULL(state, false);
    3435
     
    5152        return false;
    5253    }
     54
     55    return true;
     56}
     57
     58
     59bool pxcamRunSetStateByQuery(pxConfig *config, psMetadata *where, const char *state)
     60{
     61    PS_ASSERT_PTR_NON_NULL(config, false);
     62    PS_ASSERT_PTR_NON_NULL(state, false);
     63
     64    // check that state is a valid string value
     65    if (!(
     66            (strncmp(state, "run", 4) == 0)
     67            || (strncmp(state, "stop", 5) == 0)
     68            || (strncmp(state, "reg", 4) == 0)
     69        )
     70    ) {
     71        psError(PS_ERR_UNKNOWN, false,
     72                "invalid chipRun state: %s", state);
     73        return false;
     74    }
     75
     76    psString query = psStringCopy("UPDATE camRun JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) SET state = '%s'");
     77
     78    if (where) {
     79        psString whereClause = psDBGenerateWhereSQL(where, NULL);
     80        psStringAppend(&query, " %s", whereClause);
     81        psFree(whereClause);
     82    }
     83
     84    if (!p_psDBRunQuery(config->dbh, query, state)) {
     85        psFree(query);
     86        psError(PS_ERR_UNKNOWN, false, "database error");
     87        return false;
     88    }
     89
     90    psFree(query);
     91
     92    return true;
     93}
     94
     95
     96bool pxcamRunSetLabel(pxConfig *config, psS64 cam_id, const char *label)
     97{
     98    PS_ASSERT_PTR_NON_NULL(config, false);
     99    // note label == NULL should be explicitly allowed
     100
     101    char *query = "UPDATE camRun SET camRun.label = '%s' WHERE cam_id = %" PRId64;
     102    if (!p_psDBRunQuery(config->dbh, query, label, cam_id)) {
     103        psError(PS_ERR_UNKNOWN, false,
     104                "failed to change state for cam_id %" PRId64, cam_id);
     105        return false;
     106    }
     107
     108    return true;
     109}
     110
     111
     112bool pxcamRunSetLabelByQuery(pxConfig *config, psMetadata *where, const char *label)
     113{
     114    PS_ASSERT_PTR_NON_NULL(config, false);
     115    // note label == NULL should be explicitly allowed
     116
     117    psString query = psStringCopy("UPDATE camRun JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) SET camRun.label = '%s'");
     118
     119    if (where) {
     120        psString whereClause = psDBGenerateWhereSQL(where, NULL);
     121        psStringAppend(&query, " %s", whereClause);
     122        psFree(whereClause);
     123    }
     124
     125    if (!p_psDBRunQuery(config->dbh, query, label)) {
     126        psFree(query);
     127        psError(PS_ERR_UNKNOWN, false, "database error");
     128        return false;
     129    }
     130
     131    psFree(query);
    53132
    54133    return true;
Note: See TracChangeset for help on using the changeset viewer.