47 const char* AshtechMBEN::mpcId =
"MPC";
48 const char* AshtechMBEN::mcaId =
"MCA";
52 void AshtechMBEN::reallyGetRecord(
FFStream& ffs)
58 string& rawData = stream.
rawData;
62 if (
id ==
"" && rawData.size()>=11 &&
63 rawData.substr(0,7) == preamble &&
65 id = rawData.substr(7,3);
69 if (
id ==
"" || !checkId(
id))
77 void AshtechMBEN::decode(
const std::string&
data)
84 if (str.length() == 108 || str.length()==52)
87 header = str.substr(0,11); str.erase(0,11);
89 seq = decodeVar<uint16_t>(str);
90 left = decodeVar<uint8_t>(str);
91 svprn = decodeVar<uint8_t>(str);
92 el = decodeVar<uint8_t>(str);
93 az = decodeVar<uint8_t>(str);
94 chid = decodeVar<uint8_t>(str);
104 checksum = decodeVar<uint8_t>(str);
108 int end =
data.size() - 3;
109 for (
int i=11; i<end; i++)
115 header = str.substr(0,11); str.erase(0,11);
116 stringstream iss(str);
138 int end=
data.rfind(
',');
139 for (
int i=11; i<=end; i++)
144 if (csum != checksum)
148 cout <<
"checksum error, computed:" << hex << (uint16_t) csum
149 <<
" received:" << checksum << dec << endl;
158 void AshtechMBEN::code_block::decodeASCII(stringstream& str)
163 >> polarity_known>> c
180 void AshtechMBEN::code_block::decodeBIN(
string& str)
184 warning = decodeVar<uint8_t>(str);
185 goodbad = decodeVar<uint8_t>(str);
186 polarity_known = decodeVar<uint8_t>(str);
187 ireg = decodeVar<uint8_t>(str);
188 qa_phase = decodeVar<uint8_t>(str);
189 full_phase = decodeVar<double>(str);
190 raw_range = decodeVar<double>(str);
191 doppler = decodeVar<int32_t>(str);
192 smo = decodeVar<uint32_t>(str);
195 smoothing = (smo & 0x800000 ? -1e-3 : 1e-3) * (smo & 0x7fffff);
196 smooth_cnt = (smo >> 24) & 0xff;
205 <<
"warn:" << (int)warning
206 <<
" gb:" << (
int)goodbad
207 <<
" pol:" << (int)polarity_known
209 <<
" ireg:" << (
int)ireg
210 <<
" qa:" << (int)qa_phase
211 <<
" phase:" <<
asString(full_phase, 1)
212 <<
" range:" <<
asString(raw_range*1e3, 3)
213 <<
" doppler:" << doppler
214 <<
" smo:" << smoothing
215 <<
" smo_cnt:" << smooth_cnt;
220 float AshtechMBEN::code_block::snr(
float chipRate,
float m)
const noexcept
222 const float n = 20000;
223 const float bw = 0.9 * chipRate;
225 const float d =
PI/(n*n*m*m*4.0);
231 snr = exp(((
float)ireg)/25.0);
233 snr = 10 * log10(snr);
246 oss << getName() <<
"1:"
247 <<
" seq:" << 0.05 * seq
248 <<
" left:" << (int)left
249 <<
" prn:" << (
int)svprn
252 <<
" chid:" << (int)chid
253 <<
" " << (ascii?
"ascii":
"bin")
256 oss << getName() <<
"2: ca ";
262 oss << getName() <<
"3: p1 ";
265 oss << getName() <<
"4: p2 ";
269 out << oss.str() << flush;