IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 3, 2010, 8:45:22 AM (16 years ago)
Author:
eugene
Message:

updates from trunk

Location:
branches/simmosaic_branches
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/simmosaic_branches

  • branches/simmosaic_branches/ippTools/src

    • Property svn:ignore
      •  

        old new  
         1*.la
         2*.lo
        13.deps
        24.gdb_history
         
        46Makefile
        57Makefile.in
         8addtool
         9caltool
         10camtool
         11chiptool
        612config.h
        713config.h.in
        8 stamp-h1
        9 *.la
        10 *.lo
         14detselect
         15dettool
         16difftool
         17disttool
         18dqstatstool
         19faketool
         20flatcorr
         21guidetool
         22magicdstool
         23magictool
         24pstamptool
         25pubtool
         26pxadmin
         27pxdata.c
         28pxinject
        1129pxtoolsErrorCodes.c
        1230pxtoolsErrorCodes.h
        13 pxadmin
        14 pxinject
        15 pztool
        1631pzgetexp
        1732pzgetimfiles
         33pztool
         34receivetool
        1835regtool
        19 guidetool
        20 chiptool
        21 camtool
         36stacktool
         37stamp-h1
        2238warptool
        23 difftool
        24 stacktool
        25 faketool
        26 dettool
        27 detselect
        28 pxdata.c
        29 magictool
        30 magicdstool
        31 caltool
        32 flatcorr
        33 pstamptool
        34 disttool
        35 receivetool
        36 
        37 pubtool
  • branches/simmosaic_branches/ippTools/src/dettool.c

    r24779 r27839  
    9494        MODECASE(DETTOOL_MODE_PENDINGCLEANUP_PROCESSEDEXP, pendingcleanup_processedexpMode);
    9595        MODECASE(DETTOOL_MODE_DONECLEANUP_PROCESSEDEXP, donecleanup_processedexpMode);
     96        MODECASE(DETTOOL_MODE_UPDATESTATE_PROCESSED, updatestateprocessedMode);
    9697        // stacked
    9798        MODECASE(DETTOOL_MODE_TOSTACKED,        tostackedMode);
     
    142143        MODECASE(DETTOOL_MODE_PENDINGCLEANUP_RESIDEXP, pendingcleanup_residexpMode);
    143144        MODECASE(DETTOOL_MODE_DONECLEANUP_RESIDEXP, donecleanup_residexpMode);
     145        MODECASE(DETTOOL_MODE_UPDATESTATE_RESID, updatestateresidMode);
    144146        // detrunsummary
    145147        MODECASE(DETTOOL_MODE_TODETRUNSUMMARY,  todetrunsummaryMode);
     
    150152        MODECASE(DETTOOL_MODE_UPDATEDETRUN,     updatedetrunMode);
    151153        MODECASE(DETTOOL_MODE_RERUN,            rerunMode);
     154        MODECASE(DETTOOL_MODE_PENDINGCLEANUP_DETRUNSUMMARY, pendingcleanup_detrunsummaryMode);
    152155        // register
    153156        MODECASE(DETTOOL_MODE_REGISTER_DETREND, register_detrendMode);
     
    184187    psString query = pxDataGet("dettool_pending.sql");
    185188    if (!query) {
    186         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    187         return false;
    188     }
    189    
     189        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     190        return false;
     191    }
     192
    190193    psMetadata *where = psMetadataAlloc();
    191194    PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "==");
     
    257260        psError(PS_ERR_UNKNOWN, false, "verify mode requires both -ref_det_id and -ref_iter");
    258261        return false;
    259     } 
     262    }
    260263    if (strcmp(mode, "verify") && ((ref_det_id != 0) || (ref_iter != -1))) {
    261264        psError(PS_ERR_UNKNOWN, false, "master mode cannot have -ref_det_id or -ref_iter set");
    262265        return false;
    263     } 
    264        
     266    }
     267
    265268    PXOPT_LOOKUP_STR(camera, config->args, "-inst", false, false);
    266269    PXOPT_LOOKUP_STR(telescope, config->args, "-telescope", false, false);
     
    276279    PXOPT_LOOKUP_F64(posang_min, config->args, "-posang_min", false, false);
    277280    PXOPT_LOOKUP_F64(posang_max, config->args, "-posang_max", false, false);
    278     PXOPT_LOOKUP_F64(solang_min, config->args, "-solang_min", false, false);
    279     PXOPT_LOOKUP_F64(solang_max, config->args, "-solang_max", false, false);
     281    PXOPT_LOOKUP_F64(solang_min, config->args, "-sun_angle_min", false, false);
     282    PXOPT_LOOKUP_F64(solang_max, config->args, "-sun_angle_max", false, false);
    280283    PXOPT_LOOKUP_TIME(time_begin, config->args, "-time_begin", false, false);
    281284    PXOPT_LOOKUP_TIME(time_end, config->args, "-time_end", false, false);
     
    307310        psMetadataItem *mItem = NULL;
    308311        while ((mItem = psListGetAndIncrement(iter))) {
    309             psS64 exp_id = mItem->data.S64;
     312            psS64 exp_id = mItem->data.S64;
    310313            if (!psMetadataAddS64(where, PS_LIST_TAIL, "exp_id", PS_META_DUPLICATE_OK, "==", exp_id)) {
    311314                psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
     
    316319        }
    317320        psFree(iter);
    318     } 
     321    }
    319322    if (item->type == PS_DATA_S64) {
    320         psS64 exp_id = item->data.S64;
    321         if (!psMetadataAddS64(where, PS_LIST_TAIL, "exp_id", PS_META_DUPLICATE_OK, "==", exp_id)) {
    322             psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
    323             psFree(where);
    324             return false;
    325         }
    326     } 
     323        psS64 exp_id = item->data.S64;
     324        if (!psMetadataAddS64(where, PS_LIST_TAIL, "exp_id", PS_META_DUPLICATE_OK, "==", exp_id)) {
     325            psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
     326            psFree(where);
     327            return false;
     328        }
     329    }
    327330
    328331    if (psListLength(where->list) < 1) {
     
    504507        psError(PS_ERR_UNKNOWN, false, "verify mode requires both -ref_det_id and -ref_iter");
    505508        return false;
    506     } 
     509    }
    507510    if (strcmp(mode, "verify") && ((ref_det_id != 0) || (ref_iter != -1))) {
    508511        psError(PS_ERR_UNKNOWN, false, "master mode cannot have -ref_det_id or -ref_iter set");
    509512        return false;
    510     } 
     513    }
    511514
    512515    PXOPT_LOOKUP_STR(filelevel, config->args, "-filelevel", false, false);
     
    521524    PXOPT_LOOKUP_F64(posang_min, config->args, "-posang_min", false, false);
    522525    PXOPT_LOOKUP_F64(posang_max, config->args, "-posang_max", false, false);
    523     PXOPT_LOOKUP_F64(solang_min, config->args, "-solang_min", false, false);
    524     PXOPT_LOOKUP_F64(solang_max, config->args, "-solang_max", false, false);
     526    PXOPT_LOOKUP_F64(solang_min, config->args, "-sun_angle_min", false, false);
     527    PXOPT_LOOKUP_F64(solang_max, config->args, "-sun_angle_max", false, false);
    525528
    526529    PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false);
     
    549552    PXOPT_COPY_F32(config->args, where, "-select_airmass_max", "airmass", "<=");
    550553    PXOPT_COPY_F32(config->args, where, "-select_sat_pixel_frac_max", "sat_pixel_frac", "<=");
     554    PXOPT_COPY_F32(config->args, where, "-select_sat_pixel_frac_min", "sat_pixel_frac", ">=");
    551555    PXOPT_COPY_F32(config->args, where, "-select_exp_time_min", "exp_time", ">=");
    552556    PXOPT_COPY_F32(config->args, where, "-select_exp_time_max", "exp_time", "<=");
     
    557561    PXOPT_COPY_F64(config->args, where, "-select_posang_min", "posang", ">=");
    558562    PXOPT_COPY_F64(config->args, where, "-select_posang_max", "posang", "<=");
    559     PXOPT_COPY_F64(config->args, where, "-select_solang_min", "solang", ">=");
    560     PXOPT_COPY_F64(config->args, where, "-select_solang_max", "solang", "<=");
     563    PXOPT_COPY_F64(config->args, where, "-select_sun_angle_min", "sun_angle", ">=");
     564    PXOPT_COPY_F64(config->args, where, "-select_sun_angle_max", "sun_angle", "<=");
     565    PXOPT_COPY_F64(config->args, where, "-select_sun_alt_min", "sun_alt", ">=");
     566    PXOPT_COPY_F64(config->args, where, "-select_sun_alt_max", "sun_alt", "<=");
    561567
    562568    PXOPT_COPY_F64(config->args, where, "-select_moon_angle_min", "moon_angle", ">=");
     
    670676                 label,
    671677                 ref_det_id,
    672                 ref_iter
     678                ref_iter
    673679        );
    674680    psS64 det_id = psDBLastInsertID(config->dbh);
     
    739745{
    740746    PS_ASSERT_PTR_NON_NULL(config, false);
    741    
     747
    742748    // XXX this mode is not well-tested: probably need to specify iteration here
    743749    PXOPT_LOOKUP_S64(det_id, config->args, "-det_id", true, false); // required
     
    756762        psError(PS_ERR_UNKNOWN, false, "verify mode requires both -ref_det_id and -ref_iter");
    757763        return false;
    758     } 
     764    }
    759765    if (strcmp(mode, "verify") && ((ref_det_id != 0) || (ref_iter != -1))) {
    760766        psError(PS_ERR_UNKNOWN, false, "master mode cannot have -ref_det_id or -ref_iter set");
    761767        return false;
    762     } 
     768    }
    763769
    764770    // the new detRun may have different values for these limits:
     
    775781    PXOPT_LOOKUP_F64(posang_min, config->args, "-set_posang_min", false, false);
    776782    PXOPT_LOOKUP_F64(posang_max, config->args, "-set_posang_max", false, false);
    777     PXOPT_LOOKUP_F64(solang_min, config->args, "-set_solang_min", false, false);
    778     PXOPT_LOOKUP_F64(solang_max, config->args, "-set_solang_max", false, false);
     783    PXOPT_LOOKUP_F64(solang_min, config->args, "-set_sun_angle_min", false, false);
     784    PXOPT_LOOKUP_F64(solang_max, config->args, "-set_sun_angle_max", false, false);
    779785    PXOPT_LOOKUP_TIME(registered, config->args, "-set_registered", false, false);
    780786    PXOPT_LOOKUP_TIME(time_begin, config->args, "-set_time_begin", false, false);
     
    814820
    815821    if (iteration < 0) {
    816         iteration = detRun->iteration;
     822        iteration = detRun->iteration;
    817823    }
    818824
     
    974980    psString query = pxDataGet("dettool_definebydetrun.sql");
    975981    if (!query) {
    976         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     982        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    977983        return false;
    978984    }
     
    986992
    987993    if (only_accepted) {
    988         psStringAppend(&query, " AND accept = 1");
     994        psStringAppend(&query, " AND accept = 1");
    989995    }
    990996
     
    10651071    psString query = pxDataGet("dettool_runs.sql");
    10661072    if (!query) {
    1067         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     1073        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    10681074        return false;
    10691075    }
     
    11351141    psString query = pxDataGet("dettool_childlessrun.sql");
    11361142    if (!query) {
    1137         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     1143        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    11381144        psFree(where);
    11391145        return false;
     
    12091215    psString query = pxDataGet("dettool_input.sql");
    12101216    if (!query) {
    1211         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     1217        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    12121218        psFree(where);
    12131219        return false;
     
    12611267    psString query = pxDataGet("dettool_raw.sql");
    12621268    if (!query) {
    1263         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     1269        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    12641270        return false;
    12651271    }
     
    13351341}
    13361342
    1337 // used by updatedetrunMode 
     1343// used by updatedetrunMode
    13381344bool startNewIteration(pxConfig *config, psS64 det_id)
    13391345{
     
    13421348    psString query = pxDataGet("dettool_start_new_iteration.sql");
    13431349    if (!query) {
    1344         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     1350        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    13451351        return false;
    13461352    }
     
    15611567        }
    15621568        detInputExpRow *newInputExp = detInputExpRowAlloc(
    1563             det_id,
     1569            det_id,
    15641570            newIteration,
    15651571            inputExp->exp_id,
     
    16131619    PXOPT_LOOKUP_F64(posang_min, config->args, "-posang_min", false, false);
    16141620    PXOPT_LOOKUP_F64(posang_max, config->args, "-posang_max", false, false);
    1615     PXOPT_LOOKUP_F64(solang_min, config->args, "-solang_min", false, false);
    1616     PXOPT_LOOKUP_F64(solang_max, config->args, "-solang_max", false, false);
     1621    PXOPT_LOOKUP_F64(solang_min, config->args, "-sun_angle_min", false, false);
     1622    PXOPT_LOOKUP_F64(solang_max, config->args, "-sun_angle_max", false, false);
    16171623    PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false);
    16181624    PXOPT_LOOKUP_TIME(time_begin, config->args, "-time_begin", false, false);
     
    16591665                      solang_max,
    16601666                      label,
    1661                       ref_det_id,
    1662                       ref_iter
     1667                      ref_det_id,
     1668                      ref_iter
    16631669            )) {
    16641670        psError(PS_ERR_UNKNOWN, false, "database error");
     
    17101716{
    17111717    PS_ASSERT_PTR_NON_NULL(config, false);
    1712    
     1718
    17131719    PXOPT_LOOKUP_S64(det_id, config->args, "-det_id", true, false); // required
    17141720    PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", true, false); // required
     
    17251731
    17261732    if (!detRegisteredImfileInsert(config->dbh,
    1727                                    det_id,
    1728                                    0,  // the iteration is fixed at 0
    1729                                    class_id,
    1730                                    uri,
    1731                                    bg,
    1732                                    bg_stdev,
    1733                                    bg_mean_stdev,
    1734                                    user_1,
    1735                                    user_2,
    1736                                    user_3,
    1737                                    user_4,
    1738                                    user_5,
    1739                                    path_base,
    1740                                    "full",                                 
    1741                                    0       // fault code
    1742             )) {
     1733                                   det_id,
     1734                                   0,  // the iteration is fixed at 0
     1735                                   class_id,
     1736                                   uri,
     1737                                   bg,
     1738                                   bg_stdev,
     1739                                   bg_mean_stdev,
     1740                                   user_1,
     1741                                   user_2,
     1742                                   user_3,
     1743                                   user_4,
     1744                                   user_5,
     1745                                   path_base,
     1746                                   "full",
     1747                                   0       // fault code
     1748            )) {
    17431749        psError(PS_ERR_UNKNOWN, false, "database error");
    17441750        return false;
     
    18251831    if (!strcmp(data_state, "drop")) return true;
    18261832    if (!strcmp(data_state, "register")) return true;
     1833    // These are valid data states, and are necessary for the cleanup to work correctly.
     1834    if (!strcmp(data_state, "full")) return true;
     1835    if (!strcmp(data_state, "goto_cleaned")) return true;
     1836    if (!strcmp(data_state, "goto_scrubbed")) return true;
     1837    if (!strcmp(data_state, "goto_purged")) return true;
     1838    if (!strcmp(data_state, "cleaned")) return true;
     1839    if (!strcmp(data_state, "scrubbed")) return true;
     1840    if (!strcmp(data_state, "purged")) return true;
     1841    if (!strcmp(data_state, "error_cleaned")) return true;
     1842    if (!strcmp(data_state, "error_scrubbed")) return true;
     1843    if (!strcmp(data_state, "error_purged")) return true;
    18271844
    18281845    psError(PS_ERR_UNKNOWN, true, "invalid data state: %s", data_state);
     
    18441861
    18451862
    1846 bool setProcessedImfileDataState(pxConfig *config, psS64 det_id, psS64 exp_id, const char *class_id, const char *data_state)
     1863bool setProcessedImfileDataState(pxConfig *config, psMetadata *where, const char *data_state)
    18471864{
    18481865    PS_ASSERT_PTR_NON_NULL(config, false);
     1866    PS_ASSERT_PTR_NON_NULL(where, false);
    18491867    PS_ASSERT_PTR_NON_NULL(data_state, false);
    1850     PS_ASSERT_PTR_NON_NULL(class_id, false);
    18511868
    18521869    if (!isValidDataState (data_state)) return false;
    18531870
    1854     char *query = "UPDATE detProcessedImfile SET data_state = '%s'"
    1855         " WHERE det_id = %" PRId64
    1856         " AND exp_id = %" PRId64
    1857         " AND class_id = '%s'";
    1858     if (!p_psDBRunQueryF(config->dbh, query, data_state, det_id, exp_id, class_id)) {
    1859         psError(PS_ERR_UNKNOWN, false,
    1860                 "failed to change state for det_id %" PRId64 ", exp_id %" PRId64 ", class_id %s",
    1861                 det_id, exp_id, class_id);
    1862         return false;
    1863     }
    1864 
    1865     return true;
    1866 }
    1867 
    1868 bool setProcessedExpDataState(pxConfig *config, psS64 det_id, psS64 exp_id, const char *data_state)
     1871    psString query = psStringCopy("UPDATE detProcessedImfile SET data_state = '%s'");
     1872    if (where && psListLength(where->list) > 0) {
     1873      psString whereClause = psDBGenerateWhereSQL(where,NULL);
     1874      psStringAppend(&query," %s",whereClause);
     1875      psFree(whereClause);
     1876    } else {
     1877      psError(PS_ERR_UNKNOWN, true, "search parameters are required");
     1878      return(false);
     1879    }
     1880
     1881    if (!p_psDBRunQueryF(config->dbh, query, data_state)) {
     1882      psFree(query);
     1883      psError(PS_ERR_UNKNOWN, false, "database error");
     1884      return(false);
     1885    }
     1886    psFree(query);
     1887    return(true);
     1888}
     1889
     1890bool setProcessedExpDataState(pxConfig *config, psMetadata *where, const char *data_state)
    18691891{
    18701892    PS_ASSERT_PTR_NON_NULL(config, false);
     1893    PS_ASSERT_PTR_NON_NULL(where, false);
    18711894    PS_ASSERT_PTR_NON_NULL(data_state, false);
    18721895
    18731896    if (!isValidDataState (data_state)) return false;
    18741897
    1875     char *query = "UPDATE detProcessedExp SET data_state = '%s'"
    1876         " WHERE det_id = %" PRId64
    1877         " AND exp_id = %" PRId64;
    1878     if (!p_psDBRunQueryF(config->dbh, query, data_state, det_id, exp_id)) {
    1879         psError(PS_ERR_UNKNOWN, false,
    1880                 "failed to change state for det_id %" PRId64 ", exp_id %" PRId64,
    1881                 det_id, exp_id);
    1882         return false;
    1883     }
    1884 
    1885     return true;
    1886 }
    1887 
    1888 
     1898    psString query = psStringCopy("UPDATE detProcessedExp SET data_state = '%s'");
     1899    if (where && psListLength(where->list) > 0) {
     1900      psString whereClause = psDBGenerateWhereSQL(where,NULL);
     1901      psStringAppend(&query," %s",whereClause);
     1902      psFree(whereClause);
     1903    } else {
     1904      psError(PS_ERR_UNKNOWN, true, "search parameters are required");
     1905      return(false);
     1906    }
     1907
     1908    if (!p_psDBRunQueryF(config->dbh, query, data_state)) {
     1909      psFree(query);
     1910      psError(PS_ERR_UNKNOWN, false, "database error");
     1911      return(false);
     1912    }
     1913    psFree(query);
     1914    return(true);
     1915}
     1916
     1917bool setResidImfileDataState(pxConfig *config, psMetadata *where, const char *data_state)
     1918{
     1919    PS_ASSERT_PTR_NON_NULL(config, false);
     1920    PS_ASSERT_PTR_NON_NULL(where,false);
     1921    PS_ASSERT_PTR_NON_NULL(data_state, false);
     1922
     1923    if (!isValidDataState (data_state)) return false;
     1924
     1925    psString query = psStringCopy("UPDATE detResidImfile SET data_state = '%s'");
     1926    if (where && psListLength(where->list) > 0) {
     1927      psString whereClause = psDBGenerateWhereSQL(where,NULL);
     1928      psStringAppend(&query," %s",whereClause);
     1929      psFree(whereClause);
     1930    } else {
     1931      psError(PS_ERR_UNKNOWN, true, "search parameters are required");
     1932      return(false);
     1933    }
     1934
     1935    if (!p_psDBRunQueryF(config->dbh, query, data_state)) {
     1936      psFree(query);
     1937      psError(PS_ERR_UNKNOWN, false, "database error");
     1938      return(false);
     1939    }
     1940    psFree(query);
     1941    return(true);
     1942}
     1943// This function apparently not used anymore.
     1944bool setResidExpDataState(pxConfig *config, psMetadata *where, const char *data_state)
     1945{
     1946    PS_ASSERT_PTR_NON_NULL(config, false);
     1947    PS_ASSERT_PTR_NON_NULL(where,false);
     1948    PS_ASSERT_PTR_NON_NULL(data_state, false);
     1949
     1950    if (!isValidDataState (data_state)) return false;
     1951
     1952    psString query = psStringCopy("UPDATE detResidExp SET data_state = '%s'");
     1953    if (where && psListLength(where->list) > 0) {
     1954      psString whereClause = psDBGenerateWhereSQL(where,NULL);
     1955      psStringAppend(&query," %s",whereClause);
     1956      psFree(whereClause);
     1957    } else {
     1958      psError(PS_ERR_UNKNOWN, true, "search parameters are required");
     1959      return(false);
     1960    }
     1961
     1962    if (!p_psDBRunQueryF(config->dbh, query, data_state)) {
     1963      psFree(query);
     1964      psError(PS_ERR_UNKNOWN, false, "database error");
     1965      return(false);
     1966    }
     1967    psFree(query);
     1968    return(true);
     1969}
     1970
     1971// Not yet updated for cleaning
    18891972bool setStackedImfileDataState(pxConfig *config, psS64 det_id, psS32 iteration, const char *class_id, const char *data_state)
    18901973{
     
    18961979
    18971980    char *query = "UPDATE detStackedImfile SET data_state = '%s'"
    1898         " WHERE det_id = %" PRId64
    1899         " AND iteration = %" PRId32
    1900         " AND class_id = %s";
     1981        " WHERE det_id = %" PRId64
     1982        " AND iteration = %" PRId32
     1983        " AND class_id = '%s'";
    19011984    if (!p_psDBRunQueryF(config->dbh, query, data_state, det_id, iteration, class_id)) {
    19021985        psError(PS_ERR_UNKNOWN, false,
    1903                 "failed to change state for det_id %" PRId64 ", iteration %" PRId32 "class_id %s", 
    1904                 det_id, iteration, class_id);
     1986                "failed to change state for det_id %" PRId64 ", iteration %" PRId32 "class_id %s",
     1987                det_id, iteration, class_id);
    19051988        return false;
    19061989    }
     
    19182001
    19192002    char *query = "UPDATE detNormalizedStatImfile SET data_state = '%s'"
    1920         " WHERE det_id = %" PRId64
    1921         " AND iteration = %" PRId32
    1922         " AND class_id = %s";
    1923     if (!p_psDBRunQueryF(config->dbh, query, data_state, det_id, iteration)) {
     2003        " WHERE det_id = %" PRId64
     2004        " AND iteration = %" PRId32
     2005        " AND class_id = '%s'";
     2006/*     fprintf(stderr,"DETTOOL SAYS: %s\n",query); */
     2007    if (!p_psDBRunQueryF(config->dbh, query, data_state, det_id, iteration,class_id)) {
    19242008        psError(PS_ERR_UNKNOWN, false,
    1925                 "failed to change state for det_id %" PRId64 ", iteration %" PRId32, 
    1926                 det_id, iteration);
     2009                "failed to change state for det_id %" PRId64 ", iteration %" PRId32,
     2010                det_id, iteration);
    19272011        return false;
    19282012    }
     
    19402024
    19412025    char *query = "UPDATE detNormalizedImfile SET data_state = '%s'"
    1942         " WHERE det_id = %" PRId64
    1943         " AND iteration = %" PRId32
    1944         " AND class_id = %s";
     2026        " WHERE det_id = %" PRId64
     2027        " AND iteration = %" PRId32
     2028        " AND class_id = '%s'";
    19452029    if (!p_psDBRunQueryF(config->dbh, query, data_state, det_id, iteration, class_id)) {
    19462030        psError(PS_ERR_UNKNOWN, false,
    1947                 "failed to change state for det_id %" PRId64 ", iteration %" PRId32 " class %s", 
    1948                 det_id, iteration, class_id);
     2031                "failed to change state for det_id %" PRId64 ", iteration %" PRId32 " class %s",
     2032                det_id, iteration, class_id);
    19492033        return false;
    19502034    }
     
    19612045
    19622046    char *query = "UPDATE detNormalizedExp SET data_state = '%s'"
    1963         " WHERE det_id = %" PRId64
    1964         " AND iteration = %" PRId32;
     2047        " WHERE det_id = %" PRId64
     2048        " AND iteration = %" PRId32;
    19652049    if (!p_psDBRunQueryF(config->dbh, query, data_state, det_id, iteration)) {
    19662050        psError(PS_ERR_UNKNOWN, false,
    1967                 "failed to change state for det_id %" PRId64 ", iteration %" PRId32, 
    1968                 det_id, iteration);
     2051                "failed to change state for det_id %" PRId64 ", iteration %" PRId32,
     2052                det_id, iteration);
    19692053        return false;
    19702054    }
     
    19722056    return true;
    19732057}
    1974 
    1975 bool setResidImfileDataState(pxConfig *config, psS64 det_id, psS32 iteration, psS64 exp_id, const char *class_id, const char *data_state)
    1976 {
    1977     PS_ASSERT_PTR_NON_NULL(config, false);
    1978     PS_ASSERT_PTR_NON_NULL(data_state, false);
    1979     PS_ASSERT_PTR_NON_NULL(class_id, false);
    1980 
    1981     if (!isValidDataState (data_state)) return false;
    1982 
    1983     char *query = "UPDATE detResidImfile SET data_state = '%s'"
    1984         " WHERE det_id = %" PRId64
    1985         " AND iteration = %" PRId32
    1986         " AND exp_id = %" PRId64
    1987         " AND class_id = '%s'";
    1988     if (!p_psDBRunQueryF(config->dbh, query, data_state, det_id, iteration, exp_id, class_id)) {
    1989         psError(PS_ERR_UNKNOWN, false,
    1990                 "failed to change state for det_id %" PRId64 ", iteration %" PRId32 ", exp_id %" PRId64 ", class_id %s",
    1991                 det_id, iteration, exp_id, class_id);
    1992         return false;
    1993     }
    1994 
    1995     return true;
    1996 }
    1997 
    1998 bool setResidExpDataState(pxConfig *config, psS64 det_id, psS32 iteration, psS64 exp_id, const char *data_state)
    1999 {
    2000     PS_ASSERT_PTR_NON_NULL(config, false);
    2001     PS_ASSERT_PTR_NON_NULL(data_state, false);
    2002 
    2003     if (!isValidDataState (data_state)) return false;
    2004 
    2005     char *query = "UPDATE detResidExp SET data_state = '%s'"
    2006         " WHERE det_id = %" PRId64
    2007         " AND iteration = %" PRId32
    2008         " AND exp_id = %" PRId64;
    2009     if (!p_psDBRunQueryF(config->dbh, query, data_state, det_id, iteration, exp_id)) {
    2010         psError(PS_ERR_UNKNOWN, false,
    2011                 "failed to change state for det_id %" PRId64 ", iteration %" PRId32 ", exp_id %" PRId64,
    2012                 det_id, iteration, exp_id);
    2013         return false;
    2014     }
    2015 
    2016     return true;
    2017 }
     2058// End not yet modified for cleanup.
    20182059
    20192060bool exportrunMode(pxConfig *config)
     
    20232064    char sqlFilename[80];
    20242065  } ExportTable;
    2025  
     2066
    20262067  int numExportTables = 12;
    20272068
     
    20592100    psString query = pxDataGet(tables[i].sqlFilename);
    20602101    if (!query) {
    2061       psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     2102      psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    20622103      return false;
    20632104    }
     
    21012142    }
    21022143    psFree(output);
    2103  
     2144
    21042145  }
    21052146
     
    21122153{
    21132154  unsigned int nFail;
    2114  
     2155
    21152156  int numImportTables = 11;
    2116  
     2157
    21172158  char tables[11] [80] = {"detInputExp", "detNormalizedExp",
    21182159    "detNormalizedImfile", "detNormalizedStatImfile", "detProcessedExp",
     
    21212162
    21222163  PS_ASSERT_PTR_NON_NULL(config, NULL);
    2123  
     2164
    21242165  PXOPT_LOOKUP_STR(infile, config->args, "-infile", true,  false);
    21252166
     
    21282169  fprintf (stdout, "---- input ----\n");
    21292170  psMetadataPrint (stderr, input, 1);
    2130  
     2171
    21312172  psMetadataItem *item = psMetadataLookup (input, "detRun");
    21322173  psAssert (item, "entry not in input?");
     
    21382179  detRunRow *detRun = detRunObjectFromMetadata (entry->data.md);
    21392180  detRunInsertObject (config->dbh, detRun);
    2140  
     2181
    21412182  // fprintf (stdout, "---- det run ----\n");
    21422183  // psMetadataPrint (stderr, entry->data.md, 1);
     
    21462187    psAssert (item, "entry not in input?");
    21472188    psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?");
    2148  
     2189
    21492190    switch (i) {
    21502191      case 0:
     
    21602201        }
    21612202        break;
    2162  
     2203
    21632204      case 1:
    21642205        for (int i = 0; i < item->data.list->n; i++) {
     
    21732214        }
    21742215        break;
    2175        
     2216
    21762217      case 2:
    21772218        for (int i = 0; i < item->data.list->n; i++) {
     
    21862227        }
    21872228        break;
    2188  
     2229
    21892230      case 3:
    21902231        for (int i = 0; i < item->data.list->n; i++) {
     
    21992240        }
    22002241        break;
    2201        
     2242
    22022243      case 4:
    22032244        for (int i = 0; i < item->data.list->n; i++) {
     
    22122253        }
    22132254        break;
    2214        
     2255
    22152256      case 5:
    22162257        for (int i = 0; i < item->data.list->n; i++) {
     
    22252266        }
    22262267        break;
    2227        
     2268
    22282269      case 6:
    22292270        for (int i = 0; i < item->data.list->n; i++) {
     
    22382279        }
    22392280        break;
    2240        
     2281
    22412282      case 7:
    22422283        for (int i = 0; i < item->data.list->n; i++) {
     
    22512292        }
    22522293        break;
    2253        
     2294
    22542295      case 8:
    22552296        for (int i = 0; i < item->data.list->n; i++) {
     
    22642305        }
    22652306        break;
    2266        
     2307
    22672308      case 9:
    22682309        for (int i = 0; i < item->data.list->n; i++) {
     
    22772318        }
    22782319        break;
    2279        
     2320
    22802321      case 10:
    22812322        for (int i = 0; i < item->data.list->n; i++) {
Note: See TracChangeset for help on using the changeset viewer.