IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23229 for trunk/ippTools


Ignore:
Timestamp:
Mar 8, 2009, 4:50:46 PM (17 years ago)
Author:
eugene
Message:

merging changes from branches/eam_branches/eam_branch_20090303 (detrend normalization resequence, cleanup error state changes; SVN_VERSION from psbuild)

Location:
trunk
Files:
16 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/ippTools/share/chiptool_change_imfile_data_state.sql

    r19527 r23229  
    77    chip_id = %lld
    88    AND class_id = '%s'
    9     -- only update if chipRun.state has the expected value
    10     AND (
    11         SELECT state from chipRun where chipRun.chip_id = chipProcessedImfile.chip_id
    12     ) = '%s'
    13    
    14 
     9--    -- only update if chipRun.state has the expected value
     10--    AND (
     11--        SELECT state from chipRun where chipRun.chip_id = chipProcessedImfile.chip_id
     12--    ) = '%s'
  • trunk/ippTools/share/dettool_processedimfile.sql

    r18561 r23229  
     1-- is this DISTINCT needed?
    12SELECT DISTINCT
    23  detRun.det_type,
  • trunk/ippTools/share/dettool_residimfile.sql

    r19632 r23229  
    22   detRun.det_type,
    33   detRun.mode,
    4    detResidImfile.*,
    5    rawExp.exp_time
    6  FROM detResidImfile
    7  JOIN detRun
    8    USING(det_id, iteration)
    9  JOIN rawExp
    10    USING(exp_id)
     4   rawExp.exp_time,
     5   detResidImfile.*
     6FROM detResidImfile
     7JOIN detRun
     8  USING(det_id, iteration)
     9JOIN detInputExp
     10  ON detRun.det_id = detInputExp.det_id
     11  AND detRun.iteration = detInputExp.iteration
     12  AND detResidImfile.exp_id = detInputExp.exp_id
     13JOIN rawExp
     14  ON rawExp.exp_id = detResidImfile.exp_id
  • trunk/ippTools/share/dettool_tonormalizedstat.sql

    r18118 r23229  
    1 -- select detRun.det_id (det_id)
    2 -- select detRun.iteration
    3 -- by:
    4 -- find the current iteration bassed on det_id
    5 -- find all exp_ids in the current det_id/iteration from detInputExp
    6 -- sort to detInputExp.imfiles to find the largest value per det_id/iter
    7 -- compare imfiles to the number of detStackedImfiles by class_id
    8 -- and:
    9 -- ???
    10 -- det_id is not in detStackedImfile;
    11 -- iteration is not in detStackedImfile;
    12 
    13 SELECT
    14     det_id,
    15     det_type,
    16     iteration,
    17     camera,
    18     workdir,
    19     class_id
    20 FROM
    21     (SELECT DISTINCT
    22         detRun.det_id,
    23         detRun.det_type,
    24         detRun.iteration,
    25         detRun.workdir,
    26         rawExp.camera,
    27         detStackedImfile.class_id,
    28         rawImfile.class_id as rawimfile_class_id
    29     FROM detRun
    30     JOIN detInputExp
    31         ON detRun.det_id = detInputExp.det_id
    32         AND detRun.iteration = detInputExp.iteration
    33     JOIN rawExp
    34         ON detInputExp.exp_id = rawExp.exp_id
    35     JOIN rawImfile
    36         ON rawExp.exp_id = rawImfile.exp_id
    37     LEFT JOIN detStackedImfile
    38         ON detInputExp.det_id = detStackedImfile.det_id
    39         AND detInputExp.iteration = detStackedImfile.iteration
    40         AND rawImfile.class_id = detStackedImfile.class_id
    41     LEFT JOIN detNormalizedStatImfile
    42         ON detStackedImfile.det_id = detNormalizedStatImfile.det_id
    43         AND detStackedImfile.iteration = detNormalizedStatImfile.iteration
    44         AND detStackedImfile.class_id = detNormalizedStatImfile.class_id
    45     WHERE
    46         detRun.state = 'run'
    47         AND detRun.mode = 'master'
    48         AND detNormalizedStatImfile.det_id IS NULL
    49         AND detNormalizedStatImfile.iteration IS NULL
    50         AND detNormalizedStatImfile.class_id IS NULL
    51     GROUP BY
    52 --        rawExp.exp_id,
    53         detRun.iteration,
    54         detRun.det_id
    55     HAVING
    56         COUNT(rawImfile.class_id) = COUNT(detStackedImfile.class_id)
    57         AND SUM(detStackedImfile.fault) = 0
    58     ) as tonormalizedstat
     1-- a det_run + iteration is ready for normstat when: all detResidImfile entries for that iteration corresponding to all detProcessedImfile entries are available
     2SELECT
     3  detRun.det_id,
     4  detRun.det_type,
     5  detRun.iteration,
     6  detRun.camera,
     7  detRun.workdir,
     8  detProcessedImfile.class_id,
     9  COUNT(detProcessedImfile.class_id),
     10  COUNT(detResidImfile.class_id)
     11FROM detRun
     12JOIN detProcessedImfile
     13    ON  detProcessedImfile.det_id    = detRun.det_id
     14LEFT JOIN detResidImfile
     15    ON  detResidImfile.det_id    = detProcessedImfile.det_id
     16    AND detResidImfile.class_id  = detProcessedImfile.class_id
     17    AND detResidImfile.iteration = detRun.iteration
     18LEFT JOIN detNormalizedStatImfile
     19    ON  detNormalizedStatImfile.det_id    = detRun.det_id   
     20    AND detNormalizedStatImfile.iteration = detRun.iteration
     21    AND detNormalizedStatImfile.class_id  = detProcessedImfile.class_id
     22WHERE
     23    detRun.state = 'run'
     24    AND detRun.mode = 'master'
     25    AND detNormalizedStatImfile.det_id IS NULL
     26    AND detNormalizedStatImfile.iteration IS NULL
     27    AND detNormalizedStatImfile.class_id IS NULL
     28GROUP BY
     29    detRun.iteration,
     30    detRun.det_id
     31HAVING
     32    COUNT(detProcessedImfile.class_id) = COUNT(detResidImfile.class_id)
     33    AND SUM(detResidImfile.fault) = 0
  • trunk/ippTools/share/dettool_toresidexp.sql

    r19815 r23229  
    55-- id, detrend type, and whether the exposure was included in the stack for
    66-- this iteration.
     7
     8-- require the corresponding detNormalizedExp to complete before starting
    79
    810-- select detRun.det_id
     
    4143        detResidImfile.class_id
    4244    FROM detRun
     45    JOIN detNormalizedExp
     46        USING(det_id, iteration)
    4347    JOIN detInputExp
    4448        USING(det_id, iteration)
  • trunk/ippTools/share/dettool_toresidimfile.sql

    r19816 r23229  
    1313    detProcessedImfile.class_id,
    1414    detProcessedImfile.uri,
    15     detNormalizedImfile.uri AS det_uri,
     15--  detNormalizedImfile.uri AS det_uri,
     16    detStackedImfile.uri AS det_uri,
    1617    detRun.det_id AS ref_det_id,
    1718    detRun.iteration AS ref_iter,
     
    2627    ON detRun.det_id = detProcessedImfile.det_id
    2728    AND detInputExp.exp_id = detProcessedImfile.exp_id
    28 JOIN detNormalizedImfile
    29     ON detRun.det_id = detNormalizedImfile.det_id
    30     AND detRun.iteration = detNormalizedImfile.iteration
    31     AND detProcessedImfile.class_id = detNormalizedImfile.class_id
    32 JOIN detNormalizedExp
    33     ON detRun.det_id = detNormalizedExp.det_id
    34     AND detRun.iteration = detNormalizedExp.iteration
     29JOIN detStackedImfile
     30    ON detRun.det_id = detStackedImfile.det_id
     31    AND detRun.iteration = detStackedImfile.iteration
     32    AND detProcessedImfile.class_id = detStackedImfile.class_id
     33-- EAM : replacing detNormalizedImfile with detStackedImfile to change the sequencing
     34-- JOIN detNormalizedImfile
     35--     ON detRun.det_id = detNormalizedImfile.det_id
     36--     AND detRun.iteration = detNormalizedImfile.iteration
     37--     AND detProcessedImfile.class_id = detNormalizedImfile.class_id
     38-- EAM : we there is no reason to wait for all stacks to complete before continuing
     39-- JOIN detNormalizedExp
     40--     ON detRun.det_id = detNormalizedExp.det_id
     41--     AND detRun.iteration = detNormalizedExp.iteration
    3542LEFT JOIN detResidImfile
    3643    ON detRun.det_id = detResidImfile.det_id
     
    4148    detRun.state = 'run'
    4249    AND detRun.mode = 'master'
    43     AND detNormalizedImfile.fault = 0
    44     AND detNormalizedExp.fault = 0
     50    AND detStackedImfile.fault = 0
     51--  AND detNormalizedImfile.fault = 0
     52--  AND detNormalizedExp.fault = 0
    4553    AND detResidImfile.det_id IS NULL
    4654    AND detResidImfile.iteration IS NULL
  • trunk/ippTools/share/pxadmin_create_tables.sql

    r21308 r23229  
    737737    REFERENCES  detInputExp(det_id, iteration, exp_id),
    738738    FOREIGN KEY (det_id, exp_id, class_id)
    739     REFERENCES  detProcessedImfile(det_id, exp_id, class_id),
    740     FOREIGN KEY (ref_det_id, ref_iter)
    741     REFERENCES  detNormalizedExp(det_id, iteration)
     739    REFERENCES  detProcessedImfile(det_id, exp_id, class_id)
    742740) ENGINE=innodb DEFAULT CHARSET=latin1;
    743741
  • trunk/ippTools/share/warptool_change_skyfile_data_state.sql

    r19521 r23229  
    99    AND skycell_id = '%s'
    1010    -- only update if chipRun.state has the expected value
    11     AND (
    12         SELECT state from warpRun where warpRun.warp_id = warpSkyfile.warp_id
    13     ) = '%s'
    14    
    15 
     11--    AND (
     12--        SELECT state from warpRun where warpRun.warp_id = warpSkyfile.warp_id
     13--    ) = '%s'
  • trunk/ippTools/src/chiptool.c

    r22751 r23229  
    5252static bool runMode(pxConfig *config);
    5353static bool tocleanedimfileMode(pxConfig *config);
    54 static bool tocleanedimfile_from_scrubbedMode(pxConfig *config);
     54// static bool tocleanedimfile_from_scrubbedMode(pxConfig *config);
    5555static bool tofullimfileMode(pxConfig *config);
    5656static bool topurgedimfileMode(pxConfig *config);
    5757static bool exportrunMode(pxConfig *config);
    5858static bool importrunMode(pxConfig *config);
     59static bool change_imfile_data_state(pxConfig *config, psString data_state, psString run_state);
    5960
    6061# define MODECASE(caseName, func) \
     
    9293        MODECASE(CHIPTOOL_MODE_RUN,                     runMode);
    9394        MODECASE(CHIPTOOL_MODE_TOCLEANEDIMFILE,         tocleanedimfileMode);
    94         MODECASE(CHIPTOOL_MODE_TOCLEANEDIMFILE_FROM_SCRUBBED, tocleanedimfile_from_scrubbedMode);
     95        // MODECASE(CHIPTOOL_MODE_TOCLEANEDIMFILE_FROM_SCRUBBED, tocleanedimfile_from_scrubbedMode);
    9596        MODECASE(CHIPTOOL_MODE_TOFULLIMFILE,            tofullimfileMode);
    9697        MODECASE(CHIPTOOL_MODE_TOPURGEDIMFILE,          topurgedimfileMode);
     
    651652    PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");
    652653    PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "==");
    653     PXOPT_LOOKUP_S16(code, config->args, "-code", true, false);
    654 
    655     if (!pxSetFaultCode(config->dbh, "chipProcessedImfile", where, code)) {
     654    PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false);
     655    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
     656
     657    if (state && code) {
     658        psError(PS_ERR_UNKNOWN, true, "only one of -set_state and -code may be supplied");
     659        return false;
     660    }
     661
     662    if (state) {
     663      // make sure that the state string is valid
     664      if (!pxIsValidState(state)) {
     665        psError(PXTOOLS_ERR_DATA, false, "%s is not a valid state", state);
     666        return false;
     667      }
     668      if (!change_imfile_data_state(config, state, "unknown")) {
    656669        psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
    657670        return false;
    658     }
    659     psFree(where);
    660 
    661     return true;
     671      }
     672      return true;
     673    }
     674
     675    if (code) {
     676      if (!pxSetFaultCode(config->dbh, "chipProcessedImfile", where, code)) {
     677        psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
     678        return false;
     679      }
     680      psFree(where);
     681      return true;
     682    }
     683
     684    psError(PS_ERR_UNKNOWN, true, "one of -set_state or -code must be supplied");
     685    return false;
    662686}
    663687
     
    11951219// shared code for the modes -tocleanedimfile -tofullimfile -topurgedimfile
    11961220
     1221// XXX EAM : this function was enforcing only certain transitions with the SQL.  However,
     1222// this is getting fairly messy now that we have added a few additional target and
     1223// destination states.  I'm disabling these restrictions for now; is there are better way
     1224// to enforce the allowed state transitions?
     1225
    11971226static bool change_imfile_data_state(pxConfig *config, psString data_state, psString run_state)
    11981227{
     
    12101239    }
    12111240
     1241    // XXX this feature is disabled (run_state is ignored)
    12121242    // note only updates if chipRun.state = run_state
    1213     if (!p_psDBRunQueryF(config->dbh, query, data_state, chip_id, class_id, run_state)) {
     1243
     1244    if (!p_psDBRunQueryF(config->dbh, query, data_state, chip_id, class_id)) {
    12141245        psError(PS_ERR_UNKNOWN, false, "database error");
    12151246        // rollback
     
    12461277{
    12471278    return change_imfile_data_state(config, "cleaned", "goto_cleaned");
    1248 }
    1249 static bool tocleanedimfile_from_scrubbedMode(pxConfig *config)
    1250 {
    1251     return change_imfile_data_state(config, "cleaned", "goto_scrubbed");
    12521279}
    12531280static bool tofullimfileMode(pxConfig *config)
  • trunk/ippTools/src/chiptoolConfig.c

    r22751 r23229  
    172172    // -updateprocessedimfile
    173173    psMetadata *updateprocessedimfileArgs = psMetadataAlloc();
    174     psMetadataAddS64(updateprocessedimfileArgs, PS_LIST_TAIL, "-chip_id",  0,            "search by chip ID", 0);
    175     psMetadataAddStr(updateprocessedimfileArgs,  PS_LIST_TAIL, "-class_id",           0, "search by class ID", NULL);
    176     psMetadataAddS16(updateprocessedimfileArgs, PS_LIST_TAIL, "-code",  0,            "set fault code (required)", 0);
     174    psMetadataAddS64(updateprocessedimfileArgs, PS_LIST_TAIL, "-chip_id",    0, "search by chip ID", 0);
     175    psMetadataAddStr(updateprocessedimfileArgs,  PS_LIST_TAIL, "-class_id",  0, "search by class ID", NULL);
     176    psMetadataAddS16(updateprocessedimfileArgs, PS_LIST_TAIL, "-code",       0, "set fault code", 0);
     177    psMetadataAddStr(updateprocessedimfileArgs, PS_LIST_TAIL, "-set_state",  0, "set state", NULL);
    177178
    178179    // -promoteexp
     
    234235    psMetadataAddStr(tocleanedimfileArgs, PS_LIST_TAIL, "-class_id",  0,        "class ID to update", NULL);
    235236
    236     // -tocleanedimfile_from_scrubbed
    237     psMetadata *tocleanedimfile_from_scrubbedArgs = psMetadataAlloc();
    238     psMetadataAddS64(tocleanedimfile_from_scrubbedArgs, PS_LIST_TAIL, "-chip_id", 0,          "chip ID to update", 0);
    239     psMetadataAddStr(tocleanedimfile_from_scrubbedArgs, PS_LIST_TAIL, "-class_id",  0,        "class ID to update", NULL);
    240 
     237//    // -tocleanedimfile_from_scrubbed
     238//    psMetadata *tocleanedimfile_from_scrubbedArgs = psMetadataAlloc();
     239//    psMetadataAddS64(tocleanedimfile_from_scrubbedArgs, PS_LIST_TAIL, "-chip_id", 0,          "chip ID to update", 0);
     240//    psMetadataAddStr(tocleanedimfile_from_scrubbedArgs, PS_LIST_TAIL, "-class_id",  0,        "class ID to update", NULL);
     241//
    241242    // -tofullimfile
    242243    psMetadata *tofullimfileArgs = psMetadataAlloc();
     
    280281    PXOPT_ADD_MODE("-run",                  "show runs",                            CHIPTOOL_MODE_RUN,                  runArgs);
    281282    PXOPT_ADD_MODE("-tocleanedimfile",      "set imfile state to cleaned",          CHIPTOOL_MODE_TOCLEANEDIMFILE,      tocleanedimfileArgs);
    282     PXOPT_ADD_MODE("-tocleanedimfile_from_scrubbed", "set imfile state to cleaned (for goto_scrubbed)", CHIPTOOL_MODE_TOCLEANEDIMFILE_FROM_SCRUBBED, tocleanedimfile_from_scrubbedArgs);
     283    //    PXOPT_ADD_MODE("-tocleanedimfile_from_scrubbed", "set imfile state to cleaned (for goto_scrubbed)", CHIPTOOL_MODE_TOCLEANEDIMFILE_FROM_SCRUBBED, tocleanedimfile_from_scrubbedArgs);
    283284    PXOPT_ADD_MODE("-tofullimfile",         "set imfile state to full",              CHIPTOOL_MODE_TOFULLIMFILE,         tofullimfileArgs);
    284285    PXOPT_ADD_MODE("-topurgedimfile",       "set imfile state to purged",            CHIPTOOL_MODE_TOPURGEDIMFILE,       topurgedimfileArgs);
  • trunk/ippTools/src/dettoolConfig.c

    r23154 r23229  
    640640    // -residimfile
    641641    psMetadata *residimfileArgs = psMetadataAlloc();
    642     psMetadataAddS64(residimfileArgs, PS_LIST_TAIL, "-det_id",  0,            "search for detrend ID", 0);
    643     psMetadataAddS32(residimfileArgs, PS_LIST_TAIL, "-iteration",  0,            "search for iteration number", 0);
    644     psMetadataAddS64(residimfileArgs, PS_LIST_TAIL, "-exp_id",  0,            "search by detrend ID", 0);
    645     psMetadataAddStr(residimfileArgs, PS_LIST_TAIL, "-class_id",  0,            "search for class ID", NULL);
    646     psMetadataAddStr(residimfileArgs, PS_LIST_TAIL, "-recip",  0,            "search for recipe", NULL);
    647     psMetadataAddU64(residimfileArgs, PS_LIST_TAIL, "-limit",  0,            "limit result set to N items", 0);
     642    psMetadataAddS64(residimfileArgs,  PS_LIST_TAIL, "-det_id",  0,            "search for detrend ID", 0);
     643    psMetadataAddS32(residimfileArgs,  PS_LIST_TAIL, "-iteration",  0,            "search for iteration number", 0);
     644    psMetadataAddS64(residimfileArgs,  PS_LIST_TAIL, "-exp_id",  0,            "search by detrend ID", 0);
     645    psMetadataAddStr(residimfileArgs,  PS_LIST_TAIL, "-class_id",  0,            "search for class ID", NULL);
     646    psMetadataAddStr(residimfileArgs,  PS_LIST_TAIL, "-recip",  0,            "search for recipe", NULL);
     647    psMetadataAddU64(residimfileArgs,  PS_LIST_TAIL, "-limit",  0,            "limit result set to N items", 0);
    648648    psMetadataAddBool(residimfileArgs, PS_LIST_TAIL, "-faulted",  0,            "only return imfiles with a fault status set", false);
    649649    psMetadataAddBool(residimfileArgs, PS_LIST_TAIL, "-simple",  0,            "use the simple output format", false);
    650     psMetadataAddStr(residimfileArgs, PS_LIST_TAIL, "-select_state",  0,            "search for state", NULL);
     650    psMetadataAddBool(residimfileArgs, PS_LIST_TAIL, "-included",  0,            "restrict results to exposures 'includeded' in the current iteration", false);
     651    psMetadataAddStr(residimfileArgs,  PS_LIST_TAIL, "-select_state",  0,            "search for state", NULL);
    651652
    652653    // -revertresidimfile
  • trunk/ippTools/src/dettool_processedimfile.c

    r19621 r23229  
    165165    PS_ASSERT_PTR_NON_NULL(config, false);
    166166
    167     bool hasWhere = false;
    168 
    169     PXOPT_LOOKUP_BOOL(included, config->args, "-included", false);
    170     PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false);
    171     PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    172     PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    173 
    174167    psMetadata *where = psMetadataAlloc();
    175168    PXOPT_COPY_S64(config->args, where, "-det_id", "detProcessedImfile.det_id", "==");
     
    179172    PXOPT_COPY_STR(config->args, where, "-select_mode", "detRun.mode", "==");
    180173
     174    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     175    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     176
     177    PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false);
     178    PXOPT_LOOKUP_BOOL(included, config->args, "-included", false);
     179
    181180    psString query = pxDataGet("dettool_processedimfile.sql");
    182181    if (!query) {
     
    186185    }
    187186
     187    bool hasWhere = false;
    188188    if (psListLength(where->list)) {
    189189        psString whereClause = psDBGenerateWhereSQL(where, NULL);
     
    211211
    212212    if (faulted) {
     213        // list only faulted rows
    213214        psStringAppend(&query, " %s", " detProcessedImfile.fault != 0");
    214215    } else {
  • trunk/ippTools/src/dettool_residimfile.c

    r19632 r23229  
    159159    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    160160    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     161
    161162    PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false);
     163    PXOPT_LOOKUP_BOOL(included, config->args, "-included", false);
    162164
    163165    psString query = pxDataGet("dettool_residimfile.sql");
     
    175177    }
    176178    psFree(where);
     179
     180    // restrict search to included imfiles
     181    if (included) {
     182        if (hasWhere) {
     183            psStringAppend(&query, " AND detInputExp.include = 1");
     184        } else {
     185            psStringAppend(&query, " WHERE detInputExp.include = 1");
     186        }
     187        hasWhere = true;
     188    }
    177189
    178190    if (hasWhere) {
  • trunk/ippTools/src/warptool.c

    r21402 r23229  
    5555static bool updateskyfileMode(pxConfig *config);
    5656
     57static bool change_skyfile_data_state(pxConfig *config, psString data_state, psString run_state);
    5758static bool parseAndInsertSkyCellMap(pxConfig *config, const char *mapfile);
    5859static bool isValidMode(pxConfig *config, const char *mode);
     
    16041605// shared code for the modes -tocleanedskyfile -tofullskyfile -topurgedskyfile
    16051606
     1607// XXX EAM : this function was enforcing only certain transitions with the SQL.  However,
     1608// this is getting fairly messy now that we have added a few additional target and
     1609// destination states.  I'm disabling these restrictions for now; is there are better way
     1610// to enforce the allowed state transitions?
     1611
    16061612static bool change_skyfile_data_state(pxConfig *config, psString data_state, psString run_state)
    16071613{
     
    16191625    }
    16201626
     1627    // XXX this feature is disabled (run_state is ignored)
    16211628    // note only updates if warpRun.state = run_state
    1622     if (!p_psDBRunQueryF(config->dbh, query, data_state, warp_id, skycell_id, run_state)) {
     1629
     1630    if (!p_psDBRunQueryF(config->dbh, query, data_state, warp_id, skycell_id)) {
    16231631        psError(PS_ERR_UNKNOWN, false, "database error");
    16241632        // rollback
     
    16681676    PXOPT_LOOKUP_S64(warp_id, config->args, "-warp_id", true, false);
    16691677    PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false);
     1678    PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false);
    16701679    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
    16711680
    1672     psString query = pxDataGet("warptool_updateskyfile.sql");
    1673 
    1674     if (!p_psDBRunQueryF(config->dbh, query, code, warp_id, skycell_id)) {
    1675         psError(PS_ERR_UNKNOWN, false, "database error");
    1676         return false;
    1677     }
    1678     psFree(query);
    1679 
    1680     return true;
    1681 }
     1681    if (state && code) {
     1682        psError(PS_ERR_UNKNOWN, true, "only one of -set_state and -code may be supplied");
     1683        return false;
     1684    }
     1685
     1686    if (state) {
     1687      // make sure that the state string is valid
     1688      if (!pxIsValidState(state)) {
     1689        psError(PXTOOLS_ERR_DATA, false, "%s is not a valid state", state);
     1690        return false;
     1691      }
     1692      if (!change_skyfile_data_state(config, state, "unknown")) {
     1693        psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
     1694        return false;
     1695      }
     1696      return true;
     1697    }
     1698
     1699    if (code) {
     1700      psString query = pxDataGet("warptool_updateskyfile.sql");
     1701
     1702      if (!p_psDBRunQueryF(config->dbh, query, code, warp_id, skycell_id)) {
     1703        psError(PS_ERR_UNKNOWN, false, "database error");
     1704        return false;
     1705      }
     1706      psFree(query);
     1707      return true;
     1708    }
     1709
     1710    psError(PS_ERR_UNKNOWN, true, "one of -set_state or -code must be supplied");
     1711    return false;
     1712}
  • trunk/ippTools/src/warptoolConfig.c

    r20973 r23229  
    348348    psMetadataAddStr(tofullskyfileArgs, PS_LIST_TAIL, "-skycell_id", 0, "skycell ID to update", NULL);
    349349
    350     // -toupdateskyfile
     350    // -updateskyfile
    351351    psMetadata *updateskyfileArgs = psMetadataAlloc();
    352     psMetadataAddS64(updateskyfileArgs, PS_LIST_TAIL, "-warp_id", 0,    "warptool ID to update", 0);
     352    psMetadataAddS64(updateskyfileArgs, PS_LIST_TAIL, "-warp_id",    0, "warptool ID to update", 0);
    353353    psMetadataAddStr(updateskyfileArgs, PS_LIST_TAIL, "-skycell_id", 0, "skycell ID to update", NULL);
    354     psMetadataAddS16(updateskyfileArgs, PS_LIST_TAIL, "-code",  0,      "new fault code", 0);
     354    psMetadataAddS16(updateskyfileArgs, PS_LIST_TAIL, "-code",       0, "set fault code", 0);
     355    psMetadataAddStr(updateskyfileArgs, PS_LIST_TAIL, "-set_state",  0, "set state", NULL);
    355356
    356357    psFree(now);
Note: See TracChangeset for help on using the changeset viewer.