MDPPVTSolution.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: MDPPVTSolution.cpp 640 2007-06-22 02:45:41Z ocibu $"
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 
00025 //============================================================================
00026 //
00027 //This software developed by Applied Research Laboratories at the University of
00028 //Texas at Austin, under contract to an agency or agencies within the U.S. 
00029 //Department of Defense. The U.S. Government retains all rights to use,
00030 //duplicate, distribute, disclose, or release this software. 
00031 //
00032 //Pursuant to DoD Directive 523024 
00033 //
00034 // DISTRIBUTION STATEMENT A: This software has been approved for public 
00035 //                           release, distribution is unlimited.
00036 //
00037 //=============================================================================
00038 
00039 #include <sstream>
00040 
00041 #include "StringUtils.hpp"
00042 #include "BinUtils.hpp"
00043 
00044 #include "MDPPVTSolution.hpp"
00045 #include "MDPStream.hpp"
00046 
00047 using gpstk::StringUtils::asString;
00048 using gpstk::BinUtils::hostToNet;
00049 using gpstk::BinUtils::netToHost;
00050 using gpstk::BinUtils::encodeVar;
00051 using gpstk::BinUtils::decodeVar;
00052 using namespace std;
00053 
00054 namespace gpstk
00055 {
00056    //---------------------------------------------------------------------------
00057    MDPPVTSolution::MDPPVTSolution()
00058       throw()
00059    {
00060       id = myId;
00061       timep = gpstk::DayTime::BEGINNING_OF_TIME;
00062       x[0] = x[1] = x[2] = 0;
00063       v[0] = v[1] = v[2] = 0;
00064       dtime = ddtime = 0;
00065       numSVs = fom = pvtMode = corrections = 0;
00066    } // MDPPVTSolution::MDPPVTSolution()
00067 
00068 
00069    //---------------------------------------------------------------------------
00070    string MDPPVTSolution::encode() const
00071       throw()
00072    {
00073       string str;
00074       str += encodeVar<double>(x[0]);
00075       str += encodeVar<double>(x[1]);
00076       str += encodeVar<double>(x[2]);
00077       str += encodeVar<float>(v[0]);
00078       str += encodeVar<float>(v[1]);
00079       str += encodeVar<float>(v[2]);
00080       str += encodeVar<uint8_t>(numSVs);
00081       str += encodeVar<int8_t>(fom);
00082       str += encodeVar<uint16_t>(time.GPSfullweek());
00083       str += encodeVar<double>(time.GPSsecond());
00084       str += encodeVar<double>(dtime);
00085       str += encodeVar<double>(ddtime);
00086       str += encodeVar<uint8_t>(pvtMode);
00087       str += encodeVar<uint8_t>(corrections);
00088       return str;
00089    } // MDPPVTSolution::encode()
00090 
00091       
00092    //---------------------------------------------------------------------------
00093    void MDPPVTSolution::decode(string str)
00094       throw()
00095    {
00096       if (str.length() != myLength)
00097          return;
00098 
00099       clearstate(lenbit);
00100       
00101       x[0]        = decodeVar<double>(str);
00102       x[1]        = decodeVar<double>(str);
00103       x[2]        = decodeVar<double>(str);
00104       v[0]        = decodeVar<float>(str);
00105       v[1]        = decodeVar<float>(str);
00106       v[2]        = decodeVar<float>(str);
00107       numSVs      = decodeVar<uint8_t>(str);
00108       fom         = decodeVar<int8_t>(str);
00109       int week    = decodeVar<uint16_t>(str);
00110       double sow  = decodeVar<double>(str);
00111       dtime       = decodeVar<double>(str);
00112       ddtime      = decodeVar<double>(str);
00113       pvtMode     = decodeVar<uint8_t>(str);
00114       corrections = decodeVar<uint8_t>(str);
00115 
00116       if (week < 0 || week > 5000 || sow < 0 || sow > 604800)
00117          return;
00118 
00119       timep.setGPS(week, sow);
00120 
00121       clearstate(fmtbit);
00122    } // MDPPVTSolution::decode()
00123 
00124 
00125    //---------------------------------------------------------------------------
00126    void MDPPVTSolution::dump(ostream& out) const
00127       throw()
00128    {
00129       ostringstream oss;
00130       using gpstk::StringUtils::asString;
00131       using gpstk::StringUtils::leftJustify;
00132 
00133       MDPHeader::dump(oss);
00134       oss << getName() << "1:"
00135           << " #SV:" << (int)numSVs
00136           << " FoM:" << (int)fom
00137           << " ClkOff:" << asString(dtime*1e9, 3) 
00138           << " ClkDft:" << asString(ddtime*86400*1e6, 3)
00139           << " PVTMode:" << (int)pvtMode
00140           << " Corr:" << hex << (int)corrections << dec
00141           << endl
00142           << getName() << "2:"
00143           << " X:" << asString(x[0], 3)
00144           << " Y:" << asString(x[1], 3)
00145           << " Z:" << asString(x[2], 3)
00146           << " Vx:" << asString(v[0], 3)
00147           << " Vy:" << asString(v[1], 3)
00148           << " Vz:" << asString(v[2], 3)
00149           << endl;
00150       out << oss.str() << flush;
00151    } // MDPPVTSolution::dump()
00152 }

Generated on Tue May 22 03:30:59 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1