SEMData.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: SEMData.cpp 3140 2012-06-18 15:03:02Z susancummins $"
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
00020 //
00021 //  Copyright 2004, The University of Texas at Austin
00022 //
00023 //============================================================================
00024 
00030 #include "StringUtils.hpp"
00031 #include "GNSSconstants.hpp"
00032 
00033 #include "SEMData.hpp"
00034 #include "SEMStream.hpp"
00035 
00036 
00037 using namespace gpstk::StringUtils;
00038 using namespace std;
00039 
00040 namespace gpstk
00041 {
00042    void SEMData::reallyPutRecord(FFStream& ffs) const
00043       throw(std::exception, FFStreamError,
00044                gpstk::StringUtils::StringException)
00045    {
00046       string line;
00047 
00048       SEMStream& strm = dynamic_cast<SEMStream&>(ffs);
00049 
00050       //First output blank line to mark between records
00051       strm << std::endl;
00052 
00053       //PRN output
00054       strm << asString<short>(PRN) << endl;
00055 
00056       //SVNnum
00057       strm << asString<short>(SVNnum) << endl;
00058 
00059       //URAnum
00060       strm << asString<short>(URAnum) << endl;
00061 
00062       //Ecc, i_offset, OMEGAdot
00063       line += rightJustify(asString(doub2for(ecc,22,4,false)),23);
00064       line += rightJustify(asString(doub2for(i_offset/gpstk::PI,22,4,false)),24);
00065       line += rightJustify(asString(doub2for((OMEGAdot/gpstk::PI),22,4,false)),24);
00066       strm << line << endl;
00067       line.erase();
00068 
00069       //Ahalf, OMEGA0, w
00070       line += rightJustify(asString(doub2for(Ahalf,22,4,false)),23);
00071       line += rightJustify(asString(doub2for((OMEGA0/gpstk::PI),22,4,false)),24);
00072       line += rightJustify(asString(doub2for((w/gpstk::PI),22,4,false)),24);
00073       strm << line << endl;
00074       line.erase();
00075 
00076       //M0, AF0, AF1
00077       line += rightJustify(asString(doub2for((M0/gpstk::PI),22,4,false)),23);
00078       line += rightJustify(asString(doub2for(AF0,22,4,false)),24);
00079       line += rightJustify(asString(doub2for(AF1,22,4,false)),24);
00080       strm << line << endl;
00081       line.erase();
00082 
00083       //SV_health
00084       strm << asString<short>(SV_health) << endl;
00085 
00086       //satConfig
00087       strm << asString<short>(satConfig) << endl;
00088 
00089 
00090    }   // end SEMData::reallyPutRecord
00091 
00092 
00093    void SEMData::reallyGetRecord(FFStream& ffs)
00094       throw(std::exception, FFStreamError,
00095                gpstk::StringUtils::StringException)
00096    {
00097       string line;
00098 
00099       SEMStream& strm = dynamic_cast<SEMStream&>(ffs);
00100 
00101       //if(!strm.headerRead)
00102       //    strm >> strm.header;
00103 
00104       SEMHeader& hdr = strm.header;
00105 
00106       //Don't need first line - empty space
00107       strm.formattedGetLine(line, true);
00108 
00109       // Second line - PRN
00110       strm.formattedGetLine(line, true);
00111       PRN = asInt(line);
00112 
00113       // Third line - SVN Number
00114       // HACKHACKHACK This information might not be here??? Find out more info
00115       strm.formattedGetLine(line, true);
00116       SVNnum = (short) asInt(line);
00117 
00118       // Fourth line - Average URA Number as defined in ICD-GPS-200
00119       strm.formattedGetLine(line, true);
00120       URAnum = (short) asInt(line);
00121 
00122       string whitespace = " \t\r\n";
00123 
00124       // Fifth line - Eccentricity, Inclination Offset, and Rate of Right Ascension
00125       strm.formattedGetLine(line, true);
00126       string::size_type front = line.find_first_not_of(whitespace);
00127       string::size_type end = line.find_first_of(whitespace,front);
00128       string::size_type length = end - front;
00129       ecc = asDouble(line.substr(front,length));
00130 
00131       front = line.find_first_not_of(whitespace,end);
00132       end = line.find_first_of(whitespace,front);
00133       length = end - front;
00134       i_offset = asDouble(line.substr(front,length));
00135 
00136       front = line.find_first_not_of(whitespace,end);
00137       length = line.length() - front;
00138       OMEGAdot = asDouble(line.substr(front,length));
00139       i_offset *= gpstk::PI;
00140       OMEGAdot *= gpstk::PI;
00141 
00142 
00143       // Sixth line - Sqrt of A, Omega0, and Arg of Perigee
00144       strm.formattedGetLine(line, true);
00145 
00146       front = line.find_first_not_of(whitespace);
00147       end = line.find_first_of(whitespace,front);
00148       length = end - front;
00149       Ahalf = asDouble(line.substr(front,length));
00150 
00151       front = line.find_first_not_of(whitespace,end);
00152       end = line.find_first_of(whitespace,front);
00153       length = end - front;
00154       OMEGA0 = asDouble(line.substr(front,length));
00155 
00156       front = line.find_first_not_of(whitespace,end);
00157       length = line.length() - front;
00158       OMEGA0 *= gpstk::PI;
00159       w = asDouble(line.substr(front,length));
00160       w *= gpstk::PI;
00161 
00162       // Seventh Line - M0, AF0, AF1
00163       strm.formattedGetLine(line, true);
00164 
00165       front = line.find_first_not_of(whitespace);
00166       end = line.find_first_of(whitespace,front);
00167       length = end - front;
00168       M0 = asDouble(line.substr(front,length));
00169       M0 *= gpstk::PI;
00170 
00171       front = line.find_first_not_of(whitespace,end);
00172       end = line.find_first_of(whitespace,front);
00173       length = end - front;
00174       AF0 = asDouble(line.substr(front,length));
00175 
00176       front = line.find_first_not_of(whitespace,end);
00177       length = line.length() - front;
00178       AF1 = asDouble(line.substr(front,length));
00179 
00180       // Eigth line - Satellite Health
00181       strm.formattedGetLine(line, true);
00182       SV_health = (short) asInt(line);
00183 
00184       // Ninth line - Satellite Config
00185       strm.formattedGetLine(line, true);
00186       satConfig = (short) asInt(line);
00187 
00188       week = hdr.week;
00189       Toa = hdr.Toa;
00190 
00191       xmit_time = 0;
00192 
00193    } // end of reallyGetRecord()
00194 
00195    void SEMData::dump(ostream& s) const
00196    {
00197       std::cout << "PRN = " << PRN << std::endl;
00198       std::cout << "SVNnum = " << SVNnum << std::endl;
00199       std::cout << "URAnum = " << URAnum << std::endl;
00200       std::cout << "ecc = " << ecc << std::endl;
00201       std::cout << "i_offset = " << i_offset << std::endl;
00202       std::cout << "OMEGAdot = " << OMEGAdot << std::endl;
00203       std::cout << "Ahalf = " << Ahalf << std::endl;
00204       std::cout << "OMEGA0 = " << OMEGA0 << std::endl;
00205       std::cout << "w = " << w << std::endl;
00206       std::cout << "M0 = " << M0 << std::endl;
00207       std::cout << "AF0 = " << AF0 << std::endl;
00208       std::cout << "AF1 = " << AF1 << std::endl;
00209       std::cout << "SV_health = " << SV_health << std::endl;
00210       std::cout << "satConfig = " << satConfig << std::endl;
00211       std::cout << "xmit_time = " << xmit_time << std::endl;
00212       std::cout << "week = " << week << std::endl;
00213       std::cout << "toa = " << Toa << std::endl;
00214    }
00215 
00216    SEMData::operator AlmOrbit() const
00217    {
00218 
00219       AlmOrbit ao(PRN, ecc,i_offset, OMEGAdot, Ahalf, OMEGA0,
00220                    w, M0, AF0, AF1, Toa, xmit_time, week, SV_health);
00221 
00222       return ao;
00223 
00224    }
00225 
00226 } // namespace

Generated on Wed May 22 03:31:13 2013 for GPS ToolKit Software Library by  doxygen 1.3.9.1