00001 #pragma ident "$Id: MDPPVTSolution.cpp 640 2007-06-22 02:45:41Z ocibu $"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
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 }
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 }
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 }
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 }
00152 }