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