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