IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19334


Ignore:
Timestamp:
Sep 2, 2008, 2:05:26 PM (18 years ago)
Author:
bills
Message:

Add modes for transitioning chipProcessedImfiles from full to cleaned
and cleaned to full and full to purged.
Added COLUMN data_state to chipProcessedImfile to record the state.

Location:
trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/dbconfig/changes.txt

    r19323 r19334  
    423423
    424424-- ALTER TABLE flatcorrCamLink ADD COLUMN chip_id BIGINT AFTER corr_id;
     425
     426ALTER TABLE chipProcessedImfile ADD COLUMN data_state VARCHAR(64) AFTER
     427class_id;
     428UPDATE chipProcessedImfile SET data_state = 'full';
  • trunk/dbconfig/chip.md

    r16253 r19334  
    1717    exp_id          S64     64      # Primary Key fkey (exp_id, class_id) ref rawImfile(exp_id, class_id)
    1818    class_id        STR     64      # Primary Key
     19    data_state      STR     64      # Key
    1920    uri             STR     255
    2021    bg              F32     0.0
  • trunk/ippTasks/chip.pro

    r19179 r19334  
    130130    book getword chipPendingImfile $pageName dbname -var DBNAME
    131131    book getword chipPendingImfile $pageName reduction -var REDUCTION
    132     # book getword chipPendingImfile $pageName state -var RUN_STATE
     132    book getword chipPendingImfile $pageName state -var RUN_STATE
    133133
    134134    # specify choice of local or remote host based on camera and chip (class_id)
     
    153153
    154154    # XXX EAM : use this line for update processing
    155     # $run = chip_imfile.pl --threads @MAX_THREADS@ --exp_id $EXP_ID --chip_id $CHIP_ID --class_id $CLASS_ID --uri $URI --camera $CAMERA --run-state $RUN_STATE --outroot $outroot --redirect-output
    156     $run = chip_imfile.pl --threads @MAX_THREADS@ --exp_id $EXP_ID --chip_id $CHIP_ID --class_id $CLASS_ID --uri $URI --camera $CAMERA --outroot $outroot --redirect-output
     155    $run = chip_imfile.pl --threads @MAX_THREADS@ --exp_id $EXP_ID --chip_id $CHIP_ID --class_id $CLASS_ID --uri $URI --camera $CAMERA --run-state $RUN_STATE --outroot $outroot --redirect-output
     156    # $run = chip_imfile.pl --threads @MAX_THREADS@ --exp_id $EXP_ID --chip_id $CHIP_ID --class_id $CLASS_ID --uri $URI --camera $CAMERA --outroot $outroot --redirect-output
    157157    if ("$REDUCTION" != "NULL")
    158158      $run = $run --reduction $REDUCTION
  • trunk/ippTools/share/Makefile.am

    r19325 r19334  
    1010     camtool_reset_faulted_runs.sql \
    1111     camtool_revertprocessedexp.sql \
     12     chiptool_change_exp_state.sql \
     13     chiptool_change_imfile_data_state.sql \
    1214     chiptool_completely_processed_exp.sql \
    1315     chiptool_donecleanup.sql \
  • trunk/ippTools/share/chiptool_pendingcleanupimfile.sql

    r18366 r19334  
    1414WHERE
    1515    chipRun.state = 'goto_cleaned'
     16    AND chipProcessedImfile.data_state = 'full'
  • trunk/ippTools/share/chiptool_pendingimfile.sql

    r19181 r19334  
    2020    ON chipRun.label = chipMask.label
    2121WHERE
    22     chipRun.state = 'new'
     22    (chipRun.state = 'new'
    2323    AND chipProcessedImfile.chip_id IS NULL
    2424    AND chipProcessedImfile.exp_id IS NULL
    2525    AND chipProcessedImfile.class_id IS NULL
    26     AND chipMask.label IS NULL
    27 
    28 -- new where logic for update.  we probably need to add a 'data_state'
    29 -- field to chipProcessedImfile and update it (full, cleaned, etc) as
    30 -- we cleanup or update
    31 --    (chipRun.state = 'new'
    32 --    AND chipProcessedImfile.chip_id IS NULL
    33 --    AND chipProcessedImfile.exp_id IS NULL
    34 --    AND chipProcessedImfile.class_id IS NULL
    35 --    AND chipMask.label IS NULL)
    36 --    OR
    37 --    (chipRun.state = 'update'
    38 --    AND chipProcessedImfile.data_state = 'cleaned'
     26    AND chipMask.label IS NULL)
     27    OR
     28    (chipRun.state = 'update'
     29    AND chipProcessedImfile.data_state = 'cleaned')
  • trunk/ippTools/share/pxadmin_create_tables.sql

    r19325 r19334  
    261261    exp_id BIGINT,
    262262    class_id VARCHAR(64),
     263    data_state VARCHAR(64),
    263264    uri VARCHAR(255),
    264265    bg FLOAT,
     
    289290    fault SMALLINT NOT NULL,
    290291    PRIMARY KEY(chip_id, exp_id, class_id),
     292    KEY(data_state),
    291293    KEY(fault),
    292294    FOREIGN KEY (chip_id, exp_id)
  • trunk/ippTools/src/chiptool.c

    r19324 r19334  
    5050static bool donecleanupMode(pxConfig *config);
    5151static bool runMode(pxConfig *config);
     52static bool tocleanedimfileMode(pxConfig *config);
     53static bool tofullimfileMode(pxConfig *config);
     54static bool topurgedimfileMode(pxConfig *config);
    5255
    5356static bool chipProcessedCompleteExp(pxConfig *config);
     
    7679        MODECASE(CHIPTOOL_MODE_PROCESSEDIMFILE,         processedimfileMode);
    7780        MODECASE(CHIPTOOL_MODE_REVERTPROCESSEDIMFILE,   revertprocessedimfileMode);
    78         MODECASE(CHIPTOOL_MODE_UPDATEPROCESSEDIMFILE,updateprocessedimfileMode);
     81        MODECASE(CHIPTOOL_MODE_UPDATEPROCESSEDIMFILE,   updateprocessedimfileMode);
    7982        MODECASE(CHIPTOOL_MODE_BLOCK,                   blockMode);
    8083        MODECASE(CHIPTOOL_MODE_MASKED,                  maskedMode);
     
    8588        MODECASE(CHIPTOOL_MODE_DONECLEANUP,             donecleanupMode);
    8689        MODECASE(CHIPTOOL_MODE_RUN,                     runMode);
     90        MODECASE(CHIPTOOL_MODE_TOCLEANEDIMFILE,         tocleanedimfileMode);
     91        MODECASE(CHIPTOOL_MODE_TOFULLIMFILE,            tofullimfileMode);
     92        MODECASE(CHIPTOOL_MODE_TOPURGEDIMFILE,          topurgedimfileMode);
    8793        default:
    8894            psAbort("invalid option (this should not happen)");
     
    334340    PS_ASSERT_PTR_NON_NULL(config, false);
    335341
    336     // chip_id, ext_tag, class_id are required
     342    // chip_id, exp_tag, class_id are required
    337343    PXOPT_LOOKUP_S64(chip_id, config->args, "-chip_id", true, false);
    338344    PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", true, false);
     
    379385                                   exp_id,
    380386                                   class_id,
     387                                   "full",
    381388                                   uri,
    382389                                   bg,
     
    417424    // XXX I've decided to make the transaction cover the Exp migration as
    418425    // well.  Otherwise, if the last imfile in an exp is moved and the exp
    419     // migration fails then the data base is left in a satuation where the exp
     426    // migration fails then the data base is left in a situation where the exp
    420427    // migration can't happen.
    421428
     
    10691076    return true;
    10701077}
     1078
     1079// update chipProcessedImfile.data_state to given value.
     1080// afterwards, if all imfiles in the exposure have the new state, update the state for the exposure as well
     1081// shared code for the modes -tocleanedimfile -tofullimfile -topurgedimfile
     1082
     1083static bool change_imfile_data_state(pxConfig *config, psString data_state, psString run_state)
     1084{
     1085    PS_ASSERT_PTR_NON_NULL(config, false);
     1086
     1087    // chip_id, class_id are required
     1088    PXOPT_LOOKUP_S64(chip_id, config->args, "-chip_id", true, false);
     1089    PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", true, false);
     1090
     1091    psString query = pxDataGet("chiptool_change_imfile_data_state.sql");
     1092
     1093    if (!psDBTransaction(config->dbh)) {
     1094        psError(PS_ERR_UNKNOWN, false, "database error");
     1095        return false;
     1096    }
     1097
     1098    // note only updates if chipRun.state = run_state
     1099    if (!p_psDBRunQuery(config->dbh, query, data_state, chip_id, class_id, run_state)) {
     1100        psError(PS_ERR_UNKNOWN, false, "database error");
     1101        // rollback
     1102        if (!psDBRollback(config->dbh)) {
     1103            psError(PS_ERR_UNKNOWN, false, "database error");
     1104        }
     1105        psError(PS_ERR_UNKNOWN, false, "database error");
     1106        return false;
     1107    }
     1108    psFree(query);
     1109
     1110    // XXX Comment copied from addpendingimfile
     1111    // I've decided to make the transaction cover the Exp migration as
     1112    // well.  Otherwise, if the last imfile in an exp is moved and the exp
     1113    // migration fails then the data base is left in a situation where the exp
     1114    // migration can't happen.
     1115
     1116    query = pxDataGet("chiptool_change_exp_state.sql");
     1117    if (!p_psDBRunQuery(config->dbh, query, data_state, chip_id, data_state)) {
     1118        // rollback
     1119        if (!psDBRollback(config->dbh)) {
     1120            psError(PS_ERR_UNKNOWN, false, "database error");
     1121        }
     1122        psError(PS_ERR_UNKNOWN, false, "database error");
     1123        return false;
     1124    }
     1125
     1126    if (!psDBCommit(config->dbh)) {
     1127        psError(PS_ERR_UNKNOWN, false, "database error");
     1128        return false;
     1129    }
     1130
     1131    return true;
     1132}
     1133static bool tocleanedimfileMode(pxConfig *config)
     1134{
     1135    return change_imfile_data_state(config, "cleaned", "goto_cleaned");
     1136}
     1137static bool tofullimfileMode(pxConfig *config)
     1138{
     1139    return change_imfile_data_state(config, "full", "update");
     1140}
     1141static bool topurgedimfileMode(pxConfig *config)
     1142{
     1143    return change_imfile_data_state(config, "purged", "goto_purged");
     1144}
  • trunk/ippTools/src/chiptool.h

    r18366 r19334  
    4040    CHIPTOOL_MODE_PENDINGCLEANUPIMFILE,
    4141    CHIPTOOL_MODE_DONECLEANUP,
    42     CHIPTOOL_MODE_RUN
     42    CHIPTOOL_MODE_RUN,
     43    CHIPTOOL_MODE_TOCLEANEDIMFILE,
     44    CHIPTOOL_MODE_TOFULLIMFILE,
     45    CHIPTOOL_MODE_TOPURGEDIMFILE
    4346} chiptoolMode;
    4447
  • trunk/ippTools/src/chiptoolConfig.c

    r19324 r19334  
    177177    psMetadataAddStr(runArgs, PS_LIST_TAIL, "-state", 0,        "search by state (required)", NULL);
    178178
     179    // -tocleanedimfile
     180    psMetadata *tocleanedimfileArgs = psMetadataAlloc();
     181    psMetadataAddS64(tocleanedimfileArgs, PS_LIST_TAIL, "-chip_id", 0,          "chip ID to update", 0);
     182    psMetadataAddStr(tocleanedimfileArgs, PS_LIST_TAIL, "-class_id",  0,        "class ID to update", NULL);
     183
     184    // -tofullimfile
     185    psMetadata *tofullimfileArgs = psMetadataAlloc();
     186    psMetadataAddS64(tofullimfileArgs, PS_LIST_TAIL, "-chip_id", 0,          "chip ID to update", 0);
     187    psMetadataAddStr(tofullimfileArgs, PS_LIST_TAIL, "-class_id",  0,        "class ID to update", NULL);
     188
     189    // -topurgedimfile
     190    psMetadata *topurgedimfileArgs = psMetadataAlloc();
     191    psMetadataAddS64(topurgedimfileArgs, PS_LIST_TAIL, "-chip_id", 0,          "chip ID to update", 0);
     192    psMetadataAddStr(topurgedimfileArgs, PS_LIST_TAIL, "-class_id",  0,        "class ID to update", NULL);
     193
    179194    psMetadata *argSets = psMetadataAlloc();
    180195    psMetadata *modes = psMetadataAlloc();
     
    195210    PXOPT_ADD_MODE("-donecleanup",          "show runs that have been cleaned",     CHIPTOOL_MODE_DONECLEANUP,          donecleanupArgs);
    196211    PXOPT_ADD_MODE("-run",                  "show runs",                            CHIPTOOL_MODE_RUN,                  runArgs);
     212    PXOPT_ADD_MODE("-tocleanedimfile",      "set imfile state to cleaned",          CHIPTOOL_MODE_TOCLEANEDIMFILE,      tocleanedimfileArgs);
     213    PXOPT_ADD_MODE("-tofullimfile",        "set imfile state to full",              CHIPTOOL_MODE_TOFULLIMFILE,         tofullimfileArgs);
     214    PXOPT_ADD_MODE("-topurgdimfile",       "set imfile state to purged",            CHIPTOOL_MODE_TOPURGEDIMFILE,       topurgedimfileArgs);
    197215
    198216    if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) {
Note: See TracChangeset for help on using the changeset viewer.