00001 #pragma ident "$Id: SEMData.cpp 3140 2012-06-18 15:03:02Z susancummins $"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
00051 strm << std::endl;
00052
00053
00054 strm << asString<short>(PRN) << endl;
00055
00056
00057 strm << asString<short>(SVNnum) << endl;
00058
00059
00060 strm << asString<short>(URAnum) << endl;
00061
00062
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
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
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
00084 strm << asString<short>(SV_health) << endl;
00085
00086
00087 strm << asString<short>(satConfig) << endl;
00088
00089
00090 }
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
00102
00103
00104 SEMHeader& hdr = strm.header;
00105
00106
00107 strm.formattedGetLine(line, true);
00108
00109
00110 strm.formattedGetLine(line, true);
00111 PRN = asInt(line);
00112
00113
00114
00115 strm.formattedGetLine(line, true);
00116 SVNnum = (short) asInt(line);
00117
00118
00119 strm.formattedGetLine(line, true);
00120 URAnum = (short) asInt(line);
00121
00122 string whitespace = " \t\r\n";
00123
00124
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
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
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
00181 strm.formattedGetLine(line, true);
00182 SV_health = (short) asInt(line);
00183
00184
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 }
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 }