IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 16, 2007, 6:54:55 PM (19 years ago)
Author:
jhoblitt
Message:

add warptool -runone

File:
1 edited

Legend:

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

    r14105 r14262  
    3131#include "warptool.h"
    3232
    33 static bool definerunMode(pxConfig *config);
     33static psS64 definerunMode(pxConfig *config);
     34static bool runoneMode(pxConfig *config);
    3435static bool updaterunMode(pxConfig *config);
    3536static bool addinputexpMode(pxConfig *config);
     
    4546
    4647static bool parseAndInsertSkyCellMap(pxConfig *config, const char *mapfile);
    47 static bool setwarpRunState(pxConfig *config, const char *warp_id, const char *state);
     48static bool setwarpRunState(pxConfig *config, psS64 warp_id, const char *state);
    4849static bool isValidMode(pxConfig *config, const char *mode);
    4950bool warpCompletedRuns(pxConfig *config);
     
    6869    switch (config->mode) {
    6970        MODECASE(WARPTOOL_MODE_DEFINERUN,         definerunMode);
     71        MODECASE(WARPTOOL_MODE_RUNONE,            runoneMode);
    7072        MODECASE(WARPTOOL_MODE_UPDATERUN,         updaterunMode);
    7173        MODECASE(WARPTOOL_MODE_ADDINPUTEXP,       addinputexpMode);
     
    101103
    102104
    103 static bool definerunMode(pxConfig *config)
     105static psS64 definerunMode(pxConfig *config)
    104106{
    105107    PS_ASSERT_PTR_NON_NULL(config, false);
     
    167169
    168170    // get the assigned warp_id
    169     warpRun->warp_id = psDBLastInsertID(config->dbh);
     171    psS64 warp_id = psDBLastInsertID(config->dbh);
     172    warpRun->warp_id = warp_id;
    170173
    171174    bool simple = false;
     
    188191    psFree(warpRun);
    189192
    190     return true;
    191 }
    192 
     193    return warp_id;
     194}
     195
     196static bool runoneMode(pxConfig *config)
     197{
     198    PS_ASSERT_PTR_NON_NULL(config, false);
     199
     200    if (!psDBTransaction(config->dbh)) {
     201        psError(PS_ERR_UNKNOWN, false, "database error");
     202        return false;
     203    }
     204
     205    psS64 warp_id = definerunMode(config);
     206    if (!warp_id) {
     207        // rollback
     208        if (!psDBRollback(config->dbh)) {
     209            psError(PS_ERR_UNKNOWN, false, "database error");
     210        }
     211        psError(PS_ERR_UNKNOWN, false, "failed to define warpRun");
     212        return false;
     213    }
     214
     215    psString warp_id_str = psDBIntToString(warp_id);
     216    if (!psMetadataAddStr(config->args, PS_LIST_TAIL, "-warp_id", 0, NULL, warp_id_str)) {
     217        // rollback
     218        if (!psDBRollback(config->dbh)) {
     219            psError(PS_ERR_UNKNOWN, false, "database error");
     220        }
     221        psError(PS_ERR_UNKNOWN, false, "failed to add item warp_id");
     222        psFree(warp_id_str);
     223        return false;
     224    }
     225    psFree(warp_id_str);
     226
     227    if (!addinputexpMode(config)) {
     228        // rollback
     229        if (!psDBRollback(config->dbh)) {
     230            psError(PS_ERR_UNKNOWN, false, "database error");
     231        }
     232        psError(PS_ERR_UNKNOWN, false, "failed to add cam_id to warpRun");
     233        return false;
     234    }
     235    if (!setwarpRunState(config, warp_id, "run")) {
     236        // rollback
     237        if (!psDBRollback(config->dbh)) {
     238            psError(PS_ERR_UNKNOWN, false, "database error");
     239        }
     240        psError(PS_ERR_UNKNOWN, false, "failed to set warpRun.state to run");
     241        return false;
     242    }
     243
     244    // point of no return
     245    if (!psDBCommit(config->dbh)) {
     246        psError(PS_ERR_UNKNOWN, false, "database error");
     247        return false;
     248    }
     249
     250    return true;
     251}
    193252
    194253static bool updaterunMode(pxConfig *config)
     
    219278    if (state) {
    220279        // set detRun.state to state
    221         return setwarpRunState(config, warp_id, state);
     280        return setwarpRunState(config, (psS64)atoll(warp_id), state);
    222281    }
    223282
     
    11611220
    11621221
    1163 static bool setwarpRunState(pxConfig *config, const char *warp_id, const char *state)
    1164 {
    1165     PS_ASSERT_PTR_NON_NULL(warp_id, false);
     1222static bool setwarpRunState(pxConfig *config, psS64 warp_id, const char *state)
     1223{
    11661224    PS_ASSERT_PTR_NON_NULL(state, false);
    11671225
     
    11781236    }
    11791237
    1180     char *query = "UPDATE warpRun SET state = '%s' WHERE warp_id = '%s'";
     1238    char *query = "UPDATE warpRun SET state = '%s' WHERE warp_id = %" PRId64;
    11811239    if (!p_psDBRunQuery(config->dbh, query, state, warp_id)) {
    11821240        psError(PS_ERR_UNKNOWN, false,
    1183                 "failed to change state for warp_id %s", warp_id);
     1241                "failed to change state for warp_id %" PRId64, warp_id);
    11841242        return false;
    11851243    }
Note: See TracChangeset for help on using the changeset viewer.