Changeset 18438 for trunk/FACT++/src


Ignore:
Timestamp:
02/17/16 08:26:25 (9 years ago)
Author:
tbretz
Message:
Make the source-database a required option, removed the default from the schedule database to be able to detect if no option was given; replaced map::emplace which could not be compiled on La Palma; removed the 'helping output' from the database INSERT query; fixed a problem with the data if no time was specified.
File:
1 edited

Legend:

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

    r18437 r18438  
    1818    po::options_description control("Makeschedule");
    1919    control.add_options()
    20         ("date", var<string>(), "SQL time (UTC), e.g. '2016-12-24'")
    21         ("source-database", var<string>(""), "Database link as in\n\tuser:password@server[:port]/database.")
    22         ("schedule-database", var<string>(""), "Database link as in\n\tuser:password@server[:port]/database.")
     20        ("date", var<string>(), "SQL time (UTC), e.g. '2016-12-24' (equiv. '2016-12-24 12:00:00' to '2016-12-25 11:59:59')")
     21        ("source-database", var<string>()->required(), "Database link as in\n\tuser:password@server[:port]/database.")
     22        ("schedule-database", var<string>(), "Database link as in\n\tuser:password@server[:port]/database.")
    2323        ("max-current", var<double>(90), "Global maximum current limit in uA")
    2424        ("max-zd", var<double>(75), "Global zenith distance limit in degree")
     
    460460    map<string, uint32_t> types;
    461461    for (const auto &row: res1)
    462         types.emplace(string(row[0]), uint32_t(row[1]));
     462        types.insert(make_pair(string(row[0]), uint32_t(row[1])));
    463463
    464464    ostringstream str;
    465465    str << "INSERT INTO Schedule (fStart, fUser, fMeasurementID, fMeasurementTypeKEY, fSourceKEY) VALUES\n";
    466466
    467     str << "('" << Time(obs[0].begin-startup_offset).GetAsStr() << "', auto, 0, " << types["Startup"] << ", NULL), [Startup]\n";
     467    str << "('" << Time(obs[0].begin-startup_offset).GetAsStr() << "', auto, 0, " << types["Startup"] << ", NULL),\n"; // [Startup]\n";
    468468    for (const auto& src: obs)
    469469    {
     
    481481
    482482        if (src.name!="SLEEP")
    483             str << "('" << tm << "', auto, 0, " << types["Data"] << ", " << src.key << "), [Data: " << src.name << "]\n";
     483            str << "('" << tm << "', auto, 0, " << types["Data"] << ", " << src.key << "),\n"; // [Data: " << src.name << "]\n";
    484484        else
    485             str << "('" << tm << "', auto, 0, " << types["Sleep"] << ", NULL), [Sleep]\n";
    486     }
    487 
    488     str << "('" << Time(obs.back().end).GetAsStr() << "', auto, 0, " << types["Shutdown"] << ", NULL) [Shutdown]";
     485            str << "('" << tm << "', auto, 0, " << types["Sleep"] << ", NULL),\n"; // [Sleep]\n";
     486    }
     487
     488    str << "('" << Time(obs.back().end).GetAsStr() << "', auto, 0, " << types["Shutdown"] << ", NULL)";// [Shutdown]";
    489489
    490490    if (enter<0)
     
    519519    Time time;
    520520    if (conf.Has("date"))
    521         time.SetFromStr(conf.Get<string>("date"));
     521        time.SetFromStr(conf.Get<string>("date")+" 12:00:00");
    522522
    523523    if (enter && floor(time.JD())<ceil(Time().JD()))
Note: See TracChangeset for help on using the changeset viewer.