IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 2, 2008, 7:46:21 AM (18 years ago)
Author:
eugene
Message:

fixed the options for definebydetrun; added additional states: wait, test ignore

File:
1 edited

Legend:

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

    r19771 r19812  
    245245    PXOPT_LOOKUP_S64(ref_det_id, config->args, "-ref_det_id", true, false);
    246246    PXOPT_LOOKUP_S32(ref_iter, config->args, "-ref_iter", true, false);
    247     if (!strncmp(mode, "verify", 7) && ((ref_det_id == 0) || (ref_iter == -1))) {
     247    if (!strcmp(mode, "verify") && ((ref_det_id == 0) || (ref_iter == -1))) {
    248248        psError(PS_ERR_UNKNOWN, false, "verify mode requires both -ref_det_id and -ref_iter");
    249249        return false;
    250250    }
    251     if (strncmp(mode, "verify", 7) && ((ref_det_id != 0) || (ref_iter != -1))) {
     251    if (strcmp(mode, "verify") && ((ref_det_id != 0) || (ref_iter != -1))) {
    252252        psError(PS_ERR_UNKNOWN, false, "master mode cannot have -ref_det_id or -ref_iter set");
    253253        return false;
     
    494494    PXOPT_LOOKUP_S64(ref_det_id, config->args, "-ref_det_id", false, false);
    495495    PXOPT_LOOKUP_S32(ref_iter, config->args, "-ref_iter", false, false);
    496     if (!strncmp(mode, "verify", 7) && ((ref_det_id == 0) || (ref_iter == -1))) {
     496    if (!strcmp(mode, "verify") && ((ref_det_id == 0) || (ref_iter == -1))) {
    497497        psError(PS_ERR_UNKNOWN, false, "verify mode requires both -ref_det_id and -ref_iter");
    498498        return false;
    499499    }
    500     if (strncmp(mode, "verify", 7) && ((ref_det_id != 0) || (ref_iter != -1))) {
     500    if (strcmp(mode, "verify") && ((ref_det_id != 0) || (ref_iter != -1))) {
    501501        psError(PS_ERR_UNKNOWN, false, "master mode cannot have -ref_det_id or -ref_iter set");
    502502        return false;
     
    734734    PXOPT_LOOKUP_S64(ref_det_id, config->args, "-ref_det_id", false, false);
    735735    PXOPT_LOOKUP_S32(ref_iter, config->args, "-ref_iter", false, false);
    736     if (!strncmp(mode, "verify", 7) && ((ref_det_id == 0) || (ref_iter == -1))) {
     736    if (!strcmp(mode, "verify") && ((ref_det_id == 0) || (ref_iter == -1))) {
    737737        psError(PS_ERR_UNKNOWN, false, "verify mode requires both -ref_det_id and -ref_iter");
    738738        return false;
    739739    }
    740     if (strncmp(mode, "verify", 7) && ((ref_det_id != 0) || (ref_iter != -1))) {
     740    if (strcmp(mode, "verify") && ((ref_det_id != 0) || (ref_iter != -1))) {
    741741        psError(PS_ERR_UNKNOWN, false, "master mode cannot have -ref_det_id or -ref_iter set");
    742742        return false;
     
    920920
    921921    // additional restriction on the detInputExp's to be selected
    922     PXOPT_COPY_TIME(config->args, input_filter, "-set_input_begin", "dateobs", ">=");
    923     PXOPT_COPY_TIME(config->args, input_filter, "-set_input_end", "dateobs", "<");
    924 
     922    PXOPT_LOOKUP_TIME(input_begin, config->args, "-set_input_begin", false, false);
     923    if (input_begin) {
     924      PXOPT_COPY_TIME(config->args, input_filter, "-set_input_begin", "dateobs", ">=");
     925    }
     926    PXOPT_LOOKUP_TIME(input_end, config->args, "-set_input_end", false, false);
     927    if (input_end) {
     928      PXOPT_COPY_TIME(config->args, input_filter, "-set_input_end", "dateobs", "<");
     929    }
    925930    PXOPT_LOOKUP_BOOL(only_accepted, config->args, "-only_accepted", false); // optional
    926931
     
    962967
    963968    if (only_accepted) {
    964         psString whereClause = NULL;
    965         psStringAppend(&whereClause, " AND accept = 1");
    966         psStringAppend(&query, " AND %s", whereClause);
    967         psFree(whereClause);
     969        psStringAppend(&query, " AND accept = 1");
    968970    }
    969971
     
    17701772    PS_ASSERT_PTR_NON_NULL(state, false);
    17711773
    1772     // check that state is a valid string value
    1773     if (!(
    1774             (strncmp(state, "run", 4) == 0)
    1775             || (strncmp(state, "stop", 5) == 0)
    1776             || (strncmp(state, "drop", 5) == 0)
    1777             || (strncmp(state, "register", 4) == 0)
    1778         )
    1779     ) {
    1780         psError(PS_ERR_UNKNOWN, false,
    1781                 "invalid detRun state: %s", state);
    1782         return false;
    1783     }
     1774    if (!isValidDetRunState (state)) return false;
    17841775
    17851776    char *query = "UPDATE detRun SET state = '%s' WHERE det_id = %" PRId64;
    17861777    if (!p_psDBRunQuery(config->dbh, query, state, det_id)) {
    1787         psError(PS_ERR_UNKNOWN, false,
    1788                 "failed to change state for det_id %" PRId64, det_id);
    1789         return false;
    1790     }
    1791 
    1792     return true;
     1778        psError(PS_ERR_UNKNOWN, false, "failed to change state for det_id %" PRId64, det_id);
     1779        return false;
     1780    }
     1781
     1782    return true;
     1783}
     1784
     1785// the detRun states are a superset of the data states below
     1786bool isValidDetRunState (const char *state) {
     1787
     1788    // check that state is a valid string value
     1789    if (!strcmp(state, "run")) return true;
     1790    if (!strcmp(state, "stop")) return true;
     1791    if (!strcmp(state, "drop")) return true;
     1792    if (!strcmp(state, "wait")) return true;
     1793    if (!strcmp(state, "test")) return true;
     1794    if (!strcmp(state, "ignore")) return true;
     1795    if (!strcmp(state, "register")) return true;
     1796
     1797    psError(PS_ERR_UNKNOWN, true, "invalid detRun state: %s", state);
     1798    return false;
    17931799}
    17941800
     
    17961802
    17971803    // check that state is a valid string value
    1798     if (!strncmp(data_state, "run", 4)) return true;
    1799     if (!strncmp(data_state, "stop", 5)) return true;
    1800     if (!strncmp(data_state, "drop", 5)) return true;
    1801     if (!strncmp(data_state, "register", 4)) return true;
     1804    if (!strcmp(data_state, "run")) return true;
     1805    if (!strcmp(data_state, "stop")) return true;
     1806    if (!strcmp(data_state, "drop")) return true;
     1807    if (!strcmp(data_state, "register")) return true;
    18021808
    18031809    psError(PS_ERR_UNKNOWN, true, "invalid data state: %s", data_state);
     
    18111817
    18121818    // check that state is a valid string value
    1813     if (!strncmp(mode, "master", 7)) return true;
    1814     if (!strncmp(mode, "verify", 7)) return true;
     1819    if (!strcmp(mode, "master")) return true;
     1820    if (!strcmp(mode, "verify")) return true;
    18151821
    18161822    psError(PS_ERR_UNKNOWN, false, "invalid detRun mode: %s", mode);
Note: See TracChangeset for help on using the changeset viewer.