IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 15, 2023, 11:29:37 AM (3 years ago)
Author:
eugene
Message:

adding option to set a fault for summitExp entries

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20230313/ippTools/src/pztool.c

    r41598 r42414  
    5050static bool updatenewexpMode(pxConfig *config);
    5151
    52 // XXX EAM : 2021.05.18 : code for updatesummitExp was added but not finished.
    53 // XXX static bool updatesummitExpMode(pxConfig *config);
     52static bool updatesummitExpMode(pxConfig *config);
    5453
    5554// static bool copydoneCompleteExp(pxConfig *config);
     
    9392        MODECASE(PZTOOL_MODE_UPDATEPZEXP, updatepzexpMode);
    9493        MODECASE(PZTOOL_MODE_UPDATENEWEXP, updatenewexpMode);
    95         // XXX MODECASE(PZTOOL_MODE_UPDATESUMMITEXP, updatesummitExpMode);
     94        MODECASE(PZTOOL_MODE_UPDATESUMMITEXP, updatesummitExpMode);
    9695        default:
    9796            psAbort("invalid option (this should not happen)");
     
    810809}
    811810
    812 
    813811static bool updatecopiedMode(pxConfig *config)
    814812{
     
    939937}
    940938
    941 # if (0)
    942 static bool summitExpSetFault(pxConfig *config, const psS64 summit_id, const int fault)
     939static bool summitExpSetFault(pxConfig *config, const psString exp_name, const psS64 summit_id, const int fault)
    943940{
    944941    // check that state is a valid string value
     
    949946  }
    950947
    951     char *query = "UPDATE summitExp SET fault = %d WHERE summit_id = %ld";
    952     if (!p_psDBRunQueryF(config->dbh, query, fault, summit_id)) {
    953         psError(PS_ERR_UNKNOWN, false, "failed to change state for %lld", (long long) summit_id);
     948    char *query = "UPDATE summitExp SET fault = %d WHERE summit_id = %ld AND exp_name = '%s'";
     949    if (!p_psDBRunQueryF(config->dbh, query, fault, summit_id, exp_name)) {
     950        psError(PS_ERR_UNKNOWN, false, "failed to change state for %s = %lld", exp_name, (long long) summit_id);
    954951        return false;
    955952    }
     
    960957static bool updatesummitExpMode(pxConfig *config)
    961958{
    962   int fault;
    963 
     959  // require both exp_name and summit_id as a double-check
    964960  PS_ASSERT_PTR_NON_NULL(config, false);
    965961  PXOPT_LOOKUP_S64(summit_id, config->args, "-summit_id", true, false);
    966   PXOPT_LOOKUP_S32(state,    config->args, "-set_fault",true, false);
    967 
    968   if (!summitExpSetFault(config,summit_id, fault)) {
    969     psError(PS_ERR_UNKNOWN, false, "failed to change state for %lld", (long long) summit_id);
    970     return false;
     962  PXOPT_LOOKUP_STR(exp_name,  config->args, "-exp_name",  true, false);
     963  PXOPT_LOOKUP_S32(fault,     config->args, "-set_fault", true, false);
     964
     965  if (!summitExpSetFault(config, exp_name, summit_id, fault)) {
     966      psError(PS_ERR_UNKNOWN, false, "failed to change state for %s = %lld", exp_name, (long long) summit_id);
     967      return false;
    971968  }
    972969  return true;
    973970}
    974 # endif 
    975971 
    976972static bool updatepzexpMode(pxConfig *config)
Note: See TracChangeset for help on using the changeset viewer.