Changeset 18437 for trunk/FACT++


Ignore:
Timestamp:
02/14/16 18:03:48 (9 years ago)
Author:
tbretz
Message:
get the source keys already with the first query.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/makeschedule.cc

    r18436 r18437  
    116116    // Source descrition
    117117    string name;
     118    uint16_t key;
    118119    EquPosn equ;
    119120
     
    135136    vector<string> preobs;
    136137
    137     Source(const string &n="") : name(n), begin(0), threshold(std::numeric_limits<double>::max()) { }
     138    Source(const string &n="", uint16_t k=-1) : name(n), key(k), begin(0), threshold(std::numeric_limits<double>::max()) { }
    138139
    139140    //bool IsSpecial() const { return threshold==std::numeric_limits<double>::max(); }
     
    456457    }
    457458
    458     const mysqlpp::StoreQueryResult res1 = db.query("SELECT fSourceName, fSourceKEY FROM Source").store();
    459 
    460     map<string, uint32_t> keys;
     459    const mysqlpp::StoreQueryResult res1 = db.query("SELECT fMeasurementTypeName, fMeasurementTypeKEY FROM MeasurementType").store();
     460    map<string, uint32_t> types;
    461461    for (const auto &row: res1)
    462         keys.emplace(string(row[0]), uint32_t(row[1]));
    463 
    464     const mysqlpp::StoreQueryResult res2 = db.query("SELECT fMeasurementTypeName, fMeasurementTypeKEY FROM MeasurementType").store();
    465 
    466     map<string, uint32_t> types;
    467     for (const auto &row: res2)
    468462        types.emplace(string(row[0]), uint32_t(row[1]));
    469463
     
    487481
    488482        if (src.name!="SLEEP")
    489             str << "('" << tm << "', auto, 0, " << types["Data"] << ", " << keys[src.name] << "), [Data: " << src.name << "]\n";
     483            str << "('" << tm << "', auto, 0, " << types["Data"] << ", " << src.key << "), [Data: " << src.name << "]\n";
    490484        else
    491485            str << "('" << tm << "', auto, 0, " << types["Sleep"] << ", NULL), [Sleep]\n";
     
    568562    cout << "Nsources = " << sourcenames.size() << "\n";
    569563
    570     string query = "SELECT fSourceName, fRightAscension, fDeclination FROM Source WHERE fSourceTypeKEY=1";
     564    string query = "SELECT fSourceName, fSourceKEY, fRightAscension, fDeclination FROM Source WHERE fSourceTypeKEY=1";
    571565    if (sourcenames.size()>0)
    572566        query += " AND fSourceName IN ('" + boost::algorithm::join(sourcenames, "', '")+"')";
     
    583577        const string name = string(row[0]);
    584578
    585         Source src(name);
    586 
    587         src.equ.ra  = double(row[1])*15;
    588         src.equ.dec = double(row[2]);
     579        Source src(name, row[1]);
     580
     581        src.equ.ra  = double(row[2])*15;
     582        src.equ.dec = double(row[3]);
    589583
    590584        src.maxzd = MyDouble(conf, "setup."+name+".max-zd");
Note: See TracChangeset for help on using the changeset viewer.