IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 15, 2021, 8:38:08 AM (5 years ago)
Author:
eugene
Message:

new functions added: updatesummitExpMode, summitExpSetFault; add faults 200 & 203

File:
1 edited

Legend:

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

    r39519 r41582  
    4949static bool updatepzexpMode(pxConfig *config);
    5050static bool updatenewexpMode(pxConfig *config);
     51static bool updatesummitExpMode(pxConfig *config);
    5152
    5253// static bool copydoneCompleteExp(pxConfig *config);
     
    5455static psArray *pzArrayZip(psArray *arraySet, psS64 limit);
    5556static bool pzDownloadExpSetState(pxConfig *config, const psS64 summit_id, const char *state);
     57static bool summitExpSetFault(pxConfig *config, const psS64 summit_id, const int fault);
    5658
    5759# define MODECASE(caseName, func) \
     
    8890        MODECASE(PZTOOL_MODE_UPDATEPZEXP, updatepzexpMode);
    8991        MODECASE(PZTOOL_MODE_UPDATENEWEXP, updatenewexpMode);
     92        MODECASE(PZTOOL_MODE_UPDATESUMMITEXP, updatesummitExpMode);
    9093        default:
    9194            psAbort("invalid option (this should not happen)");
     
    933936}
    934937
     938static bool summitExpSetFault(pxConfig *config, const psS64 summit_id, const int fault)
     939{
     940    // check that state is a valid string value
     941  if ((fault < 0) || (fault > 2048)) {
     942    psError(PS_ERR_UNKNOWN, false,
     943            "invalid summitExp fault: %d", fault);
     944    return false;
     945  }
     946
     947    char *query = "UPDATE summitExp SET fault = %d WHERE summit_id = %ld";
     948    if (!p_psDBRunQueryF(config->dbh, query, fault, summit_id)) {
     949        psError(PS_ERR_UNKNOWN, false, "failed to change state for %lld", (long long) summit_id);
     950        return false;
     951    }
     952
     953    return true;
     954}
     955
     956static bool updatesummitExpMode(pxConfig *config)
     957{
     958  PS_ASSERT_PTR_NON_NULL(config, false);
     959  PXOPT_LOOKUP_S64(summit_id, config->args, "-summit_id", true, false);
     960  PXOPT_LOOKUP_S32(state,    config->args, "-set_fault",true, false);
     961
     962  if (!summitExpSetFault(config,summit_id, fault)) {
     963    psError(PS_ERR_UNKNOWN, false, "failed to change state for %lld", (long long) summit_id);
     964    return false;
     965  }
     966  return true;
     967}
     968 
     969 
    935970static bool updatepzexpMode(pxConfig *config)
    936971{
Note: See TracChangeset for help on using the changeset viewer.