Changeset 19771 for trunk/FACT++


Ignore:
Timestamp:
10/15/19 08:42:18 (5 years ago)
Author:
tbretz
Message:
Fixed a bug which could lead (not in La Palma though) to inconsistent path and file names.
File:
1 edited

Legend:

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

    r19391 r19771  
    349349    string CompileFileNameWithPath(const string &path, const string &service, const string & extension);
    350350    ///Form the file names only
    351     string CompileFileName(const string& service, const string& extension, const Time& time=Time()) const;
     351    string CompileFileName(const string& service, const string& extension, const uint32_t& night) const;
    352352    ///Check whether service is in black and/or white list
    353353    bool ShouldSubscribe(const string& server, const string& service);
     
    831831//! @param extension the extension to add, if any
    832832//
    833 string DataLogger::CompileFileName(const string& service, const string& extension, const Time& time) const
     833string DataLogger::CompileFileName(const string& service, const string& extension, const uint32_t& night) const
    834834{
    835835    ostringstream str;
    836836
    837     const Time ftime(time);//removed this as already done by nightAsInt: -boost::posix_time::hours(12));
    838     str << ftime.NightAsInt();
     837    str << night;
    839838
    840839    if (!service.empty())
     
    853852    const Time time;
    854853
    855     //calculate time suitable for naming files.
    856     //fCurrentDay is 30 minutes after upcoming sunrise. So just use 12 hours before then
     854    // calculate time suitable for naming files. Get a time between the next sun-rise (fCurrentDay)
     855    // and the previous sun-rise so that NightAsInt (which refers to the previous sun-rise)
     856    // provides reasonable results.
     857
     858    // WARNING: This fails if the sun-rise is around midnight UTC!
     859    // It would be more appropriate to relate the "NightAsInt" to
     860    // the LOCAL time of sun-rise!
    857861    const Time ftime = fCurrentDay-boost::posix_time::hours(12);
    858862
    859863    //output it
    860     str << path << ftime.GetAsStr("/%Y/%m/%d");
     864    const uint32_t night = ftime.NightAsInt();
     865    str << path << Tools::Form("/%04d/%02d/%02d/", night/10000, (night/100)%100, night%100);
    861866
    862867    //check if target directory exist
     
    864869        CreateDirectory(str.str());
    865870
    866     str << '/' << CompileFileName(service, extension, ftime);//fCurrentDay);
     871    str << '/' << CompileFileName(service, extension, night);//fCurrentDay);
    867872
    868873    return str.str();
Note: See TracChangeset for help on using the changeset viewer.