00001 #pragma ident "$Id: AshtechEPB.cpp 824 2007-10-10 14:21:58Z 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 "StringUtils.hpp"
00040 #include "BinUtils.hpp"
00041
00042 #include "AshtechEPB.hpp"
00043 #include "AshtechStream.hpp"
00044
00045 using namespace std;
00046
00047 namespace gpstk
00048 {
00049 const char* AshtechEPB::myId = "EPB";
00050
00051
00052 void AshtechEPB::reallyGetRecord(FFStream& ffs)
00053 throw(std::exception, FFStreamError, EndOfFile)
00054 {
00055 AshtechStream& stream=dynamic_cast<AshtechStream&>(ffs);
00056
00057
00058 clear(fmtbit | lenbit | crcbit);
00059 string& rawData = stream.rawData;
00060
00061
00062
00063 if (id == "" && rawData.size()>=10 &&
00064 rawData.substr(0,7) == preamble)
00065 id = rawData.substr(7,3);
00066
00067
00068
00069 if (id == "" || !checkId(id))
00070 return;
00071
00072 readBody(stream);
00073 }
00074
00075
00076 void AshtechEPB::decode(const std::string& data)
00077 throw(std::exception, FFStreamError)
00078 {
00079 using BinUtils::decodeVar;
00080 using gpstk::StringUtils::asInt;
00081
00082 string str(data);
00083
00084 if (str.length() == 138)
00085 {
00086 ascii = false;
00087 header = str.substr(0,11); str.erase(0,11);
00088 prn = asInt(str.substr(0,2));
00089 str.erase(0,3);
00090
00091 for (int s=1; s<=3; s++)
00092 for (int w=1; w<=10; w++)
00093 word[s][w] = decodeVar<uint32_t>(str);
00094
00095 unsigned cksum = decodeVar<uint16_t>(str);
00096 clear(ios_base::goodbit);
00097 }
00098 }
00099
00100
00101 void AshtechEPB::dump(ostream& out) const throw()
00102 {
00103 ostringstream oss;
00104 using gpstk::StringUtils::asString;
00105 using gpstk::StringUtils::leftJustify;
00106
00107 AshtechData::dump(out);
00108 oss << getName() << "0:" << " prn:" << prn << endl;
00109
00110 oss << setfill('0') << hex;
00111 for (int s=1; s<=3; s++)
00112 {
00113 for (int w=1; w<=10; w++)
00114 {
00115 if ((w % 5) == 1)
00116 oss << getName() << s*2+w/5-1 << ": ";
00117 oss << setw(8) << uppercase << word[s][w] << " ";
00118 if ((w % 5) == 0)
00119 oss << endl;
00120 }
00121 }
00122
00123 out << oss.str() << flush;
00124 }
00125 }