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