IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 17, 2011, 3:19:36 PM (15 years ago)
Author:
eugene
Message:

merge changes from the trunk

Location:
branches/eam_branches/ipp-20110213/ippTools
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110213/ippTools/share/camtool_find_pendingimfile.sql

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/ipp-20110213/ippTools/share/disttool_pending_raw.sql

    r30387 r30675  
    1212    TRIM(TRAILING '.fits' FROM rawImfile.uri) AS path_base,
    1313    CAST(NULL AS CHAR(255)) AS alt_path_base,
    14     chipProcessedImfile.path_base as chip_path_base,
     14    -- pass camera stage path base since we want the camera mask file. The script knows what to do
     15    camProcessedExp.path_base as chip_path_base,
    1516    CAST(NULL AS CHAR(255)) AS state,
    1617    CAST(NULL AS CHAR(255)) AS data_state,
     
    2627JOIN chipProcessedImfile
    2728    USING(chip_id, class_id)
     29JOIN camRun USING(chip_id)
     30JOIN camProcessedExp using(cam_id)
    2831LEFT JOIN distComponent
    2932    ON distRun.dist_id = distComponent.dist_id
     
    3639    AND distComponent.dist_id IS NULL
    3740    AND (rawExp.magicked OR distRun.no_magic)
     41    -- need to have magicked the chip image which makes the camera mask
     42    AND chipProcessedImfile.magicked != 0
     43    AND camRun.magicked > 0
    3844    AND (Label.active OR Label.active IS NULL)
    3945UNION
     
    5258    TRIM(TRAILING '.fits' FROM rawImfile.uri) AS path_base,
    5359    magicDSFile.backup_path_base AS alt_path_base,
    54     chipProcessedImfile.path_base AS chip_path_base,
     60    -- pass camera stage path base since we want the camera mask file. The script knows what to do
     61    camProcessedExp.path_base AS chip_path_base,
    5562    CAST('full' AS CHAR(255)) AS state,
    5663    CAST('full' AS CHAR(255)) AS data_state,
     
    7784    AND distRun.clean = 0
    7885    AND distComponent.dist_id IS NULL
    79     AND chipProcessedImfile.data_state = 'full'
    80     AND chipProcessedImfile.magicked > 0
     86    AND chipProcessedImfile.magicked != 0
     87    AND camRun.magicked > 0
    8188    AND (Label.active OR Label.active IS NULL)
    8289UNION
  • branches/eam_branches/ipp-20110213/ippTools/share/magicdstool_torevert_camera.sql

    r27945 r30675  
    1111    camProcessedExp.path_base,
    1212    camProcessedExp.path_base AS cam_path_base,
     13    recovery_path_base,
    1314    0 AS bothways,
    1415    0 AS bytes,
  • branches/eam_branches/ipp-20110213/ippTools/share/magicdstool_torevert_chip.sql

    r29561 r30675  
    1111    chipProcessedImfile.path_base,
    1212    camProcessedExp.path_base AS cam_path_base,
     13    recovery_path_base,
    1314    0 AS bothways,
    1415    0 AS bytes,
  • branches/eam_branches/ipp-20110213/ippTools/share/magicdstool_torevert_diff.sql

    r30256 r30675  
    1313    magicDSFile.recovery_path_base,
    1414    "NULL" AS cam_path_base,
     15    recovery_path_base,
    1516    CAST(diffRun.bothways AS SIGNED) AS bothways,
    1617    0 AS bytes,
  • branches/eam_branches/ipp-20110213/ippTools/share/magicdstool_torevert_raw.sql

    r27945 r30675  
    1111    rawImfile.uri AS path_base,
    1212    CAST(NULL AS CHAR(255)) AS cam_path_base,
     13    recovery_path_base,
    1314    0 AS bothways,
    1415    bytes,
  • branches/eam_branches/ipp-20110213/ippTools/share/magicdstool_torevert_warp.sql

    r27945 r30675  
    1111    warpSkyfile.path_base,
    1212    "NULL" AS cam_path_base,
     13    recovery_path_base,
    1314    0 AS bothways,
    1415    0 AS bytes,
  • branches/eam_branches/ipp-20110213/ippTools/share/pxadmin_create_tables.sql

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/ipp-20110213/ippTools/src

  • branches/eam_branches/ipp-20110213/ippTools/src/magicdstool.c

    r30548 r30675  
    709709
    710710
     711// update the magicked column for the underlying component
     712// Note: Must be called inside a transaction
     713
    711714static bool
    712 setMagicked(pxConfig *config, psS64 magic_ds_id, psString component)
     715setMagicked(pxConfig *config, psS64 magic_ds_id, psString component, bool clearMagicked)
    713716{
    714717    // first query the magicDSRun to find the stage and the stage_id
     
    741744    psS64 stage_id = psMetadataLookupS64(NULL, row, "stage_id");
    742745    psS64 magic_id = psMetadataLookupS64(NULL, row, "magic_id");
     746    psFree(output);
     747
     748    psS64 newMagickedValue;
     749    if (clearMagicked) {
     750        newMagickedValue = 0;
     751    } else {
     752        newMagickedValue = magic_id;
     753    }
    743754
    744755    ippStage stageNum = ippStringToStage(stage);
    745756
    746757    // chose the appropriate query based on the stage
     758    char *clearRunQuery = NULL;
    747759    switch (stageNum) {
    748760    case IPP_STAGE_RAW:
    749761        query = "UPDATE rawImfile SET magicked = %" PRId64 " where exp_id = %" PRId64 " AND class_id = '%s'";
     762        clearRunQuery = "UPDATE rawExp SET magicked = 0 where exp_id = %" PRId64;
    750763        break;
    751764    case IPP_STAGE_CHIP:
    752765        query = "UPDATE chipProcessedImfile SET magicked = %" PRId64 " where chip_id = %" PRId64 " AND class_id = '%s'";
     766        clearRunQuery = "UPDATE chipRun set magicked = 0 where chip_id = %" PRId64;
    753767        break;
    754768    case IPP_STAGE_CHIP_BG:
    755769        query = "UPDATE chipBackgroundImfile SET magicked = %" PRId64 " where chip_bg_id = %" PRId64 " AND class_id = '%s'";
     770        clearRunQuery = "UPDATE chipBackgroundRun SET magicked = 0 where chip_bg_id = %" PRId64;
    756771        break;
    757772    case IPP_STAGE_CAMERA:
    758         // no there is no magicked column in camProcessedExp so we have nothing to do
    759         psFree(output);
    760         return true;
     773        psFree(query);
     774        query = NULL;
     775        clearRunQuery = "UPDATE chipBackgroundRun SET magicked = 0 where chip_bg_id = %" PRId64;
     776        break;
    761777    case IPP_STAGE_WARP:
    762778        query = "UPDATE warpSkyfile SET magicked = %" PRId64 " where warp_id = %" PRId64 " AND skycell_id = '%s'";
     779        clearRunQuery = "UPDATE warpRun SET magicked = 0 where warp_id = %" PRId64;
    763780        break;
    764781    case IPP_STAGE_WARP_BG:
    765782        query = "UPDATE warpBackgroundSkyfile SET magicked = %" PRId64 " where warp_bg_id = %" PRId64 " AND skycell_id = '%s'";
     783        clearRunQuery = "UPDATE warpBackgroundRun SET magicked = 0 where warp_bg_id = %" PRId64;
    766784        break;
    767785    case IPP_STAGE_DIFF:
    768786        query = "UPDATE diffSkyfile SET magicked = %" PRId64 " where diff_id = %" PRId64 " AND skycell_id = '%s'";
     787        clearRunQuery = "UPDATE diffRun SET magicked = 0 where diff_id = %" PRId64;
    769788        break;
    770789    default:
    771790        psError(PS_ERR_UNKNOWN, true, "unexpected value for stage: %s found", stage);
    772         psFree(output);
    773         return false;
    774     }
    775 
    776     if (!p_psDBRunQueryF(config->dbh, query, magic_id, stage_id, component)) {
    777         psError(PS_ERR_UNKNOWN, false, "database error");
    778         return false;
    779     }
    780     psFree(output);
    781 
    782     psU64 affected = psDBAffectedRows(config->dbh);
    783     if (affected != 1) {
    784         psError(PS_ERR_UNKNOWN, false, "should have affected 1 row");
    785         return false;
     791        return false;
     792    }
     793
     794    if (query) {
     795        if (!p_psDBRunQueryF(config->dbh, query, newMagickedValue, stage_id, component)) {
     796            psError(PS_ERR_UNKNOWN, false, "database error");
     797            return false;
     798        }
     799    }
     800
     801    if (clearMagicked && clearRunQuery) {
     802        if (!p_psDBRunQueryF(config->dbh, clearRunQuery, stage_id)) {
     803            psError(PS_ERR_UNKNOWN, false, "database error");
     804            return false;
     805        }
    786806    }
    787807
     
    896916    if (setmagicked) {
    897917        // set the image file's magicked flag
    898         if (!setMagicked(config, magic_ds_id, component)) {
     918        if (!setMagicked(config, magic_ds_id, component, false)) {
    899919            psError(PS_ERR_UNKNOWN, false, "setMagicked failed");
    900920            if (!psDBRollback(config->dbh)) {
     
    11111131    pxAddLabelSearchArgs (config, where, "-label", "label", "==");
    11121132
     1133    PXOPT_LOOKUP_S64(magic_ds_id, config->args, "-magic_ds_id", true, false);
     1134    PXOPT_LOOKUP_STR(component, config->args, "-component", true, false);
    11131135    PXOPT_LOOKUP_STR(state, config->args, "-state", false, false);
    11141136    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
     
    11161138    psString queryFile = NULL;
    11171139    bool stateIsUpdate = false;
     1140    bool toRestored = !strcmp(state, "goto_restored");
    11181141    if (state) {
    1119         if (! strcmp(state, "new") || !strcmp(state, "goto_restored")) {
     1142        if (! strcmp(state, "new") || toRestored) {
    11201143            queryFile = "magicdstool_revertdestreakedfile.sql";
    11211144        } else if (!strcmp(state, "update")) {
     
    11531176    }
    11541177
     1178    if (!psDBTransaction(config->dbh)) {
     1179        psError(PS_ERR_UNKNOWN, false, "database error");
     1180        return false;
     1181    }
    11551182    if (!p_psDBRunQuery(config->dbh, query)) {
    11561183        psError(PS_ERR_UNKNOWN, false, "failed to revert");
     
    11591186    }
    11601187    psFree(query);
     1188    if (toRestored) {
     1189        // clear the underlying component's magicked value
     1190        if (!setMagicked(config, magic_ds_id, component, true)) {
     1191            psError(PS_ERR_UNKNOWN, false, "setMagicked failed");
     1192            if (!psDBRollback(config->dbh)) {
     1193                psError(PS_ERR_UNKNOWN, false, "database error");
     1194            }
     1195            return false;
     1196        }
     1197    }
     1198    if (!psDBCommit(config->dbh)) {
     1199        psError(PS_ERR_UNKNOWN, false, "database error");
     1200        return false;
     1201    }
    11611202    return true;
    11621203}
     
    16611702    }
    16621703    if (!strcmp(data_state, "full")) {
    1663         // if -tofullfile optoinally set the magicked value for the component
    1664         PXOPT_LOOKUP_BOOL(setmagicked, config->args, "-setmagicked", false);
    1665         // set the image file's magicked flag
    1666         if (!setMagicked(config, magic_ds_id, component)) {
     1704        // set the component's magicked flag
     1705       
     1706        if (!setMagicked(config, magic_ds_id, component, false)) {
    16671707            psError(PS_ERR_UNKNOWN, false, "setMagicked failed");
    16681708            if (!psDBRollback(config->dbh)) {
     
    17161756    return change_file_data_state(config, "full");
    17171757}
    1718 /*
    1719 static bool topurgedimfileMode(pxConfig *config)
    1720 {
    1721     return change_imfile_data_state(config, "purged", "goto_purged");
    1722 }
    1723 static bool toscrubbedfileMode(pxConfig *config)
    1724 {
    1725   return change_file_data_state(config, "scrubbed", "goto_scrubbed");
    1726 }
    1727 */
    17281758
    17291759// a very specfic function to queue a cleaned magicDSFile to be updated
  • branches/eam_branches/ipp-20110213/ippTools/src/magictool.c

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/ipp-20110213/ippTools/src/regtool.c

    r30594 r30675  
    259259      continue;
    260260    }
     261    char *is_ccim = strchr(psMetadataLookupStr(NULL,row,"exp_name"),'c');
     262    if (is_ccim) { // Is a camera commanded exposure
     263      //      fprintf(stderr,"IN camera commanded!\n");
     264      if ((strcasecmp(psMetadataLookupStr(NULL,row,"exp_type"),"DOMEFLAT") == 0)||
     265          (strcasecmp(psMetadataLookupStr(NULL,row,"exp_type"),"DARK") == 0) ||
     266          (strcasecmp(psMetadataLookupStr(NULL,row,"exp_type"),"BIAS") == 0)) {
     267        continue;
     268      }
     269    }
    261270   
    262271    if ((psMetadataLookupS32(NULL,row,"is_downloaded") != 1)||
     
    367376    }
    368377
     378    char *is_ccim = strchr(psMetadataLookupStr(NULL,row,"exp_name"),'c');
     379    if (is_ccim) { // Is a camera commanded exposure
     380      //      fprintf(stderr,"IN camera commanded!\n");
     381      if ((strcasecmp(psMetadataLookupStr(NULL,row,"exp_type"),"DOMEFLAT") == 0)||
     382          (strcasecmp(psMetadataLookupStr(NULL,row,"exp_type"),"DARK") == 0) ||
     383          (strcasecmp(psMetadataLookupStr(NULL,row,"exp_type"),"BIAS") == 0)) {
     384        continue;
     385      }
     386    }
     387
    369388    bool status = false;
    370389    char *tmp_id = psMetadataLookupStr(&status,row,"summit_class_id");
     
    389408    }
    390409
     410   
    391411    if (0 && !strcmp(this_class_id, "ota44")) {
    392412        printf("STAT 1: %s (%d %d) %d %d %d\n",
     
    857877    PXOPT_LOOKUP_STR(set_md5sum, config->args, "-set_md5sum", false, false);
    858878    PXOPT_LOOKUP_STR(set_state, config->args, "-set_state", false, false);
    859 
     879    PXOPT_LOOKUP_STR(hostname, config->args, "-hostname", false, false);
     880   
    860881    if ((fault == INT16_MAX) && (burntool_state == INT16_MAX) && !set_state) {
    861882        psError(PS_ERR_UNKNOWN, false, "one of -fault or -burntool_state or -set_state must be selected");
     
    905926      psStringAppend(&setvalues,"rawImfile.data_state = '%s'",set_state);
    906927    }
    907 
     928    if (hostname) {
     929      if (setvalues) {
     930        psStringAppend(&setvalues,",");
     931      }
     932      psStringAppend(&setvalues,"rawImfile.hostname = '%s'", hostname);
     933    }
    908934    psString query = pxDataGet("regtool_updateprocessedimfile.sql");
    909935    if (!query) {
  • branches/eam_branches/ipp-20110213/ippTools/src/regtoolConfig.c

    r30352 r30675  
    189189    ADD_OPT(S16, updateprocessedimfileArgs, "-burntool_state",        "set burntool state", INT16_MAX);
    190190    ADD_OPT(S16, updateprocessedimfileArgs, "-fault",          "set fault code", INT16_MAX);
     191    ADD_OPT(Str, updateprocessedimfileArgs, "-hostname",       "set host name",                NULL);
    191192    ADD_OPT(S32, updateprocessedimfileArgs, "-set_bytes",      "set bytes", INT32_MAX);
    192193    ADD_OPT(Str, updateprocessedimfileArgs, "-set_md5sum",     "set md5sum", NULL);
Note: See TracChangeset for help on using the changeset viewer.