Changeset 12536 for trunk


Ignore:
Timestamp:
11/16/11 12:09:16 (13 years ago)
Author:
lyard
Message:
added flushing of nightly files after each row
Location:
trunk/FACT++/src
Files:
5 edited

Legend:

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

    r12443 r12536  
    362362}
    363363
     364void Fits::Flush()
     365{
     366    if (!fFile)
     367        return;
     368
     369    fFile->Flush();
     370}
    364371// --------------------------------------------------------------------------
    365372//! Returns the size on the disk of the Fits file being written.
  • trunk/FACT++/src/Fits.h

    r12443 r12536  
    9191    void Close();
    9292
     93    ///Flush the currently opened file to disk.
     94    void Flush();
     95
    9396    ///Get the size currently written on the disk
    9497    int GetWrittenSize() const;
  • trunk/FACT++/src/FitsFile.cc

    r12529 r12536  
    403403}
    404404
     405void FitsFile::Flush()
     406{
     407    if (!fFile)
     408        return;
     409
     410    int status = 0;
     411    fits_flush_file(fFile->fitsPointer(), &status);
     412
     413    if (status)
     414    {
     415        char text[30];
     416        fits_get_errstatus(status, text);
     417
     418        ostringstream str;
     419        str << "Flushing file " << fFile->name() << " failed: " << text << " (fits_flush_file, rc=" << status << ")";
     420        Error(str);
     421    }
     422}
    405423size_t FitsFile::GetDataSize() const
    406424{
  • trunk/FACT++/src/FitsFile.h

    r11744 r12536  
    9393    void Close();
    9494
     95    void Flush();
     96
    9597    bool IsOpen() const { return fFile && fTable; }
    9698
  • trunk/FACT++/src/datalogger.cc

    r12535 r12536  
    11721172    //
    11731173    // Check whether we should close and reopen daily text files or not
    1174     //
    1175     // This should work in any case base of the following:
    1176     //  - fDailyFileDayChangedAlready is initialized to true. So if the
    1177     //    dataLogger is started around noon, no file will be closed
    1178     //  - fDailyFileDayChangedAlready is set to false if (time != 12), so
    1179     //    the file will be closed and reopened only if the logger runs since
    1180     //    before noon (which is the required behavior)
    1181     //
    1182     // This only applies to text files. Fits are closed and reopened based on
    1183     // the last and current service received time.
    1184     // This was not applicable to text files, because as they gather several
    1185     // services, we have no guarantee that the received time will be greater
    1186     // than the previous one, which could lead to several close/reopen instead
    1187     // of only one.
    1188     //
    1189     // Last but not least, the datalogger MUST receive at least one service update during
    1190     // noon otherwise this is skipped (which is not good). Thus I would suggest that the datalogger
    1191     // should always subscribe to at least its statistics services.
    1192     //
    1193     //calculate time "centered" around noon instead of midnight
     1174    // calculate time "centered" around noon instead of midnight
     1175    // if number of days has changed, then files should be closed and reopenned.
    11941176    const Time timeNow;
    11951177    const Time nowMinusTwelve = timeNow-boost::posix_time::hours(12);
     
    19231905                return;
    19241906            }
     1907            sub.nightlyFile.Flush();
    19251908         }
    19261909
Note: See TracChangeset for help on using the changeset viewer.