IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17863


Ignore:
Timestamp:
May 30, 2008, 11:03:23 AM (18 years ago)
Author:
jhoblitt
Message:

convert chiptool to use the new cleanup states

Location:
branches/cleanup/ippTools
Files:
2 added
17 edited

Legend:

Unmodified
Added
Removed
  • branches/cleanup/ippTools/scripts/regtest.sh

    r15776 r17863  
    3333$regtool -pendingexp|| exit 1
    3434
    35 $regtool -addprocessedexp -exp_id $exp_id1 -exp_name t10 -inst gpc -telescope ps1 -exp_tag batman.t10 -filelevel OTA -filter r -airmass 10 -ra 1 -decl 2 -exp_type bias -exp_time 0 -bg 10 -bg_stdev 1 -bg_mean_stdev 10 -alt 10 -az 10 -ccd_temp 45 -posang 10 -object dog -dateobs "2006-10-20T10:10:10Z" -label foobar $* || exit 1
     35$regtool -addprocessedexp -exp_id $exp_id1 -exp_name t10 -inst gpc -telescope ps1 -exp_tag batman.t10 -filelevel OTA -filter r -airmass 10 -ra 1 -decl 2 -exp_type object -exp_time 0 -bg 10 -bg_stdev 1 -bg_mean_stdev 10 -alt 10 -az 10 -ccd_temp 45 -posang 10 -object dog -dateobs "2006-10-20T10:10:10Z" -label foobar $* || exit 1
    3636
    3737$regtool -pendingimfile || exit 1
     
    4343$regtool -pendingexp|| exit 1
    4444
    45 $regtool -addprocessedexp -exp_id $exp_id2 -exp_name t11 -inst gpc -telescope ps1 -exp_tag batman.t11 -filelevel OTA -filter r -airmass 11 -ra 1 -decl 2 -exp_type bias -exp_time 0 -bg 11 -bg_stdev 1 -bg_mean_stdev 11 -alt 11 -az 11 -ccd_temp 45 -posang 11 -object dog -dateobs 2006-10-20T10:10:10Z -label foobar $* || exit 1
     45$regtool -addprocessedexp -exp_id $exp_id2 -exp_name t11 -inst gpc -telescope ps1 -exp_tag batman.t11 -filelevel OTA -filter r -airmass 11 -ra 1 -decl 2 -exp_type object -exp_time 0 -bg 11 -bg_stdev 1 -bg_mean_stdev 11 -alt 11 -az 11 -ccd_temp 45 -posang 11 -object dog -dateobs 2006-10-20T10:10:10Z -label foobar $* || exit 1
  • branches/cleanup/ippTools/share/Makefile.am

    r17859 r17863  
    1414        chiptool_pendingimfile.sql \
    1515        chiptool_processedimfile.sql \
     16        chiptool_run.sql \
    1617        chiptool_revertprocessedimfile.sql \
    1718        chiptool_unmasked.sql \
  • branches/cleanup/ippTools/share/camtool_find_chip_id.sql

    r14227 r17863  
    2929        using(exp_id)
    3030    WHERE
    31         chipRun.state = 'stop') as Foo
     31        chipRun.state = 'full') as Foo
  • branches/cleanup/ippTools/share/camtool_find_pendingexp.sql

    r15956 r17863  
    2424        ON camRun.label = camMask.label
    2525    WHERE
    26         chipRun.state = 'stop'
     26        chipRun.state = 'full'
    2727        AND camRun.state = 'run'
    2828        AND camMask.label IS NULL
  • branches/cleanup/ippTools/share/camtool_queue_chip_id.sql

    r16170 r17863  
    1616    FROM chipRun
    1717    WHERE
    18         chipRun.state = 'stop'
     18        chipRun.state = 'full'
    1919        AND chipRun.chip_id = %lld
  • branches/cleanup/ippTools/share/chiptool_pendingcleanup.sql

    r17859 r17863  
    33FROM chipRun
    44WHERE
    5     chipRun.state = 'goto_clean'
     5    chipRun.state = 'goto_cleaned'
  • branches/cleanup/ippTools/share/chiptool_pendingimfile.sql

    r14065 r17863  
    2020    ON chipRun.label = chipMask.label
    2121WHERE
    22     chipRun.state = 'run'
     22    chipRun.state = 'new'
    2323    AND chipProcessedImfile.chip_id IS NULL
    2424    AND chipProcessedImfile.exp_id IS NULL
  • branches/cleanup/ippTools/share/flatcorr_completely_processed_chiprun.sql

    r15769 r17863  
    2626            AND rawImfile.class_id = chipProcessedImfile.class_id
    2727        WHERE
    28             chipRun.state = 'stop'
     28            chipRun.state = 'full'
    2929        GROUP BY
    3030            chipRun.chip_id,
  • branches/cleanup/ippTools/share/flatcorr_find_processedimfiles.sql

    r15755 r17863  
    1111WHERE
    1212    flatcorrRun.state = 'run'
    13     AND chipRun.state = 'stop'
     13    AND chipRun.state = 'new'
    1414
  • branches/cleanup/ippTools/share/flatcorr_pending.sql

    r15769 r17863  
    1515WHERE
    1616    flatcorrRun.state = 'run'
    17     AND chipRun.state = 'stop'
     17    AND chipRun.state = 'full'
    1818GROUP BY
    1919    chipRun.chip_id,
  • branches/cleanup/ippTools/src/Makefile.am

    r17856 r17863  
    6969        pxregister.c \
    7070        pxtag.c \
     71        pxtools.c \
    7172        pxtoolsErrorCodes.c \
    7273        pxtree.c \
  • branches/cleanup/ippTools/src/chiptool.c

    r17859 r17863  
    4747static bool pendingcleanupMode(pxConfig *config);
    4848static bool donecleanupMode(pxConfig *config);
     49static bool runMode(pxConfig *config);
    4950
    5051static bool chipProcessedCompleteExp(pxConfig *config);
     
    8081        MODECASE(CHIPTOOL_MODE_PENDINGCLEANUP,          pendingcleanupMode);
    8182        MODECASE(CHIPTOOL_MODE_DONECLEANUP,             donecleanupMode);
     83        MODECASE(CHIPTOOL_MODE_RUN,                     runMode);
    8284        default:
    8385            psAbort("invalid option (this should not happen)");
     
    10741076
    10751077
     1078static bool runMode(pxConfig *config)
     1079{
     1080    PS_ASSERT_PTR_NON_NULL(config, NULL);
     1081
     1082    PXOPT_LOOKUP_STR(state, config->args, "-state", true, false);
     1083    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     1084    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     1085
     1086    // make sure that the state string is valid
     1087    if (!pxIsValidState(state)) {
     1088        psError(PXTOOLS_ERR_DATA, false, "%s is not a valid state", state);
     1089        return false;
     1090    }
     1091
     1092    psMetadata *where = psMetadataAlloc();
     1093    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     1094    PXOPT_COPY_STR(config->args, where, "-state", "state", "==");
     1095
     1096    psString query = pxDataGet("chiptool_run.sql");
     1097    if (!query) {
     1098        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     1099        return false;
     1100    }
     1101
     1102    if (where && psListLength(where->list)) {
     1103        psString whereClause = psDBGenerateWhereSQL(where, NULL);
     1104        psStringAppend(&query, " %s", whereClause);
     1105        psFree(whereClause);
     1106    }
     1107    psFree(where);
     1108
     1109    // treat limit == 0 as "no limit"
     1110    if (limit) {
     1111        psString limitString = psDBGenerateLimitSQL(limit);
     1112        psStringAppend(&query, " %s", limitString);
     1113        psFree(limitString);
     1114    }
     1115
     1116    if (!p_psDBRunQuery(config->dbh, query)) {
     1117        psError(PS_ERR_UNKNOWN, false, "database error");
     1118        psFree(query);
     1119        return false;
     1120    }
     1121    psFree(query);
     1122
     1123    psArray *output = p_psDBFetchResult(config->dbh);
     1124    if (!output) {
     1125        psError(PS_ERR_UNKNOWN, false, "database error");
     1126        return false;
     1127    }
     1128    if (!psArrayLength(output)) {
     1129        psTrace("chiptool", PS_LOG_INFO, "no rows found");
     1130        psFree(output);
     1131        return true;
     1132    }
     1133
     1134    if (!convertIdToStr(output)) {
     1135        psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
     1136        psFree(output);
     1137        return false;
     1138    }
     1139
     1140    // negative simple so the default is true
     1141    if (!ippdbPrintMetadatas(stdout, output, "chipDoneCleanup", !simple)) {
     1142        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     1143        psFree(output);
     1144        return false;
     1145    }
     1146
     1147    psFree(output);
     1148
     1149    return true;
     1150}
     1151
     1152
    10761153static bool chipProcessedCompleteExp(pxConfig *config)
    10771154{
     
    11091186        chipRunRow *chipRun = chipRunObjectFromMetadata(row);
    11101187        // set chipRun.state to 'stop'
    1111         if (!pxchipRunSetState(config, chipRun->chip_id, "stop")) {
     1188        if (!pxchipRunSetState(config, chipRun->chip_id, "full")) {
    11121189            psError(PS_ERR_UNKNOWN, false, "failed to change chipRun.state for chip_id: %" PRId64, chipRun->chip_id);
    11131190            psFree(chipRun);
  • branches/cleanup/ippTools/src/chiptool.h

    r17859 r17863  
    3939    CHIPTOOL_MODE_PENDINGCLEANUP,
    4040    CHIPTOOL_MODE_DONECLEANUP,
     41    CHIPTOOL_MODE_RUN
    4142} chiptoolMode;
    4243
  • branches/cleanup/ippTools/src/chiptoolConfig.c

    r17859 r17863  
    283283    psMetadataAddU64(donecleanupArgs, PS_LIST_TAIL, "-limit",  0,            "limit result set to N items", 0);
    284284
     285    // -run
     286    psMetadata *runArgs = psMetadataAlloc();
     287    psMetadataAddStr(runArgs, PS_LIST_TAIL, "-label",  0,       "search by label", NULL);
     288    psMetadataAddBool(runArgs, PS_LIST_TAIL, "-simple",  0,     "use the simple output format", false);
     289    psMetadataAddU64(runArgs, PS_LIST_TAIL, "-limit",  0,       "limit result set to N items", 0);
     290    psMetadataAddStr(runArgs, PS_LIST_TAIL, "-state", 0,        "search by state (required)", NULL);
     291
    285292    psMetadata *argSets = psMetadataAlloc();
    286293    psMetadata *modes = psMetadataAlloc();
     
    312319    PXOPT_ADD_MODE("-donecleanup",          "show runs that have been cleaned",
    313320        CHIPTOOL_MODE_DONECLEANUP,          donecleanupArgs);
     321    PXOPT_ADD_MODE("-run",                  "show runs",
     322        CHIPTOOL_MODE_RUN,                  runArgs);
    314323
    315324    if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) {
  • branches/cleanup/ippTools/src/pxchip.c

    r17161 r17863  
    3535
    3636    // check that state is a valid string value
    37     if (!(
    38             (strncmp(state, "run", 4) == 0)
    39             || (strncmp(state, "stop", 5) == 0)
    40             || (strncmp(state, "reg", 4) == 0)
    41         )
    42     ) {
    43         psError(PS_ERR_UNKNOWN, false,
    44                 "invalid chipRun state: %s", state);
     37    if (!pxIsValidState(state)) {
     38        psError(PS_ERR_UNKNOWN, false, "invalid chipRun state: %s", state);
    4539        return false;
    4640    }
     
    6357
    6458    // check that state is a valid string value
    65     if (!(
    66             (strncmp(state, "run", 4) == 0)
    67             || (strncmp(state, "stop", 5) == 0)
    68             || (strncmp(state, "reg", 4) == 0)
    69         )
    70     ) {
    71         psError(PS_ERR_UNKNOWN, false,
    72                 "invalid chipRun state: %s", state);
     59    if (!pxIsValidState(state)) {
     60        psError(PS_ERR_UNKNOWN, false, "invalid chipRun state: %s", state);
    7361        return false;
    7462    }
     63
    7564
    7665    psString query = psStringCopy("UPDATE chipRun JOIN rawExp USING(exp_id) SET state = '%s'");
     
    151140            0x0, // chip_id
    152141            exp_id,
    153             "run",      // state               
     142            "new",      // state               
    154143            workdir,
    155144            "dirty",    // workdir_state
     
    167156    return psDBLastInsertID(config->dbh);
    168157}
     158
  • branches/cleanup/ippTools/src/pxchip.h

    r17161 r17863  
    4040                         const char *end_stage);
    4141
     42
    4243#endif // PXCHIP_H
  • branches/cleanup/ippTools/src/pxtools.h

    r16170 r17863  
    4141# define PXTOOL_MODE_NONE 0x0
    4242
    43 bool pxCreateTables (pxConfig *config);
    44 bool pxDeleteTables (pxConfig *config);
     43bool pxIsValidState(const char *state);
    4544
    4645bool pxSetFaultCode(psDB *dbh, const char *tableName, psMetadata *where, psS16 code);
Note: See TracChangeset for help on using the changeset viewer.