SEMHeader.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: SEMHeader.cpp 2741 2011-06-22 16:37:02Z nwu $"
00002 
00003 //============================================================================
00004 //
00005 //  This file is part of GPSTk, the GPS Toolkit.
00006 //
00007 //  The GPSTk is free software; you can redistribute it and/or modify
00008 //  it under the terms of the GNU Lesser General Public License as published
00009 //  by the Free Software Foundation; either version 2.1 of the License, or
00010 //  any later version.
00011 //
00012 //  The GPSTk is distributed in the hope that it will be useful,
00013 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 //  GNU Lesser General Public License for more details.
00016 //
00017 //  You should have received a copy of the GNU Lesser General Public
00018 //  License along with GPSTk; if not, write to the Free Software Foundation,
00019 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 //
00021 //  Copyright 2004, The University of Texas at Austin
00022 //
00023 //============================================================================
00024 
00030 #include "StringUtils.hpp"
00031 #include "icd_200_constants.hpp"
00032 
00033 #include "SEMHeader.hpp"
00034 #include "SEMStream.hpp"
00035 
00036 
00037 using namespace gpstk::StringUtils;
00038 using namespace std;
00039 
00040 namespace gpstk
00041 {
00042    short SEMHeader::nearFullWeek = 0;
00043 
00044    void SEMHeader::reallyPutRecord(FFStream& ffs) const
00045       throw(std::exception, FFStreamError,
00046                gpstk::StringUtils::StringException)
00047    {
00048       string line;
00049 
00050       SEMStream& strm = dynamic_cast<SEMStream&>(ffs);
00051 
00052       line = leftJustify(asString<short>(numRecords),2);
00053       line += " ";
00054       line += Title;
00055       strm << line << endl;
00056       line.erase();
00057 
00058       line = rightJustify(asString<short>(week),4);
00059       line += " ";
00060       line += asString<long>(Toa);
00061       strm << line << endl;
00062       line.erase();
00063 
00064    }   // end SEMAHeader::reallyPutRecord
00065 
00066 
00067    void SEMHeader::reallyGetRecord(FFStream& ffs)
00068       throw(std::exception, FFStreamError,
00069                gpstk::StringUtils::StringException)
00070    {
00071       string line;
00072 
00073       SEMStream& strm = dynamic_cast<SEMStream&>(ffs);
00074 
00075       //Grab the first line
00076       strm.formattedGetLine(line);
00077 
00078       numRecords = (short) asInt(line.substr(0,2));
00079       Title = line.substr(3,24);
00080 
00081       //Grab the second line
00082       strm.formattedGetLine(line);
00083       week = (short) asInt(line.substr(0,4));
00084       Toa = asInt(line.substr(5,6));
00085 
00086       if (nearFullWeek > 0)
00087       {
00088             // In case a full week is provided.
00089          week %= 1024;
00090          week += (nearFullWeek / 1024) * 1024;
00091          short diff = nearFullWeek - week;
00092          if (diff > 512)
00093             week += 512;
00094          else if(diff < -512)
00095             week -= 512;
00096       }
00097 
00098       strm.header = *this;
00099       strm.headerRead = true;
00100 
00101    } // end of reallyGetRecord()
00102 
00103    void SEMHeader::dump(ostream& s) const
00104    {
00105       std::cout << "numRecords = " << numRecords << std::endl;
00106       std::cout << "Title = " << Title << std::endl;
00107       std::cout << "week = " << week << std::endl;
00108       std::cout << "Toa = " << Toa << std::endl;
00109    }
00110 
00111 } // namespace

Generated on Wed Feb 8 03:31:02 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1