LemiTsFormat.cpp
Go to the documentation of this file.00001 #include "LemiTsFormat.h"
00002 #include "MtuFormat.h"
00003 #include "BirrpAsciiFormat.h"
00004 #include "FatalException.h"
00005 #include <boost/cast.hpp>
00006 #include <fstream>
00007
00008 using namespace std;
00009
00010 namespace gplib
00011 {
00012 LemiTsFormat::LemiTsFormat()
00013 {
00014 }
00015
00016 LemiTsFormat::~LemiTsFormat()
00017 {
00018 }
00019
00020 void LemiTsFormat::GetData()
00021 {
00022 throw FatalException("Not implemented");
00023 }
00024
00025 void LemiTsFormat::GetData(const std::string filename)
00026 {
00027 ifstream infile(filename.c_str());
00028 double rawsecond, fraction;
00029 int year, month, day, hour, minute, second;
00030 const double rate = 4.0;
00031 double number;
00032
00033 while (infile.good())
00034 {
00035 infile.precision(15);
00036 infile >> year >> month >> day >> hour >> minute >> rawsecond;
00037 second = static_cast<int> (rawsecond);
00038 fraction = rawsecond - static_cast<int> (rawsecond);
00039 TimeSeries::ttime currtime(
00040 boost::gregorian::date(year, month, day),
00041 boost::posix_time::time_duration(hour, minute, second));
00042 currtime += boost::posix_time::microseconds(
00043 boost::numeric_cast<int>(fraction * 1000000));
00044 t.push_back(currtime);
00045 if (infile.good())
00046 {
00047 infile >> number;
00048 Hx.GetData().push_back(number);
00049 infile >> number;
00050 Hy.GetData().push_back(number);
00051 infile >> number;
00052 Hz.GetData().push_back(number);
00053 infile >> number >> number >> number;
00054 Ex.GetData().push_back(number);
00055 infile >> number;
00056 Ey.GetData().push_back(number);
00057 infile >> number >> number >> number;
00058 }
00059 }
00060 if (!infile.eof())
00061 {
00062 throw FatalException("Problem reading from file: " + filename);
00063 }
00064 Hx.SetSamplerate(rate);
00065 Hy.SetSamplerate(rate);
00066 Hz.SetSamplerate(rate);
00067 Ex.SetSamplerate(rate);
00068 Ey.SetSamplerate(rate);
00069 }
00070
00071 void LemiTsFormat::WriteData(const std::string filename)
00072 {
00073 throw FatalException("Not implemented");
00074 }
00075
00076 LemiTsFormat& LemiTsFormat::operator=(BirrpAsciiFormat& source)
00077 {
00078 this->TimeSeries::operator=(source);
00079 return *this;
00080 }
00081
00082 LemiTsFormat& LemiTsFormat::operator=(MtuFormat& source)
00083 {
00084 this->TimeSeries::operator=(source);
00085 return *this;
00086 }
00087
00088 LemiTsFormat& LemiTsFormat::operator=(TimeSeries& source)
00089 {
00090 this->TimeSeries::operator=(source);
00091 return *this;
00092 }
00093
00094 LemiTsFormat& LemiTsFormat::operator=(LemiTsFormat& source)
00095 {
00096 if (this != &source)
00097 {
00098 this->TimeSeries::operator=(source);
00099 }
00100 return *this;
00101 }
00102 }