[297] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
[464] | 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
[297] | 3 | //
|
---|
[464] | 4 | // Copyright (C) 2007
|
---|
[297] | 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
[464] | 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
[297] | 8 | // http://www.fsv.cvut.cz
|
---|
| 9 | //
|
---|
| 10 | // Email: euref-ip@bkg.bund.de
|
---|
| 11 | //
|
---|
| 12 | // This program is free software; you can redistribute it and/or
|
---|
| 13 | // modify it under the terms of the GNU General Public License
|
---|
| 14 | // as published by the Free Software Foundation, version 2.
|
---|
| 15 | //
|
---|
| 16 | // This program is distributed in the hope that it will be useful,
|
---|
| 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | // GNU General Public License for more details.
|
---|
| 20 | //
|
---|
| 21 | // You should have received a copy of the GNU General Public License
|
---|
| 22 | // along with this program; if not, write to the Free Software
|
---|
| 23 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
[296] | 24 |
|
---|
| 25 | /* -------------------------------------------------------------------------
|
---|
| 26 | * BKG NTRIP Client
|
---|
| 27 | * -------------------------------------------------------------------------
|
---|
| 28 | *
|
---|
| 29 | * Class: RTCM3Decoder
|
---|
| 30 | *
|
---|
| 31 | * Purpose: RTCM3 Decoder
|
---|
| 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 24-Aug-2006
|
---|
| 36 | *
|
---|
[7753] | 37 | * Changes:
|
---|
[296] | 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
| 41 | #include <iostream>
|
---|
[1807] | 42 | #include <iomanip>
|
---|
| 43 | #include <sstream>
|
---|
[296] | 44 | #include <math.h>
|
---|
[585] | 45 | #include <string.h>
|
---|
[296] | 46 |
|
---|
[6812] | 47 | #include "bits.h"
|
---|
| 48 | #include "gnss.h"
|
---|
[296] | 49 | #include "RTCM3Decoder.h"
|
---|
[6812] | 50 | #include "rtcm_utils.h"
|
---|
[296] | 51 | #include "bncconst.h"
|
---|
[5070] | 52 | #include "bnccore.h"
|
---|
[1535] | 53 | #include "bncutils.h"
|
---|
[7753] | 54 | #include "bncsettings.h"
|
---|
[296] | 55 |
|
---|
| 56 | using namespace std;
|
---|
| 57 |
|
---|
[320] | 58 | // Error Handling
|
---|
| 59 | ////////////////////////////////////////////////////////////////////////////
|
---|
[504] | 60 | void RTCM3Error(const char*, ...) {
|
---|
[505] | 61 | }
|
---|
[320] | 62 |
|
---|
[296] | 63 | // Constructor
|
---|
| 64 | ////////////////////////////////////////////////////////////////////////////
|
---|
[7753] | 65 | RTCM3Decoder::RTCM3Decoder(const QString& staID, bncRawFile* rawFile) :
|
---|
[8161] | 66 | GPSDecoder() {
|
---|
[505] | 67 |
|
---|
[8161] | 68 | _staID = staID;
|
---|
[2527] | 69 | _rawFile = rawFile;
|
---|
[2387] | 70 |
|
---|
[8161] | 71 | connect(this, SIGNAL(newGPSEph(t_ephGPS)), BNC_CORE,
|
---|
| 72 | SLOT(slotNewGPSEph(t_ephGPS)));
|
---|
| 73 | connect(this, SIGNAL(newGlonassEph(t_ephGlo)), BNC_CORE,
|
---|
| 74 | SLOT(slotNewGlonassEph(t_ephGlo)));
|
---|
| 75 | connect(this, SIGNAL(newGalileoEph(t_ephGal)), BNC_CORE,
|
---|
| 76 | SLOT(slotNewGalileoEph(t_ephGal)));
|
---|
| 77 | connect(this, SIGNAL(newSBASEph(t_ephSBAS)), BNC_CORE,
|
---|
| 78 | SLOT(slotNewSBASEph(t_ephSBAS)));
|
---|
| 79 | connect(this, SIGNAL(newBDSEph(t_ephBDS)), BNC_CORE,
|
---|
| 80 | SLOT(slotNewBDSEph(t_ephBDS)));
|
---|
[939] | 81 |
|
---|
[6812] | 82 | _MessageSize = _SkipBytes = _BlockSize = _NeedBytes = 0;
|
---|
[296] | 83 | }
|
---|
| 84 |
|
---|
| 85 | // Destructor
|
---|
| 86 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 87 | RTCM3Decoder::~RTCM3Decoder() {
|
---|
[3001] | 88 | QMapIterator<QByteArray, RTCM3coDecoder*> it(_coDecoders);
|
---|
[8161] | 89 | while (it.hasNext())
|
---|
[6812] | 90 | {
|
---|
[3008] | 91 | it.next();
|
---|
| 92 | delete it.value();
|
---|
[3001] | 93 | }
|
---|
[296] | 94 | }
|
---|
| 95 |
|
---|
[7753] | 96 | //
|
---|
[296] | 97 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8161] | 98 | bool RTCM3Decoder::DecodeRTCM3GPS(unsigned char* data, int size) {
|
---|
[6812] | 99 | bool decoded = false;
|
---|
| 100 | bncTime CurrentObsTime;
|
---|
| 101 | int i, numsats, syncf, type;
|
---|
| 102 | uint64_t numbits = 0, bitfield = 0;
|
---|
[508] | 103 |
|
---|
[6812] | 104 | data += 3; /* header */
|
---|
| 105 | size -= 6; /* header + crc */
|
---|
[1218] | 106 |
|
---|
[6812] | 107 | GETBITS(type, 12)
|
---|
[8161] | 108 | SKIPBITS(12)
|
---|
| 109 | /* id */
|
---|
| 110 | GETBITS(i, 30)
|
---|
[913] | 111 |
|
---|
[6812] | 112 | CurrentObsTime.set(i);
|
---|
[8161] | 113 | if (_CurrentTime.valid() && CurrentObsTime != _CurrentTime) {
|
---|
[6812] | 114 | decoded = true;
|
---|
[8163] | 115 | _obsList.append(_CurrentObsList);
|
---|
[6812] | 116 | _CurrentObsList.clear();
|
---|
[2551] | 117 | }
|
---|
[7753] | 118 |
|
---|
[6812] | 119 | _CurrentTime = CurrentObsTime;
|
---|
[2551] | 120 |
|
---|
[8161] | 121 | GETBITS(syncf, 1)
|
---|
| 122 | /* sync */
|
---|
| 123 | GETBITS(numsats, 5)
|
---|
| 124 | SKIPBITS(4)
|
---|
| 125 | /* smind, smint */
|
---|
[3002] | 126 |
|
---|
[8161] | 127 | while (numsats--) {
|
---|
| 128 | int sv, code, l1range, amb = 0;
|
---|
[6812] | 129 | t_satObs CurrentObs;
|
---|
| 130 | CurrentObs._time = CurrentObsTime;
|
---|
| 131 |
|
---|
| 132 | GETBITS(sv, 6)
|
---|
[8161] | 133 | if (sv < 40)
|
---|
[6812] | 134 | CurrentObs._prn.set('G', sv);
|
---|
| 135 | else
|
---|
[8161] | 136 | CurrentObs._prn.set('S', sv - 20);
|
---|
[6812] | 137 |
|
---|
| 138 | t_frqObs *frqObs = new t_frqObs;
|
---|
| 139 | /* L1 */
|
---|
| 140 | GETBITS(code, 1);
|
---|
[8161] | 141 | (code) ?
|
---|
| 142 | frqObs->_rnxType2ch.assign("1W") : frqObs->_rnxType2ch.assign("1C");
|
---|
[6812] | 143 | GETBITS(l1range, 24);
|
---|
| 144 | GETBITSSIGN(i, 20);
|
---|
[8161] | 145 | if ((i & ((1 << 20) - 1)) != 0x80000) {
|
---|
| 146 | frqObs->_code = l1range * 0.02;
|
---|
| 147 | frqObs->_phase = (l1range * 0.02 + i * 0.0005) / GPS_WAVELENGTH_L1;
|
---|
[6812] | 148 | frqObs->_codeValid = frqObs->_phaseValid = true;
|
---|
[3002] | 149 | }
|
---|
[9089] | 150 | GETBITS(frqObs->_lockTimeIndicator, 7);
|
---|
| 151 | frqObs->_lockTime = lti2sec(type, frqObs->_lockTimeIndicator);
|
---|
[8616] | 152 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0 && frqObs->_phaseValid);
|
---|
[8161] | 153 | if (type == 1002 || type == 1004) {
|
---|
| 154 | GETBITS(amb, 8);
|
---|
| 155 | if (amb) {
|
---|
| 156 | frqObs->_code += amb * 299792.458;
|
---|
| 157 | frqObs->_phase += (amb * 299792.458) / GPS_WAVELENGTH_L1;
|
---|
[1021] | 158 | }
|
---|
[6812] | 159 | GETBITS(i, 8);
|
---|
[8161] | 160 | if (i) {
|
---|
| 161 | frqObs->_snr = i * 0.25;
|
---|
[6812] | 162 | frqObs->_snrValid = true;
|
---|
| 163 | }
|
---|
[1021] | 164 | }
|
---|
[6812] | 165 | CurrentObs._obs.push_back(frqObs);
|
---|
[8161] | 166 | if (type == 1003 || type == 1004) {
|
---|
[6812] | 167 | frqObs = new t_frqObs;
|
---|
| 168 | /* L2 */
|
---|
[8161] | 169 | GETBITS(code, 2);
|
---|
| 170 | switch (code) {
|
---|
| 171 | case 3:
|
---|
| 172 | frqObs->_rnxType2ch.assign("2W"); /* or "2Y"? */
|
---|
| 173 | break;
|
---|
| 174 | case 2:
|
---|
| 175 | frqObs->_rnxType2ch.assign("2W");
|
---|
| 176 | break;
|
---|
| 177 | case 1:
|
---|
| 178 | frqObs->_rnxType2ch.assign("2P");
|
---|
| 179 | break;
|
---|
| 180 | case 0:
|
---|
| 181 | frqObs->_rnxType2ch.assign("2X"); /* or "2S" or "2L"? */
|
---|
| 182 | break;
|
---|
[6812] | 183 | }
|
---|
[8161] | 184 | GETBITSSIGN(i, 14);
|
---|
| 185 | if ((i & ((1 << 14) - 1)) != 0x2000) {
|
---|
| 186 | frqObs->_code = l1range * 0.02 + i * 0.02 + amb * 299792.458;
|
---|
[6812] | 187 | frqObs->_codeValid = true;
|
---|
| 188 | }
|
---|
[8161] | 189 | GETBITSSIGN(i, 20);
|
---|
| 190 | if ((i & ((1 << 20) - 1)) != 0x80000) {
|
---|
| 191 | frqObs->_phase = (l1range * 0.02 + i * 0.0005 + amb * 299792.458)
|
---|
| 192 | / GPS_WAVELENGTH_L2;
|
---|
[6812] | 193 | frqObs->_phaseValid = true;
|
---|
| 194 | }
|
---|
[9089] | 195 | GETBITS(frqObs->_lockTimeIndicator, 7);
|
---|
| 196 | frqObs->_lockTime = lti2sec(type, frqObs->_lockTimeIndicator);
|
---|
[8616] | 197 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0 && frqObs->_phaseValid);
|
---|
[8161] | 198 | if (type == 1004) {
|
---|
[6812] | 199 | GETBITS(i, 8);
|
---|
[8161] | 200 | if (i) {
|
---|
| 201 | frqObs->_snr = i * 0.25;
|
---|
[6812] | 202 | frqObs->_snrValid = true;
|
---|
| 203 | }
|
---|
| 204 | }
|
---|
| 205 | CurrentObs._obs.push_back(frqObs);
|
---|
| 206 | }
|
---|
| 207 | _CurrentObsList.push_back(CurrentObs);
|
---|
[913] | 208 | }
|
---|
[7753] | 209 |
|
---|
[8161] | 210 | if (!syncf) {
|
---|
[6812] | 211 | decoded = true;
|
---|
[7753] | 212 | _obsList.append(_CurrentObsList);
|
---|
[6812] | 213 | _CurrentTime.reset();
|
---|
| 214 | _CurrentObsList.clear();
|
---|
[2527] | 215 | }
|
---|
[6812] | 216 | return decoded;
|
---|
| 217 | }
|
---|
[2527] | 218 |
|
---|
[6812] | 219 | #define RTCM3_MSM_NUMSIG 32
|
---|
| 220 | #define RTCM3_MSM_NUMSAT 64
|
---|
| 221 | #define RTCM3_MSM_NUMCELLS 96 /* arbitrary limit */
|
---|
[1127] | 222 |
|
---|
[6812] | 223 | /**
|
---|
| 224 | * Frequency numbers of GLONASS with an offset of 100 to detect unset values.
|
---|
| 225 | * Gets filled by ephemeris and data blocks and shared between different streams.
|
---|
| 226 | */
|
---|
| 227 | static int GLOFreq[RTCM3_MSM_NUMSAT];
|
---|
[1127] | 228 |
|
---|
[6812] | 229 | /*
|
---|
| 230 | * Storage structure to store frequency and RINEX ID assignment for MSM
|
---|
| 231 | * message */
|
---|
| 232 | struct CodeData {
|
---|
| 233 | double wl;
|
---|
| 234 | const char *code; /* currently unused */
|
---|
| 235 | };
|
---|
[2677] | 236 |
|
---|
[6812] | 237 | /** MSM signal types for GPS and SBAS */
|
---|
[8161] | 238 | static struct CodeData gps[RTCM3_MSM_NUMSIG] = {
|
---|
| 239 | {0.0, 0},
|
---|
| 240 | {GPS_WAVELENGTH_L1, "1C"},
|
---|
| 241 | {GPS_WAVELENGTH_L1, "1P"},
|
---|
| 242 | {GPS_WAVELENGTH_L1, "1W"},
|
---|
| 243 | {0.0, 0},
|
---|
| 244 | {0.0, 0},
|
---|
[8805] | 245 | {0.0, 0},
|
---|
[8161] | 246 | {GPS_WAVELENGTH_L2, "2C"},
|
---|
| 247 | {GPS_WAVELENGTH_L2, "2P"},
|
---|
| 248 | {GPS_WAVELENGTH_L2, "2W"},
|
---|
| 249 | {0.0, 0},
|
---|
| 250 | {0.0, 0},
|
---|
| 251 | {0.0, 0},
|
---|
[8805] | 252 | {0.0, 0},
|
---|
[8161] | 253 | {GPS_WAVELENGTH_L2, "2S"},
|
---|
| 254 | {GPS_WAVELENGTH_L2, "2L"},
|
---|
| 255 | {GPS_WAVELENGTH_L2, "2X"},
|
---|
| 256 | {0.0, 0},
|
---|
| 257 | {0.0, 0},
|
---|
| 258 | {0.0, 0},
|
---|
| 259 | {0.0, 0},
|
---|
| 260 | {GPS_WAVELENGTH_L5, "5I"},
|
---|
| 261 | {GPS_WAVELENGTH_L5, "5Q"},
|
---|
| 262 | {GPS_WAVELENGTH_L5, "5X"},
|
---|
| 263 | {0.0, 0},
|
---|
| 264 | {0.0, 0},
|
---|
| 265 | {0.0, 0},
|
---|
| 266 | {0.0, 0},
|
---|
| 267 | {0.0, 0},
|
---|
| 268 | {GPS_WAVELENGTH_L1, "1S"},
|
---|
| 269 | {GPS_WAVELENGTH_L1, "1L"},
|
---|
| 270 | {GPS_WAVELENGTH_L1, "1X"}
|
---|
| 271 | };
|
---|
[1185] | 272 |
|
---|
[6812] | 273 | /**
|
---|
| 274 | * MSM signal types for GLONASS
|
---|
[7753] | 275 | *
|
---|
[6812] | 276 | * NOTE: Uses 0.0, 1.0 for wavelength as sat index dependence is done later!
|
---|
| 277 | */
|
---|
[8161] | 278 | static struct CodeData glo[RTCM3_MSM_NUMSIG] = {
|
---|
| 279 | {0.0, 0},
|
---|
| 280 | {0.0, "1C"},
|
---|
| 281 | {0.0, "1P"},
|
---|
| 282 | {0.0, 0},
|
---|
| 283 | {0.0, 0},
|
---|
| 284 | {0.0, 0},
|
---|
| 285 | {0.0, 0},
|
---|
| 286 | {1.0, "2C"},
|
---|
| 287 | {1.0, "2P"},
|
---|
[8805] | 288 | {GLO_WAVELENGTH_L1a, "4A"},
|
---|
| 289 | {GLO_WAVELENGTH_L1a, "4B"},
|
---|
| 290 | {GLO_WAVELENGTH_L1a, "4X"},
|
---|
| 291 | {GLO_WAVELENGTH_L2a, "6A"},
|
---|
| 292 | {GLO_WAVELENGTH_L2a, "6B"},
|
---|
| 293 | {GLO_WAVELENGTH_L2a, "6X"},
|
---|
| 294 | {GLO_WAVELENGTH_L3, "3I"},
|
---|
| 295 | {GLO_WAVELENGTH_L3, "3Q"},
|
---|
| 296 | {GLO_WAVELENGTH_L3, "3X"},
|
---|
[8161] | 297 | {0.0, 0},
|
---|
| 298 | {0.0, 0},
|
---|
| 299 | {0.0, 0},
|
---|
| 300 | {0.0, 0},
|
---|
| 301 | {0.0, 0},
|
---|
| 302 | {0.0, 0},
|
---|
| 303 | {0.0, 0},
|
---|
| 304 | {0.0, 0},
|
---|
| 305 | {0.0, 0},
|
---|
| 306 | {0.0, 0},
|
---|
| 307 | {0.0, 0},
|
---|
| 308 | {0.0, 0},
|
---|
| 309 | {0.0, 0},
|
---|
| 310 | {0.0, 0}
|
---|
| 311 | };
|
---|
[1130] | 312 |
|
---|
[6812] | 313 | /** MSM signal types for Galileo */
|
---|
[8161] | 314 | static struct CodeData gal[RTCM3_MSM_NUMSIG] = {
|
---|
| 315 | {0.0, 0},
|
---|
[9008] | 316 | {GAL_WAVELENGTH_E1, "1C"},
|
---|
| 317 | {GAL_WAVELENGTH_E1, "1A"},
|
---|
| 318 | {GAL_WAVELENGTH_E1, "1B"},
|
---|
| 319 | {GAL_WAVELENGTH_E1, "1X"},
|
---|
| 320 | {GAL_WAVELENGTH_E1, "1Z"},
|
---|
[8161] | 321 | {0.0, 0},
|
---|
[9008] | 322 | {GAL_WAVELENGTH_E6, "6C"},
|
---|
| 323 | {GAL_WAVELENGTH_E6, "6A"},
|
---|
| 324 | {GAL_WAVELENGTH_E6, "6B"},
|
---|
| 325 | {GAL_WAVELENGTH_E6, "6X"},
|
---|
| 326 | {GAL_WAVELENGTH_E6, "6Z"},
|
---|
[8161] | 327 | {0.0, 0},
|
---|
| 328 | {GAL_WAVELENGTH_E5B, "7I"},
|
---|
| 329 | {GAL_WAVELENGTH_E5B, "7Q"},
|
---|
| 330 | {GAL_WAVELENGTH_E5B, "7X"},
|
---|
| 331 | {0.0, 0},
|
---|
[9008] | 332 | {GAL_WAVELENGTH_E5AB,"8I"},
|
---|
| 333 | {GAL_WAVELENGTH_E5AB,"8Q"},
|
---|
| 334 | {GAL_WAVELENGTH_E5AB,"8X"},
|
---|
[8161] | 335 | {0.0, 0},
|
---|
| 336 | {GAL_WAVELENGTH_E5A, "5I"},
|
---|
| 337 | {GAL_WAVELENGTH_E5A, "5Q"},
|
---|
| 338 | {GAL_WAVELENGTH_E5A, "5X"},
|
---|
| 339 | {0.0, 0},
|
---|
| 340 | {0.0, 0},
|
---|
| 341 | {0.0, 0},
|
---|
| 342 | {0.0, 0},
|
---|
| 343 | {0.0, 0},
|
---|
| 344 | {0.0, 0},
|
---|
| 345 | {0.0, 0},
|
---|
[8805] | 346 | {0.0, 0}
|
---|
[8161] | 347 | };
|
---|
[1185] | 348 |
|
---|
[6812] | 349 | /** MSM signal types for QZSS */
|
---|
[8161] | 350 | static struct CodeData qzss[RTCM3_MSM_NUMSIG] = {
|
---|
| 351 | {0.0, 0},
|
---|
| 352 | {GPS_WAVELENGTH_L1, "1C"},
|
---|
| 353 | {0.0, 0},
|
---|
| 354 | {0.0, 0},
|
---|
| 355 | {0.0, 0},
|
---|
| 356 | {0.0, 0},
|
---|
| 357 | {0.0, 0},
|
---|
[8843] | 358 | {0.0, 0},
|
---|
[8681] | 359 | {QZSS_WAVELENGTH_L6, "6S"},
|
---|
| 360 | {QZSS_WAVELENGTH_L6, "6L"},
|
---|
| 361 | {QZSS_WAVELENGTH_L6, "6X"},
|
---|
[8161] | 362 | {0.0, 0},
|
---|
| 363 | {0.0, 0},
|
---|
| 364 | {0.0, 0},
|
---|
| 365 | {GPS_WAVELENGTH_L2, "2S"},
|
---|
| 366 | {GPS_WAVELENGTH_L2, "2L"},
|
---|
| 367 | {GPS_WAVELENGTH_L2, "2X"},
|
---|
| 368 | {0.0, 0},
|
---|
| 369 | {0.0, 0},
|
---|
| 370 | {0.0, 0},
|
---|
| 371 | {0.0, 0},
|
---|
| 372 | {GPS_WAVELENGTH_L5, "5I"},
|
---|
| 373 | {GPS_WAVELENGTH_L5, "5Q"},
|
---|
| 374 | {GPS_WAVELENGTH_L5, "5X"},
|
---|
| 375 | {0.0, 0},
|
---|
| 376 | {0.0, 0},
|
---|
| 377 | {0.0, 0},
|
---|
| 378 | {0.0, 0},
|
---|
| 379 | {0.0, 0},
|
---|
[8681] | 380 | {GPS_WAVELENGTH_L1, "1S"},
|
---|
| 381 | {GPS_WAVELENGTH_L1, "1L"},
|
---|
[8161] | 382 | {GPS_WAVELENGTH_L1, "1X"}
|
---|
| 383 | };
|
---|
[1185] | 384 |
|
---|
[6812] | 385 | /** MSM signal types for Beidou/BDS */
|
---|
[8161] | 386 | static struct CodeData bds[RTCM3_MSM_NUMSIG] = {
|
---|
| 387 | {0.0, 0},
|
---|
| 388 | {BDS_WAVELENGTH_B1, "2I"},
|
---|
[8681] | 389 | {BDS_WAVELENGTH_B1, "2Q"},
|
---|
| 390 | {BDS_WAVELENGTH_B1, "2X"},
|
---|
[8161] | 391 | {0.0, 0},
|
---|
| 392 | {0.0, 0},
|
---|
| 393 | {0.0, 0},
|
---|
| 394 | {BDS_WAVELENGTH_B3, "6I"},
|
---|
[8681] | 395 | {BDS_WAVELENGTH_B3, "6Q"},
|
---|
| 396 | {BDS_WAVELENGTH_B3, "6X"},
|
---|
[8161] | 397 | {0.0, 0},
|
---|
| 398 | {0.0, 0},
|
---|
| 399 | {0.0, 0},
|
---|
| 400 | {BDS_WAVELENGTH_B2, "7I"},
|
---|
[8681] | 401 | {BDS_WAVELENGTH_B2, "7Q"},
|
---|
| 402 | {BDS_WAVELENGTH_B2, "7X"},
|
---|
[8161] | 403 | {0.0, 0},
|
---|
| 404 | {0.0, 0},
|
---|
| 405 | {0.0, 0},
|
---|
| 406 | {0.0, 0},
|
---|
| 407 | {0.0, 0},
|
---|
[8795] | 408 | {BDS_WAVELENGTH_B2a, "5D"},
|
---|
| 409 | {BDS_WAVELENGTH_B2a, "5P"},
|
---|
| 410 | {BDS_WAVELENGTH_B2a, "5X"},
|
---|
[9001] | 411 | {BDS_WAVELENGTH_B2b, "7D"},
|
---|
[8161] | 412 | {0.0, 0},
|
---|
| 413 | {0.0, 0},
|
---|
| 414 | {0.0, 0},
|
---|
| 415 | {0.0, 0},
|
---|
[8819] | 416 | {BDS_WAVELENGTH_B1C, "1D"},
|
---|
| 417 | {BDS_WAVELENGTH_B1C, "1P"},
|
---|
| 418 | {BDS_WAVELENGTH_B1C, "1X"}
|
---|
[8161] | 419 | };
|
---|
[1807] | 420 |
|
---|
[8843] | 421 | /** MSM signal types for IRNSS */
|
---|
[8805] | 422 | static struct CodeData irn[RTCM3_MSM_NUMSIG] = {
|
---|
| 423 | {0.0, 0},
|
---|
| 424 | {0.0, 0},
|
---|
| 425 | {0.0, 0},
|
---|
| 426 | {0.0, 0},
|
---|
| 427 | {0.0, 0},
|
---|
| 428 | {0.0, 0},
|
---|
| 429 | {0.0, 0},
|
---|
| 430 | {IRNSS_WAVELENGTH_S, "9A"},
|
---|
| 431 | {0.0, 0},
|
---|
| 432 | {0.0, 0},
|
---|
| 433 | {0.0, 0},
|
---|
| 434 | {0.0, 0},
|
---|
| 435 | {0.0, 0},
|
---|
| 436 | {0.0, 0},
|
---|
| 437 | {0.0, 0},
|
---|
| 438 | {0.0, 0},
|
---|
| 439 | {0.0, 0},
|
---|
| 440 | {0.0, 0},
|
---|
| 441 | {0.0, 0},
|
---|
| 442 | {0.0, 0},
|
---|
| 443 | {0.0, 0},
|
---|
| 444 | {IRNSS_WAVELENGTH_L5, "5A"},
|
---|
| 445 | {0.0, 0},
|
---|
| 446 | {0.0, 0},
|
---|
| 447 | {0.0, 0},
|
---|
| 448 | {0.0, 0},
|
---|
| 449 | {0.0, 0},
|
---|
| 450 | {0.0, 0},
|
---|
| 451 | {0.0, 0},
|
---|
| 452 | {0.0, 0},
|
---|
| 453 | {0.0, 0},
|
---|
| 454 | {0.0, 0}
|
---|
| 455 | };
|
---|
| 456 |
|
---|
[6812] | 457 | #define UINT64(c) c ## ULL
|
---|
[1033] | 458 |
|
---|
[7753] | 459 | //
|
---|
[6812] | 460 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8805] | 461 | bool RTCM3Decoder::DecodeRTCM3MSM(unsigned char* data, int size) {
|
---|
[6812] | 462 | bool decoded = false;
|
---|
| 463 | int type, syncf, i;
|
---|
| 464 | uint64_t numbits = 0, bitfield = 0;
|
---|
[1807] | 465 |
|
---|
[6812] | 466 | data += 3; /* header */
|
---|
| 467 | size -= 6; /* header + crc */
|
---|
[1239] | 468 |
|
---|
[6812] | 469 | GETBITS(type, 12)
|
---|
[8161] | 470 | SKIPBITS(12)
|
---|
| 471 | /* id */
|
---|
[6812] | 472 | char sys;
|
---|
[9263] | 473 | if (type >= 1131 && type <= 1137) {
|
---|
[9008] | 474 | sys = 'I';
|
---|
[9263] | 475 | }
|
---|
| 476 | else if (type >= 1121 && type <= 1127) {
|
---|
[6812] | 477 | sys = 'C';
|
---|
[9263] | 478 | }
|
---|
| 479 | else if (type >= 1111 && type <= 1117) {
|
---|
[6812] | 480 | sys = 'J';
|
---|
[9263] | 481 | }
|
---|
| 482 | else if (type >= 1101 && type <= 1007) {
|
---|
[6812] | 483 | sys = 'S';
|
---|
[9263] | 484 | }
|
---|
| 485 | else if (type >= 1091 && type <= 1097) {
|
---|
[6812] | 486 | sys = 'E';
|
---|
[9263] | 487 | }
|
---|
| 488 | else if (type >= 1081 && type <= 1087) {
|
---|
[6812] | 489 | sys = 'R';
|
---|
[9263] | 490 | }
|
---|
| 491 | else if (type >= 1071 && type <= 1077) {
|
---|
[6812] | 492 | sys = 'G';
|
---|
[9263] | 493 | }
|
---|
| 494 | else {
|
---|
| 495 | return decoded; // false
|
---|
| 496 | }
|
---|
[6812] | 497 | bncTime CurrentObsTime;
|
---|
[9036] | 498 | if (sys == 'C') /* BDS */ {
|
---|
[8161] | 499 | GETBITS(i, 30)
|
---|
[6812] | 500 | CurrentObsTime.setBDS(i);
|
---|
| 501 | }
|
---|
[8161] | 502 | else if (sys == 'R') /* GLONASS */ {
|
---|
[6812] | 503 | SKIPBITS(3)
|
---|
[8161] | 504 | GETBITS(i, 27)
|
---|
| 505 | /* tk */
|
---|
[6812] | 506 | CurrentObsTime.setTk(i);
|
---|
| 507 | }
|
---|
[8161] | 508 | else /* GPS style date */ {
|
---|
| 509 | GETBITS(i, 30)
|
---|
[6812] | 510 | CurrentObsTime.set(i);
|
---|
| 511 | }
|
---|
[8161] | 512 | if (_CurrentTime.valid() && CurrentObsTime != _CurrentTime) {
|
---|
[6812] | 513 | decoded = true;
|
---|
[8161] | 514 | _obsList.append(_CurrentObsList);
|
---|
[6812] | 515 | _CurrentObsList.clear();
|
---|
| 516 | }
|
---|
| 517 | _CurrentTime = CurrentObsTime;
|
---|
[2677] | 518 |
|
---|
[6812] | 519 | GETBITS(syncf, 1)
|
---|
| 520 | /**
|
---|
| 521 | * Ignore unknown types except for sync flag
|
---|
[7753] | 522 | *
|
---|
[6812] | 523 | * We actually support types 1-3 in following code, but as they are missing
|
---|
| 524 | * the full cycles and can't be used later we skip interpretation here already.
|
---|
| 525 | */
|
---|
[9008] | 526 | if (type <= 1137 && (type % 10) >= 4 && (type % 10) <= 7) {
|
---|
[6812] | 527 | int sigmask, numsat = 0, numsig = 0;
|
---|
| 528 | uint64_t satmask, cellmask, ui;
|
---|
[8805] | 529 | // satellite data
|
---|
| 530 | double rrmod[RTCM3_MSM_NUMSAT]; // GNSS sat rough ranges modulo 1 millisecond
|
---|
| 531 | int rrint[RTCM3_MSM_NUMSAT]; // number of integer msecs in GNSS sat rough ranges
|
---|
| 532 | int rdop[RTCM3_MSM_NUMSAT]; // GNSS sat rough phase range rates
|
---|
| 533 | int extsat[RTCM3_MSM_NUMSAT];// extended sat info
|
---|
| 534 | // signal data
|
---|
| 535 | int ll[RTCM3_MSM_NUMCELLS]; // lock time indicator
|
---|
| 536 | /*int hc[RTCM3_MSM_NUMCELLS];*/ // half cycle ambiguity indicator
|
---|
| 537 | double cnr[RTCM3_MSM_NUMCELLS]; // signal cnr
|
---|
| 538 | double cp[RTCM3_MSM_NUMCELLS]; // fine phase range data
|
---|
| 539 | double psr[RTCM3_MSM_NUMCELLS]; // fine psr
|
---|
| 540 | double dop[RTCM3_MSM_NUMCELLS]; // fine phase range rates
|
---|
[2674] | 541 |
|
---|
[8161] | 542 | SKIPBITS(3 + 7 + 2 + 2 + 1 + 3)
|
---|
[6812] | 543 | GETBITS64(satmask, RTCM3_MSM_NUMSAT)
|
---|
[2674] | 544 |
|
---|
[6812] | 545 | /* http://gurmeetsingh.wordpress.com/2008/08/05/fast-bit-counting-routines/ */
|
---|
[8161] | 546 | for (ui = satmask; ui; ui &= (ui - 1) /* remove rightmost bit */)
|
---|
[6812] | 547 | ++numsat;
|
---|
| 548 | GETBITS(sigmask, RTCM3_MSM_NUMSIG)
|
---|
[8161] | 549 | for (i = sigmask; i; i &= (i - 1) /* remove rightmost bit */)
|
---|
[6812] | 550 | ++numsig;
|
---|
[8161] | 551 | for (i = 0; i < RTCM3_MSM_NUMSAT; ++i)
|
---|
[6812] | 552 | extsat[i] = 15;
|
---|
[2674] | 553 |
|
---|
[8161] | 554 | i = numsat * numsig;
|
---|
| 555 | GETBITS64(cellmask, (unsigned )i)
|
---|
[8805] | 556 | // satellite data
|
---|
[8161] | 557 | switch (type % 10) {
|
---|
[6812] | 558 | case 1:
|
---|
| 559 | case 2:
|
---|
| 560 | case 3:
|
---|
[8161] | 561 | /* partial data, already skipped above, but implemented for future expansion ! */
|
---|
| 562 | for (int j = numsat; j--;)
|
---|
| 563 | GETFLOAT(rrmod[j], 10, 1.0 / 1024.0)
|
---|
[6812] | 564 | break;
|
---|
| 565 | case 4:
|
---|
[8161] | 566 | case 6:
|
---|
| 567 | for (int j = numsat; j--;)
|
---|
| 568 | GETBITS(rrint[j], 8)
|
---|
| 569 | for (int j = numsat; j--;)
|
---|
| 570 | GETFLOAT(rrmod[j], 10, 1.0 / 1024.0)
|
---|
[6812] | 571 | break;
|
---|
| 572 | case 5:
|
---|
| 573 | case 7:
|
---|
[8161] | 574 | for (int j = numsat; j--;)
|
---|
| 575 | GETBITS(rrint[j], 8)
|
---|
| 576 | for (int j = numsat; j--;)
|
---|
| 577 | GETBITS(extsat[j], 4)
|
---|
| 578 | for (int j = numsat; j--;)
|
---|
| 579 | GETFLOAT(rrmod[j], 10, 1.0 / 1024.0)
|
---|
| 580 | for (int j = numsat; j--;)
|
---|
| 581 | GETBITSSIGN(rdop[j], 14)
|
---|
[6812] | 582 | break;
|
---|
[8161] | 583 | }
|
---|
[8805] | 584 | // signal data
|
---|
[8161] | 585 | int numcells = numsat * numsig;
|
---|
| 586 | /** Drop anything which exceeds our cell limit. Increase limit definition
|
---|
| 587 | * when that happens. */
|
---|
| 588 | if (numcells <= RTCM3_MSM_NUMCELLS) {
|
---|
| 589 | switch (type % 10) {
|
---|
| 590 | case 1:
|
---|
| 591 | for (int count = numcells; count--;)
|
---|
| 592 | if (cellmask & (UINT64(1) << count))
|
---|
| 593 | GETFLOATSIGN(psr[count], 15, 1.0 / (1 << 24))
|
---|
| 594 | break;
|
---|
| 595 | case 2:
|
---|
| 596 | for (int count = numcells; count--;)
|
---|
| 597 | if (cellmask & (UINT64(1) << count))
|
---|
| 598 | GETFLOATSIGN(cp[count], 22, 1.0 / (1 << 29))
|
---|
| 599 | for (int count = numcells; count--;)
|
---|
| 600 | if (cellmask & (UINT64(1) << count))
|
---|
| 601 | GETBITS(ll[count], 4)
|
---|
| 602 | for (int count = numcells; count--;)
|
---|
| 603 | if (cellmask & (UINT64(1) << count))
|
---|
| 604 | SKIPBITS(1)/*GETBITS(hc[count], 1)*/
|
---|
| 605 | break;
|
---|
| 606 | case 3:
|
---|
| 607 | for (int count = numcells; count--;)
|
---|
| 608 | if (cellmask & (UINT64(1) << count))
|
---|
| 609 | GETFLOATSIGN(psr[count], 15, 1.0 / (1 << 24))
|
---|
| 610 | for (int count = numcells; count--;)
|
---|
| 611 | if (cellmask & (UINT64(1) << count))
|
---|
| 612 | GETFLOATSIGN(cp[count], 22, 1.0 / (1 << 29))
|
---|
| 613 | for (int count = numcells; count--;)
|
---|
| 614 | if (cellmask & (UINT64(1) << count))
|
---|
| 615 | GETBITS(ll[count], 4)
|
---|
| 616 | for (int count = numcells; count--;)
|
---|
| 617 | if (cellmask & (UINT64(1) << count))
|
---|
| 618 | SKIPBITS(1)/*GETBITS(hc[count], 1)*/
|
---|
| 619 | break;
|
---|
| 620 | case 4:
|
---|
| 621 | for (int count = numcells; count--;)
|
---|
| 622 | if (cellmask & (UINT64(1) << count))
|
---|
| 623 | GETFLOATSIGN(psr[count], 15, 1.0 / (1 << 24))
|
---|
| 624 | for (int count = numcells; count--;)
|
---|
| 625 | if (cellmask & (UINT64(1) << count))
|
---|
| 626 | GETFLOATSIGN(cp[count], 22, 1.0 / (1 << 29))
|
---|
| 627 | for (int count = numcells; count--;)
|
---|
| 628 | if (cellmask & (UINT64(1) << count))
|
---|
| 629 | GETBITS(ll[count], 4)
|
---|
| 630 | for (int count = numcells; count--;)
|
---|
| 631 | if (cellmask & (UINT64(1) << count))
|
---|
| 632 | SKIPBITS(1)/*GETBITS(hc[count], 1)*/
|
---|
| 633 | for (int count = numcells; count--;)
|
---|
| 634 | if (cellmask & (UINT64(1) << count))
|
---|
| 635 | GETBITS(cnr[count], 6)
|
---|
| 636 | break;
|
---|
| 637 | case 5:
|
---|
| 638 | for (int count = numcells; count--;)
|
---|
| 639 | if (cellmask & (UINT64(1) << count))
|
---|
| 640 | GETFLOATSIGN(psr[count], 15, 1.0 / (1 << 24))
|
---|
| 641 | for (int count = numcells; count--;)
|
---|
| 642 | if (cellmask & (UINT64(1) << count))
|
---|
| 643 | GETFLOATSIGN(cp[count], 22, 1.0 / (1 << 29))
|
---|
| 644 | for (int count = numcells; count--;)
|
---|
| 645 | if (cellmask & (UINT64(1) << count))
|
---|
| 646 | GETBITS(ll[count], 4)
|
---|
| 647 | for (int count = numcells; count--;)
|
---|
| 648 | if (cellmask & (UINT64(1) << count))
|
---|
| 649 | SKIPBITS(1)/*GETBITS(hc[count], 1)*/
|
---|
| 650 | for (int count = numcells; count--;)
|
---|
| 651 | if (cellmask & (UINT64(1) << count))
|
---|
| 652 | GETFLOAT(cnr[count], 6, 1.0)
|
---|
| 653 | for (int count = numcells; count--;)
|
---|
| 654 | if (cellmask & (UINT64(1) << count))
|
---|
| 655 | GETFLOATSIGN(dop[count], 15, 0.0001)
|
---|
| 656 | break;
|
---|
| 657 | case 6:
|
---|
| 658 | for (int count = numcells; count--;)
|
---|
| 659 | if (cellmask & (UINT64(1) << count))
|
---|
| 660 | GETFLOATSIGN(psr[count], 20, 1.0 / (1 << 29))
|
---|
| 661 | for (int count = numcells; count--;)
|
---|
| 662 | if (cellmask & (UINT64(1) << count))
|
---|
| 663 | GETFLOATSIGN(cp[count], 24, 1.0 / (1U << 31))
|
---|
| 664 | for (int count = numcells; count--;)
|
---|
| 665 | if (cellmask & (UINT64(1) << count))
|
---|
| 666 | GETBITS(ll[count], 10)
|
---|
| 667 | for (int count = numcells; count--;)
|
---|
| 668 | if (cellmask & (UINT64(1) << count))
|
---|
| 669 | SKIPBITS(1)/*GETBITS(hc[count], 1)*/
|
---|
| 670 | for (int count = numcells; count--;)
|
---|
| 671 | if (cellmask & (UINT64(1) << count))
|
---|
| 672 | GETFLOAT(cnr[count], 10, 1.0 / (1 << 4))
|
---|
| 673 | break;
|
---|
| 674 | case 7:
|
---|
| 675 | for (int count = numcells; count--;)
|
---|
| 676 | if (cellmask & (UINT64(1) << count))
|
---|
| 677 | GETFLOATSIGN(psr[count], 20, 1.0 / (1 << 29))
|
---|
| 678 | for (int count = numcells; count--;)
|
---|
| 679 | if (cellmask & (UINT64(1) << count))
|
---|
| 680 | GETFLOATSIGN(cp[count], 24, 1.0 / (1U << 31))
|
---|
| 681 | for (int count = numcells; count--;)
|
---|
| 682 | if (cellmask & (UINT64(1) << count))
|
---|
| 683 | GETBITS(ll[count], 10)
|
---|
| 684 | for (int count = numcells; count--;)
|
---|
| 685 | if (cellmask & (UINT64(1) << count))
|
---|
| 686 | SKIPBITS(1)/*GETBITS(hc[count], 1)*/
|
---|
| 687 | for (int count = numcells; count--;)
|
---|
| 688 | if (cellmask & (UINT64(1) << count))
|
---|
| 689 | GETFLOAT(cnr[count], 10, 1.0 / (1 << 4))
|
---|
| 690 | for (int count = numcells; count--;)
|
---|
| 691 | if (cellmask & (UINT64(1) << count))
|
---|
| 692 | GETFLOATSIGN(dop[count], 15, 0.0001)
|
---|
| 693 | break;
|
---|
[6812] | 694 | }
|
---|
| 695 | i = RTCM3_MSM_NUMSAT;
|
---|
| 696 | int j = -1;
|
---|
| 697 | t_satObs CurrentObs;
|
---|
[8161] | 698 | for (int count = numcells; count--;) {
|
---|
| 699 | while (j >= 0 && !(sigmask & (1 << --j)))
|
---|
[6812] | 700 | ;
|
---|
[8161] | 701 | if (j < 0) {
|
---|
| 702 | while (!(satmask & (UINT64(1) << (--i))))
|
---|
| 703 | /* next satellite */
|
---|
[6812] | 704 | ;
|
---|
[8161] | 705 | if (CurrentObs._obs.size() > 0)
|
---|
[6812] | 706 | _CurrentObsList.push_back(CurrentObs);
|
---|
| 707 | CurrentObs.clear();
|
---|
| 708 | CurrentObs._time = CurrentObsTime;
|
---|
[8161] | 709 | if (sys == 'S')
|
---|
| 710 | CurrentObs._prn.set(sys, 20 - 1 + RTCM3_MSM_NUMSAT - i);
|
---|
[6812] | 711 | else
|
---|
[8161] | 712 | CurrentObs._prn.set(sys, RTCM3_MSM_NUMSAT - i);
|
---|
[6812] | 713 | j = RTCM3_MSM_NUMSIG;
|
---|
[8161] | 714 | while (!(sigmask & (1 << --j)))
|
---|
[6812] | 715 | ;
|
---|
| 716 | --numsat;
|
---|
| 717 | }
|
---|
[8161] | 718 | if (cellmask & (UINT64(1) << count)) {
|
---|
| 719 | struct CodeData cd = {0.0, 0};
|
---|
| 720 | switch (sys) {
|
---|
| 721 | case 'J':
|
---|
| 722 | cd = qzss[RTCM3_MSM_NUMSIG - j - 1];
|
---|
| 723 | break;
|
---|
| 724 | case 'C':
|
---|
| 725 | cd = bds[RTCM3_MSM_NUMSIG - j - 1];
|
---|
| 726 | break;
|
---|
| 727 | case 'G':
|
---|
| 728 | case 'S':
|
---|
| 729 | cd = gps[RTCM3_MSM_NUMSIG - j - 1];
|
---|
| 730 | break;
|
---|
| 731 | case 'R':
|
---|
| 732 | cd = glo[RTCM3_MSM_NUMSIG - j - 1];
|
---|
[6812] | 733 | {
|
---|
[8161] | 734 | int k = GLOFreq[RTCM3_MSM_NUMSAT - i - 1];
|
---|
[8805] | 735 | if (extsat[numsat] < 14) { // channel number is available as extended info for MSM5/7
|
---|
| 736 | k = GLOFreq[RTCM3_MSM_NUMSAT - i - 1] = 100 + extsat[numsat] - 7;
|
---|
[8161] | 737 | }
|
---|
[8805] | 738 | if (k) {
|
---|
| 739 | if (cd.wl == 0.0) {
|
---|
| 740 | cd.wl = GLO_WAVELENGTH_L1(k - 100);
|
---|
| 741 | }
|
---|
| 742 | else if (cd.wl == 1.0) {
|
---|
| 743 | cd.wl = GLO_WAVELENGTH_L2(k - 100);
|
---|
| 744 | }
|
---|
| 745 | }
|
---|
| 746 | else if (!k && cd.wl <= 1) {
|
---|
[8161] | 747 | cd.code = 0;
|
---|
[8805] | 748 | }
|
---|
[2676] | 749 | }
|
---|
[8161] | 750 | break;
|
---|
| 751 | case 'E':
|
---|
| 752 | cd = gal[RTCM3_MSM_NUMSIG - j - 1];
|
---|
| 753 | break;
|
---|
[8805] | 754 | case 'I':
|
---|
| 755 | cd = irn[RTCM3_MSM_NUMSIG - j - 1];
|
---|
[8843] | 756 | break;
|
---|
[6812] | 757 | }
|
---|
[8161] | 758 | if (cd.code) {
|
---|
[6812] | 759 | t_frqObs *frqObs = new t_frqObs;
|
---|
[7850] | 760 | frqObs->_rnxType2ch.assign(cd.code);
|
---|
[2674] | 761 |
|
---|
[8161] | 762 | switch (type % 10) {
|
---|
| 763 | case 1:
|
---|
| 764 | if (psr[count] > -1.0 / (1 << 10)) {
|
---|
| 765 | frqObs->_code = psr[count] * LIGHTSPEED / 1000.0
|
---|
| 766 | + (rrmod[numsat]) * LIGHTSPEED / 1000.0;
|
---|
| 767 | frqObs->_codeValid = true;
|
---|
| 768 | }
|
---|
| 769 | break;
|
---|
| 770 | case 2:
|
---|
| 771 | if (cp[count] > -1.0 / (1 << 8)) {
|
---|
| 772 | frqObs->_phase = cp[count] * LIGHTSPEED / 1000.0 / cd.wl
|
---|
| 773 | + (rrmod[numsat]) * LIGHTSPEED / 1000.0 / cd.wl;
|
---|
| 774 | frqObs->_phaseValid = true;
|
---|
[8616] | 775 | frqObs->_lockTime = lti2sec(type,ll[count]);
|
---|
| 776 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0);
|
---|
[9089] | 777 | frqObs->_lockTimeIndicator = ll[count];
|
---|
[8161] | 778 | }
|
---|
| 779 | break;
|
---|
| 780 | case 3:
|
---|
| 781 | if (psr[count] > -1.0 / (1 << 10)) {
|
---|
| 782 | frqObs->_code = psr[count] * LIGHTSPEED / 1000.0
|
---|
| 783 | + (rrmod[numsat]) * LIGHTSPEED / 1000.0;
|
---|
| 784 | frqObs->_codeValid = true;
|
---|
| 785 | }
|
---|
| 786 | if (cp[count] > -1.0 / (1 << 8)) {
|
---|
| 787 | frqObs->_phase = cp[count] * LIGHTSPEED / 1000.0 / cd.wl
|
---|
| 788 | + rrmod[numsat] * LIGHTSPEED / 1000.0 / cd.wl;
|
---|
| 789 | frqObs->_phaseValid = true;
|
---|
[8616] | 790 | frqObs->_lockTime = lti2sec(type,ll[count]);
|
---|
| 791 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0);
|
---|
[9089] | 792 | frqObs->_lockTimeIndicator = ll[count];
|
---|
[8161] | 793 | }
|
---|
| 794 | break;
|
---|
| 795 | case 4:
|
---|
| 796 | if (psr[count] > -1.0 / (1 << 10)) {
|
---|
| 797 | frqObs->_code = psr[count] * LIGHTSPEED / 1000.0
|
---|
| 798 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0;
|
---|
| 799 | frqObs->_codeValid = true;
|
---|
| 800 | }
|
---|
| 801 | if (cp[count] > -1.0 / (1 << 8)) {
|
---|
| 802 | frqObs->_phase = cp[count] * LIGHTSPEED / 1000.0 / cd.wl
|
---|
[8805] | 803 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0 / cd.wl;
|
---|
[8161] | 804 | frqObs->_phaseValid = true;
|
---|
[8616] | 805 | frqObs->_lockTime = lti2sec(type,ll[count]);
|
---|
| 806 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0);
|
---|
[9089] | 807 | frqObs->_lockTimeIndicator = ll[count];
|
---|
[8161] | 808 | }
|
---|
| 809 | frqObs->_snr = cnr[count];
|
---|
| 810 | frqObs->_snrValid = true;
|
---|
| 811 | break;
|
---|
| 812 | case 5:
|
---|
| 813 | if (psr[count] > -1.0 / (1 << 10)) {
|
---|
| 814 | frqObs->_code = psr[count] * LIGHTSPEED / 1000.0
|
---|
| 815 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0;
|
---|
| 816 | frqObs->_codeValid = true;
|
---|
| 817 | }
|
---|
| 818 | if (cp[count] > -1.0 / (1 << 8)) {
|
---|
| 819 | frqObs->_phase = cp[count] * LIGHTSPEED / 1000.0 / cd.wl
|
---|
[8805] | 820 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0 / cd.wl;
|
---|
[8161] | 821 | frqObs->_phaseValid = true;
|
---|
[8616] | 822 | frqObs->_lockTime = lti2sec(type,ll[count]);
|
---|
| 823 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0);
|
---|
[9089] | 824 | frqObs->_lockTimeIndicator = ll[count];
|
---|
[8161] | 825 | }
|
---|
| 826 | frqObs->_snr = cnr[count];
|
---|
| 827 | frqObs->_snrValid = true;
|
---|
| 828 | if (dop[count] > -1.6384) {
|
---|
| 829 | frqObs->_doppler = -(dop[count] + rdop[numsat]) / cd.wl;
|
---|
| 830 | frqObs->_dopplerValid = true;
|
---|
| 831 | }
|
---|
| 832 | break;
|
---|
| 833 | case 6:
|
---|
| 834 | if (psr[count] > -1.0 / (1 << 10)) {
|
---|
| 835 | frqObs->_code = psr[count] * LIGHTSPEED / 1000.0
|
---|
| 836 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0;
|
---|
| 837 | frqObs->_codeValid = true;
|
---|
| 838 | }
|
---|
| 839 | if (cp[count] > -1.0 / (1 << 8)) {
|
---|
| 840 | frqObs->_phase = cp[count] * LIGHTSPEED / 1000.0 / cd.wl
|
---|
[8805] | 841 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0 / cd.wl;
|
---|
[8161] | 842 | frqObs->_phaseValid = true;
|
---|
[8616] | 843 | frqObs->_lockTime = lti2sec(type,ll[count]);
|
---|
| 844 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0);
|
---|
[9089] | 845 | frqObs->_lockTimeIndicator = ll[count];
|
---|
[8161] | 846 | }
|
---|
[6812] | 847 |
|
---|
[8161] | 848 | frqObs->_snr = cnr[count];
|
---|
| 849 | frqObs->_snrValid = true;
|
---|
| 850 | break;
|
---|
| 851 | case 7:
|
---|
| 852 | if (psr[count] > -1.0 / (1 << 10)) {
|
---|
| 853 | frqObs->_code = psr[count] * LIGHTSPEED / 1000.0
|
---|
| 854 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0;
|
---|
| 855 | frqObs->_codeValid = true;
|
---|
| 856 | }
|
---|
| 857 | if (cp[count] > -1.0 / (1 << 8)) {
|
---|
| 858 | frqObs->_phase = cp[count] * LIGHTSPEED / 1000.0 / cd.wl
|
---|
[8805] | 859 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0 / cd.wl;
|
---|
[8161] | 860 | frqObs->_phaseValid = true;
|
---|
[8616] | 861 | frqObs->_lockTime = lti2sec(type,ll[count]);
|
---|
| 862 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0);
|
---|
[9089] | 863 | frqObs->_lockTimeIndicator = ll[count];
|
---|
[8161] | 864 | }
|
---|
[6137] | 865 |
|
---|
[8161] | 866 | frqObs->_snr = cnr[count];
|
---|
| 867 | frqObs->_snrValid = true;
|
---|
[6137] | 868 |
|
---|
[8161] | 869 | if (dop[count] > -1.6384) {
|
---|
| 870 | frqObs->_doppler = -(dop[count] + rdop[numsat]) / cd.wl;
|
---|
| 871 | frqObs->_dopplerValid = true;
|
---|
| 872 | }
|
---|
| 873 | break;
|
---|
[366] | 874 | }
|
---|
[6812] | 875 | CurrentObs._obs.push_back(frqObs);
|
---|
[296] | 876 | }
|
---|
[6812] | 877 | }
|
---|
| 878 | }
|
---|
[8805] | 879 | if (CurrentObs._obs.size() > 0) {
|
---|
[6812] | 880 | _CurrentObsList.push_back(CurrentObs);
|
---|
[8805] | 881 | }
|
---|
[6812] | 882 | }
|
---|
| 883 | }
|
---|
[8938] | 884 | else if ((type % 10) < 4) {
|
---|
[6812] | 885 | emit(newMessage(QString("%1: Block %2 contain partial data! Ignored!")
|
---|
[8161] | 886 | .arg(_staID).arg(type).toAscii(), true));
|
---|
[6812] | 887 | }
|
---|
[8161] | 888 | if (!syncf) {
|
---|
[6812] | 889 | decoded = true;
|
---|
[8165] | 890 | _obsList.append(_CurrentObsList);
|
---|
[6812] | 891 | _CurrentTime.reset();
|
---|
| 892 | _CurrentObsList.clear();
|
---|
| 893 | }
|
---|
| 894 | return decoded;
|
---|
| 895 | }
|
---|
| 896 |
|
---|
[7753] | 897 | //
|
---|
[6812] | 898 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8161] | 899 | bool RTCM3Decoder::DecodeRTCM3GLONASS(unsigned char* data, int size) {
|
---|
[6812] | 900 | bool decoded = false;
|
---|
| 901 | bncTime CurrentObsTime;
|
---|
| 902 | int i, numsats, syncf, type;
|
---|
| 903 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 904 |
|
---|
| 905 | data += 3; /* header */
|
---|
| 906 | size -= 6; /* header + crc */
|
---|
| 907 |
|
---|
| 908 | GETBITS(type, 12)
|
---|
[8161] | 909 | SKIPBITS(12)
|
---|
| 910 | /* id */
|
---|
| 911 | GETBITS(i, 27)
|
---|
| 912 | /* tk */
|
---|
[6812] | 913 |
|
---|
| 914 | CurrentObsTime.setTk(i);
|
---|
[8161] | 915 | if (_CurrentTime.valid() && CurrentObsTime != _CurrentTime) {
|
---|
[6812] | 916 | decoded = true;
|
---|
[7753] | 917 | _obsList.append(_CurrentObsList);
|
---|
[6812] | 918 | _CurrentObsList.clear();
|
---|
| 919 | }
|
---|
| 920 | _CurrentTime = CurrentObsTime;
|
---|
| 921 |
|
---|
[8161] | 922 | GETBITS(syncf, 1)
|
---|
| 923 | /* sync */
|
---|
| 924 | GETBITS(numsats, 5)
|
---|
| 925 | SKIPBITS(4)
|
---|
| 926 | /* smind, smint */
|
---|
[6812] | 927 |
|
---|
[8161] | 928 | while (numsats--) {
|
---|
| 929 | int sv, code, l1range, amb = 0, freq;
|
---|
[6812] | 930 | t_satObs CurrentObs;
|
---|
| 931 | CurrentObs._time = CurrentObsTime;
|
---|
| 932 |
|
---|
| 933 | GETBITS(sv, 6)
|
---|
| 934 | CurrentObs._prn.set('R', sv);
|
---|
| 935 | GETBITS(code, 1)
|
---|
| 936 | GETBITS(freq, 5)
|
---|
[8161] | 937 | GLOFreq[sv - 1] = 100 + freq - 7; /* store frequency for other users (MSM) */
|
---|
[6812] | 938 |
|
---|
| 939 | t_frqObs *frqObs = new t_frqObs;
|
---|
| 940 | /* L1 */
|
---|
[8161] | 941 | (code) ?
|
---|
| 942 | frqObs->_rnxType2ch.assign("1P") : frqObs->_rnxType2ch.assign("1C");
|
---|
[6812] | 943 | GETBITS(l1range, 25);
|
---|
| 944 | GETBITSSIGN(i, 20);
|
---|
[8161] | 945 | if ((i & ((1 << 20) - 1)) != 0x80000) {
|
---|
| 946 | frqObs->_code = l1range * 0.02;
|
---|
[9205] | 947 | frqObs->_phase = (l1range * 0.02 + i * 0.0005) / GLO_WAVELENGTH_L1(freq - 7);
|
---|
[6812] | 948 | frqObs->_codeValid = frqObs->_phaseValid = true;
|
---|
| 949 | }
|
---|
[9089] | 950 | GETBITS(frqObs->_lockTimeIndicator, 7);
|
---|
| 951 | frqObs->_lockTime = lti2sec(type, frqObs->_lockTimeIndicator);
|
---|
[8616] | 952 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0 && frqObs->_phaseValid);
|
---|
[8161] | 953 | if (type == 1010 || type == 1012) {
|
---|
| 954 | GETBITS(amb, 7);
|
---|
| 955 | if (amb) {
|
---|
| 956 | frqObs->_code += amb * 599584.916;
|
---|
| 957 | frqObs->_phase += (amb * 599584.916) / GLO_WAVELENGTH_L1(freq - 7);
|
---|
[6812] | 958 | }
|
---|
| 959 | GETBITS(i, 8);
|
---|
[8161] | 960 | if (i) {
|
---|
| 961 | frqObs->_snr = i * 0.25;
|
---|
[6812] | 962 | frqObs->_snrValid = true;
|
---|
| 963 | }
|
---|
| 964 | }
|
---|
| 965 | CurrentObs._obs.push_back(frqObs);
|
---|
[8161] | 966 | if (type == 1011 || type == 1012) {
|
---|
[6812] | 967 | frqObs = new t_frqObs;
|
---|
| 968 | /* L2 */
|
---|
[8161] | 969 | GETBITS(code, 2);
|
---|
| 970 | switch (code) {
|
---|
| 971 | case 3:
|
---|
| 972 | frqObs->_rnxType2ch.assign("2P");
|
---|
| 973 | break;
|
---|
| 974 | case 2:
|
---|
| 975 | frqObs->_rnxType2ch.assign("2P");
|
---|
| 976 | break;
|
---|
| 977 | case 1:
|
---|
| 978 | frqObs->_rnxType2ch.assign("2P");
|
---|
| 979 | break;
|
---|
| 980 | case 0:
|
---|
| 981 | frqObs->_rnxType2ch.assign("2C");
|
---|
| 982 | break;
|
---|
[6812] | 983 | }
|
---|
[8161] | 984 | GETBITSSIGN(i, 14);
|
---|
| 985 | if ((i & ((1 << 14) - 1)) != 0x2000) {
|
---|
| 986 | frqObs->_code = l1range * 0.02 + i * 0.02 + amb * 599584.916;
|
---|
[6812] | 987 | frqObs->_codeValid = true;
|
---|
| 988 | }
|
---|
[8161] | 989 | GETBITSSIGN(i, 20);
|
---|
| 990 | if ((i & ((1 << 20) - 1)) != 0x80000) {
|
---|
| 991 | frqObs->_phase = (l1range * 0.02 + i * 0.0005 + amb * 599584.916)
|
---|
| 992 | / GLO_WAVELENGTH_L2(freq - 7);
|
---|
[6812] | 993 | frqObs->_phaseValid = true;
|
---|
| 994 | }
|
---|
[9089] | 995 | GETBITS(frqObs->_lockTimeIndicator, 7);
|
---|
| 996 | frqObs->_lockTime = lti2sec(type, frqObs->_lockTimeIndicator);
|
---|
[8616] | 997 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0 && frqObs->_phaseValid);
|
---|
[8161] | 998 | if (type == 1012) {
|
---|
[6812] | 999 | GETBITS(i, 8);
|
---|
[8161] | 1000 | if (i) {
|
---|
| 1001 | frqObs->_snr = i * 0.25;
|
---|
[6812] | 1002 | frqObs->_snrValid = true;
|
---|
| 1003 | }
|
---|
| 1004 | }
|
---|
| 1005 | CurrentObs._obs.push_back(frqObs);
|
---|
| 1006 | }
|
---|
| 1007 | _CurrentObsList.push_back(CurrentObs);
|
---|
| 1008 | }
|
---|
[8161] | 1009 | if (!syncf) {
|
---|
[6812] | 1010 | decoded = true;
|
---|
[7753] | 1011 | _obsList.append(_CurrentObsList);
|
---|
[6812] | 1012 | _CurrentTime.reset();
|
---|
| 1013 | _CurrentObsList.clear();
|
---|
| 1014 | }
|
---|
| 1015 | return decoded;
|
---|
| 1016 | }
|
---|
| 1017 |
|
---|
| 1018 | //
|
---|
| 1019 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8161] | 1020 | bool RTCM3Decoder::DecodeGPSEphemeris(unsigned char* data, int size) {
|
---|
[6812] | 1021 | bool decoded = false;
|
---|
| 1022 |
|
---|
[8161] | 1023 | if (size == 67) {
|
---|
[6812] | 1024 | t_ephGPS eph;
|
---|
| 1025 | int i, week;
|
---|
| 1026 | uint64_t numbits = 0, bitfield = 0;
|
---|
[8854] | 1027 | int fitIntervalFalg = 0;
|
---|
[6812] | 1028 |
|
---|
| 1029 | data += 3; /* header */
|
---|
| 1030 | size -= 6; /* header + crc */
|
---|
| 1031 | SKIPBITS(12)
|
---|
| 1032 |
|
---|
| 1033 | eph._receptDateTime = currentDateAndTimeGPS();
|
---|
[9286] | 1034 | eph._receptStaID = _staID;
|
---|
[6812] | 1035 |
|
---|
| 1036 | GETBITS(i, 6)
|
---|
| 1037 | eph._prn.set('G', i);
|
---|
| 1038 | GETBITS(week, 10)
|
---|
| 1039 | GETBITS(i, 4)
|
---|
| 1040 | eph._ura = accuracyFromIndex(i, eph.type());
|
---|
| 1041 | GETBITS(eph._L2Codes, 2)
|
---|
| 1042 | GETFLOATSIGN(eph._IDOT, 14, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 1043 | GETBITS(eph._IODE, 8)
|
---|
| 1044 | GETBITS(i, 16)
|
---|
| 1045 | i <<= 4;
|
---|
[8161] | 1046 | eph._TOC.set(i * 1000);
|
---|
[8805] | 1047 | GETFLOATSIGN(eph._clock_driftrate, 8, 1.0 / (double )(1 << 30) / (double )(1 << 25))
|
---|
| 1048 | GETFLOATSIGN(eph._clock_drift, 16, 1.0 / (double )(1 << 30) / (double )(1 << 13))
|
---|
| 1049 | GETFLOATSIGN(eph._clock_bias, 22, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
[6812] | 1050 | GETBITS(eph._IODC, 10)
|
---|
[8161] | 1051 | GETFLOATSIGN(eph._Crs, 16, 1.0 / (double )(1 << 5))
|
---|
[6812] | 1052 | GETFLOATSIGN(eph._Delta_n, 16, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 1053 | GETFLOATSIGN(eph._M0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[8161] | 1054 | GETFLOATSIGN(eph._Cuc, 16, 1.0 / (double )(1 << 29))
|
---|
| 1055 | GETFLOAT(eph._e, 32, 1.0 / (double )(1 << 30) / (double )(1 << 3))
|
---|
| 1056 | GETFLOATSIGN(eph._Cus, 16, 1.0 / (double )(1 << 29))
|
---|
| 1057 | GETFLOAT(eph._sqrt_A, 32, 1.0 / (double )(1 << 19))
|
---|
[9205] | 1058 | if (eph._sqrt_A < 1000.0) {
|
---|
[9209] | 1059 | #ifdef BNC_DEBUG_BCEP
|
---|
[9205] | 1060 | emit(newMessage(QString("%1: Block %2 (%3) SQRT_A %4 m!")
|
---|
[9319] | 1061 | .arg(_staID).arg(1019,4).arg(eph._prn.toString().c_str())
|
---|
[9205] | 1062 | .arg(eph._sqrt_A,10,'F',3).toAscii(), true));
|
---|
[9209] | 1063 | #endif
|
---|
[9205] | 1064 | return false;
|
---|
| 1065 | }
|
---|
[6812] | 1066 | GETBITS(i, 16)
|
---|
| 1067 | i <<= 4;
|
---|
| 1068 | eph._TOEsec = i;
|
---|
| 1069 | bncTime t;
|
---|
[8161] | 1070 | t.set(i * 1000);
|
---|
[6812] | 1071 | eph._TOEweek = t.gpsw();
|
---|
[8473] | 1072 | int numOfRollOvers = int(floor(t.gpsw()/1024.0));
|
---|
| 1073 | week += (numOfRollOvers * 1024);
|
---|
[6812] | 1074 | /* week from HOW, differs from TOC, TOE week, we use adapted value instead */
|
---|
[8161] | 1075 | if (eph._TOEweek > week + 1 || eph._TOEweek < week - 1) /* invalid week */
|
---|
[6812] | 1076 | return false;
|
---|
[8161] | 1077 | GETFLOATSIGN(eph._Cic, 16, 1.0 / (double )(1 << 29))
|
---|
[6812] | 1078 | GETFLOATSIGN(eph._OMEGA0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[8161] | 1079 | GETFLOATSIGN(eph._Cis, 16, 1.0 / (double )(1 << 29))
|
---|
[6812] | 1080 | GETFLOATSIGN(eph._i0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[8161] | 1081 | GETFLOATSIGN(eph._Crc, 16, 1.0 / (double )(1 << 5))
|
---|
[6812] | 1082 | GETFLOATSIGN(eph._omega, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1083 | GETFLOATSIGN(eph._OMEGADOT, 24, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
[8161] | 1084 | GETFLOATSIGN(eph._TGD, 8, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
[6812] | 1085 | GETBITS(eph._health, 6)
|
---|
| 1086 | GETBITS(eph._L2PFlag, 1)
|
---|
[8854] | 1087 | GETBITS(fitIntervalFalg, 1)
|
---|
[8855] | 1088 | eph._fitInterval = fitIntervalFromFlag(fitIntervalFalg, eph._IODC, eph.type());
|
---|
[6812] | 1089 | eph._TOT = 0.9999e9;
|
---|
| 1090 |
|
---|
| 1091 | emit newGPSEph(eph);
|
---|
| 1092 | decoded = true;
|
---|
| 1093 | }
|
---|
| 1094 | return decoded;
|
---|
| 1095 | }
|
---|
| 1096 |
|
---|
| 1097 | //
|
---|
| 1098 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8161] | 1099 | bool RTCM3Decoder::DecodeGLONASSEphemeris(unsigned char* data, int size) {
|
---|
[6812] | 1100 | bool decoded = false;
|
---|
| 1101 |
|
---|
[8161] | 1102 | if (size == 51) {
|
---|
[6812] | 1103 | t_ephGlo eph;
|
---|
| 1104 | int sv, i, tk;
|
---|
| 1105 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 1106 |
|
---|
| 1107 | data += 3; /* header */
|
---|
| 1108 | size -= 6; /* header + crc */
|
---|
| 1109 | SKIPBITS(12)
|
---|
| 1110 |
|
---|
| 1111 | eph._receptDateTime = currentDateAndTimeGPS();
|
---|
[9216] | 1112 | eph._receptStaID = _staID;
|
---|
[9286] | 1113 |
|
---|
[6812] | 1114 | GETBITS(sv, 6)
|
---|
| 1115 | eph._prn.set('R', sv);
|
---|
| 1116 |
|
---|
| 1117 | GETBITS(i, 5)
|
---|
[8161] | 1118 | eph._frequency_number = i - 7;
|
---|
[8184] | 1119 | GETBITS(eph._almanac_health, 1) /* almanac healthy */
|
---|
| 1120 | GETBITS(eph._almanac_health_availablility_indicator, 1) /* almanac health ok */
|
---|
[9205] | 1121 | if (eph._almanac_health_availablility_indicator == 0.0) {
|
---|
[9209] | 1122 | #ifdef BNC_DEBUG_BCEP
|
---|
[9205] | 1123 | emit(newMessage(QString("%1: Block %2 (%3): ALM = %4: missing data!")
|
---|
[9319] | 1124 | .arg(_staID).arg(1020,4).arg(eph._prn.toString().c_str())
|
---|
[9205] | 1125 | .arg(eph._almanac_health_availablility_indicator).toAscii(), true));
|
---|
[9209] | 1126 | #endif
|
---|
[9205] | 1127 | return false;
|
---|
| 1128 | }
|
---|
[8184] | 1129 | GETBITS(eph._P1, 2) /* P1 */
|
---|
[6812] | 1130 | GETBITS(i, 5)
|
---|
[8161] | 1131 | tk = i * 60 * 60;
|
---|
[6812] | 1132 | GETBITS(i, 6)
|
---|
[8161] | 1133 | tk += i * 60;
|
---|
[6812] | 1134 | GETBITS(i, 1)
|
---|
[8161] | 1135 | tk += i * 30;
|
---|
[9193] | 1136 | eph._tki = tk - 3*60*60;
|
---|
[8805] | 1137 | if(eph._tki < 0.0) {
|
---|
| 1138 | eph._tki += 86400.0;
|
---|
| 1139 | }
|
---|
[8184] | 1140 | GETBITS(eph._health, 1) /* MSB of Bn*/
|
---|
| 1141 | GETBITS(eph._P2, 1) /* P2 */
|
---|
[6812] | 1142 | GETBITS(i, 7)
|
---|
[8161] | 1143 | eph._TOC.setTk(i * 15 * 60 * 1000); /* tb */
|
---|
[6812] | 1144 |
|
---|
[8161] | 1145 | GETFLOATSIGNM(eph._x_velocity, 24, 1.0 / (double )(1 << 20))
|
---|
| 1146 | GETFLOATSIGNM(eph._x_pos, 27, 1.0 / (double )(1 << 11))
|
---|
| 1147 | GETFLOATSIGNM(eph._x_acceleration, 5, 1.0 / (double )(1 << 30))
|
---|
| 1148 | GETFLOATSIGNM(eph._y_velocity, 24, 1.0 / (double )(1 << 20))
|
---|
| 1149 | GETFLOATSIGNM(eph._y_pos, 27, 1.0 / (double )(1 << 11))
|
---|
| 1150 | GETFLOATSIGNM(eph._y_acceleration, 5, 1.0 / (double )(1 << 30))
|
---|
| 1151 | GETFLOATSIGNM(eph._z_velocity, 24, 1.0 / (double )(1 << 20))
|
---|
| 1152 | GETFLOATSIGNM(eph._z_pos, 27, 1.0 / (double )(1 << 11))
|
---|
| 1153 | GETFLOATSIGNM(eph._z_acceleration, 5, 1.0 / (double )(1 << 30))
|
---|
[8184] | 1154 | GETBITS(eph._P3, 1) /* P3 */
|
---|
[8161] | 1155 | GETFLOATSIGNM(eph._gamma, 11, 1.0 / (double )(1 << 30) / (double )(1 << 10))
|
---|
[8184] | 1156 | GETBITS(eph._M_P, 2) /* GLONASS-M P, */
|
---|
| 1157 | GETBITS(eph._M_l3, 1) /*GLONASS-M ln (third string) */
|
---|
| 1158 | GETFLOATSIGNM(eph._tau, 22, 1.0 / (double )(1 << 30)) /* GLONASS tau n(tb) */
|
---|
| 1159 | GETFLOATSIGNM(eph._M_delta_tau, 5, 1.0 / (double )(1 << 30)) /* GLONASS-M delta tau n(tb) */
|
---|
[6812] | 1160 | GETBITS(eph._E, 5)
|
---|
[8184] | 1161 | GETBITS(eph._M_P4, 1) /* GLONASS-M P4 */
|
---|
| 1162 | GETBITS(eph._M_FT, 4) /* GLONASS-M Ft */
|
---|
| 1163 | GETBITS(eph._M_NT, 11) /* GLONASS-M Nt */
|
---|
[9205] | 1164 | if (eph._M_NT == 0.0) {
|
---|
[9209] | 1165 | #ifdef BNC_DEBUG_BCEP
|
---|
[9205] | 1166 | emit(newMessage(QString("%1: Block %2 (%3): NT = %4: missing data!")
|
---|
[9319] | 1167 | .arg(_staID).arg(1020,4).arg(eph._prn.toString().c_str()).arg(eph._M_NT,4).toAscii(), true));
|
---|
[9209] | 1168 | #endif
|
---|
[9205] | 1169 | return false;
|
---|
| 1170 | }
|
---|
[8184] | 1171 | GETBITS(eph._M_M, 2) /* GLONASS-M M */
|
---|
| 1172 | GETBITS(eph._additional_data_availability, 1) /* GLONASS-M The Availability of Additional Data */
|
---|
[9205] | 1173 | if (eph._additional_data_availability == 0.0) {
|
---|
[9209] | 1174 | #ifdef BNC_DEBUG_BCEP
|
---|
[9205] | 1175 | emit(newMessage(QString("%1: Block %2 (%3): ADD = %4: missing data!")
|
---|
[9319] | 1176 | .arg(_staID).arg(1020,4).arg(eph._prn.toString().c_str())
|
---|
[9205] | 1177 | .arg(eph._additional_data_availability).toAscii(), true));
|
---|
[9209] | 1178 | #endif
|
---|
[9205] | 1179 | return false;
|
---|
| 1180 | }
|
---|
[8184] | 1181 | GETBITS(eph._NA, 11) /* GLONASS-M Na */
|
---|
| 1182 | GETFLOATSIGNM(eph._tauC, 32, 1.0/(double)(1<<30)/(double)(1<<1)) /* GLONASS tau c */
|
---|
| 1183 | GETBITS(eph._M_N4, 5) /* GLONASS-M N4 */
|
---|
| 1184 | GETFLOATSIGNM(eph._M_tau_GPS, 22, 1.0/(double)(1<<30)) /* GLONASS-M tau GPS */
|
---|
| 1185 | GETBITS(eph._M_l5, 1) /* GLONASS-M ln (fifth string) */
|
---|
[6812] | 1186 |
|
---|
| 1187 | unsigned year, month, day;
|
---|
| 1188 | eph._TOC.civil_date(year, month, day);
|
---|
| 1189 | eph._gps_utc = gnumleap(year, month, day);
|
---|
| 1190 | eph._tt = eph._TOC;
|
---|
| 1191 |
|
---|
[8705] | 1192 | eph._xv(1) = eph._x_pos * 1.e3;
|
---|
| 1193 | eph._xv(2) = eph._y_pos * 1.e3;
|
---|
| 1194 | eph._xv(3) = eph._z_pos * 1.e3;
|
---|
[9205] | 1195 | if (eph._xv.Rows(1,3).NormFrobenius() < 1.0) {
|
---|
[9209] | 1196 | #ifdef BNC_DEBUG_BCEP
|
---|
[9205] | 1197 | emit(newMessage(QString("%1: Block %2 (%3): zero position!")
|
---|
[9319] | 1198 | .arg(_staID).arg(1020,4).arg(eph._prn.toString().c_str()).toAscii(), true));
|
---|
[9209] | 1199 | #endif
|
---|
[9205] | 1200 | return false;
|
---|
| 1201 | }
|
---|
[8705] | 1202 | eph._xv(4) = eph._x_velocity * 1.e3;
|
---|
| 1203 | eph._xv(5) = eph._y_velocity * 1.e3;
|
---|
| 1204 | eph._xv(6) = eph._z_velocity * 1.e3;
|
---|
[9205] | 1205 | if (eph._xv.Rows(4,6).NormFrobenius() < 1.0) {
|
---|
[9209] | 1206 | #ifdef BNC_DEBUG_BCEP
|
---|
[9205] | 1207 | emit(newMessage(QString("%1: Block %2 (%3): zero velocity!")
|
---|
[9319] | 1208 | .arg(_staID).arg(1020,4).arg(eph._prn.toString().c_str()).toAscii(), true));
|
---|
[9209] | 1209 | #endif
|
---|
[9205] | 1210 | return false;
|
---|
| 1211 | }
|
---|
[8475] | 1212 | GLOFreq[sv - 1] = 100 + eph._frequency_number ; /* store frequency for other users (MSM) */
|
---|
[8200] | 1213 | _gloFrq = QString("%1 %2").arg(eph._prn.toString().c_str()).arg(eph._frequency_number, 2, 'f', 0);
|
---|
[8455] | 1214 |
|
---|
[8705] | 1215 | emit newGlonassEph(eph);
|
---|
| 1216 | decoded = true;
|
---|
[6812] | 1217 | }
|
---|
| 1218 | return decoded;
|
---|
| 1219 | }
|
---|
| 1220 |
|
---|
| 1221 | //
|
---|
| 1222 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8161] | 1223 | bool RTCM3Decoder::DecodeQZSSEphemeris(unsigned char* data, int size) {
|
---|
[6812] | 1224 | bool decoded = false;
|
---|
| 1225 |
|
---|
[8161] | 1226 | if (size == 67) {
|
---|
[6812] | 1227 | t_ephGPS eph;
|
---|
| 1228 | int i, week;
|
---|
| 1229 | uint64_t numbits = 0, bitfield = 0;
|
---|
[8854] | 1230 | int fitIntervalFalg = 0;
|
---|
[8938] | 1231 |
|
---|
[6812] | 1232 | data += 3; /* header */
|
---|
| 1233 | size -= 6; /* header + crc */
|
---|
| 1234 | SKIPBITS(12)
|
---|
| 1235 |
|
---|
| 1236 | eph._receptDateTime = currentDateAndTimeGPS();
|
---|
[9216] | 1237 | eph._receptStaID = _staID;
|
---|
[9286] | 1238 |
|
---|
[6812] | 1239 | GETBITS(i, 4)
|
---|
| 1240 | eph._prn.set('J', i);
|
---|
| 1241 |
|
---|
| 1242 | GETBITS(i, 16)
|
---|
| 1243 | i <<= 4;
|
---|
[8161] | 1244 | eph._TOC.set(i * 1000);
|
---|
[6812] | 1245 |
|
---|
[8805] | 1246 | GETFLOATSIGN(eph._clock_driftrate, 8, 1.0 / (double )(1 << 30) / (double )(1 << 25))
|
---|
| 1247 | GETFLOATSIGN(eph._clock_drift, 16, 1.0 / (double )(1 << 30) / (double )(1 << 13))
|
---|
| 1248 | GETFLOATSIGN(eph._clock_bias, 22, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
[6812] | 1249 | GETBITS(eph._IODE, 8)
|
---|
[8161] | 1250 | GETFLOATSIGN(eph._Crs, 16, 1.0 / (double )(1 << 5))
|
---|
[6812] | 1251 | GETFLOATSIGN(eph._Delta_n, 16, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 1252 | GETFLOATSIGN(eph._M0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[8161] | 1253 | GETFLOATSIGN(eph._Cuc, 16, 1.0 / (double )(1 << 29))
|
---|
| 1254 | GETFLOAT(eph._e, 32, 1.0 / (double )(1 << 30) / (double )(1 << 3))
|
---|
| 1255 | GETFLOATSIGN(eph._Cus, 16, 1.0 / (double )(1 << 29))
|
---|
| 1256 | GETFLOAT(eph._sqrt_A, 32, 1.0 / (double )(1 << 19))
|
---|
[9205] | 1257 | if (eph._sqrt_A < 1000.0) {
|
---|
[9209] | 1258 | #ifdef BNC_DEBUG_BCEP
|
---|
[9205] | 1259 | emit(newMessage(QString("%1: Block %2 (%3) SQRT_A %4 m!")
|
---|
| 1260 | .arg(_staID).arg(1044,4).arg(eph._prn.toString().c_str())
|
---|
| 1261 | .arg(eph._sqrt_A,10,'F',3).toAscii(), true));
|
---|
[9209] | 1262 | #endif
|
---|
[9205] | 1263 | return false;
|
---|
| 1264 | }
|
---|
[6812] | 1265 | GETBITS(i, 16)
|
---|
| 1266 | i <<= 4;
|
---|
| 1267 | eph._TOEsec = i;
|
---|
| 1268 | bncTime t;
|
---|
[8471] | 1269 | t.set(i*1000);
|
---|
| 1270 | eph._TOEweek = t.gpsw();
|
---|
[8161] | 1271 | GETFLOATSIGN(eph._Cic, 16, 1.0 / (double )(1 << 29))
|
---|
[6812] | 1272 | GETFLOATSIGN(eph._OMEGA0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[8161] | 1273 | GETFLOATSIGN(eph._Cis, 16, 1.0 / (double )(1 << 29))
|
---|
[6812] | 1274 | GETFLOATSIGN(eph._i0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[8161] | 1275 | GETFLOATSIGN(eph._Crc, 16, 1.0 / (double )(1 << 5))
|
---|
[6812] | 1276 | GETFLOATSIGN(eph._omega, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1277 | GETFLOATSIGN(eph._OMEGADOT, 24, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 1278 | GETFLOATSIGN(eph._IDOT, 14, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 1279 | GETBITS(eph._L2Codes, 2)
|
---|
| 1280 | GETBITS(week, 10)
|
---|
[8473] | 1281 | int numOfRollOvers = int(floor(t.gpsw()/1024.0));
|
---|
| 1282 | week += (numOfRollOvers * 1024);
|
---|
[6812] | 1283 | /* week from HOW, differs from TOC, TOE week, we use adapted value instead */
|
---|
[8161] | 1284 | if (eph._TOEweek > week + 1 || eph._TOEweek < week - 1) /* invalid week */
|
---|
[6812] | 1285 | return false;
|
---|
| 1286 |
|
---|
| 1287 | GETBITS(i, 4)
|
---|
[8161] | 1288 | if (i <= 6)
|
---|
| 1289 | eph._ura = ceil(10.0 * pow(2.0, 1.0 + i / 2.0)) / 10.0;
|
---|
[6812] | 1290 | else
|
---|
[8161] | 1291 | eph._ura = ceil(10.0 * pow(2.0, i / 2.0)) / 10.0;
|
---|
[6812] | 1292 | GETBITS(eph._health, 6)
|
---|
[8161] | 1293 | GETFLOATSIGN(eph._TGD, 8, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
[6812] | 1294 | GETBITS(eph._IODC, 10)
|
---|
[8854] | 1295 | GETBITS(fitIntervalFalg, 1)
|
---|
[8855] | 1296 | eph._fitInterval = fitIntervalFromFlag(fitIntervalFalg, eph._IODC, eph.type());
|
---|
[6812] | 1297 | eph._TOT = 0.9999e9;
|
---|
| 1298 |
|
---|
| 1299 | emit newGPSEph(eph);
|
---|
| 1300 | decoded = true;
|
---|
| 1301 | }
|
---|
| 1302 | return decoded;
|
---|
| 1303 | }
|
---|
| 1304 |
|
---|
| 1305 | //
|
---|
| 1306 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8805] | 1307 | bool RTCM3Decoder::DecodeIRNSSEphemeris(unsigned char* data, int size) {
|
---|
| 1308 | bool decoded = false;
|
---|
| 1309 |
|
---|
| 1310 | if (size == 67) {
|
---|
| 1311 | t_ephGPS eph;
|
---|
| 1312 | int i, week, L5Flag, SFlag;
|
---|
| 1313 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 1314 |
|
---|
| 1315 | data += 3; /* header */
|
---|
| 1316 | size -= 6; /* header + crc */
|
---|
| 1317 | SKIPBITS(12)
|
---|
| 1318 |
|
---|
| 1319 | eph._receptDateTime = currentDateAndTimeGPS();
|
---|
[9216] | 1320 | eph._receptStaID = _staID;
|
---|
[9286] | 1321 |
|
---|
[8805] | 1322 | GETBITS(i, 6)
|
---|
| 1323 | eph._prn.set('I', i);
|
---|
| 1324 | GETBITS(week, 10)
|
---|
| 1325 | GETFLOATSIGN(eph._clock_bias, 22, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
| 1326 | GETFLOATSIGN(eph._clock_drift, 16, 1.0 / (double )(1 << 30) / (double )(1 << 13))
|
---|
| 1327 | GETFLOATSIGN(eph._clock_driftrate, 8, 1.0 / (double )(1 << 30) / (double )(1 << 25))
|
---|
| 1328 | GETBITS(i, 4)
|
---|
| 1329 | eph._ura = accuracyFromIndex(i, eph.type());
|
---|
| 1330 | GETBITS(i, 16)
|
---|
| 1331 | i <<= 4;
|
---|
| 1332 | eph._TOC.set(i * 1000);
|
---|
| 1333 | GETFLOATSIGN(eph._TGD, 8, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
| 1334 | GETFLOATSIGN(eph._Delta_n, 22, R2R_PI/(double)(1<<30)/(double)(1 << 11))
|
---|
| 1335 | // IODCE
|
---|
| 1336 | GETBITS(eph._IODE, 8)
|
---|
| 1337 | eph._IODC = eph._IODE;
|
---|
| 1338 | SKIPBITS(10)
|
---|
| 1339 | GETBITS(L5Flag, 1)
|
---|
| 1340 | GETBITS(SFlag, 1)
|
---|
| 1341 | if (L5Flag == 0 && SFlag == 0) {
|
---|
| 1342 | eph._health = 0.0;
|
---|
| 1343 | }
|
---|
| 1344 | else if (L5Flag == 0 && SFlag == 1) {
|
---|
| 1345 | eph._health = 1.0;
|
---|
| 1346 | }
|
---|
| 1347 | else if (L5Flag == 1 && SFlag == 0) {
|
---|
| 1348 | eph._health = 2.0;
|
---|
| 1349 | }
|
---|
| 1350 | else if (L5Flag == 1 && SFlag == 1) {
|
---|
| 1351 | eph._health = 3.0;
|
---|
| 1352 | }
|
---|
| 1353 | GETFLOATSIGN(eph._Cuc, 15, 1.0 / (double )(1 << 28))
|
---|
| 1354 | GETFLOATSIGN(eph._Cus, 15, 1.0 / (double )(1 << 28))
|
---|
| 1355 | GETFLOATSIGN(eph._Cic, 15, 1.0 / (double )(1 << 28))
|
---|
| 1356 | GETFLOATSIGN(eph._Cis, 15, 1.0 / (double )(1 << 28))
|
---|
| 1357 | GETFLOATSIGN(eph._Crc, 15, 1.0 / (double )(1 << 4))
|
---|
| 1358 | GETFLOATSIGN(eph._Crs, 15, 1.0 / (double )(1 << 4))
|
---|
| 1359 | GETFLOATSIGN(eph._IDOT, 14, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
[9329] | 1360 | SKIPBITS(2)
|
---|
[8805] | 1361 | GETFLOATSIGN(eph._M0, 32, R2R_PI/(double)(1<<30)/(double)(1<< 1))
|
---|
| 1362 | GETBITS(i, 16)
|
---|
| 1363 | i <<= 4;
|
---|
| 1364 | eph._TOEsec = i;
|
---|
| 1365 | bncTime t;
|
---|
| 1366 | t.set(i * 1000);
|
---|
| 1367 | eph._TOEweek = t.gpsw();
|
---|
| 1368 | int numOfRollOvers = int(floor(t.gpsw()/1024.0));
|
---|
| 1369 | week += (numOfRollOvers * 1024);
|
---|
| 1370 | /* week from HOW, differs from TOC, TOE week, we use adapted value instead */
|
---|
| 1371 | if (eph._TOEweek > week + 1 || eph._TOEweek < week - 1) /* invalid week */
|
---|
| 1372 | return false;
|
---|
| 1373 | GETFLOAT(eph._e, 32, 1.0 / (double )(1 << 30) / (double )(1 << 3))
|
---|
| 1374 | GETFLOAT(eph._sqrt_A, 32, 1.0 / (double )(1 << 19))
|
---|
[9205] | 1375 | if (eph._sqrt_A < 1000.0) {
|
---|
[9209] | 1376 | #ifdef BNC_DEBUG_BCEP
|
---|
[9205] | 1377 | emit(newMessage(QString("%1: Block %2 (%3) SQRT_A %4 m!")
|
---|
| 1378 | .arg(_staID).arg(1041,4).arg(eph._prn.toString().c_str())
|
---|
| 1379 | .arg(eph._sqrt_A,10,'F',3).toAscii(), true));
|
---|
[9209] | 1380 | #endif
|
---|
[9205] | 1381 | return false;
|
---|
| 1382 | }
|
---|
[8805] | 1383 | GETFLOATSIGN(eph._OMEGA0, 32, R2R_PI/(double)(1<<30)/(double)(1<< 1))
|
---|
| 1384 | GETFLOATSIGN(eph._omega, 32, R2R_PI/(double)(1<<30)/(double)(1<< 1))
|
---|
| 1385 | GETFLOATSIGN(eph._OMEGADOT, 22, R2R_PI/(double)(1<<30)/(double)(1<<11))
|
---|
| 1386 | GETFLOATSIGN(eph._i0, 32, R2R_PI/(double)(1<<30)/(double)(1<< 1))
|
---|
| 1387 | SKIPBITS(2)
|
---|
| 1388 | eph._TOT = 0.9999e9;
|
---|
| 1389 |
|
---|
| 1390 | emit newGPSEph(eph);
|
---|
| 1391 | decoded = true;
|
---|
| 1392 | }
|
---|
| 1393 | return decoded;
|
---|
| 1394 | }
|
---|
| 1395 |
|
---|
| 1396 | //
|
---|
| 1397 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8161] | 1398 | bool RTCM3Decoder::DecodeSBASEphemeris(unsigned char* data, int size) {
|
---|
[6812] | 1399 | bool decoded = false;
|
---|
| 1400 |
|
---|
[8161] | 1401 | if (size == 35) {
|
---|
[6812] | 1402 | t_ephSBAS eph;
|
---|
| 1403 | int i;
|
---|
| 1404 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 1405 |
|
---|
| 1406 | data += 3; /* header */
|
---|
| 1407 | size -= 6; /* header + crc */
|
---|
| 1408 | SKIPBITS(12)
|
---|
| 1409 |
|
---|
| 1410 | eph._receptDateTime = currentDateAndTimeGPS();
|
---|
[9216] | 1411 | eph._receptStaID = _staID;
|
---|
[9286] | 1412 |
|
---|
[6812] | 1413 | GETBITS(i, 6)
|
---|
[8161] | 1414 | eph._prn.set('S', 20 + i);
|
---|
[6812] | 1415 | GETBITS(eph._IODN, 8)
|
---|
| 1416 | GETBITS(i, 13)
|
---|
| 1417 | i <<= 4;
|
---|
[8161] | 1418 | eph._TOC.setTOD(i * 1000);
|
---|
[6812] | 1419 | GETBITS(i, 4)
|
---|
| 1420 | eph._ura = accuracyFromIndex(i, eph.type());
|
---|
| 1421 | GETFLOATSIGN(eph._x_pos, 30, 0.08)
|
---|
| 1422 | GETFLOATSIGN(eph._y_pos, 30, 0.08)
|
---|
| 1423 | GETFLOATSIGN(eph._z_pos, 25, 0.4)
|
---|
[9205] | 1424 | ColumnVector pos(3);
|
---|
| 1425 | pos(1) = eph._x_pos; pos(2) = eph._y_pos; pos(3) = eph._z_pos;
|
---|
| 1426 | if (pos.NormFrobenius() < 1.0) {
|
---|
[9209] | 1427 | #ifdef BNC_DEBUG_BCEP
|
---|
[9205] | 1428 | emit(newMessage(QString("%1: Block %2 (%3): zero position!")
|
---|
| 1429 | .arg(_staID).arg(1043,4).arg(eph._prn.toString().c_str()).toAscii(), true));
|
---|
[9209] | 1430 | #endif
|
---|
[9205] | 1431 | return false;
|
---|
| 1432 | }
|
---|
[6812] | 1433 | GETFLOATSIGN(eph._x_velocity, 17, 0.000625)
|
---|
| 1434 | GETFLOATSIGN(eph._y_velocity, 17, 0.000625)
|
---|
| 1435 | GETFLOATSIGN(eph._z_velocity, 18, 0.004)
|
---|
| 1436 | GETFLOATSIGN(eph._x_acceleration, 10, 0.0000125)
|
---|
| 1437 | GETFLOATSIGN(eph._y_acceleration, 10, 0.0000125)
|
---|
| 1438 | GETFLOATSIGN(eph._z_acceleration, 10, 0.0000625)
|
---|
[8161] | 1439 | GETFLOATSIGN(eph._agf0, 12, 1.0 / (1 << 30) / (1 << 1))
|
---|
| 1440 | GETFLOATSIGN(eph._agf1, 8, 1.0 / (1 << 30) / (1 << 10))
|
---|
[6812] | 1441 |
|
---|
[8455] | 1442 | eph._TOT = 0.9999E9;
|
---|
[6812] | 1443 | eph._health = 0;
|
---|
| 1444 |
|
---|
| 1445 | emit newSBASEph(eph);
|
---|
| 1446 | decoded = true;
|
---|
| 1447 | }
|
---|
| 1448 | return decoded;
|
---|
| 1449 | }
|
---|
| 1450 |
|
---|
| 1451 | //
|
---|
| 1452 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8161] | 1453 | bool RTCM3Decoder::DecodeGalileoEphemeris(unsigned char* data, int size) {
|
---|
[6812] | 1454 | bool decoded = false;
|
---|
| 1455 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 1456 | int i;
|
---|
| 1457 |
|
---|
| 1458 | data += 3; /* header */
|
---|
| 1459 | size -= 6; /* header + crc */
|
---|
| 1460 | GETBITS(i, 12)
|
---|
| 1461 |
|
---|
[8161] | 1462 | if ((i == 1046 && size == 61) || (i == 1045 && size == 60)) {
|
---|
[6812] | 1463 | t_ephGal eph;
|
---|
| 1464 |
|
---|
| 1465 | eph._receptDateTime = currentDateAndTimeGPS();
|
---|
[9216] | 1466 | eph._receptStaID = _staID;
|
---|
[9286] | 1467 |
|
---|
[6812] | 1468 | eph._inav = (i == 1046);
|
---|
| 1469 | eph._fnav = (i == 1045);
|
---|
| 1470 | GETBITS(i, 6)
|
---|
| 1471 | eph._prn.set('E', i, eph._inav ? 1 : 0);
|
---|
| 1472 |
|
---|
[8805] | 1473 | GETBITS(eph._TOEweek, 12) //FIXME: roll-over after week 4095!!
|
---|
[6812] | 1474 | GETBITS(eph._IODnav, 10)
|
---|
| 1475 | GETBITS(i, 8)
|
---|
| 1476 | eph._SISA = accuracyFromIndex(i, eph.type());
|
---|
| 1477 | GETFLOATSIGN(eph._IDOT, 14, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 1478 | GETBITSFACTOR(i, 14, 60)
|
---|
[8161] | 1479 | eph._TOC.set(1024 + eph._TOEweek, i);
|
---|
[8805] | 1480 | GETFLOATSIGN(eph._clock_driftrate, 6, 1.0 / (double )(1 << 30) / (double )(1 << 29))
|
---|
| 1481 | GETFLOATSIGN(eph._clock_drift, 21, 1.0 / (double )(1 << 30) / (double )(1 << 16))
|
---|
| 1482 | GETFLOATSIGN(eph._clock_bias, 31, 1.0 / (double )(1 << 30) / (double )(1 << 4))
|
---|
[8161] | 1483 | GETFLOATSIGN(eph._Crs, 16, 1.0 / (double )(1 << 5))
|
---|
[6812] | 1484 | GETFLOATSIGN(eph._Delta_n, 16, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 1485 | GETFLOATSIGN(eph._M0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[8161] | 1486 | GETFLOATSIGN(eph._Cuc, 16, 1.0 / (double )(1 << 29))
|
---|
| 1487 | GETFLOAT(eph._e, 32, 1.0 / (double )(1 << 30) / (double )(1 << 3))
|
---|
| 1488 | GETFLOATSIGN(eph._Cus, 16, 1.0 / (double )(1 << 29))
|
---|
| 1489 | GETFLOAT(eph._sqrt_A, 32, 1.0 / (double )(1 << 19))
|
---|
[6812] | 1490 | GETBITSFACTOR(eph._TOEsec, 14, 60)
|
---|
| 1491 | /* FIXME: overwrite value, copied from old code */
|
---|
| 1492 | eph._TOEsec = eph._TOC.gpssec();
|
---|
[8161] | 1493 | GETFLOATSIGN(eph._Cic, 16, 1.0 / (double )(1 << 29))
|
---|
[6812] | 1494 | GETFLOATSIGN(eph._OMEGA0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[8161] | 1495 | GETFLOATSIGN(eph._Cis, 16, 1.0 / (double )(1 << 29))
|
---|
[6812] | 1496 | GETFLOATSIGN(eph._i0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[8161] | 1497 | GETFLOATSIGN(eph._Crc, 16, 1.0 / (double )(1 << 5))
|
---|
[6812] | 1498 | GETFLOATSIGN(eph._omega, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1499 | GETFLOATSIGN(eph._OMEGADOT, 24, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
[8987] | 1500 | GETFLOATSIGN(eph._BGD_1_5A, 10, 1.0 / (double )(1 << 30) / (double )(1 << 2))
|
---|
[8161] | 1501 | if (eph._inav) {
|
---|
[7006] | 1502 | /* set unused F/NAV values */
|
---|
[6812] | 1503 | eph._E5aHS = 0.0;
|
---|
| 1504 | eph._e5aDataInValid = false;
|
---|
| 1505 |
|
---|
[9193] | 1506 | GETFLOATSIGN(eph._BGD_1_5B, 10, 1.0 / (double )(1 << 30) / (double )(1 << 2))
|
---|
[6812] | 1507 | GETBITS(eph._E5bHS, 2)
|
---|
| 1508 | GETBITS(eph._e5bDataInValid, 1)
|
---|
| 1509 | GETBITS(eph._E1_bHS, 2)
|
---|
| 1510 | GETBITS(eph._e1DataInValid, 1)
|
---|
[9193] | 1511 | if (eph._E5bHS != eph._E1_bHS) {
|
---|
[9209] | 1512 | #ifdef BNC_DEBUG_BCEP
|
---|
[9205] | 1513 | emit(newMessage(QString("%1: Block %2 (%3) SHS E5b %4 E1B %5: inconsistent health!")
|
---|
| 1514 | .arg(_staID).arg(1046,4).arg(eph._prn.toString().c_str())
|
---|
| 1515 | .arg(eph._E5bHS).arg(eph._E1_bHS).toAscii(), true));
|
---|
[9209] | 1516 | #endif
|
---|
[9193] | 1517 | return false;
|
---|
| 1518 | }
|
---|
| 1519 | if ((eph._BGD_1_5A == 0.0 && fabs(eph._BGD_1_5B) > 1e-9) ||
|
---|
| 1520 | (eph._BGD_1_5B == 0.0 && fabs(eph._BGD_1_5A) > 1e-9)) {
|
---|
[9209] | 1521 | #ifdef BNC_DEBUG_BCEP
|
---|
[9205] | 1522 | emit(newMessage(QString("%1: Block %2 (%3) BGD_15a = %4 BGD_15b = %5: inconsistent BGD!")
|
---|
| 1523 | .arg(_staID).arg(1046,4).arg(eph._prn.toString().c_str())
|
---|
| 1524 | .arg(eph._BGD_1_5A,10,'E',3).arg(eph._BGD_1_5B,10,'E',3).toAscii(), true));
|
---|
[9209] | 1525 | #endif
|
---|
[9193] | 1526 | return false;
|
---|
| 1527 | }
|
---|
[6812] | 1528 | }
|
---|
[8161] | 1529 | else {
|
---|
[7006] | 1530 | /* set unused I/NAV values */
|
---|
[6812] | 1531 | eph._BGD_1_5B = 0.0;
|
---|
| 1532 | eph._E5bHS = 0.0;
|
---|
| 1533 | eph._E1_bHS = 0.0;
|
---|
| 1534 | eph._e1DataInValid = false;
|
---|
| 1535 | eph._e5bDataInValid = false;
|
---|
| 1536 |
|
---|
| 1537 | GETBITS(eph._E5aHS, 2)
|
---|
| 1538 | GETBITS(eph._e5aDataInValid, 1)
|
---|
| 1539 | }
|
---|
| 1540 | eph._TOT = 0.9999e9;
|
---|
| 1541 |
|
---|
[9205] | 1542 | if (eph._sqrt_A < 1000.0) {
|
---|
[9209] | 1543 | #ifdef BNC_DEBUG_BCEP
|
---|
[9205] | 1544 | emit(newMessage(QString("%1: Block %2 (%3) SQRT_A %4 m!")
|
---|
| 1545 | .arg(_staID).arg(eph._inav? 1046 : 1045,4).arg(eph._prn.toString().c_str())
|
---|
| 1546 | .arg(eph._sqrt_A,10,'F',3).toLatin1(), true));
|
---|
[9209] | 1547 | #endif
|
---|
[9205] | 1548 | return false;
|
---|
| 1549 | }
|
---|
| 1550 |
|
---|
[6812] | 1551 | emit newGalileoEph(eph);
|
---|
| 1552 | decoded = true;
|
---|
| 1553 | }
|
---|
| 1554 | return decoded;
|
---|
| 1555 | }
|
---|
| 1556 |
|
---|
| 1557 | //
|
---|
| 1558 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8161] | 1559 | bool RTCM3Decoder::DecodeBDSEphemeris(unsigned char* data, int size) {
|
---|
[6812] | 1560 | bool decoded = false;
|
---|
| 1561 |
|
---|
[8161] | 1562 | if (size == 70) {
|
---|
[6812] | 1563 | t_ephBDS eph;
|
---|
| 1564 | int i;
|
---|
| 1565 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 1566 |
|
---|
| 1567 | data += 3; /* header */
|
---|
| 1568 | size -= 6; /* header + crc */
|
---|
| 1569 | SKIPBITS(12)
|
---|
| 1570 |
|
---|
| 1571 | eph._receptDateTime = currentDateAndTimeGPS();
|
---|
[9216] | 1572 | eph._receptStaID = _staID;
|
---|
[9286] | 1573 |
|
---|
[6812] | 1574 | GETBITS(i, 6)
|
---|
| 1575 | eph._prn.set('C', i);
|
---|
| 1576 |
|
---|
[8161] | 1577 | SKIPBITS(13)
|
---|
| 1578 | /* week */
|
---|
[6812] | 1579 | GETBITS(i, 4)
|
---|
| 1580 | eph._URA = accuracyFromIndex(i, eph.type());
|
---|
| 1581 | GETFLOATSIGN(eph._IDOT, 14, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 1582 | GETBITS(eph._AODE, 5)
|
---|
| 1583 | GETBITS(i, 17)
|
---|
| 1584 | i <<= 3;
|
---|
[8161] | 1585 | eph._TOC.setBDS(i * 1000);
|
---|
[8805] | 1586 | GETFLOATSIGN(eph._clock_driftrate, 11, 1.0 / (double )(1 << 30) / (double )(1 << 30) / (double )(1 << 6))
|
---|
| 1587 | GETFLOATSIGN(eph._clock_drift, 22, 1.0 / (double )(1 << 30) / (double )(1 << 20))
|
---|
| 1588 | GETFLOATSIGN(eph._clock_bias, 24, 1.0 / (double )(1 << 30) / (double )(1 << 3))
|
---|
[6812] | 1589 | GETBITS(eph._AODC, 5)
|
---|
[8161] | 1590 | GETFLOATSIGN(eph._Crs, 18, 1.0 / (double )(1 << 6))
|
---|
[6812] | 1591 | GETFLOATSIGN(eph._Delta_n, 16, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 1592 | GETFLOATSIGN(eph._M0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[8161] | 1593 | GETFLOATSIGN(eph._Cuc, 18, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
| 1594 | GETFLOAT(eph._e, 32, 1.0 / (double )(1 << 30) / (double )(1 << 3))
|
---|
| 1595 | GETFLOATSIGN(eph._Cus, 18, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
| 1596 | GETFLOAT(eph._sqrt_A, 32, 1.0 / (double )(1 << 19))
|
---|
[9205] | 1597 | if (eph._sqrt_A < 1000.0) {
|
---|
[9209] | 1598 | #ifdef BNC_DEBUG_BCEP
|
---|
[9205] | 1599 | emit(newMessage(QString("%1: Block %2 (%3) SQRT_A %4 m!")
|
---|
| 1600 | .arg(_staID).arg(1042,4).arg(eph._prn.toString().c_str())
|
---|
| 1601 | .arg(eph._sqrt_A,10,'F',3).toAscii(), true));
|
---|
[9209] | 1602 | #endif
|
---|
[9205] | 1603 | return false;
|
---|
| 1604 | }
|
---|
| 1605 | GETBITS(i, 17)
|
---|
[6812] | 1606 | i <<= 3;
|
---|
| 1607 | eph._TOEsec = i;
|
---|
[8161] | 1608 | eph._TOE.setBDS(i * 1000);
|
---|
| 1609 | GETFLOATSIGN(eph._Cic, 18, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
[6812] | 1610 | GETFLOATSIGN(eph._OMEGA0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[8161] | 1611 | GETFLOATSIGN(eph._Cis, 18, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
[6812] | 1612 | GETFLOATSIGN(eph._i0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[8161] | 1613 | GETFLOATSIGN(eph._Crc, 18, 1.0 / (double )(1 << 6))
|
---|
[6812] | 1614 | GETFLOATSIGN(eph._omega, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1615 | GETFLOATSIGN(eph._OMEGADOT, 24, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 1616 | GETFLOATSIGN(eph._TGD1, 10, 0.0000000001)
|
---|
| 1617 | GETFLOATSIGN(eph._TGD2, 10, 0.0000000001)
|
---|
| 1618 | GETBITS(eph._SatH1, 1)
|
---|
| 1619 |
|
---|
[8455] | 1620 | eph._TOT = 0.9999E9;
|
---|
[6812] | 1621 | emit newBDSEph(eph);
|
---|
| 1622 | decoded = true;
|
---|
| 1623 | }
|
---|
| 1624 | return decoded;
|
---|
| 1625 | }
|
---|
| 1626 |
|
---|
| 1627 | //
|
---|
| 1628 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8200] | 1629 | bool RTCM3Decoder::DecodeAntennaReceiver(unsigned char* data, int size) {
|
---|
| 1630 | char *antenna, anttype[256];
|
---|
| 1631 | char *dummy;
|
---|
| 1632 | char *receiver, rectype[256];
|
---|
| 1633 |
|
---|
| 1634 | int type;
|
---|
| 1635 |
|
---|
| 1636 | int dnum = -1;
|
---|
[7875] | 1637 | int antnum = -1;
|
---|
[8200] | 1638 | int recnum = -1;
|
---|
[6812] | 1639 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 1640 |
|
---|
[8200] | 1641 | data += 3; /* header*/
|
---|
[6812] | 1642 | size -= 6; /* header + crc */
|
---|
| 1643 |
|
---|
[8200] | 1644 | GETBITS(type, 12)
|
---|
[6812] | 1645 | SKIPBITS(12)
|
---|
[7873] | 1646 | GETSTRING(antnum, antenna)
|
---|
[7875] | 1647 | if (antnum > -1 && antnum < 265) {
|
---|
[8200] | 1648 | memcpy(anttype, antenna, antnum);
|
---|
| 1649 | anttype[antnum] = 0;
|
---|
| 1650 | if (!_antType.contains(anttype)) {
|
---|
| 1651 | _antType.push_back(anttype);
|
---|
[7875] | 1652 | }
|
---|
[7873] | 1653 | }
|
---|
[8200] | 1654 | if (type == 1033) {
|
---|
| 1655 | SKIPBITS(8)
|
---|
| 1656 | GETSTRING(dnum, dummy)
|
---|
| 1657 | GETSTRING(recnum, receiver)
|
---|
| 1658 | if (recnum > -1 && recnum < 265) {
|
---|
| 1659 | memcpy(rectype, receiver, recnum);
|
---|
| 1660 | rectype[recnum] = 0;
|
---|
| 1661 | if (!_recType.contains(rectype)) {
|
---|
| 1662 | _recType.push_back(rectype);
|
---|
| 1663 | }
|
---|
| 1664 | }
|
---|
| 1665 | }
|
---|
[6812] | 1666 | return true;
|
---|
| 1667 | }
|
---|
| 1668 |
|
---|
| 1669 | //
|
---|
| 1670 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8161] | 1671 | bool RTCM3Decoder::DecodeAntennaPosition(unsigned char* data, int size) {
|
---|
[6812] | 1672 | int type;
|
---|
| 1673 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 1674 | double x, y, z;
|
---|
| 1675 |
|
---|
| 1676 | data += 3; /* header */
|
---|
| 1677 | size -= 6; /* header + crc */
|
---|
| 1678 |
|
---|
| 1679 | GETBITS(type, 12)
|
---|
| 1680 | _antList.push_back(t_antInfo());
|
---|
| 1681 | _antList.back().type = t_antInfo::ARP;
|
---|
| 1682 | SKIPBITS(22)
|
---|
| 1683 | GETBITSSIGN(x, 38)
|
---|
| 1684 | _antList.back().xx = x * 1e-4;
|
---|
| 1685 | SKIPBITS(2)
|
---|
| 1686 | GETBITSSIGN(y, 38)
|
---|
| 1687 | _antList.back().yy = y * 1e-4;
|
---|
| 1688 | SKIPBITS(2)
|
---|
| 1689 | GETBITSSIGN(z, 38)
|
---|
| 1690 | _antList.back().zz = z * 1e-4;
|
---|
[8161] | 1691 | if (type == 1006)
|
---|
| 1692 | {
|
---|
[6812] | 1693 | double h;
|
---|
| 1694 | GETBITS(h, 16)
|
---|
| 1695 | _antList.back().height = h * 1e-4;
|
---|
| 1696 | _antList.back().height_f = true;
|
---|
| 1697 | }
|
---|
[8161] | 1698 | _antList.back().message = type;
|
---|
[6812] | 1699 |
|
---|
| 1700 | return true;
|
---|
| 1701 | }
|
---|
| 1702 |
|
---|
[7753] | 1703 | //
|
---|
[6812] | 1704 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8161] | 1705 | t_irc RTCM3Decoder::Decode(char* buffer, int bufLen, vector<string>& errmsg) {
|
---|
[6812] | 1706 | bool decoded = false;
|
---|
| 1707 |
|
---|
| 1708 | errmsg.clear();
|
---|
| 1709 |
|
---|
[8161] | 1710 | while (bufLen && _MessageSize < sizeof(_Message)) {
|
---|
[6812] | 1711 | int l = sizeof(_Message) - _MessageSize;
|
---|
[8161] | 1712 | if (l > bufLen)
|
---|
[6812] | 1713 | l = bufLen;
|
---|
[8161] | 1714 | memcpy(_Message + _MessageSize, buffer, l);
|
---|
[6812] | 1715 | _MessageSize += l;
|
---|
| 1716 | bufLen -= l;
|
---|
| 1717 | buffer += l;
|
---|
| 1718 | int id;
|
---|
[8161] | 1719 | while ((id = GetMessage())) {
|
---|
[6812] | 1720 | /* reset station ID for file loading as it can change */
|
---|
[8161] | 1721 | if (_rawFile)
|
---|
[6812] | 1722 | _staID = _rawFile->staID();
|
---|
| 1723 | /* store the id into the list of loaded blocks */
|
---|
| 1724 | _typeList.push_back(id);
|
---|
| 1725 |
|
---|
[6856] | 1726 | /* SSR I+II data handled in another function, already pass the
|
---|
[6812] | 1727 | * extracted data block. That does no harm, as it anyway skip everything
|
---|
| 1728 | * else. */
|
---|
[9001] | 1729 | if ((id >= 1057 && id <= 1068) ||
|
---|
[9036] | 1730 | (id >= 1240 && id <= 1270) ||
|
---|
| 1731 | (id == 4076)) {
|
---|
[9049] | 1732 | if (!_coDecoders.contains(_staID.toLatin1())) {
|
---|
| 1733 | _coDecoders[_staID.toLatin1()] = new RTCM3coDecoder(_staID);
|
---|
[9307] | 1734 | if (id == 4076) {
|
---|
| 1735 | _coDecoders[_staID.toLatin1()]->initSsrFormatType(RTCM3coDecoder::IGSssr);
|
---|
| 1736 | }
|
---|
| 1737 | else {
|
---|
| 1738 | _coDecoders[_staID.toLatin1()]->initSsrFormatType(RTCM3coDecoder::RTCMssr);
|
---|
| 1739 | }
|
---|
[9049] | 1740 | }
|
---|
| 1741 | RTCM3coDecoder* coDecoder = _coDecoders[_staID.toLatin1()];
|
---|
[9307] | 1742 | if (coDecoder->Decode(reinterpret_cast<char *>(_Message), _BlockSize, errmsg) == success) {
|
---|
[6812] | 1743 | decoded = true;
|
---|
| 1744 | }
|
---|
| 1745 | }
|
---|
[9307] | 1746 | else if (id >= 1070 && id <= 1237) { /* MSM */
|
---|
[8161] | 1747 | if (DecodeRTCM3MSM(_Message, _BlockSize))
|
---|
[6812] | 1748 | decoded = true;
|
---|
| 1749 | }
|
---|
[8161] | 1750 | else {
|
---|
| 1751 | switch (id) {
|
---|
| 1752 | case 1001:
|
---|
| 1753 | case 1003:
|
---|
[9209] | 1754 | emit(newMessage(QString("%1: Block %2 contain partial data! Ignored!")
|
---|
| 1755 | .arg(_staID).arg(id).toAscii(), true));
|
---|
[8161] | 1756 | break; /* no use decoding partial data ATM, remove break when data can be used */
|
---|
| 1757 | case 1002:
|
---|
| 1758 | case 1004:
|
---|
| 1759 | if (DecodeRTCM3GPS(_Message, _BlockSize))
|
---|
| 1760 | decoded = true;
|
---|
| 1761 | break;
|
---|
| 1762 | case 1009:
|
---|
| 1763 | case 1011:
|
---|
[9209] | 1764 | emit(newMessage(QString("%1: Block %2 contain partial data! Ignored!")
|
---|
| 1765 | .arg(_staID).arg(id).toAscii(), true));
|
---|
[8161] | 1766 | break; /* no use decoding partial data ATM, remove break when data can be used */
|
---|
| 1767 | case 1010:
|
---|
| 1768 | case 1012:
|
---|
| 1769 | if (DecodeRTCM3GLONASS(_Message, _BlockSize))
|
---|
| 1770 | decoded = true;
|
---|
| 1771 | break;
|
---|
| 1772 | case 1019:
|
---|
| 1773 | if (DecodeGPSEphemeris(_Message, _BlockSize))
|
---|
| 1774 | decoded = true;
|
---|
| 1775 | break;
|
---|
| 1776 | case 1020:
|
---|
| 1777 | if (DecodeGLONASSEphemeris(_Message, _BlockSize))
|
---|
| 1778 | decoded = true;
|
---|
| 1779 | break;
|
---|
| 1780 | case 1043:
|
---|
| 1781 | if (DecodeSBASEphemeris(_Message, _BlockSize))
|
---|
| 1782 | decoded = true;
|
---|
| 1783 | break;
|
---|
| 1784 | case 1044:
|
---|
| 1785 | if (DecodeQZSSEphemeris(_Message, _BlockSize))
|
---|
| 1786 | decoded = true;
|
---|
| 1787 | break;
|
---|
[9003] | 1788 | case 1041:
|
---|
[8805] | 1789 | if (DecodeIRNSSEphemeris(_Message, _BlockSize))
|
---|
| 1790 | decoded = true;
|
---|
[8843] | 1791 | break;
|
---|
[8161] | 1792 | case 1045:
|
---|
| 1793 | case 1046:
|
---|
| 1794 | if (DecodeGalileoEphemeris(_Message, _BlockSize))
|
---|
| 1795 | decoded = true;
|
---|
| 1796 | break;
|
---|
[9001] | 1797 | case 1042:
|
---|
[8161] | 1798 | if (DecodeBDSEphemeris(_Message, _BlockSize))
|
---|
| 1799 | decoded = true;
|
---|
| 1800 | break;
|
---|
| 1801 | case 1007:
|
---|
| 1802 | case 1008:
|
---|
| 1803 | case 1033:
|
---|
[8200] | 1804 | DecodeAntennaReceiver(_Message, _BlockSize);
|
---|
[8161] | 1805 | break;
|
---|
| 1806 | case 1005:
|
---|
| 1807 | case 1006:
|
---|
| 1808 | DecodeAntennaPosition(_Message, _BlockSize);
|
---|
| 1809 | break;
|
---|
[296] | 1810 | }
|
---|
| 1811 | }
|
---|
| 1812 | }
|
---|
[6812] | 1813 | }
|
---|
| 1814 | return decoded ? success : failure;
|
---|
[8161] | 1815 | }
|
---|
| 1816 | ;
|
---|
[6812] | 1817 |
|
---|
[7753] | 1818 | //
|
---|
[6812] | 1819 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8161] | 1820 | uint32_t RTCM3Decoder::CRC24(long size, const unsigned char *buf) {
|
---|
[6812] | 1821 | uint32_t crc = 0;
|
---|
[9205] | 1822 | int ii;
|
---|
[9307] | 1823 | while (size--) {
|
---|
[6812] | 1824 | crc ^= (*buf++) << (16);
|
---|
[9205] | 1825 | for (ii = 0; ii < 8; ii++) {
|
---|
[6812] | 1826 | crc <<= 1;
|
---|
[8161] | 1827 | if (crc & 0x1000000)
|
---|
[6812] | 1828 | crc ^= 0x01864cfb;
|
---|
[1021] | 1829 | }
|
---|
[296] | 1830 | }
|
---|
[6812] | 1831 | return crc;
|
---|
| 1832 | }
|
---|
[1021] | 1833 |
|
---|
[7753] | 1834 | //
|
---|
[6812] | 1835 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8161] | 1836 | int RTCM3Decoder::GetMessage(void) {
|
---|
[6812] | 1837 | unsigned char *m, *e;
|
---|
| 1838 | int i;
|
---|
| 1839 |
|
---|
[8161] | 1840 | m = _Message + _SkipBytes;
|
---|
| 1841 | e = _Message + _MessageSize;
|
---|
[6812] | 1842 | _NeedBytes = _SkipBytes = 0;
|
---|
[8161] | 1843 | while (e - m >= 3) {
|
---|
| 1844 | if (m[0] == 0xD3) {
|
---|
| 1845 | _BlockSize = ((m[1] & 3) << 8) | m[2];
|
---|
| 1846 | if (e - m >= static_cast<int>(_BlockSize + 6)) {
|
---|
| 1847 | if (static_cast<uint32_t>((m[3 + _BlockSize] << 16)
|
---|
| 1848 | | (m[3 + _BlockSize + 1] << 8)
|
---|
| 1849 | | (m[3 + _BlockSize + 2])) == CRC24(_BlockSize + 3, m)) {
|
---|
| 1850 | _BlockSize += 6;
|
---|
[6812] | 1851 | _SkipBytes = _BlockSize;
|
---|
| 1852 | break;
|
---|
| 1853 | }
|
---|
| 1854 | else
|
---|
| 1855 | ++m;
|
---|
| 1856 | }
|
---|
[8161] | 1857 | else {
|
---|
[6812] | 1858 | _NeedBytes = _BlockSize;
|
---|
| 1859 | break;
|
---|
| 1860 | }
|
---|
| 1861 | }
|
---|
| 1862 | else
|
---|
| 1863 | ++m;
|
---|
[658] | 1864 | }
|
---|
[8161] | 1865 | if (e - m < 3)
|
---|
[6812] | 1866 | _NeedBytes = 3;
|
---|
| 1867 |
|
---|
| 1868 | /* copy buffer to front */
|
---|
| 1869 | i = m - _Message;
|
---|
[8161] | 1870 | if (i && m < e)
|
---|
| 1871 | memmove(_Message, m, static_cast<size_t>(_MessageSize - i));
|
---|
[6812] | 1872 | _MessageSize -= i;
|
---|
| 1873 |
|
---|
[8161] | 1874 | return !_NeedBytes ? ((_Message[3] << 4) | (_Message[4] >> 4)) : 0;
|
---|
[296] | 1875 | }
|
---|
[1807] | 1876 |
|
---|
[3001] | 1877 | // Time of Corrections
|
---|
| 1878 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 1879 | int RTCM3Decoder::corrGPSEpochTime() const {
|
---|
[8161] | 1880 | return
|
---|
| 1881 | _coDecoders.size() > 0 ?
|
---|
| 1882 | _coDecoders.begin().value()->corrGPSEpochTime() : -1;
|
---|
[3001] | 1883 | }
|
---|