[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"
|
---|
[10534] | 55 | #include "bnctime.h"
|
---|
| 56 | #include "crs.h"
|
---|
[296] | 57 |
|
---|
| 58 | using namespace std;
|
---|
| 59 |
|
---|
[320] | 60 | // Error Handling
|
---|
| 61 | ////////////////////////////////////////////////////////////////////////////
|
---|
[504] | 62 | void RTCM3Error(const char*, ...) {
|
---|
[505] | 63 | }
|
---|
[320] | 64 |
|
---|
[296] | 65 | // Constructor
|
---|
| 66 | ////////////////////////////////////////////////////////////////////////////
|
---|
[7753] | 67 | RTCM3Decoder::RTCM3Decoder(const QString& staID, bncRawFile* rawFile) :
|
---|
[8158] | 68 | GPSDecoder() {
|
---|
[505] | 69 |
|
---|
[8158] | 70 | _staID = staID;
|
---|
[2527] | 71 | _rawFile = rawFile;
|
---|
[2387] | 72 |
|
---|
[8158] | 73 | connect(this, SIGNAL(newGPSEph(t_ephGPS)), BNC_CORE,
|
---|
| 74 | SLOT(slotNewGPSEph(t_ephGPS)));
|
---|
| 75 | connect(this, SIGNAL(newGlonassEph(t_ephGlo)), BNC_CORE,
|
---|
| 76 | SLOT(slotNewGlonassEph(t_ephGlo)));
|
---|
| 77 | connect(this, SIGNAL(newGalileoEph(t_ephGal)), BNC_CORE,
|
---|
| 78 | SLOT(slotNewGalileoEph(t_ephGal)));
|
---|
| 79 | connect(this, SIGNAL(newSBASEph(t_ephSBAS)), BNC_CORE,
|
---|
| 80 | SLOT(slotNewSBASEph(t_ephSBAS)));
|
---|
| 81 | connect(this, SIGNAL(newBDSEph(t_ephBDS)), BNC_CORE,
|
---|
| 82 | SLOT(slotNewBDSEph(t_ephBDS)));
|
---|
[939] | 83 |
|
---|
[6812] | 84 | _MessageSize = _SkipBytes = _BlockSize = _NeedBytes = 0;
|
---|
[296] | 85 | }
|
---|
| 86 |
|
---|
| 87 | // Destructor
|
---|
| 88 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 89 | RTCM3Decoder::~RTCM3Decoder() {
|
---|
[3001] | 90 | QMapIterator<QByteArray, RTCM3coDecoder*> it(_coDecoders);
|
---|
[10234] | 91 | while (it.hasNext()) {
|
---|
[3008] | 92 | it.next();
|
---|
| 93 | delete it.value();
|
---|
[3001] | 94 | }
|
---|
[10234] | 95 | _coDecoders.clear();
|
---|
[296] | 96 | }
|
---|
| 97 |
|
---|
[7753] | 98 | //
|
---|
[296] | 99 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 100 | bool RTCM3Decoder::DecodeRTCM3GPS(unsigned char* data, int size) {
|
---|
[6812] | 101 | bool decoded = false;
|
---|
| 102 | bncTime CurrentObsTime;
|
---|
| 103 | int i, numsats, syncf, type;
|
---|
| 104 | uint64_t numbits = 0, bitfield = 0;
|
---|
[508] | 105 |
|
---|
[6812] | 106 | data += 3; /* header */
|
---|
| 107 | size -= 6; /* header + crc */
|
---|
[1218] | 108 |
|
---|
[6812] | 109 | GETBITS(type, 12)
|
---|
[8158] | 110 | SKIPBITS(12)
|
---|
| 111 | /* id */
|
---|
| 112 | GETBITS(i, 30)
|
---|
[8159] | 113 |
|
---|
[8158] | 114 | CurrentObsTime.set(i);
|
---|
| 115 | if (_CurrentTime.valid() && CurrentObsTime != _CurrentTime) {
|
---|
[6812] | 116 | decoded = true;
|
---|
[8164] | 117 | _obsList.append(_CurrentObsList);
|
---|
[6812] | 118 | _CurrentObsList.clear();
|
---|
[2551] | 119 | }
|
---|
[7753] | 120 |
|
---|
[6812] | 121 | _CurrentTime = CurrentObsTime;
|
---|
[2551] | 122 |
|
---|
[8158] | 123 | GETBITS(syncf, 1)
|
---|
| 124 | /* sync */
|
---|
| 125 | GETBITS(numsats, 5)
|
---|
| 126 | SKIPBITS(4)
|
---|
| 127 | /* smind, smint */
|
---|
[3002] | 128 |
|
---|
[8158] | 129 | while (numsats--) {
|
---|
| 130 | int sv, code, l1range, amb = 0;
|
---|
[6812] | 131 | t_satObs CurrentObs;
|
---|
| 132 | CurrentObs._time = CurrentObsTime;
|
---|
[9541] | 133 | CurrentObs._type = type;
|
---|
[6812] | 134 |
|
---|
| 135 | GETBITS(sv, 6)
|
---|
[8158] | 136 | if (sv < 40)
|
---|
[6812] | 137 | CurrentObs._prn.set('G', sv);
|
---|
| 138 | else
|
---|
[8158] | 139 | CurrentObs._prn.set('S', sv - 20);
|
---|
[6812] | 140 |
|
---|
| 141 | t_frqObs *frqObs = new t_frqObs;
|
---|
| 142 | /* L1 */
|
---|
| 143 | GETBITS(code, 1);
|
---|
[8158] | 144 | (code) ?
|
---|
| 145 | frqObs->_rnxType2ch.assign("1W") : frqObs->_rnxType2ch.assign("1C");
|
---|
[6812] | 146 | GETBITS(l1range, 24);
|
---|
| 147 | GETBITSSIGN(i, 20);
|
---|
[8158] | 148 | if ((i & ((1 << 20) - 1)) != 0x80000) {
|
---|
| 149 | frqObs->_code = l1range * 0.02;
|
---|
| 150 | frqObs->_phase = (l1range * 0.02 + i * 0.0005) / GPS_WAVELENGTH_L1;
|
---|
[6812] | 151 | frqObs->_codeValid = frqObs->_phaseValid = true;
|
---|
[3002] | 152 | }
|
---|
[9088] | 153 | GETBITS(frqObs->_lockTimeIndicator, 7);
|
---|
| 154 | frqObs->_lockTime = lti2sec(type, frqObs->_lockTimeIndicator);
|
---|
[8617] | 155 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0 && frqObs->_phaseValid);
|
---|
[8158] | 156 | if (type == 1002 || type == 1004) {
|
---|
| 157 | GETBITS(amb, 8);
|
---|
| 158 | if (amb) {
|
---|
| 159 | frqObs->_code += amb * 299792.458;
|
---|
| 160 | frqObs->_phase += (amb * 299792.458) / GPS_WAVELENGTH_L1;
|
---|
[1021] | 161 | }
|
---|
[6812] | 162 | GETBITS(i, 8);
|
---|
[8158] | 163 | if (i) {
|
---|
| 164 | frqObs->_snr = i * 0.25;
|
---|
[6812] | 165 | frqObs->_snrValid = true;
|
---|
| 166 | }
|
---|
[1021] | 167 | }
|
---|
[6812] | 168 | CurrentObs._obs.push_back(frqObs);
|
---|
[8158] | 169 | if (type == 1003 || type == 1004) {
|
---|
[6812] | 170 | frqObs = new t_frqObs;
|
---|
| 171 | /* L2 */
|
---|
[8158] | 172 | GETBITS(code, 2);
|
---|
| 173 | switch (code) {
|
---|
| 174 | case 3:
|
---|
| 175 | frqObs->_rnxType2ch.assign("2W"); /* or "2Y"? */
|
---|
| 176 | break;
|
---|
| 177 | case 2:
|
---|
| 178 | frqObs->_rnxType2ch.assign("2W");
|
---|
| 179 | break;
|
---|
| 180 | case 1:
|
---|
| 181 | frqObs->_rnxType2ch.assign("2P");
|
---|
| 182 | break;
|
---|
| 183 | case 0:
|
---|
| 184 | frqObs->_rnxType2ch.assign("2X"); /* or "2S" or "2L"? */
|
---|
| 185 | break;
|
---|
[6812] | 186 | }
|
---|
[8158] | 187 | GETBITSSIGN(i, 14);
|
---|
| 188 | if ((i & ((1 << 14) - 1)) != 0x2000) {
|
---|
| 189 | frqObs->_code = l1range * 0.02 + i * 0.02 + amb * 299792.458;
|
---|
[6812] | 190 | frqObs->_codeValid = true;
|
---|
| 191 | }
|
---|
[8158] | 192 | GETBITSSIGN(i, 20);
|
---|
| 193 | if ((i & ((1 << 20) - 1)) != 0x80000) {
|
---|
| 194 | frqObs->_phase = (l1range * 0.02 + i * 0.0005 + amb * 299792.458)
|
---|
| 195 | / GPS_WAVELENGTH_L2;
|
---|
[6812] | 196 | frqObs->_phaseValid = true;
|
---|
| 197 | }
|
---|
[9088] | 198 | GETBITS(frqObs->_lockTimeIndicator, 7);
|
---|
| 199 | frqObs->_lockTime = lti2sec(type, frqObs->_lockTimeIndicator);
|
---|
[8682] | 200 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0 && frqObs->_phaseValid);
|
---|
[8158] | 201 | if (type == 1004) {
|
---|
[6812] | 202 | GETBITS(i, 8);
|
---|
[8158] | 203 | if (i) {
|
---|
| 204 | frqObs->_snr = i * 0.25;
|
---|
[6812] | 205 | frqObs->_snrValid = true;
|
---|
| 206 | }
|
---|
| 207 | }
|
---|
| 208 | CurrentObs._obs.push_back(frqObs);
|
---|
| 209 | }
|
---|
| 210 | _CurrentObsList.push_back(CurrentObs);
|
---|
[913] | 211 | }
|
---|
[7753] | 212 |
|
---|
[8158] | 213 | if (!syncf) {
|
---|
[6812] | 214 | decoded = true;
|
---|
[7753] | 215 | _obsList.append(_CurrentObsList);
|
---|
[6812] | 216 | _CurrentTime.reset();
|
---|
| 217 | _CurrentObsList.clear();
|
---|
[2527] | 218 | }
|
---|
[6812] | 219 | return decoded;
|
---|
| 220 | }
|
---|
[2527] | 221 |
|
---|
[6812] | 222 | #define RTCM3_MSM_NUMSIG 32
|
---|
| 223 | #define RTCM3_MSM_NUMSAT 64
|
---|
| 224 | #define RTCM3_MSM_NUMCELLS 96 /* arbitrary limit */
|
---|
[1127] | 225 |
|
---|
[6812] | 226 | /**
|
---|
| 227 | * Frequency numbers of GLONASS with an offset of 100 to detect unset values.
|
---|
| 228 | * Gets filled by ephemeris and data blocks and shared between different streams.
|
---|
| 229 | */
|
---|
| 230 | static int GLOFreq[RTCM3_MSM_NUMSAT];
|
---|
[1127] | 231 |
|
---|
[6812] | 232 | /*
|
---|
| 233 | * Storage structure to store frequency and RINEX ID assignment for MSM
|
---|
| 234 | * message */
|
---|
| 235 | struct CodeData {
|
---|
| 236 | double wl;
|
---|
| 237 | const char *code; /* currently unused */
|
---|
| 238 | };
|
---|
[2677] | 239 |
|
---|
[6812] | 240 | /** MSM signal types for GPS and SBAS */
|
---|
[8158] | 241 | static struct CodeData gps[RTCM3_MSM_NUMSIG] = {
|
---|
| 242 | {0.0, 0},
|
---|
| 243 | {GPS_WAVELENGTH_L1, "1C"},
|
---|
| 244 | {GPS_WAVELENGTH_L1, "1P"},
|
---|
| 245 | {GPS_WAVELENGTH_L1, "1W"},
|
---|
| 246 | {0.0, 0},
|
---|
| 247 | {0.0, 0},
|
---|
[8801] | 248 | {0.0, 0},
|
---|
[8158] | 249 | {GPS_WAVELENGTH_L2, "2C"},
|
---|
| 250 | {GPS_WAVELENGTH_L2, "2P"},
|
---|
| 251 | {GPS_WAVELENGTH_L2, "2W"},
|
---|
| 252 | {0.0, 0},
|
---|
| 253 | {0.0, 0},
|
---|
| 254 | {0.0, 0},
|
---|
[8801] | 255 | {0.0, 0},
|
---|
[8158] | 256 | {GPS_WAVELENGTH_L2, "2S"},
|
---|
| 257 | {GPS_WAVELENGTH_L2, "2L"},
|
---|
| 258 | {GPS_WAVELENGTH_L2, "2X"},
|
---|
| 259 | {0.0, 0},
|
---|
| 260 | {0.0, 0},
|
---|
| 261 | {0.0, 0},
|
---|
| 262 | {0.0, 0},
|
---|
| 263 | {GPS_WAVELENGTH_L5, "5I"},
|
---|
| 264 | {GPS_WAVELENGTH_L5, "5Q"},
|
---|
| 265 | {GPS_WAVELENGTH_L5, "5X"},
|
---|
| 266 | {0.0, 0},
|
---|
| 267 | {0.0, 0},
|
---|
| 268 | {0.0, 0},
|
---|
| 269 | {0.0, 0},
|
---|
| 270 | {0.0, 0},
|
---|
| 271 | {GPS_WAVELENGTH_L1, "1S"},
|
---|
| 272 | {GPS_WAVELENGTH_L1, "1L"},
|
---|
| 273 | {GPS_WAVELENGTH_L1, "1X"}
|
---|
| 274 | };
|
---|
[1185] | 275 |
|
---|
[6812] | 276 | /**
|
---|
| 277 | * MSM signal types for GLONASS
|
---|
[7753] | 278 | *
|
---|
[6812] | 279 | * NOTE: Uses 0.0, 1.0 for wavelength as sat index dependence is done later!
|
---|
| 280 | */
|
---|
[8158] | 281 | static struct CodeData glo[RTCM3_MSM_NUMSIG] = {
|
---|
| 282 | {0.0, 0},
|
---|
| 283 | {0.0, "1C"},
|
---|
| 284 | {0.0, "1P"},
|
---|
| 285 | {0.0, 0},
|
---|
| 286 | {0.0, 0},
|
---|
| 287 | {0.0, 0},
|
---|
| 288 | {0.0, 0},
|
---|
| 289 | {1.0, "2C"},
|
---|
| 290 | {1.0, "2P"},
|
---|
[8801] | 291 | {GLO_WAVELENGTH_L1a, "4A"},
|
---|
| 292 | {GLO_WAVELENGTH_L1a, "4B"},
|
---|
| 293 | {GLO_WAVELENGTH_L1a, "4X"},
|
---|
| 294 | {GLO_WAVELENGTH_L2a, "6A"},
|
---|
| 295 | {GLO_WAVELENGTH_L2a, "6B"},
|
---|
| 296 | {GLO_WAVELENGTH_L2a, "6X"},
|
---|
| 297 | {GLO_WAVELENGTH_L3, "3I"},
|
---|
| 298 | {GLO_WAVELENGTH_L3, "3Q"},
|
---|
| 299 | {GLO_WAVELENGTH_L3, "3X"},
|
---|
[8158] | 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 | {0.0, 0}
|
---|
| 314 | };
|
---|
[1130] | 315 |
|
---|
[6812] | 316 | /** MSM signal types for Galileo */
|
---|
[8158] | 317 | static struct CodeData gal[RTCM3_MSM_NUMSIG] = {
|
---|
| 318 | {0.0, 0},
|
---|
[8801] | 319 | {GAL_WAVELENGTH_E1, "1C"},
|
---|
| 320 | {GAL_WAVELENGTH_E1, "1A"},
|
---|
| 321 | {GAL_WAVELENGTH_E1, "1B"},
|
---|
| 322 | {GAL_WAVELENGTH_E1, "1X"},
|
---|
| 323 | {GAL_WAVELENGTH_E1, "1Z"},
|
---|
[8158] | 324 | {0.0, 0},
|
---|
[8801] | 325 | {GAL_WAVELENGTH_E6, "6C"},
|
---|
| 326 | {GAL_WAVELENGTH_E6, "6A"},
|
---|
| 327 | {GAL_WAVELENGTH_E6, "6B"},
|
---|
| 328 | {GAL_WAVELENGTH_E6, "6X"},
|
---|
| 329 | {GAL_WAVELENGTH_E6, "6Z"},
|
---|
[8158] | 330 | {0.0, 0},
|
---|
| 331 | {GAL_WAVELENGTH_E5B, "7I"},
|
---|
| 332 | {GAL_WAVELENGTH_E5B, "7Q"},
|
---|
| 333 | {GAL_WAVELENGTH_E5B, "7X"},
|
---|
| 334 | {0.0, 0},
|
---|
[8801] | 335 | {GAL_WAVELENGTH_E5AB,"8I"},
|
---|
| 336 | {GAL_WAVELENGTH_E5AB,"8Q"},
|
---|
| 337 | {GAL_WAVELENGTH_E5AB,"8X"},
|
---|
[8158] | 338 | {0.0, 0},
|
---|
| 339 | {GAL_WAVELENGTH_E5A, "5I"},
|
---|
| 340 | {GAL_WAVELENGTH_E5A, "5Q"},
|
---|
| 341 | {GAL_WAVELENGTH_E5A, "5X"},
|
---|
| 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},
|
---|
[8801] | 349 | {0.0, 0}
|
---|
[8158] | 350 | };
|
---|
[1185] | 351 |
|
---|
[6812] | 352 | /** MSM signal types for QZSS */
|
---|
[8158] | 353 | static struct CodeData qzss[RTCM3_MSM_NUMSIG] = {
|
---|
| 354 | {0.0, 0},
|
---|
| 355 | {GPS_WAVELENGTH_L1, "1C"},
|
---|
| 356 | {0.0, 0},
|
---|
| 357 | {0.0, 0},
|
---|
| 358 | {0.0, 0},
|
---|
| 359 | {0.0, 0},
|
---|
| 360 | {0.0, 0},
|
---|
[8844] | 361 | {0.0, 0},
|
---|
[8682] | 362 | {QZSS_WAVELENGTH_L6, "6S"},
|
---|
| 363 | {QZSS_WAVELENGTH_L6, "6L"},
|
---|
| 364 | {QZSS_WAVELENGTH_L6, "6X"},
|
---|
[8158] | 365 | {0.0, 0},
|
---|
| 366 | {0.0, 0},
|
---|
| 367 | {0.0, 0},
|
---|
| 368 | {GPS_WAVELENGTH_L2, "2S"},
|
---|
| 369 | {GPS_WAVELENGTH_L2, "2L"},
|
---|
| 370 | {GPS_WAVELENGTH_L2, "2X"},
|
---|
| 371 | {0.0, 0},
|
---|
| 372 | {0.0, 0},
|
---|
| 373 | {0.0, 0},
|
---|
| 374 | {0.0, 0},
|
---|
| 375 | {GPS_WAVELENGTH_L5, "5I"},
|
---|
| 376 | {GPS_WAVELENGTH_L5, "5Q"},
|
---|
| 377 | {GPS_WAVELENGTH_L5, "5X"},
|
---|
| 378 | {0.0, 0},
|
---|
| 379 | {0.0, 0},
|
---|
| 380 | {0.0, 0},
|
---|
| 381 | {0.0, 0},
|
---|
| 382 | {0.0, 0},
|
---|
[8682] | 383 | {GPS_WAVELENGTH_L1, "1S"},
|
---|
| 384 | {GPS_WAVELENGTH_L1, "1L"},
|
---|
[8158] | 385 | {GPS_WAVELENGTH_L1, "1X"}
|
---|
| 386 | };
|
---|
[1185] | 387 |
|
---|
[6812] | 388 | /** MSM signal types for Beidou/BDS */
|
---|
[8158] | 389 | static struct CodeData bds[RTCM3_MSM_NUMSIG] = {
|
---|
| 390 | {0.0, 0},
|
---|
| 391 | {BDS_WAVELENGTH_B1, "2I"},
|
---|
[8682] | 392 | {BDS_WAVELENGTH_B1, "2Q"},
|
---|
| 393 | {BDS_WAVELENGTH_B1, "2X"},
|
---|
[8158] | 394 | {0.0, 0},
|
---|
| 395 | {0.0, 0},
|
---|
| 396 | {0.0, 0},
|
---|
| 397 | {BDS_WAVELENGTH_B3, "6I"},
|
---|
[8682] | 398 | {BDS_WAVELENGTH_B3, "6Q"},
|
---|
| 399 | {BDS_WAVELENGTH_B3, "6X"},
|
---|
[8158] | 400 | {0.0, 0},
|
---|
| 401 | {0.0, 0},
|
---|
| 402 | {0.0, 0},
|
---|
| 403 | {BDS_WAVELENGTH_B2, "7I"},
|
---|
[8682] | 404 | {BDS_WAVELENGTH_B2, "7Q"},
|
---|
| 405 | {BDS_WAVELENGTH_B2, "7X"},
|
---|
[8158] | 406 | {0.0, 0},
|
---|
| 407 | {0.0, 0},
|
---|
| 408 | {0.0, 0},
|
---|
| 409 | {0.0, 0},
|
---|
| 410 | {0.0, 0},
|
---|
[8801] | 411 | {BDS_WAVELENGTH_B2a, "5D"},
|
---|
| 412 | {BDS_WAVELENGTH_B2a, "5P"},
|
---|
| 413 | {BDS_WAVELENGTH_B2a, "5X"},
|
---|
[9000] | 414 | {BDS_WAVELENGTH_B2b, "7D"},
|
---|
[8158] | 415 | {0.0, 0},
|
---|
| 416 | {0.0, 0},
|
---|
| 417 | {0.0, 0},
|
---|
| 418 | {0.0, 0},
|
---|
[8818] | 419 | {BDS_WAVELENGTH_B1C, "1D"},
|
---|
| 420 | {BDS_WAVELENGTH_B1C, "1P"},
|
---|
| 421 | {BDS_WAVELENGTH_B1C, "1X"}
|
---|
[8158] | 422 | };
|
---|
[1807] | 423 |
|
---|
[8844] | 424 | /** MSM signal types for IRNSS */
|
---|
[8783] | 425 | static struct CodeData irn[RTCM3_MSM_NUMSIG] = {
|
---|
| 426 | {0.0, 0},
|
---|
| 427 | {0.0, 0},
|
---|
| 428 | {0.0, 0},
|
---|
| 429 | {0.0, 0},
|
---|
| 430 | {0.0, 0},
|
---|
| 431 | {0.0, 0},
|
---|
| 432 | {0.0, 0},
|
---|
| 433 | {IRNSS_WAVELENGTH_S, "9A"},
|
---|
| 434 | {0.0, 0},
|
---|
| 435 | {0.0, 0},
|
---|
| 436 | {0.0, 0},
|
---|
| 437 | {0.0, 0},
|
---|
| 438 | {0.0, 0},
|
---|
| 439 | {0.0, 0},
|
---|
| 440 | {0.0, 0},
|
---|
| 441 | {0.0, 0},
|
---|
| 442 | {0.0, 0},
|
---|
| 443 | {0.0, 0},
|
---|
| 444 | {0.0, 0},
|
---|
| 445 | {0.0, 0},
|
---|
| 446 | {0.0, 0},
|
---|
| 447 | {IRNSS_WAVELENGTH_L5, "5A"},
|
---|
| 448 | {0.0, 0},
|
---|
| 449 | {0.0, 0},
|
---|
| 450 | {0.0, 0},
|
---|
| 451 | {0.0, 0},
|
---|
| 452 | {0.0, 0},
|
---|
| 453 | {0.0, 0},
|
---|
| 454 | {0.0, 0},
|
---|
| 455 | {0.0, 0},
|
---|
| 456 | {0.0, 0},
|
---|
| 457 | {0.0, 0}
|
---|
| 458 | };
|
---|
| 459 |
|
---|
[6812] | 460 | #define UINT64(c) c ## ULL
|
---|
[1033] | 461 |
|
---|
[7753] | 462 | //
|
---|
[6812] | 463 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8801] | 464 | bool RTCM3Decoder::DecodeRTCM3MSM(unsigned char* data, int size) {
|
---|
[6812] | 465 | bool decoded = false;
|
---|
| 466 | int type, syncf, i;
|
---|
| 467 | uint64_t numbits = 0, bitfield = 0;
|
---|
[1807] | 468 |
|
---|
[6812] | 469 | data += 3; /* header */
|
---|
| 470 | size -= 6; /* header + crc */
|
---|
[1239] | 471 |
|
---|
[6812] | 472 | GETBITS(type, 12)
|
---|
[8158] | 473 | SKIPBITS(12)
|
---|
| 474 | /* id */
|
---|
[6812] | 475 | char sys;
|
---|
[9262] | 476 | if (type >= 1131 && type <= 1137) {
|
---|
[9007] | 477 | sys = 'I';
|
---|
[9262] | 478 | }
|
---|
| 479 | else if (type >= 1121 && type <= 1127) {
|
---|
[6812] | 480 | sys = 'C';
|
---|
[9262] | 481 | }
|
---|
| 482 | else if (type >= 1111 && type <= 1117) {
|
---|
[6812] | 483 | sys = 'J';
|
---|
[9262] | 484 | }
|
---|
[10534] | 485 | else if (type >= 1101 && type <= 1107) {
|
---|
[6812] | 486 | sys = 'S';
|
---|
[9262] | 487 | }
|
---|
| 488 | else if (type >= 1091 && type <= 1097) {
|
---|
[6812] | 489 | sys = 'E';
|
---|
[9262] | 490 | }
|
---|
| 491 | else if (type >= 1081 && type <= 1087) {
|
---|
[6812] | 492 | sys = 'R';
|
---|
[9262] | 493 | }
|
---|
| 494 | else if (type >= 1071 && type <= 1077) {
|
---|
[6812] | 495 | sys = 'G';
|
---|
[9262] | 496 | }
|
---|
| 497 | else {
|
---|
| 498 | return decoded; // false
|
---|
| 499 | }
|
---|
[6812] | 500 | bncTime CurrentObsTime;
|
---|
[8783] | 501 | if (sys == 'C') /* BDS */ {
|
---|
[8158] | 502 | GETBITS(i, 30)
|
---|
[6812] | 503 | CurrentObsTime.setBDS(i);
|
---|
| 504 | }
|
---|
[8158] | 505 | else if (sys == 'R') /* GLONASS */ {
|
---|
[6812] | 506 | SKIPBITS(3)
|
---|
[8158] | 507 | GETBITS(i, 27)
|
---|
| 508 | /* tk */
|
---|
[6812] | 509 | CurrentObsTime.setTk(i);
|
---|
| 510 | }
|
---|
[8158] | 511 | else /* GPS style date */ {
|
---|
| 512 | GETBITS(i, 30)
|
---|
[6812] | 513 | CurrentObsTime.set(i);
|
---|
| 514 | }
|
---|
[8158] | 515 | if (_CurrentTime.valid() && CurrentObsTime != _CurrentTime) {
|
---|
[6812] | 516 | decoded = true;
|
---|
[8160] | 517 | _obsList.append(_CurrentObsList);
|
---|
[6812] | 518 | _CurrentObsList.clear();
|
---|
| 519 | }
|
---|
| 520 | _CurrentTime = CurrentObsTime;
|
---|
[2677] | 521 |
|
---|
[6812] | 522 | GETBITS(syncf, 1)
|
---|
| 523 | /**
|
---|
| 524 | * Ignore unknown types except for sync flag
|
---|
[7753] | 525 | *
|
---|
[6812] | 526 | * We actually support types 1-3 in following code, but as they are missing
|
---|
| 527 | * the full cycles and can't be used later we skip interpretation here already.
|
---|
| 528 | */
|
---|
[9007] | 529 | if (type <= 1137 && (type % 10) >= 4 && (type % 10) <= 7) {
|
---|
[6812] | 530 | int sigmask, numsat = 0, numsig = 0;
|
---|
| 531 | uint64_t satmask, cellmask, ui;
|
---|
[8801] | 532 | // satellite data
|
---|
| 533 | double rrmod[RTCM3_MSM_NUMSAT]; // GNSS sat rough ranges modulo 1 millisecond
|
---|
| 534 | int rrint[RTCM3_MSM_NUMSAT]; // number of integer msecs in GNSS sat rough ranges
|
---|
| 535 | int rdop[RTCM3_MSM_NUMSAT]; // GNSS sat rough phase range rates
|
---|
| 536 | int extsat[RTCM3_MSM_NUMSAT];// extended sat info
|
---|
| 537 | // signal data
|
---|
| 538 | int ll[RTCM3_MSM_NUMCELLS]; // lock time indicator
|
---|
| 539 | /*int hc[RTCM3_MSM_NUMCELLS];*/ // half cycle ambiguity indicator
|
---|
| 540 | double cnr[RTCM3_MSM_NUMCELLS]; // signal cnr
|
---|
| 541 | double cp[RTCM3_MSM_NUMCELLS]; // fine phase range data
|
---|
| 542 | double psr[RTCM3_MSM_NUMCELLS]; // fine psr
|
---|
| 543 | double dop[RTCM3_MSM_NUMCELLS]; // fine phase range rates
|
---|
[2674] | 544 |
|
---|
[8158] | 545 | SKIPBITS(3 + 7 + 2 + 2 + 1 + 3)
|
---|
[6812] | 546 | GETBITS64(satmask, RTCM3_MSM_NUMSAT)
|
---|
[2674] | 547 |
|
---|
[6812] | 548 | /* http://gurmeetsingh.wordpress.com/2008/08/05/fast-bit-counting-routines/ */
|
---|
[8158] | 549 | for (ui = satmask; ui; ui &= (ui - 1) /* remove rightmost bit */)
|
---|
[6812] | 550 | ++numsat;
|
---|
| 551 | GETBITS(sigmask, RTCM3_MSM_NUMSIG)
|
---|
[8158] | 552 | for (i = sigmask; i; i &= (i - 1) /* remove rightmost bit */)
|
---|
[6812] | 553 | ++numsig;
|
---|
[8158] | 554 | for (i = 0; i < RTCM3_MSM_NUMSAT; ++i)
|
---|
[6812] | 555 | extsat[i] = 15;
|
---|
[2674] | 556 |
|
---|
[8158] | 557 | i = numsat * numsig;
|
---|
| 558 | GETBITS64(cellmask, (unsigned )i)
|
---|
[8801] | 559 | // satellite data
|
---|
[8158] | 560 | switch (type % 10) {
|
---|
[6812] | 561 | case 1:
|
---|
| 562 | case 2:
|
---|
| 563 | case 3:
|
---|
[8158] | 564 | /* partial data, already skipped above, but implemented for future expansion ! */
|
---|
| 565 | for (int j = numsat; j--;)
|
---|
| 566 | GETFLOAT(rrmod[j], 10, 1.0 / 1024.0)
|
---|
[6812] | 567 | break;
|
---|
| 568 | case 4:
|
---|
[8158] | 569 | case 6:
|
---|
| 570 | for (int j = numsat; j--;)
|
---|
| 571 | GETBITS(rrint[j], 8)
|
---|
| 572 | for (int j = numsat; j--;)
|
---|
| 573 | GETFLOAT(rrmod[j], 10, 1.0 / 1024.0)
|
---|
[6812] | 574 | break;
|
---|
| 575 | case 5:
|
---|
| 576 | case 7:
|
---|
[8158] | 577 | for (int j = numsat; j--;)
|
---|
| 578 | GETBITS(rrint[j], 8)
|
---|
| 579 | for (int j = numsat; j--;)
|
---|
| 580 | GETBITS(extsat[j], 4)
|
---|
| 581 | for (int j = numsat; j--;)
|
---|
| 582 | GETFLOAT(rrmod[j], 10, 1.0 / 1024.0)
|
---|
| 583 | for (int j = numsat; j--;)
|
---|
| 584 | GETBITSSIGN(rdop[j], 14)
|
---|
[6812] | 585 | break;
|
---|
[8158] | 586 | }
|
---|
[8801] | 587 | // signal data
|
---|
[8158] | 588 | int numcells = numsat * numsig;
|
---|
| 589 | /** Drop anything which exceeds our cell limit. Increase limit definition
|
---|
| 590 | * when that happens. */
|
---|
| 591 | if (numcells <= RTCM3_MSM_NUMCELLS) {
|
---|
| 592 | switch (type % 10) {
|
---|
| 593 | case 1:
|
---|
| 594 | for (int count = numcells; count--;)
|
---|
| 595 | if (cellmask & (UINT64(1) << count))
|
---|
| 596 | GETFLOATSIGN(psr[count], 15, 1.0 / (1 << 24))
|
---|
| 597 | break;
|
---|
| 598 | case 2:
|
---|
| 599 | for (int count = numcells; count--;)
|
---|
| 600 | if (cellmask & (UINT64(1) << count))
|
---|
| 601 | GETFLOATSIGN(cp[count], 22, 1.0 / (1 << 29))
|
---|
| 602 | for (int count = numcells; count--;)
|
---|
| 603 | if (cellmask & (UINT64(1) << count))
|
---|
| 604 | GETBITS(ll[count], 4)
|
---|
| 605 | for (int count = numcells; count--;)
|
---|
| 606 | if (cellmask & (UINT64(1) << count))
|
---|
| 607 | SKIPBITS(1)/*GETBITS(hc[count], 1)*/
|
---|
| 608 | break;
|
---|
| 609 | case 3:
|
---|
| 610 | for (int count = numcells; count--;)
|
---|
| 611 | if (cellmask & (UINT64(1) << count))
|
---|
| 612 | GETFLOATSIGN(psr[count], 15, 1.0 / (1 << 24))
|
---|
| 613 | for (int count = numcells; count--;)
|
---|
| 614 | if (cellmask & (UINT64(1) << count))
|
---|
| 615 | GETFLOATSIGN(cp[count], 22, 1.0 / (1 << 29))
|
---|
| 616 | for (int count = numcells; count--;)
|
---|
| 617 | if (cellmask & (UINT64(1) << count))
|
---|
| 618 | GETBITS(ll[count], 4)
|
---|
| 619 | for (int count = numcells; count--;)
|
---|
| 620 | if (cellmask & (UINT64(1) << count))
|
---|
| 621 | SKIPBITS(1)/*GETBITS(hc[count], 1)*/
|
---|
| 622 | break;
|
---|
| 623 | case 4:
|
---|
| 624 | for (int count = numcells; count--;)
|
---|
| 625 | if (cellmask & (UINT64(1) << count))
|
---|
| 626 | GETFLOATSIGN(psr[count], 15, 1.0 / (1 << 24))
|
---|
| 627 | for (int count = numcells; count--;)
|
---|
| 628 | if (cellmask & (UINT64(1) << count))
|
---|
| 629 | GETFLOATSIGN(cp[count], 22, 1.0 / (1 << 29))
|
---|
| 630 | for (int count = numcells; count--;)
|
---|
| 631 | if (cellmask & (UINT64(1) << count))
|
---|
| 632 | GETBITS(ll[count], 4)
|
---|
| 633 | for (int count = numcells; count--;)
|
---|
| 634 | if (cellmask & (UINT64(1) << count))
|
---|
| 635 | SKIPBITS(1)/*GETBITS(hc[count], 1)*/
|
---|
| 636 | for (int count = numcells; count--;)
|
---|
| 637 | if (cellmask & (UINT64(1) << count))
|
---|
| 638 | GETBITS(cnr[count], 6)
|
---|
| 639 | break;
|
---|
| 640 | case 5:
|
---|
| 641 | for (int count = numcells; count--;)
|
---|
| 642 | if (cellmask & (UINT64(1) << count))
|
---|
| 643 | GETFLOATSIGN(psr[count], 15, 1.0 / (1 << 24))
|
---|
| 644 | for (int count = numcells; count--;)
|
---|
| 645 | if (cellmask & (UINT64(1) << count))
|
---|
| 646 | GETFLOATSIGN(cp[count], 22, 1.0 / (1 << 29))
|
---|
| 647 | for (int count = numcells; count--;)
|
---|
| 648 | if (cellmask & (UINT64(1) << count))
|
---|
| 649 | GETBITS(ll[count], 4)
|
---|
| 650 | for (int count = numcells; count--;)
|
---|
| 651 | if (cellmask & (UINT64(1) << count))
|
---|
| 652 | SKIPBITS(1)/*GETBITS(hc[count], 1)*/
|
---|
| 653 | for (int count = numcells; count--;)
|
---|
| 654 | if (cellmask & (UINT64(1) << count))
|
---|
| 655 | GETFLOAT(cnr[count], 6, 1.0)
|
---|
| 656 | for (int count = numcells; count--;)
|
---|
| 657 | if (cellmask & (UINT64(1) << count))
|
---|
| 658 | GETFLOATSIGN(dop[count], 15, 0.0001)
|
---|
| 659 | break;
|
---|
| 660 | case 6:
|
---|
| 661 | for (int count = numcells; count--;)
|
---|
| 662 | if (cellmask & (UINT64(1) << count))
|
---|
| 663 | GETFLOATSIGN(psr[count], 20, 1.0 / (1 << 29))
|
---|
| 664 | for (int count = numcells; count--;)
|
---|
| 665 | if (cellmask & (UINT64(1) << count))
|
---|
| 666 | GETFLOATSIGN(cp[count], 24, 1.0 / (1U << 31))
|
---|
| 667 | for (int count = numcells; count--;)
|
---|
| 668 | if (cellmask & (UINT64(1) << count))
|
---|
| 669 | GETBITS(ll[count], 10)
|
---|
| 670 | for (int count = numcells; count--;)
|
---|
| 671 | if (cellmask & (UINT64(1) << count))
|
---|
| 672 | SKIPBITS(1)/*GETBITS(hc[count], 1)*/
|
---|
| 673 | for (int count = numcells; count--;)
|
---|
| 674 | if (cellmask & (UINT64(1) << count))
|
---|
| 675 | GETFLOAT(cnr[count], 10, 1.0 / (1 << 4))
|
---|
| 676 | break;
|
---|
| 677 | case 7:
|
---|
| 678 | for (int count = numcells; count--;)
|
---|
| 679 | if (cellmask & (UINT64(1) << count))
|
---|
| 680 | GETFLOATSIGN(psr[count], 20, 1.0 / (1 << 29))
|
---|
| 681 | for (int count = numcells; count--;)
|
---|
| 682 | if (cellmask & (UINT64(1) << count))
|
---|
| 683 | GETFLOATSIGN(cp[count], 24, 1.0 / (1U << 31))
|
---|
| 684 | for (int count = numcells; count--;)
|
---|
| 685 | if (cellmask & (UINT64(1) << count))
|
---|
| 686 | GETBITS(ll[count], 10)
|
---|
| 687 | for (int count = numcells; count--;)
|
---|
| 688 | if (cellmask & (UINT64(1) << count))
|
---|
| 689 | SKIPBITS(1)/*GETBITS(hc[count], 1)*/
|
---|
| 690 | for (int count = numcells; count--;)
|
---|
| 691 | if (cellmask & (UINT64(1) << count))
|
---|
| 692 | GETFLOAT(cnr[count], 10, 1.0 / (1 << 4))
|
---|
| 693 | for (int count = numcells; count--;)
|
---|
| 694 | if (cellmask & (UINT64(1) << count))
|
---|
| 695 | GETFLOATSIGN(dop[count], 15, 0.0001)
|
---|
| 696 | break;
|
---|
[6812] | 697 | }
|
---|
| 698 | i = RTCM3_MSM_NUMSAT;
|
---|
| 699 | int j = -1;
|
---|
| 700 | t_satObs CurrentObs;
|
---|
[8158] | 701 | for (int count = numcells; count--;) {
|
---|
| 702 | while (j >= 0 && !(sigmask & (1 << --j)))
|
---|
[6812] | 703 | ;
|
---|
[8158] | 704 | if (j < 0) {
|
---|
| 705 | while (!(satmask & (UINT64(1) << (--i))))
|
---|
| 706 | /* next satellite */
|
---|
[6812] | 707 | ;
|
---|
[8158] | 708 | if (CurrentObs._obs.size() > 0)
|
---|
[6812] | 709 | _CurrentObsList.push_back(CurrentObs);
|
---|
| 710 | CurrentObs.clear();
|
---|
| 711 | CurrentObs._time = CurrentObsTime;
|
---|
[9541] | 712 | CurrentObs._type = type;
|
---|
[8158] | 713 | if (sys == 'S')
|
---|
| 714 | CurrentObs._prn.set(sys, 20 - 1 + RTCM3_MSM_NUMSAT - i);
|
---|
[6812] | 715 | else
|
---|
[8158] | 716 | CurrentObs._prn.set(sys, RTCM3_MSM_NUMSAT - i);
|
---|
[6812] | 717 | j = RTCM3_MSM_NUMSIG;
|
---|
[8158] | 718 | while (!(sigmask & (1 << --j)))
|
---|
[6812] | 719 | ;
|
---|
| 720 | --numsat;
|
---|
| 721 | }
|
---|
[8158] | 722 | if (cellmask & (UINT64(1) << count)) {
|
---|
| 723 | struct CodeData cd = {0.0, 0};
|
---|
| 724 | switch (sys) {
|
---|
| 725 | case 'J':
|
---|
| 726 | cd = qzss[RTCM3_MSM_NUMSIG - j - 1];
|
---|
| 727 | break;
|
---|
| 728 | case 'C':
|
---|
| 729 | cd = bds[RTCM3_MSM_NUMSIG - j - 1];
|
---|
| 730 | break;
|
---|
| 731 | case 'G':
|
---|
| 732 | case 'S':
|
---|
| 733 | cd = gps[RTCM3_MSM_NUMSIG - j - 1];
|
---|
| 734 | break;
|
---|
| 735 | case 'R':
|
---|
| 736 | cd = glo[RTCM3_MSM_NUMSIG - j - 1];
|
---|
[6812] | 737 | {
|
---|
[8158] | 738 | int k = GLOFreq[RTCM3_MSM_NUMSAT - i - 1];
|
---|
[8801] | 739 | if (extsat[numsat] < 14) { // channel number is available as extended info for MSM5/7
|
---|
| 740 | k = GLOFreq[RTCM3_MSM_NUMSAT - i - 1] = 100 + extsat[numsat] - 7;
|
---|
[8158] | 741 | }
|
---|
[8801] | 742 | if (k) {
|
---|
| 743 | if (cd.wl == 0.0) {
|
---|
| 744 | cd.wl = GLO_WAVELENGTH_L1(k - 100);
|
---|
| 745 | }
|
---|
| 746 | else if (cd.wl == 1.0) {
|
---|
| 747 | cd.wl = GLO_WAVELENGTH_L2(k - 100);
|
---|
| 748 | }
|
---|
| 749 | }
|
---|
| 750 | else if (!k && cd.wl <= 1) {
|
---|
[8158] | 751 | cd.code = 0;
|
---|
[8801] | 752 | }
|
---|
[2676] | 753 | }
|
---|
[8158] | 754 | break;
|
---|
| 755 | case 'E':
|
---|
| 756 | cd = gal[RTCM3_MSM_NUMSIG - j - 1];
|
---|
| 757 | break;
|
---|
[8783] | 758 | case 'I':
|
---|
| 759 | cd = irn[RTCM3_MSM_NUMSIG - j - 1];
|
---|
| 760 | break;
|
---|
[6812] | 761 | }
|
---|
[8158] | 762 | if (cd.code) {
|
---|
[6812] | 763 | t_frqObs *frqObs = new t_frqObs;
|
---|
[7850] | 764 | frqObs->_rnxType2ch.assign(cd.code);
|
---|
[2674] | 765 |
|
---|
[8158] | 766 | switch (type % 10) {
|
---|
| 767 | case 1:
|
---|
| 768 | if (psr[count] > -1.0 / (1 << 10)) {
|
---|
| 769 | frqObs->_code = psr[count] * LIGHTSPEED / 1000.0
|
---|
[8801] | 770 | + (rrmod[numsat]) * LIGHTSPEED / 1000.0;
|
---|
[8158] | 771 | frqObs->_codeValid = true;
|
---|
| 772 | }
|
---|
| 773 | break;
|
---|
| 774 | case 2:
|
---|
| 775 | if (cp[count] > -1.0 / (1 << 8)) {
|
---|
| 776 | frqObs->_phase = cp[count] * LIGHTSPEED / 1000.0 / cd.wl
|
---|
[8801] | 777 | + (rrmod[numsat]) * LIGHTSPEED / 1000.0 / cd.wl;
|
---|
[8158] | 778 | frqObs->_phaseValid = true;
|
---|
[8617] | 779 | frqObs->_lockTime = lti2sec(type,ll[count]);
|
---|
[8682] | 780 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0);
|
---|
[9088] | 781 | frqObs->_lockTimeIndicator = ll[count];
|
---|
[8158] | 782 | }
|
---|
| 783 | break;
|
---|
| 784 | case 3:
|
---|
| 785 | if (psr[count] > -1.0 / (1 << 10)) {
|
---|
| 786 | frqObs->_code = psr[count] * LIGHTSPEED / 1000.0
|
---|
[8801] | 787 | + (rrmod[numsat]) * LIGHTSPEED / 1000.0;
|
---|
[8158] | 788 | frqObs->_codeValid = true;
|
---|
| 789 | }
|
---|
| 790 | if (cp[count] > -1.0 / (1 << 8)) {
|
---|
| 791 | frqObs->_phase = cp[count] * LIGHTSPEED / 1000.0 / cd.wl
|
---|
[8801] | 792 | + rrmod[numsat] * LIGHTSPEED / 1000.0 / cd.wl;
|
---|
[8158] | 793 | frqObs->_phaseValid = true;
|
---|
[8617] | 794 | frqObs->_lockTime = lti2sec(type,ll[count]);
|
---|
[8682] | 795 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0);
|
---|
[9088] | 796 | frqObs->_lockTimeIndicator = ll[count];
|
---|
[8158] | 797 | }
|
---|
| 798 | break;
|
---|
| 799 | case 4:
|
---|
| 800 | if (psr[count] > -1.0 / (1 << 10)) {
|
---|
| 801 | frqObs->_code = psr[count] * LIGHTSPEED / 1000.0
|
---|
[8801] | 802 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0;
|
---|
[8158] | 803 | frqObs->_codeValid = true;
|
---|
| 804 | }
|
---|
| 805 | if (cp[count] > -1.0 / (1 << 8)) {
|
---|
| 806 | frqObs->_phase = cp[count] * LIGHTSPEED / 1000.0 / cd.wl
|
---|
[8801] | 807 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0 / cd.wl;
|
---|
[8158] | 808 | frqObs->_phaseValid = true;
|
---|
[8617] | 809 | frqObs->_lockTime = lti2sec(type,ll[count]);
|
---|
[8682] | 810 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0);
|
---|
[9088] | 811 | frqObs->_lockTimeIndicator = ll[count];
|
---|
[8158] | 812 | }
|
---|
| 813 | frqObs->_snr = cnr[count];
|
---|
| 814 | frqObs->_snrValid = true;
|
---|
| 815 | break;
|
---|
| 816 | case 5:
|
---|
| 817 | if (psr[count] > -1.0 / (1 << 10)) {
|
---|
| 818 | frqObs->_code = psr[count] * LIGHTSPEED / 1000.0
|
---|
[8801] | 819 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0;
|
---|
[8158] | 820 | frqObs->_codeValid = true;
|
---|
| 821 | }
|
---|
| 822 | if (cp[count] > -1.0 / (1 << 8)) {
|
---|
| 823 | frqObs->_phase = cp[count] * LIGHTSPEED / 1000.0 / cd.wl
|
---|
[8801] | 824 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0 / cd.wl;
|
---|
[8158] | 825 | frqObs->_phaseValid = true;
|
---|
[8617] | 826 | frqObs->_lockTime = lti2sec(type,ll[count]);
|
---|
[8682] | 827 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0);
|
---|
[9088] | 828 | frqObs->_lockTimeIndicator = ll[count];
|
---|
[8158] | 829 | }
|
---|
| 830 | frqObs->_snr = cnr[count];
|
---|
| 831 | frqObs->_snrValid = true;
|
---|
| 832 | if (dop[count] > -1.6384) {
|
---|
| 833 | frqObs->_doppler = -(dop[count] + rdop[numsat]) / cd.wl;
|
---|
| 834 | frqObs->_dopplerValid = true;
|
---|
| 835 | }
|
---|
| 836 | break;
|
---|
| 837 | case 6:
|
---|
| 838 | if (psr[count] > -1.0 / (1 << 10)) {
|
---|
| 839 | frqObs->_code = psr[count] * LIGHTSPEED / 1000.0
|
---|
[8801] | 840 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0;
|
---|
[8158] | 841 | frqObs->_codeValid = true;
|
---|
| 842 | }
|
---|
| 843 | if (cp[count] > -1.0 / (1 << 8)) {
|
---|
| 844 | frqObs->_phase = cp[count] * LIGHTSPEED / 1000.0 / cd.wl
|
---|
[8801] | 845 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0 / cd.wl;
|
---|
[8158] | 846 | frqObs->_phaseValid = true;
|
---|
[8617] | 847 | frqObs->_lockTime = lti2sec(type,ll[count]);
|
---|
[8682] | 848 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0);
|
---|
[9088] | 849 | frqObs->_lockTimeIndicator = ll[count];
|
---|
[8158] | 850 | }
|
---|
[6812] | 851 |
|
---|
[8158] | 852 | frqObs->_snr = cnr[count];
|
---|
| 853 | frqObs->_snrValid = true;
|
---|
| 854 | break;
|
---|
| 855 | case 7:
|
---|
| 856 | if (psr[count] > -1.0 / (1 << 10)) {
|
---|
| 857 | frqObs->_code = psr[count] * LIGHTSPEED / 1000.0
|
---|
[8801] | 858 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0;
|
---|
[8158] | 859 | frqObs->_codeValid = true;
|
---|
| 860 | }
|
---|
| 861 | if (cp[count] > -1.0 / (1 << 8)) {
|
---|
| 862 | frqObs->_phase = cp[count] * LIGHTSPEED / 1000.0 / cd.wl
|
---|
[8801] | 863 | + (rrmod[numsat] + rrint[numsat]) * LIGHTSPEED / 1000.0 / cd.wl;
|
---|
[8158] | 864 | frqObs->_phaseValid = true;
|
---|
[8617] | 865 | frqObs->_lockTime = lti2sec(type,ll[count]);
|
---|
[8682] | 866 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0);
|
---|
[9088] | 867 | frqObs->_lockTimeIndicator = ll[count];
|
---|
[8158] | 868 | }
|
---|
[6137] | 869 |
|
---|
[8158] | 870 | frqObs->_snr = cnr[count];
|
---|
| 871 | frqObs->_snrValid = true;
|
---|
[6137] | 872 |
|
---|
[8158] | 873 | if (dop[count] > -1.6384) {
|
---|
| 874 | frqObs->_doppler = -(dop[count] + rdop[numsat]) / cd.wl;
|
---|
| 875 | frqObs->_dopplerValid = true;
|
---|
| 876 | }
|
---|
| 877 | break;
|
---|
[366] | 878 | }
|
---|
[6812] | 879 | CurrentObs._obs.push_back(frqObs);
|
---|
[296] | 880 | }
|
---|
[6812] | 881 | }
|
---|
| 882 | }
|
---|
[8801] | 883 | if (CurrentObs._obs.size() > 0) {
|
---|
[6812] | 884 | _CurrentObsList.push_back(CurrentObs);
|
---|
[8801] | 885 | }
|
---|
[6812] | 886 | }
|
---|
| 887 | }
|
---|
[8937] | 888 | else if ((type % 10) < 4) {
|
---|
[10236] | 889 | #ifdef BNC_DEBUG_OBS
|
---|
[6812] | 890 | emit(newMessage(QString("%1: Block %2 contain partial data! Ignored!")
|
---|
[8204] | 891 | .arg(_staID).arg(type).toLatin1(), true));
|
---|
[10236] | 892 | #endif
|
---|
[6812] | 893 | }
|
---|
[8158] | 894 | if (!syncf) {
|
---|
[6812] | 895 | decoded = true;
|
---|
[8166] | 896 | _obsList.append(_CurrentObsList);
|
---|
[6812] | 897 | _CurrentTime.reset();
|
---|
| 898 | _CurrentObsList.clear();
|
---|
| 899 | }
|
---|
| 900 | return decoded;
|
---|
| 901 | }
|
---|
| 902 |
|
---|
[7753] | 903 | //
|
---|
[6812] | 904 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 905 | bool RTCM3Decoder::DecodeRTCM3GLONASS(unsigned char* data, int size) {
|
---|
[6812] | 906 | bool decoded = false;
|
---|
| 907 | bncTime CurrentObsTime;
|
---|
| 908 | int i, numsats, syncf, type;
|
---|
| 909 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 910 |
|
---|
| 911 | data += 3; /* header */
|
---|
| 912 | size -= 6; /* header + crc */
|
---|
| 913 |
|
---|
| 914 | GETBITS(type, 12)
|
---|
[8158] | 915 | SKIPBITS(12)
|
---|
| 916 | /* id */
|
---|
| 917 | GETBITS(i, 27)
|
---|
| 918 | /* tk */
|
---|
[6812] | 919 |
|
---|
| 920 | CurrentObsTime.setTk(i);
|
---|
[8158] | 921 | if (_CurrentTime.valid() && CurrentObsTime != _CurrentTime) {
|
---|
[6812] | 922 | decoded = true;
|
---|
[7753] | 923 | _obsList.append(_CurrentObsList);
|
---|
[6812] | 924 | _CurrentObsList.clear();
|
---|
| 925 | }
|
---|
| 926 | _CurrentTime = CurrentObsTime;
|
---|
| 927 |
|
---|
[8158] | 928 | GETBITS(syncf, 1)
|
---|
| 929 | /* sync */
|
---|
| 930 | GETBITS(numsats, 5)
|
---|
| 931 | SKIPBITS(4)
|
---|
| 932 | /* smind, smint */
|
---|
[6812] | 933 |
|
---|
[8158] | 934 | while (numsats--) {
|
---|
| 935 | int sv, code, l1range, amb = 0, freq;
|
---|
[6812] | 936 | t_satObs CurrentObs;
|
---|
| 937 | CurrentObs._time = CurrentObsTime;
|
---|
[9541] | 938 | CurrentObs._type = type;
|
---|
[6812] | 939 |
|
---|
| 940 | GETBITS(sv, 6)
|
---|
| 941 | CurrentObs._prn.set('R', sv);
|
---|
| 942 | GETBITS(code, 1)
|
---|
| 943 | GETBITS(freq, 5)
|
---|
[8158] | 944 | GLOFreq[sv - 1] = 100 + freq - 7; /* store frequency for other users (MSM) */
|
---|
[6812] | 945 |
|
---|
| 946 | t_frqObs *frqObs = new t_frqObs;
|
---|
| 947 | /* L1 */
|
---|
[8158] | 948 | (code) ?
|
---|
| 949 | frqObs->_rnxType2ch.assign("1P") : frqObs->_rnxType2ch.assign("1C");
|
---|
[6812] | 950 | GETBITS(l1range, 25);
|
---|
| 951 | GETBITSSIGN(i, 20);
|
---|
[8158] | 952 | if ((i & ((1 << 20) - 1)) != 0x80000) {
|
---|
| 953 | frqObs->_code = l1range * 0.02;
|
---|
[9088] | 954 | frqObs->_phase = (l1range * 0.02 + i * 0.0005) / GLO_WAVELENGTH_L1(freq - 7);
|
---|
[6812] | 955 | frqObs->_codeValid = frqObs->_phaseValid = true;
|
---|
| 956 | }
|
---|
[9088] | 957 | GETBITS(frqObs->_lockTimeIndicator, 7);
|
---|
| 958 | frqObs->_lockTime = lti2sec(type, frqObs->_lockTimeIndicator);
|
---|
[8682] | 959 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0 && frqObs->_phaseValid);
|
---|
[8158] | 960 | if (type == 1010 || type == 1012) {
|
---|
| 961 | GETBITS(amb, 7);
|
---|
| 962 | if (amb) {
|
---|
| 963 | frqObs->_code += amb * 599584.916;
|
---|
| 964 | frqObs->_phase += (amb * 599584.916) / GLO_WAVELENGTH_L1(freq - 7);
|
---|
[6812] | 965 | }
|
---|
| 966 | GETBITS(i, 8);
|
---|
[8158] | 967 | if (i) {
|
---|
| 968 | frqObs->_snr = i * 0.25;
|
---|
[6812] | 969 | frqObs->_snrValid = true;
|
---|
| 970 | }
|
---|
| 971 | }
|
---|
| 972 | CurrentObs._obs.push_back(frqObs);
|
---|
[8158] | 973 | if (type == 1011 || type == 1012) {
|
---|
[6812] | 974 | frqObs = new t_frqObs;
|
---|
| 975 | /* L2 */
|
---|
[8158] | 976 | GETBITS(code, 2);
|
---|
| 977 | switch (code) {
|
---|
| 978 | case 3:
|
---|
| 979 | frqObs->_rnxType2ch.assign("2P");
|
---|
| 980 | break;
|
---|
| 981 | case 2:
|
---|
| 982 | frqObs->_rnxType2ch.assign("2P");
|
---|
| 983 | break;
|
---|
| 984 | case 1:
|
---|
| 985 | frqObs->_rnxType2ch.assign("2P");
|
---|
| 986 | break;
|
---|
| 987 | case 0:
|
---|
| 988 | frqObs->_rnxType2ch.assign("2C");
|
---|
| 989 | break;
|
---|
[6812] | 990 | }
|
---|
[8158] | 991 | GETBITSSIGN(i, 14);
|
---|
| 992 | if ((i & ((1 << 14) - 1)) != 0x2000) {
|
---|
| 993 | frqObs->_code = l1range * 0.02 + i * 0.02 + amb * 599584.916;
|
---|
[6812] | 994 | frqObs->_codeValid = true;
|
---|
| 995 | }
|
---|
[8158] | 996 | GETBITSSIGN(i, 20);
|
---|
| 997 | if ((i & ((1 << 20) - 1)) != 0x80000) {
|
---|
| 998 | frqObs->_phase = (l1range * 0.02 + i * 0.0005 + amb * 599584.916)
|
---|
| 999 | / GLO_WAVELENGTH_L2(freq - 7);
|
---|
[6812] | 1000 | frqObs->_phaseValid = true;
|
---|
| 1001 | }
|
---|
[9088] | 1002 | GETBITS(frqObs->_lockTimeIndicator, 7);
|
---|
| 1003 | frqObs->_lockTime = lti2sec(type, frqObs->_lockTimeIndicator);
|
---|
[8682] | 1004 | frqObs->_lockTimeValid = (frqObs->_lockTime >= 0.0 && frqObs->_phaseValid);
|
---|
[8158] | 1005 | if (type == 1012) {
|
---|
[6812] | 1006 | GETBITS(i, 8);
|
---|
[8158] | 1007 | if (i) {
|
---|
| 1008 | frqObs->_snr = i * 0.25;
|
---|
[6812] | 1009 | frqObs->_snrValid = true;
|
---|
| 1010 | }
|
---|
| 1011 | }
|
---|
| 1012 | CurrentObs._obs.push_back(frqObs);
|
---|
| 1013 | }
|
---|
| 1014 | _CurrentObsList.push_back(CurrentObs);
|
---|
| 1015 | }
|
---|
[8158] | 1016 | if (!syncf) {
|
---|
[6812] | 1017 | decoded = true;
|
---|
[7753] | 1018 | _obsList.append(_CurrentObsList);
|
---|
[6812] | 1019 | _CurrentTime.reset();
|
---|
| 1020 | _CurrentObsList.clear();
|
---|
| 1021 | }
|
---|
| 1022 | return decoded;
|
---|
| 1023 | }
|
---|
| 1024 |
|
---|
| 1025 | //
|
---|
| 1026 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 1027 | bool RTCM3Decoder::DecodeGPSEphemeris(unsigned char* data, int size) {
|
---|
[6812] | 1028 | bool decoded = false;
|
---|
| 1029 |
|
---|
[8158] | 1030 | if (size == 67) {
|
---|
[6812] | 1031 | t_ephGPS eph;
|
---|
| 1032 | int i, week;
|
---|
| 1033 | uint64_t numbits = 0, bitfield = 0;
|
---|
[8852] | 1034 | int fitIntervalFalg = 0;
|
---|
[6812] | 1035 |
|
---|
| 1036 | data += 3; /* header */
|
---|
| 1037 | size -= 6; /* header + crc */
|
---|
| 1038 | SKIPBITS(12)
|
---|
| 1039 |
|
---|
| 1040 | eph._receptDateTime = currentDateAndTimeGPS();
|
---|
[9212] | 1041 | eph._receptStaID = _staID;
|
---|
[6812] | 1042 |
|
---|
| 1043 | GETBITS(i, 6)
|
---|
[10544] | 1044 | if (i < 1 || i > 63 ) {
|
---|
[10549] | 1045 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1046 | emit(newMessage(QString("%1: Block %2 (G) PRN# is out of range: %3!")
|
---|
| 1047 | .arg(_staID)
|
---|
| 1048 | .arg(1019,4)
|
---|
| 1049 | .arg(i).toLatin1(), true));
|
---|
| 1050 | #endif
|
---|
| 1051 | return false;
|
---|
| 1052 | }
|
---|
[6812] | 1053 | eph._prn.set('G', i);
|
---|
| 1054 | GETBITS(week, 10)
|
---|
[10544] | 1055 | if (week < 0 || week > 1023) {
|
---|
[10549] | 1056 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1057 | emit(newMessage(QString("%1: Block %2 (%3) WEEK # is out of range: %4!")
|
---|
| 1058 | .arg(_staID)
|
---|
| 1059 | .arg(1019,4)
|
---|
| 1060 | .arg(eph._prn.toString().c_str())
|
---|
| 1061 | .arg(week).toLatin1(), true));
|
---|
| 1062 | #endif
|
---|
| 1063 | return false;
|
---|
| 1064 | }
|
---|
[6812] | 1065 | GETBITS(i, 4)
|
---|
| 1066 | eph._ura = accuracyFromIndex(i, eph.type());
|
---|
| 1067 | GETBITS(eph._L2Codes, 2)
|
---|
| 1068 | GETFLOATSIGN(eph._IDOT, 14, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 1069 | GETBITS(eph._IODE, 8)
|
---|
| 1070 | GETBITS(i, 16)
|
---|
| 1071 | i <<= 4;
|
---|
[10544] | 1072 | if (i < 0 || i > 604784) {
|
---|
[10549] | 1073 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1074 | emit(newMessage(QString("%1: Block %2 (%3) TOC is out of range: %4!")
|
---|
| 1075 | .arg(_staID)
|
---|
| 1076 | .arg(1019,4)
|
---|
| 1077 | .arg(eph._prn.toString().c_str())
|
---|
| 1078 | .arg(i).toLatin1(), true));
|
---|
| 1079 | #endif
|
---|
| 1080 | return false;
|
---|
| 1081 | }
|
---|
[8158] | 1082 | eph._TOC.set(i * 1000);
|
---|
[8783] | 1083 | GETFLOATSIGN(eph._clock_driftrate, 8, 1.0 / (double )(1 << 30) / (double )(1 << 25))
|
---|
| 1084 | GETFLOATSIGN(eph._clock_drift, 16, 1.0 / (double )(1 << 30) / (double )(1 << 13))
|
---|
| 1085 | GETFLOATSIGN(eph._clock_bias, 22, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
[6812] | 1086 | GETBITS(eph._IODC, 10)
|
---|
[8783] | 1087 | GETFLOATSIGN(eph._Crs, 16, 1.0 / (double )(1 << 5))
|
---|
| 1088 | GETFLOATSIGN(eph._Delta_n, 16, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 1089 | GETFLOATSIGN(eph._M0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1090 | GETFLOATSIGN(eph._Cuc, 16, 1.0 / (double )(1 << 29))
|
---|
| 1091 | GETFLOAT(eph._e, 32, 1.0 / (double )(1 << 30) / (double )(1 << 3))
|
---|
| 1092 | GETFLOATSIGN(eph._Cus, 16, 1.0 / (double )(1 << 29))
|
---|
| 1093 | GETFLOAT(eph._sqrt_A, 32, 1.0 / (double )(1 << 19))
|
---|
[9201] | 1094 | if (eph._sqrt_A < 1000.0) {
|
---|
[10549] | 1095 | #ifdef BNC_DEBUG_BCE
|
---|
[9201] | 1096 | emit(newMessage(QString("%1: Block %2 (%3) SQRT_A %4 m!")
|
---|
[9315] | 1097 | .arg(_staID).arg(1019,4).arg(eph._prn.toString().c_str())
|
---|
[9201] | 1098 | .arg(eph._sqrt_A,10,'F',3).toLatin1(), true));
|
---|
[9210] | 1099 | #endif
|
---|
[9201] | 1100 | return false;
|
---|
| 1101 | }
|
---|
[6812] | 1102 | GETBITS(i, 16)
|
---|
| 1103 | i <<= 4;
|
---|
[10544] | 1104 | if (i < 0 || i > 604784) {
|
---|
[10549] | 1105 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1106 | emit(newMessage(QString("%1: Block %2 (%3) TOE is out of range: %4!")
|
---|
| 1107 | .arg(_staID)
|
---|
| 1108 | .arg(1019,4)
|
---|
| 1109 | .arg(eph._prn.toString().c_str())
|
---|
| 1110 | .arg(i).toLatin1(), true));
|
---|
| 1111 | #endif
|
---|
| 1112 | return false;
|
---|
| 1113 | }
|
---|
[6812] | 1114 | eph._TOEsec = i;
|
---|
| 1115 | bncTime t;
|
---|
[8158] | 1116 | t.set(i * 1000);
|
---|
[6812] | 1117 | eph._TOEweek = t.gpsw();
|
---|
[8472] | 1118 | int numOfRollOvers = int(floor(t.gpsw()/1024.0));
|
---|
| 1119 | week += (numOfRollOvers * 1024);
|
---|
[6812] | 1120 | /* week from HOW, differs from TOC, TOE week, we use adapted value instead */
|
---|
[8158] | 1121 | if (eph._TOEweek > week + 1 || eph._TOEweek < week - 1) /* invalid week */
|
---|
[6812] | 1122 | return false;
|
---|
[8783] | 1123 | GETFLOATSIGN(eph._Cic, 16, 1.0 / (double )(1 << 29))
|
---|
| 1124 | GETFLOATSIGN(eph._OMEGA0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1125 | GETFLOATSIGN(eph._Cis, 16, 1.0 / (double )(1 << 29))
|
---|
| 1126 | GETFLOATSIGN(eph._i0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1127 | GETFLOATSIGN(eph._Crc, 16, 1.0 / (double )(1 << 5))
|
---|
| 1128 | GETFLOATSIGN(eph._omega, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[6812] | 1129 | GETFLOATSIGN(eph._OMEGADOT, 24, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
[8783] | 1130 | GETFLOATSIGN(eph._TGD, 8, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
[6812] | 1131 | GETBITS(eph._health, 6)
|
---|
| 1132 | GETBITS(eph._L2PFlag, 1)
|
---|
[8852] | 1133 | GETBITS(fitIntervalFalg, 1)
|
---|
[8903] | 1134 | eph._fitInterval = fitIntervalFromFlag(fitIntervalFalg, eph._IODC, eph.type());
|
---|
[6812] | 1135 | eph._TOT = 0.9999e9;
|
---|
[9765] | 1136 | eph._navType = t_eph::LNAV;
|
---|
[6812] | 1137 |
|
---|
| 1138 | emit newGPSEph(eph);
|
---|
| 1139 | decoded = true;
|
---|
| 1140 | }
|
---|
| 1141 | return decoded;
|
---|
| 1142 | }
|
---|
| 1143 |
|
---|
| 1144 | //
|
---|
| 1145 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 1146 | bool RTCM3Decoder::DecodeGLONASSEphemeris(unsigned char* data, int size) {
|
---|
[6812] | 1147 | bool decoded = false;
|
---|
| 1148 |
|
---|
[8158] | 1149 | if (size == 51) {
|
---|
[6812] | 1150 | t_ephGlo eph;
|
---|
| 1151 | int sv, i, tk;
|
---|
| 1152 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 1153 |
|
---|
| 1154 | data += 3; /* header */
|
---|
| 1155 | size -= 6; /* header + crc */
|
---|
| 1156 | SKIPBITS(12)
|
---|
| 1157 |
|
---|
| 1158 | eph._receptDateTime = currentDateAndTimeGPS();
|
---|
[9212] | 1159 | eph._receptStaID = _staID;
|
---|
[6812] | 1160 |
|
---|
[9892] | 1161 | eph._flags_unknown = true;
|
---|
| 1162 |
|
---|
[6812] | 1163 | GETBITS(sv, 6)
|
---|
[10544] | 1164 | if (sv < 1 || sv > 63) {
|
---|
[10549] | 1165 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1166 | emit(newMessage(QString("%1: Block %2 (R): SLOT# is unknown (0) or out of range: %3!")
|
---|
| 1167 | .arg(_staID)
|
---|
| 1168 | .arg(1020,4)
|
---|
| 1169 | .arg(sv).toLatin1(), true));
|
---|
| 1170 | #endif
|
---|
| 1171 | return false;
|
---|
| 1172 | }
|
---|
[6812] | 1173 | eph._prn.set('R', sv);
|
---|
| 1174 |
|
---|
| 1175 | GETBITS(i, 5)
|
---|
[10544] | 1176 | if (i < 0 || i > 20) {
|
---|
[10549] | 1177 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1178 | emit(newMessage(QString("%1: Block %2 (%3): FRQ CHN# is out of range: %4")
|
---|
| 1179 | .arg(_staID)
|
---|
| 1180 | .arg(1020,4)
|
---|
| 1181 | .arg(eph._prn.toString().c_str())
|
---|
| 1182 | .arg(i).toLatin1(), true));
|
---|
| 1183 | #endif
|
---|
| 1184 | return false;
|
---|
| 1185 | }
|
---|
[8158] | 1186 | eph._frequency_number = i - 7;
|
---|
[8182] | 1187 | GETBITS(eph._almanac_health, 1) /* almanac healthy */
|
---|
| 1188 | GETBITS(eph._almanac_health_availablility_indicator, 1) /* almanac health ok */
|
---|
[10544] | 1189 | GETBITS(eph._P1, 2) /* P1 */
|
---|
[10555] | 1190 | /* tk */
|
---|
[10544] | 1191 | GETBITS(i, 5)
|
---|
| 1192 | if (i < 0 || i > 23) {
|
---|
[10549] | 1193 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1194 | emit(newMessage(QString("%1: Block %2 (%3): T_k (bits 11-7) is out of range: %4")
|
---|
| 1195 | .arg(_staID)
|
---|
| 1196 | .arg(1020,4)
|
---|
| 1197 | .arg(eph._prn.toString().c_str())
|
---|
| 1198 | .arg(i).toLatin1(), true));
|
---|
[9210] | 1199 | #endif
|
---|
[9892] | 1200 | return false;
|
---|
[9318] | 1201 | }
|
---|
[8158] | 1202 | tk = i * 60 * 60;
|
---|
[6812] | 1203 | GETBITS(i, 6)
|
---|
[10544] | 1204 | if (i < 0 || i > 59) {
|
---|
[10549] | 1205 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1206 | emit(newMessage(QString("%1: Block %2 (%3): T_k (bits 6-1) is out of range: %4")
|
---|
| 1207 | .arg(_staID)
|
---|
| 1208 | .arg(1020,4)
|
---|
| 1209 | .arg(eph._prn.toString().c_str())
|
---|
| 1210 | .arg(i).toLatin1(), true));
|
---|
| 1211 | #endif
|
---|
| 1212 | return false;
|
---|
| 1213 | }
|
---|
[8158] | 1214 | tk += i * 60;
|
---|
[6812] | 1215 | GETBITS(i, 1)
|
---|
[10544] | 1216 | if (i < 0 || i > 1) {
|
---|
[10549] | 1217 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1218 | emit(newMessage(QString("%1: Block %2 (%3): T_k (bit 0) is out of range: %4")
|
---|
| 1219 | .arg(_staID)
|
---|
| 1220 | .arg(1020,4)
|
---|
| 1221 | .arg(eph._prn.toString().c_str())
|
---|
| 1222 | .arg(i).toLatin1(), true));
|
---|
| 1223 | #endif
|
---|
| 1224 | return false;
|
---|
| 1225 | }
|
---|
[8158] | 1226 | tk += i * 30;
|
---|
[8801] | 1227 | eph._tki = tk - 3*60*60;
|
---|
| 1228 | if(eph._tki < 0.0) {
|
---|
| 1229 | eph._tki += 86400.0;
|
---|
| 1230 | }
|
---|
[8182] | 1231 | GETBITS(eph._health, 1) /* MSB of Bn*/
|
---|
| 1232 | GETBITS(eph._P2, 1) /* P2 */
|
---|
[6812] | 1233 | GETBITS(i, 7)
|
---|
[10544] | 1234 | i *= 15;
|
---|
| 1235 | if (i < 15 || i > 1425) {
|
---|
[10549] | 1236 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1237 | emit(newMessage(QString("%1: Block %2 (%3): T_b is out of range: %4")
|
---|
| 1238 | .arg(_staID)
|
---|
| 1239 | .arg(1020,4)
|
---|
| 1240 | .arg(eph._prn.toString().c_str())
|
---|
| 1241 | .arg(i).toLatin1(), true));
|
---|
| 1242 | #endif
|
---|
| 1243 | return false;
|
---|
| 1244 | }
|
---|
| 1245 | eph._TOC.setTk(i * 60 * 1000); /* tb */
|
---|
[6812] | 1246 |
|
---|
[8783] | 1247 | GETFLOATSIGNM(eph._x_velocity, 24, 1.0 / (double )(1 << 20))
|
---|
| 1248 | GETFLOATSIGNM(eph._x_pos, 27, 1.0 / (double )(1 << 11))
|
---|
[8158] | 1249 | GETFLOATSIGNM(eph._x_acceleration, 5, 1.0 / (double )(1 << 30))
|
---|
[8783] | 1250 | GETFLOATSIGNM(eph._y_velocity, 24, 1.0 / (double )(1 << 20))
|
---|
| 1251 | GETFLOATSIGNM(eph._y_pos, 27, 1.0 / (double )(1 << 11))
|
---|
[8158] | 1252 | GETFLOATSIGNM(eph._y_acceleration, 5, 1.0 / (double )(1 << 30))
|
---|
[8783] | 1253 | GETFLOATSIGNM(eph._z_velocity, 24, 1.0 / (double )(1 << 20))
|
---|
| 1254 | GETFLOATSIGNM(eph._z_pos, 27, 1.0 / (double )(1 << 11))
|
---|
[8158] | 1255 | GETFLOATSIGNM(eph._z_acceleration, 5, 1.0 / (double )(1 << 30))
|
---|
[8182] | 1256 | GETBITS(eph._P3, 1) /* P3 */
|
---|
[8783] | 1257 | GETFLOATSIGNM(eph._gamma, 11, 1.0 / (double )(1 << 30) / (double )(1 << 10))
|
---|
| 1258 | GETBITS(eph._M_P, 2) /* GLONASS-M P, */
|
---|
[9201] | 1259 | GETBITS(eph._M_l3, 1) /* GLONASS-M ln (third string) */
|
---|
| 1260 | GETFLOATSIGNM(eph._tau, 22, 1.0 / (double )(1 << 30)) /* GLONASS tau n(tb) */
|
---|
[8183] | 1261 | GETFLOATSIGNM(eph._M_delta_tau, 5, 1.0 / (double )(1 << 30)) /* GLONASS-M delta tau n(tb) */
|
---|
[6812] | 1262 | GETBITS(eph._E, 5)
|
---|
[8783] | 1263 | GETBITS(eph._M_P4, 1) /* GLONASS-M P4 */
|
---|
| 1264 | GETBITS(eph._M_FT, 4) /* GLONASS-M Ft */
|
---|
[8182] | 1265 | GETBITS(eph._M_NT, 11) /* GLONASS-M Nt */
|
---|
[9201] | 1266 | if (eph._M_NT == 0.0) {
|
---|
[10549] | 1267 | #ifdef BNC_DEBUG_BCE
|
---|
[9201] | 1268 | emit(newMessage(QString("%1: Block %2 (%3): NT = %4: missing data!")
|
---|
[9315] | 1269 | .arg(_staID).arg(1020,4).arg(eph._prn.toString().c_str()).arg(eph._M_NT,4).toLatin1(), true));
|
---|
[9210] | 1270 | #endif
|
---|
[9891] | 1271 | return false;
|
---|
[9201] | 1272 | }
|
---|
[8783] | 1273 | GETBITS(eph._M_M, 2) /* GLONASS-M M */
|
---|
[8182] | 1274 | GETBITS(eph._additional_data_availability, 1) /* GLONASS-M The Availability of Additional Data */
|
---|
[9201] | 1275 | if (eph._additional_data_availability == 0.0) {
|
---|
[10549] | 1276 | #ifdef BNC_DEBUG_BCE
|
---|
[9201] | 1277 | emit(newMessage(QString("%1: Block %2 (%3): ADD = %4: missing data!")
|
---|
[9315] | 1278 | .arg(_staID).arg(1020,4).arg(eph._prn.toString().c_str())
|
---|
[9201] | 1279 | .arg(eph._additional_data_availability).toLatin1(), true));
|
---|
[9210] | 1280 | #endif
|
---|
[9891] | 1281 | return false;
|
---|
[9201] | 1282 | }
|
---|
[8783] | 1283 | GETBITS(eph._NA, 11) /* GLONASS-M Na */
|
---|
| 1284 | GETFLOATSIGNM(eph._tauC, 32, 1.0/(double)(1<<30)/(double)(1<<1)) /* GLONASS tau c */
|
---|
[8182] | 1285 | GETBITS(eph._M_N4, 5) /* GLONASS-M N4 */
|
---|
[8783] | 1286 | GETFLOATSIGNM(eph._M_tau_GPS, 22, 1.0/(double)(1<<30)) /* GLONASS-M tau GPS */
|
---|
[8182] | 1287 | GETBITS(eph._M_l5, 1) /* GLONASS-M ln (fifth string) */
|
---|
[6812] | 1288 |
|
---|
| 1289 | unsigned year, month, day;
|
---|
| 1290 | eph._TOC.civil_date(year, month, day);
|
---|
| 1291 | eph._gps_utc = gnumleap(year, month, day);
|
---|
| 1292 | eph._tt = eph._TOC;
|
---|
[8783] | 1293 |
|
---|
[8708] | 1294 | eph._xv(1) = eph._x_pos * 1.e3;
|
---|
| 1295 | eph._xv(2) = eph._y_pos * 1.e3;
|
---|
| 1296 | eph._xv(3) = eph._z_pos * 1.e3;
|
---|
[9201] | 1297 | if (eph._xv.Rows(1,3).NormFrobenius() < 1.0) {
|
---|
[10549] | 1298 | #ifdef BNC_DEBUG_BCE
|
---|
[9201] | 1299 | emit(newMessage(QString("%1: Block %2 (%3): zero position!")
|
---|
[9315] | 1300 | .arg(_staID).arg(1020,4).arg(eph._prn.toString().c_str()).toLatin1(), true));
|
---|
[9210] | 1301 | #endif
|
---|
[9201] | 1302 | return false;
|
---|
| 1303 | }
|
---|
[8708] | 1304 | eph._xv(4) = eph._x_velocity * 1.e3;
|
---|
| 1305 | eph._xv(5) = eph._y_velocity * 1.e3;
|
---|
| 1306 | eph._xv(6) = eph._z_velocity * 1.e3;
|
---|
[9201] | 1307 | if (eph._xv.Rows(4,6).NormFrobenius() < 1.0) {
|
---|
[10549] | 1308 | #ifdef BNC_DEBUG_BCE
|
---|
[9201] | 1309 | emit(newMessage(QString("%1: Block %2 (%3): zero velocity!")
|
---|
[9315] | 1310 | .arg(_staID).arg(1020,4).arg(eph._prn.toString().c_str()).toLatin1(), true));
|
---|
[9210] | 1311 | #endif
|
---|
[9201] | 1312 | return false;
|
---|
| 1313 | }
|
---|
[8186] | 1314 | GLOFreq[sv - 1] = 100 + eph._frequency_number ; /* store frequency for other users (MSM) */
|
---|
| 1315 | _gloFrq = QString("%1 %2").arg(eph._prn.toString().c_str()).arg(eph._frequency_number, 2, 'f', 0);
|
---|
| 1316 |
|
---|
[9765] | 1317 | eph._navType = t_eph::FDMA;
|
---|
| 1318 |
|
---|
[8708] | 1319 | emit newGlonassEph(eph);
|
---|
| 1320 | decoded = true;
|
---|
[6812] | 1321 | }
|
---|
| 1322 | return decoded;
|
---|
| 1323 | }
|
---|
| 1324 |
|
---|
| 1325 | //
|
---|
| 1326 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 1327 | bool RTCM3Decoder::DecodeQZSSEphemeris(unsigned char* data, int size) {
|
---|
[6812] | 1328 | bool decoded = false;
|
---|
| 1329 |
|
---|
[8158] | 1330 | if (size == 67) {
|
---|
[6812] | 1331 | t_ephGPS eph;
|
---|
| 1332 | int i, week;
|
---|
| 1333 | uint64_t numbits = 0, bitfield = 0;
|
---|
[8852] | 1334 | int fitIntervalFalg = 0;
|
---|
[6812] | 1335 |
|
---|
| 1336 | data += 3; /* header */
|
---|
| 1337 | size -= 6; /* header + crc */
|
---|
| 1338 | SKIPBITS(12)
|
---|
| 1339 |
|
---|
| 1340 | eph._receptDateTime = currentDateAndTimeGPS();
|
---|
[9212] | 1341 | eph._receptStaID = _staID;
|
---|
[6812] | 1342 |
|
---|
| 1343 | GETBITS(i, 4)
|
---|
[10544] | 1344 | if (i < 1 || i > 10 ) {
|
---|
[10549] | 1345 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1346 | emit(newMessage(QString("%1: Block %2 (J) SAT ID is out of range: %3!")
|
---|
| 1347 | .arg(_staID)
|
---|
| 1348 | .arg(1044,4)
|
---|
| 1349 | .arg(i).toLatin1(), true));
|
---|
| 1350 | #endif
|
---|
| 1351 | return false;
|
---|
| 1352 | }
|
---|
[6812] | 1353 | eph._prn.set('J', i);
|
---|
[8476] | 1354 |
|
---|
[6812] | 1355 | GETBITS(i, 16)
|
---|
| 1356 | i <<= 4;
|
---|
[10544] | 1357 | if (i < 0 || i > 604784) {
|
---|
[10549] | 1358 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1359 | emit(newMessage(QString("%1: Block %2 (%3) TOC is out of range: %4!")
|
---|
| 1360 | .arg(_staID)
|
---|
| 1361 | .arg(1044,4)
|
---|
| 1362 | .arg(eph._prn.toString().c_str())
|
---|
| 1363 | .arg(i).toLatin1(), true));
|
---|
| 1364 | #endif
|
---|
| 1365 | return false;
|
---|
| 1366 | }
|
---|
[8158] | 1367 | eph._TOC.set(i * 1000);
|
---|
[6812] | 1368 |
|
---|
[8783] | 1369 | GETFLOATSIGN(eph._clock_driftrate, 8, 1.0 / (double )(1 << 30) / (double )(1 << 25))
|
---|
| 1370 | GETFLOATSIGN(eph._clock_drift, 16, 1.0 / (double )(1 << 30) / (double )(1 << 13))
|
---|
| 1371 | GETFLOATSIGN(eph._clock_bias, 22, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
[6812] | 1372 | GETBITS(eph._IODE, 8)
|
---|
[8783] | 1373 | GETFLOATSIGN(eph._Crs, 16, 1.0 / (double )(1 << 5))
|
---|
[6812] | 1374 | GETFLOATSIGN(eph._Delta_n, 16, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
[8783] | 1375 | GETFLOATSIGN(eph._M0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1376 | GETFLOATSIGN(eph._Cuc, 16, 1.0 / (double )(1 << 29))
|
---|
| 1377 | GETFLOAT(eph._e, 32, 1.0 / (double )(1 << 30) / (double )(1 << 3))
|
---|
| 1378 | GETFLOATSIGN(eph._Cus, 16, 1.0 / (double )(1 << 29))
|
---|
| 1379 | GETFLOAT(eph._sqrt_A, 32, 1.0 / (double )(1 << 19))
|
---|
[9201] | 1380 | if (eph._sqrt_A < 1000.0) {
|
---|
[10549] | 1381 | #ifdef BNC_DEBUG_BCE
|
---|
[9201] | 1382 | emit(newMessage(QString("%1: Block %2 (%3) SQRT_A %4 m!")
|
---|
| 1383 | .arg(_staID).arg(1044,4).arg(eph._prn.toString().c_str())
|
---|
| 1384 | .arg(eph._sqrt_A,10,'F',3).toLatin1(), true));
|
---|
[9210] | 1385 | #endif
|
---|
[9201] | 1386 | return false;
|
---|
| 1387 | }
|
---|
[6812] | 1388 | GETBITS(i, 16)
|
---|
| 1389 | i <<= 4;
|
---|
[10544] | 1390 | if (i < 0 || i > 604784) {
|
---|
[10549] | 1391 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1392 | emit(newMessage(QString("%1: Block %2 (%3) TOE is out of range: %4!")
|
---|
| 1393 | .arg(_staID)
|
---|
| 1394 | .arg(1044,4)
|
---|
| 1395 | .arg(eph._prn.toString().c_str())
|
---|
| 1396 | .arg(i).toLatin1(), true));
|
---|
| 1397 | #endif
|
---|
| 1398 | return false;
|
---|
| 1399 | }
|
---|
[6812] | 1400 | eph._TOEsec = i;
|
---|
| 1401 | bncTime t;
|
---|
[8470] | 1402 | t.set(i*1000);
|
---|
| 1403 | eph._TOEweek = t.gpsw();
|
---|
[8783] | 1404 | GETFLOATSIGN(eph._Cic, 16, 1.0 / (double )(1 << 29))
|
---|
| 1405 | GETFLOATSIGN(eph._OMEGA0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1406 | GETFLOATSIGN(eph._Cis, 16, 1.0 / (double )(1 << 29))
|
---|
| 1407 | GETFLOATSIGN(eph._i0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1408 | GETFLOATSIGN(eph._Crc, 16, 1.0 / (double )(1 << 5))
|
---|
| 1409 | GETFLOATSIGN(eph._omega, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[6812] | 1410 | GETFLOATSIGN(eph._OMEGADOT, 24, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
[8783] | 1411 | GETFLOATSIGN(eph._IDOT, 14, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
[6812] | 1412 | GETBITS(eph._L2Codes, 2)
|
---|
| 1413 | GETBITS(week, 10)
|
---|
[10544] | 1414 | if (week < 0 || week > 1023) {
|
---|
[10549] | 1415 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1416 | emit(newMessage(QString("%1: Block %2 (%3) WEEK # is out of range: %4!")
|
---|
| 1417 | .arg(_staID)
|
---|
| 1418 | .arg(1044,4)
|
---|
| 1419 | .arg(eph._prn.toString().c_str())
|
---|
| 1420 | .arg(week).toLatin1(), true));
|
---|
| 1421 | #endif
|
---|
| 1422 | return false;
|
---|
| 1423 | }
|
---|
[8472] | 1424 | int numOfRollOvers = int(floor(t.gpsw()/1024.0));
|
---|
| 1425 | week += (numOfRollOvers * 1024);
|
---|
[6812] | 1426 | /* week from HOW, differs from TOC, TOE week, we use adapted value instead */
|
---|
[8158] | 1427 | if (eph._TOEweek > week + 1 || eph._TOEweek < week - 1) /* invalid week */
|
---|
[6812] | 1428 | return false;
|
---|
| 1429 |
|
---|
| 1430 | GETBITS(i, 4)
|
---|
[8158] | 1431 | if (i <= 6)
|
---|
| 1432 | eph._ura = ceil(10.0 * pow(2.0, 1.0 + i / 2.0)) / 10.0;
|
---|
[6812] | 1433 | else
|
---|
[8158] | 1434 | eph._ura = ceil(10.0 * pow(2.0, i / 2.0)) / 10.0;
|
---|
[6812] | 1435 | GETBITS(eph._health, 6)
|
---|
[8783] | 1436 | GETFLOATSIGN(eph._TGD, 8, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
[6812] | 1437 | GETBITS(eph._IODC, 10)
|
---|
[8852] | 1438 | GETBITS(fitIntervalFalg, 1)
|
---|
[8903] | 1439 | eph._fitInterval = fitIntervalFromFlag(fitIntervalFalg, eph._IODC, eph.type());
|
---|
[6812] | 1440 | eph._TOT = 0.9999e9;
|
---|
[9765] | 1441 | eph._navType = t_eph::LNAV;
|
---|
[6812] | 1442 |
|
---|
| 1443 | emit newGPSEph(eph);
|
---|
| 1444 | decoded = true;
|
---|
| 1445 | }
|
---|
| 1446 | return decoded;
|
---|
| 1447 | }
|
---|
| 1448 |
|
---|
| 1449 | //
|
---|
| 1450 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8783] | 1451 | bool RTCM3Decoder::DecodeIRNSSEphemeris(unsigned char* data, int size) {
|
---|
| 1452 | bool decoded = false;
|
---|
| 1453 |
|
---|
| 1454 | if (size == 67) {
|
---|
| 1455 | t_ephGPS eph;
|
---|
| 1456 | int i, week, L5Flag, SFlag;
|
---|
| 1457 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 1458 |
|
---|
| 1459 | data += 3; /* header */
|
---|
| 1460 | size -= 6; /* header + crc */
|
---|
| 1461 | SKIPBITS(12)
|
---|
| 1462 |
|
---|
| 1463 | eph._receptDateTime = currentDateAndTimeGPS();
|
---|
[9212] | 1464 | eph._receptStaID = _staID;
|
---|
[8783] | 1465 |
|
---|
| 1466 | GETBITS(i, 6)
|
---|
[10544] | 1467 | if (i < 1 || i > 63 ) {
|
---|
[10549] | 1468 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1469 | emit(newMessage(QString("%1: Block %2 (I) PRN# is out of range: %3!")
|
---|
| 1470 | .arg(_staID)
|
---|
| 1471 | .arg(1041,4)
|
---|
| 1472 | .arg(i).toLatin1(), true));
|
---|
| 1473 | #endif
|
---|
| 1474 | return false;
|
---|
| 1475 | }
|
---|
[8783] | 1476 | eph._prn.set('I', i);
|
---|
| 1477 | GETBITS(week, 10)
|
---|
[10544] | 1478 | if (week < 0 || week > 1023) {
|
---|
[10549] | 1479 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1480 | emit(newMessage(QString("%1: Block %2 (%3) WEEK # is out of range: %4!")
|
---|
| 1481 | .arg(_staID)
|
---|
| 1482 | .arg(1041,4)
|
---|
| 1483 | .arg(eph._prn.toString().c_str())
|
---|
| 1484 | .arg(week).toLatin1(), true));
|
---|
| 1485 | #endif
|
---|
| 1486 | return false;
|
---|
| 1487 | }
|
---|
[8783] | 1488 | GETFLOATSIGN(eph._clock_bias, 22, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
| 1489 | GETFLOATSIGN(eph._clock_drift, 16, 1.0 / (double )(1 << 30) / (double )(1 << 13))
|
---|
| 1490 | GETFLOATSIGN(eph._clock_driftrate, 8, 1.0 / (double )(1 << 30) / (double )(1 << 25))
|
---|
| 1491 | GETBITS(i, 4)
|
---|
| 1492 | eph._ura = accuracyFromIndex(i, eph.type());
|
---|
| 1493 | GETBITS(i, 16)
|
---|
| 1494 | i <<= 4;
|
---|
[10544] | 1495 | if (i < 0 || i > 1048560) {
|
---|
[10549] | 1496 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1497 | emit(newMessage(QString("%1: Block %2 (%3) TOC is out of range: %4!")
|
---|
| 1498 | .arg(_staID)
|
---|
| 1499 | .arg(1041,4)
|
---|
| 1500 | .arg(eph._prn.toString().c_str())
|
---|
| 1501 | .arg(i).toLatin1(), true));
|
---|
| 1502 | #endif
|
---|
| 1503 | return false;
|
---|
| 1504 | }
|
---|
[8783] | 1505 | eph._TOC.set(i * 1000);
|
---|
| 1506 | GETFLOATSIGN(eph._TGD, 8, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
| 1507 | GETFLOATSIGN(eph._Delta_n, 22, R2R_PI/(double)(1<<30)/(double)(1 << 11))
|
---|
| 1508 | // IODCE
|
---|
| 1509 | GETBITS(eph._IODE, 8)
|
---|
| 1510 | eph._IODC = eph._IODE;
|
---|
| 1511 | SKIPBITS(10)
|
---|
| 1512 | GETBITS(L5Flag, 1)
|
---|
| 1513 | GETBITS(SFlag, 1)
|
---|
| 1514 | if (L5Flag == 0 && SFlag == 0) {
|
---|
| 1515 | eph._health = 0.0;
|
---|
| 1516 | }
|
---|
| 1517 | else if (L5Flag == 0 && SFlag == 1) {
|
---|
| 1518 | eph._health = 1.0;
|
---|
| 1519 | }
|
---|
| 1520 | else if (L5Flag == 1 && SFlag == 0) {
|
---|
| 1521 | eph._health = 2.0;
|
---|
| 1522 | }
|
---|
| 1523 | else if (L5Flag == 1 && SFlag == 1) {
|
---|
| 1524 | eph._health = 3.0;
|
---|
| 1525 | }
|
---|
| 1526 | GETFLOATSIGN(eph._Cuc, 15, 1.0 / (double )(1 << 28))
|
---|
| 1527 | GETFLOATSIGN(eph._Cus, 15, 1.0 / (double )(1 << 28))
|
---|
| 1528 | GETFLOATSIGN(eph._Cic, 15, 1.0 / (double )(1 << 28))
|
---|
| 1529 | GETFLOATSIGN(eph._Cis, 15, 1.0 / (double )(1 << 28))
|
---|
| 1530 | GETFLOATSIGN(eph._Crc, 15, 1.0 / (double )(1 << 4))
|
---|
| 1531 | GETFLOATSIGN(eph._Crs, 15, 1.0 / (double )(1 << 4))
|
---|
| 1532 | GETFLOATSIGN(eph._IDOT, 14, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
[9328] | 1533 | SKIPBITS(2)
|
---|
[8783] | 1534 | GETFLOATSIGN(eph._M0, 32, R2R_PI/(double)(1<<30)/(double)(1<< 1))
|
---|
| 1535 | GETBITS(i, 16)
|
---|
| 1536 | i <<= 4;
|
---|
[10544] | 1537 | if (i < 0 || i > 1048560) {
|
---|
[10549] | 1538 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1539 | emit(newMessage(QString("%1: Block %2 (%3) TOE is out of range: %4!")
|
---|
| 1540 | .arg(_staID)
|
---|
| 1541 | .arg(1041,4)
|
---|
| 1542 | .arg(eph._prn.toString().c_str())
|
---|
| 1543 | .arg(i).toLatin1(), true));
|
---|
| 1544 | #endif
|
---|
| 1545 | return false;
|
---|
| 1546 | }
|
---|
[8783] | 1547 | eph._TOEsec = i;
|
---|
| 1548 | bncTime t;
|
---|
| 1549 | t.set(i * 1000);
|
---|
| 1550 | eph._TOEweek = t.gpsw();
|
---|
| 1551 | int numOfRollOvers = int(floor(t.gpsw()/1024.0));
|
---|
| 1552 | week += (numOfRollOvers * 1024);
|
---|
| 1553 | /* week from HOW, differs from TOC, TOE week, we use adapted value instead */
|
---|
| 1554 | if (eph._TOEweek > week + 1 || eph._TOEweek < week - 1) /* invalid week */
|
---|
| 1555 | return false;
|
---|
| 1556 | GETFLOAT(eph._e, 32, 1.0 / (double )(1 << 30) / (double )(1 << 3))
|
---|
| 1557 | GETFLOAT(eph._sqrt_A, 32, 1.0 / (double )(1 << 19))
|
---|
[9201] | 1558 | if (eph._sqrt_A < 1000.0) {
|
---|
[10549] | 1559 | #ifdef BNC_DEBUG_BCE
|
---|
[9201] | 1560 | emit(newMessage(QString("%1: Block %2 (%3) SQRT_A %4 m!")
|
---|
| 1561 | .arg(_staID).arg(1041,4).arg(eph._prn.toString().c_str())
|
---|
| 1562 | .arg(eph._sqrt_A,10,'F',3).toLatin1(), true));
|
---|
[9210] | 1563 | #endif
|
---|
[9201] | 1564 | return false;
|
---|
| 1565 | }
|
---|
[8783] | 1566 | GETFLOATSIGN(eph._OMEGA0, 32, R2R_PI/(double)(1<<30)/(double)(1<< 1))
|
---|
| 1567 | GETFLOATSIGN(eph._omega, 32, R2R_PI/(double)(1<<30)/(double)(1<< 1))
|
---|
| 1568 | GETFLOATSIGN(eph._OMEGADOT, 22, R2R_PI/(double)(1<<30)/(double)(1<<11))
|
---|
| 1569 | GETFLOATSIGN(eph._i0, 32, R2R_PI/(double)(1<<30)/(double)(1<< 1))
|
---|
| 1570 | SKIPBITS(2)
|
---|
| 1571 | eph._TOT = 0.9999e9;
|
---|
[9765] | 1572 | eph._navType = t_eph::LNAV;
|
---|
[8783] | 1573 |
|
---|
| 1574 | emit newGPSEph(eph);
|
---|
| 1575 | decoded = true;
|
---|
| 1576 | }
|
---|
| 1577 | return decoded;
|
---|
| 1578 | }
|
---|
| 1579 |
|
---|
| 1580 | //
|
---|
| 1581 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 1582 | bool RTCM3Decoder::DecodeSBASEphemeris(unsigned char* data, int size) {
|
---|
[6812] | 1583 | bool decoded = false;
|
---|
| 1584 |
|
---|
[8158] | 1585 | if (size == 35) {
|
---|
[6812] | 1586 | t_ephSBAS eph;
|
---|
| 1587 | int i;
|
---|
| 1588 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 1589 |
|
---|
| 1590 | data += 3; /* header */
|
---|
| 1591 | size -= 6; /* header + crc */
|
---|
| 1592 | SKIPBITS(12)
|
---|
| 1593 |
|
---|
| 1594 | eph._receptDateTime = currentDateAndTimeGPS();
|
---|
[9212] | 1595 | eph._receptStaID = _staID;
|
---|
[6812] | 1596 |
|
---|
| 1597 | GETBITS(i, 6)
|
---|
[10554] | 1598 | if (i < 0 || i > 38 ) {
|
---|
[10549] | 1599 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1600 | emit(newMessage(QString("%1: Block %2 (S) PRN# is out of range: %3!")
|
---|
| 1601 | .arg(_staID)
|
---|
| 1602 | .arg(1043,4)
|
---|
| 1603 | .arg(i).toLatin1(), true));
|
---|
| 1604 | #endif
|
---|
| 1605 | return false;
|
---|
| 1606 | }
|
---|
[10554] | 1607 | eph._prn.set('S', 20 + i);
|
---|
[6812] | 1608 | GETBITS(eph._IODN, 8)
|
---|
| 1609 | GETBITS(i, 13)
|
---|
| 1610 | i <<= 4;
|
---|
[10544] | 1611 | if (i < 0 || i > 86384) {
|
---|
[10549] | 1612 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1613 | emit(newMessage(QString("%1: Block %2 (%3) TOC is out of range: %4!")
|
---|
| 1614 | .arg(_staID)
|
---|
| 1615 | .arg(1043,4)
|
---|
| 1616 | .arg(eph._prn.toString().c_str())
|
---|
| 1617 | .arg(i).toLatin1(), true));
|
---|
| 1618 | #endif
|
---|
| 1619 | return false;
|
---|
| 1620 | }
|
---|
[8158] | 1621 | eph._TOC.setTOD(i * 1000);
|
---|
[6812] | 1622 | GETBITS(i, 4)
|
---|
| 1623 | eph._ura = accuracyFromIndex(i, eph.type());
|
---|
| 1624 | GETFLOATSIGN(eph._x_pos, 30, 0.08)
|
---|
| 1625 | GETFLOATSIGN(eph._y_pos, 30, 0.08)
|
---|
| 1626 | GETFLOATSIGN(eph._z_pos, 25, 0.4)
|
---|
[9201] | 1627 | ColumnVector pos(3);
|
---|
| 1628 | pos(1) = eph._x_pos; pos(2) = eph._y_pos; pos(3) = eph._z_pos;
|
---|
| 1629 | if (pos.NormFrobenius() < 1.0) {
|
---|
[10549] | 1630 | #ifdef BNC_DEBUG_BCE
|
---|
[9201] | 1631 | emit(newMessage(QString("%1: Block %2 (%3): zero position!")
|
---|
| 1632 | .arg(_staID).arg(1043,4).arg(eph._prn.toString().c_str()).toLatin1(), true));
|
---|
[9210] | 1633 | #endif
|
---|
[9201] | 1634 | return false;
|
---|
| 1635 | }
|
---|
[6812] | 1636 | GETFLOATSIGN(eph._x_velocity, 17, 0.000625)
|
---|
| 1637 | GETFLOATSIGN(eph._y_velocity, 17, 0.000625)
|
---|
| 1638 | GETFLOATSIGN(eph._z_velocity, 18, 0.004)
|
---|
| 1639 | GETFLOATSIGN(eph._x_acceleration, 10, 0.0000125)
|
---|
| 1640 | GETFLOATSIGN(eph._y_acceleration, 10, 0.0000125)
|
---|
| 1641 | GETFLOATSIGN(eph._z_acceleration, 10, 0.0000625)
|
---|
[8158] | 1642 | GETFLOATSIGN(eph._agf0, 12, 1.0 / (1 << 30) / (1 << 1))
|
---|
| 1643 | GETFLOATSIGN(eph._agf1, 8, 1.0 / (1 << 30) / (1 << 10))
|
---|
[6812] | 1644 |
|
---|
[8456] | 1645 | eph._TOT = 0.9999E9;
|
---|
[6812] | 1646 | eph._health = 0;
|
---|
[9765] | 1647 | eph._navType = t_eph::SBASL1;
|
---|
[6812] | 1648 |
|
---|
| 1649 | emit newSBASEph(eph);
|
---|
| 1650 | decoded = true;
|
---|
| 1651 | }
|
---|
| 1652 | return decoded;
|
---|
| 1653 | }
|
---|
| 1654 |
|
---|
| 1655 | //
|
---|
| 1656 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 1657 | bool RTCM3Decoder::DecodeGalileoEphemeris(unsigned char* data, int size) {
|
---|
[6812] | 1658 | bool decoded = false;
|
---|
| 1659 | uint64_t numbits = 0, bitfield = 0;
|
---|
[10544] | 1660 | int i, week, mnum;
|
---|
[6812] | 1661 |
|
---|
| 1662 | data += 3; /* header */
|
---|
| 1663 | size -= 6; /* header + crc */
|
---|
| 1664 | GETBITS(i, 12)
|
---|
| 1665 |
|
---|
[8158] | 1666 | if ((i == 1046 && size == 61) || (i == 1045 && size == 60)) {
|
---|
[6812] | 1667 | t_ephGal eph;
|
---|
| 1668 | eph._receptDateTime = currentDateAndTimeGPS();
|
---|
[9212] | 1669 | eph._receptStaID = _staID;
|
---|
[6812] | 1670 |
|
---|
| 1671 | eph._inav = (i == 1046);
|
---|
| 1672 | eph._fnav = (i == 1045);
|
---|
[10544] | 1673 | mnum = i;
|
---|
[6812] | 1674 | GETBITS(i, 6)
|
---|
[10544] | 1675 | if (i < 1 || i > 36 ) { // max. constellation within I/NAV / F/NAV frames is 36
|
---|
[10549] | 1676 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1677 | emit(newMessage(QString("%1: Block %2 (E) PRN# is out of range: %3!")
|
---|
| 1678 | .arg(_staID)
|
---|
| 1679 | .arg(mnum,4)
|
---|
| 1680 | .arg(i).toLatin1(), true));
|
---|
| 1681 | #endif
|
---|
| 1682 | return false;
|
---|
| 1683 | }
|
---|
[6812] | 1684 | eph._prn.set('E', i, eph._inav ? 1 : 0);
|
---|
| 1685 |
|
---|
[10544] | 1686 | GETBITS(week, 12) //FIXME: roll-over after week 4095!!
|
---|
| 1687 | if (week < 0 || week > 4095) {
|
---|
[10549] | 1688 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1689 | emit(newMessage(QString("%1: Block %2 (%3) WEEK # is out of range: %4!")
|
---|
| 1690 | .arg(_staID)
|
---|
| 1691 | .arg(mnum,4)
|
---|
| 1692 | .arg(eph._prn.toString().c_str())
|
---|
| 1693 | .arg(week).toLatin1(), true));
|
---|
| 1694 | #endif
|
---|
| 1695 | return false;
|
---|
| 1696 | }
|
---|
| 1697 | eph._TOEweek = week;
|
---|
[6812] | 1698 | GETBITS(eph._IODnav, 10)
|
---|
| 1699 | GETBITS(i, 8)
|
---|
| 1700 | eph._SISA = accuracyFromIndex(i, eph.type());
|
---|
| 1701 | GETFLOATSIGN(eph._IDOT, 14, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 1702 | GETBITSFACTOR(i, 14, 60)
|
---|
[10544] | 1703 | if (i < 0 || i > 604740) {
|
---|
[10549] | 1704 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1705 | emit(newMessage(QString("%1: Block %2 (%3) TOC is out of range: %4!")
|
---|
| 1706 | .arg(_staID)
|
---|
| 1707 | .arg(mnum,4)
|
---|
| 1708 | .arg(eph._prn.toString().c_str())
|
---|
| 1709 | .arg(i).toLatin1(), true));
|
---|
| 1710 | #endif
|
---|
| 1711 | return false;
|
---|
| 1712 | }
|
---|
| 1713 | eph._TOC.set(1024 + eph._TOEweek, i);// Period #2 = + 1 x 1024 (has to be determined)
|
---|
[8783] | 1714 | GETFLOATSIGN(eph._clock_driftrate, 6, 1.0 / (double )(1 << 30) / (double )(1 << 29))
|
---|
| 1715 | GETFLOATSIGN(eph._clock_drift, 21, 1.0 / (double )(1 << 30) / (double )(1 << 16))
|
---|
| 1716 | GETFLOATSIGN(eph._clock_bias, 31, 1.0 / (double )(1 << 30) / (double )(1 << 4))
|
---|
| 1717 | GETFLOATSIGN(eph._Crs, 16, 1.0 / (double )(1 << 5))
|
---|
| 1718 | GETFLOATSIGN(eph._Delta_n, 16, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 1719 | GETFLOATSIGN(eph._M0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1720 | GETFLOATSIGN(eph._Cuc, 16, 1.0 / (double )(1 << 29))
|
---|
| 1721 | GETFLOAT(eph._e, 32, 1.0 / (double )(1 << 30) / (double )(1 << 3))
|
---|
| 1722 | GETFLOATSIGN(eph._Cus, 16, 1.0 / (double )(1 << 29))
|
---|
| 1723 | GETFLOAT(eph._sqrt_A, 32, 1.0 / (double )(1 << 19))
|
---|
[6812] | 1724 | GETBITSFACTOR(eph._TOEsec, 14, 60)
|
---|
[10544] | 1725 | if (i < 0 || i > 604740) {
|
---|
[10549] | 1726 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1727 | emit(newMessage(QString("%1: Block %2 (%3) TOE is out of range: %4!")
|
---|
| 1728 | .arg(_staID)
|
---|
| 1729 | .arg(mnum,4)
|
---|
| 1730 | .arg(eph._prn.toString().c_str())
|
---|
| 1731 | .arg(i).toLatin1(), true));
|
---|
| 1732 | #endif
|
---|
| 1733 | return false;
|
---|
| 1734 | }
|
---|
[6812] | 1735 | /* FIXME: overwrite value, copied from old code */
|
---|
| 1736 | eph._TOEsec = eph._TOC.gpssec();
|
---|
[8783] | 1737 | GETFLOATSIGN(eph._Cic, 16, 1.0 / (double )(1 << 29))
|
---|
| 1738 | GETFLOATSIGN(eph._OMEGA0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1739 | GETFLOATSIGN(eph._Cis, 16, 1.0 / (double )(1 << 29))
|
---|
| 1740 | GETFLOATSIGN(eph._i0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1741 | GETFLOATSIGN(eph._Crc, 16, 1.0 / (double )(1 << 5))
|
---|
| 1742 | GETFLOATSIGN(eph._omega, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[6812] | 1743 | GETFLOATSIGN(eph._OMEGADOT, 24, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
[8981] | 1744 | GETFLOATSIGN(eph._BGD_1_5A, 10, 1.0 / (double )(1 << 30) / (double )(1 << 2))
|
---|
[8158] | 1745 | if (eph._inav) {
|
---|
[7006] | 1746 | /* set unused F/NAV values */
|
---|
[6812] | 1747 | eph._E5aHS = 0.0;
|
---|
| 1748 | eph._e5aDataInValid = false;
|
---|
| 1749 |
|
---|
[8783] | 1750 | GETFLOATSIGN(eph._BGD_1_5B, 10, 1.0 / (double )(1 << 30) / (double )(1 << 2))
|
---|
[6812] | 1751 | GETBITS(eph._E5bHS, 2)
|
---|
| 1752 | GETBITS(eph._e5bDataInValid, 1)
|
---|
| 1753 | GETBITS(eph._E1_bHS, 2)
|
---|
| 1754 | GETBITS(eph._e1DataInValid, 1)
|
---|
[9192] | 1755 | if (eph._E5bHS != eph._E1_bHS) {
|
---|
[10549] | 1756 | #ifdef BNC_DEBUG_BCE
|
---|
[9201] | 1757 | emit(newMessage(QString("%1: Block %2 (%3) SHS E5b %4 E1B %5: inconsistent health!")
|
---|
| 1758 | .arg(_staID).arg(1046,4).arg(eph._prn.toString().c_str())
|
---|
| 1759 | .arg(eph._E5bHS).arg(eph._E1_bHS).toLatin1(), true));
|
---|
[9210] | 1760 | #endif
|
---|
[9192] | 1761 | return false;
|
---|
| 1762 | }
|
---|
| 1763 | if ((eph._BGD_1_5A == 0.0 && fabs(eph._BGD_1_5B) > 1e-9) ||
|
---|
| 1764 | (eph._BGD_1_5B == 0.0 && fabs(eph._BGD_1_5A) > 1e-9)) {
|
---|
[10549] | 1765 | #ifdef BNC_DEBUG_BCE
|
---|
[9201] | 1766 | emit(newMessage(QString("%1: Block %2 (%3) BGD_15a = %4 BGD_15b = %5: inconsistent BGD!")
|
---|
| 1767 | .arg(_staID).arg(1046,4).arg(eph._prn.toString().c_str())
|
---|
| 1768 | .arg(eph._BGD_1_5A,10,'E',3).arg(eph._BGD_1_5B,10,'E',3).toLatin1(), true));
|
---|
[9210] | 1769 | #endif
|
---|
[9192] | 1770 | return false;
|
---|
| 1771 | }
|
---|
[9765] | 1772 | eph._navType = t_eph::INAF;
|
---|
[6812] | 1773 | }
|
---|
[8158] | 1774 | else {
|
---|
[7006] | 1775 | /* set unused I/NAV values */
|
---|
[6812] | 1776 | eph._BGD_1_5B = 0.0;
|
---|
| 1777 | eph._E5bHS = 0.0;
|
---|
| 1778 | eph._E1_bHS = 0.0;
|
---|
| 1779 | eph._e1DataInValid = false;
|
---|
| 1780 | eph._e5bDataInValid = false;
|
---|
| 1781 |
|
---|
| 1782 | GETBITS(eph._E5aHS, 2)
|
---|
| 1783 | GETBITS(eph._e5aDataInValid, 1)
|
---|
[9765] | 1784 | eph._navType = t_eph::FNAV;
|
---|
[6812] | 1785 | }
|
---|
| 1786 | eph._TOT = 0.9999e9;
|
---|
| 1787 |
|
---|
[9201] | 1788 | if (eph._sqrt_A < 1000.0) {
|
---|
[10549] | 1789 | #ifdef BNC_DEBUG_BCE
|
---|
[9201] | 1790 | emit(newMessage(QString("%1: Block %2 (%3) SQRT_A %4 m!")
|
---|
| 1791 | .arg(_staID).arg(eph._inav? 1046 : 1045,4).arg(eph._prn.toString().c_str())
|
---|
| 1792 | .arg(eph._sqrt_A,10,'F',3).toLatin1(), true));
|
---|
[9210] | 1793 | #endif
|
---|
[9201] | 1794 | return false;
|
---|
| 1795 | }
|
---|
| 1796 |
|
---|
[6812] | 1797 | emit newGalileoEph(eph);
|
---|
| 1798 | decoded = true;
|
---|
| 1799 | }
|
---|
| 1800 | return decoded;
|
---|
| 1801 | }
|
---|
| 1802 |
|
---|
| 1803 | //
|
---|
| 1804 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 1805 | bool RTCM3Decoder::DecodeBDSEphemeris(unsigned char* data, int size) {
|
---|
[6812] | 1806 | bool decoded = false;
|
---|
[9765] | 1807 | const double iMaxGEO = 10.0 / 180.0 * M_PI;
|
---|
[6812] | 1808 |
|
---|
[8158] | 1809 | if (size == 70) {
|
---|
[6812] | 1810 | t_ephBDS eph;
|
---|
[10544] | 1811 | int i, week;
|
---|
[6812] | 1812 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 1813 |
|
---|
| 1814 | data += 3; /* header */
|
---|
| 1815 | size -= 6; /* header + crc */
|
---|
| 1816 | SKIPBITS(12)
|
---|
| 1817 |
|
---|
| 1818 | eph._receptDateTime = currentDateAndTimeGPS();
|
---|
[9212] | 1819 | eph._receptStaID = _staID;
|
---|
[6812] | 1820 |
|
---|
| 1821 | GETBITS(i, 6)
|
---|
[10544] | 1822 | if (i < 1 || i > 63 ) {
|
---|
[10549] | 1823 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1824 | emit(newMessage(QString("%1: Block %2 (C) PRN# is out of range: %3!")
|
---|
| 1825 | .arg(_staID)
|
---|
| 1826 | .arg(1042,4)
|
---|
| 1827 | .arg(i).toLatin1(), true));
|
---|
| 1828 | #endif
|
---|
| 1829 | return false;
|
---|
| 1830 | }
|
---|
[6812] | 1831 | eph._prn.set('C', i);
|
---|
| 1832 |
|
---|
[10544] | 1833 | GETBITS(week, 13)
|
---|
| 1834 | if (week < 0 || week > 8191) {
|
---|
[10549] | 1835 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1836 | emit(newMessage(QString("%1: Block %2 (%3) WEEK # is out of range: %4!")
|
---|
| 1837 | .arg(_staID)
|
---|
| 1838 | .arg(1042,4)
|
---|
| 1839 | .arg(eph._prn.toString().c_str())
|
---|
| 1840 | .arg(week).toLatin1(), true));
|
---|
| 1841 | #endif
|
---|
| 1842 | return false;
|
---|
| 1843 | }
|
---|
| 1844 | eph._BDTweek = week;
|
---|
[6812] | 1845 | GETBITS(i, 4)
|
---|
| 1846 | eph._URA = accuracyFromIndex(i, eph.type());
|
---|
| 1847 | GETFLOATSIGN(eph._IDOT, 14, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 1848 | GETBITS(eph._AODE, 5)
|
---|
| 1849 | GETBITS(i, 17)
|
---|
| 1850 | i <<= 3;
|
---|
[10544] | 1851 | if (i < 0 || i > 604792) {
|
---|
[10549] | 1852 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1853 | emit(newMessage(QString("%1: Block %2 (%3) TOC is out of range: %4!")
|
---|
| 1854 | .arg(_staID)
|
---|
| 1855 | .arg(1042,4)
|
---|
| 1856 | .arg(eph._prn.toString().c_str())
|
---|
| 1857 | .arg(i).toLatin1(), true));
|
---|
| 1858 | #endif
|
---|
| 1859 | return false;
|
---|
| 1860 | }
|
---|
[9785] | 1861 | eph._TOC.setBDS(eph._BDTweek, i);
|
---|
[8783] | 1862 | GETFLOATSIGN(eph._clock_driftrate, 11, 1.0 / (double )(1 << 30) / (double )(1 << 30) / (double )(1 << 6))
|
---|
| 1863 | GETFLOATSIGN(eph._clock_drift, 22, 1.0 / (double )(1 << 30) / (double )(1 << 20))
|
---|
| 1864 | GETFLOATSIGN(eph._clock_bias, 24, 1.0 / (double )(1 << 30) / (double )(1 << 3))
|
---|
[6812] | 1865 | GETBITS(eph._AODC, 5)
|
---|
[8783] | 1866 | GETFLOATSIGN(eph._Crs, 18, 1.0 / (double )(1 << 6))
|
---|
[6812] | 1867 | GETFLOATSIGN(eph._Delta_n, 16, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
[8783] | 1868 | GETFLOATSIGN(eph._M0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1869 | GETFLOATSIGN(eph._Cuc, 18, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
| 1870 | GETFLOAT(eph._e, 32, 1.0 / (double )(1 << 30) / (double )(1 << 3))
|
---|
| 1871 | GETFLOATSIGN(eph._Cus, 18, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
| 1872 | GETFLOAT(eph._sqrt_A, 32, 1.0 / (double )(1 << 19))
|
---|
[9201] | 1873 | if (eph._sqrt_A < 1000.0) {
|
---|
[10549] | 1874 | #ifdef BNC_DEBUG_BCE
|
---|
[9201] | 1875 | emit(newMessage(QString("%1: Block %2 (%3) SQRT_A %4 m!")
|
---|
| 1876 | .arg(_staID).arg(1042,4).arg(eph._prn.toString().c_str())
|
---|
| 1877 | .arg(eph._sqrt_A,10,'F',3).toLatin1(), true));
|
---|
[9210] | 1878 | #endif
|
---|
[9201] | 1879 | return false;
|
---|
| 1880 | }
|
---|
[6812] | 1881 | GETBITS(i, 17)
|
---|
| 1882 | i <<= 3;
|
---|
[10544] | 1883 | if (i < 0 || i > 604792) {
|
---|
[10549] | 1884 | #ifdef BNC_DEBUG_BCE
|
---|
[10544] | 1885 | emit(newMessage(QString("%1: Block %2 (%3) TOE is out of range: %4!")
|
---|
| 1886 | .arg(_staID)
|
---|
| 1887 | .arg(1042,4)
|
---|
| 1888 | .arg(eph._prn.toString().c_str())
|
---|
| 1889 | .arg(i).toLatin1(), true));
|
---|
| 1890 | #endif
|
---|
| 1891 | return false;
|
---|
| 1892 | }
|
---|
[6812] | 1893 | eph._TOEsec = i;
|
---|
[9785] | 1894 | eph._TOE.setBDS(eph._BDTweek, i);
|
---|
[8783] | 1895 | GETFLOATSIGN(eph._Cic, 18, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
| 1896 | GETFLOATSIGN(eph._OMEGA0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1897 | GETFLOATSIGN(eph._Cis, 18, 1.0 / (double )(1 << 30) / (double )(1 << 1))
|
---|
| 1898 | GETFLOATSIGN(eph._i0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 1899 | GETFLOATSIGN(eph._Crc, 18, 1.0 / (double )(1 << 6))
|
---|
| 1900 | GETFLOATSIGN(eph._omega, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[6812] | 1901 | GETFLOATSIGN(eph._OMEGADOT, 24, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
[8783] | 1902 | GETFLOATSIGN(eph._TGD1, 10, 0.0000000001)
|
---|
| 1903 | GETFLOATSIGN(eph._TGD2, 10, 0.0000000001)
|
---|
[6812] | 1904 | GETBITS(eph._SatH1, 1)
|
---|
| 1905 |
|
---|
[8456] | 1906 | eph._TOT = 0.9999E9;
|
---|
[9765] | 1907 | if (eph._i0 > iMaxGEO) {
|
---|
| 1908 | eph._navType = t_eph::D1;
|
---|
| 1909 | }
|
---|
| 1910 | else {
|
---|
| 1911 | eph._navType = t_eph::D2;
|
---|
| 1912 | }
|
---|
| 1913 |
|
---|
[6812] | 1914 | emit newBDSEph(eph);
|
---|
| 1915 | decoded = true;
|
---|
| 1916 | }
|
---|
| 1917 | return decoded;
|
---|
| 1918 | }
|
---|
| 1919 |
|
---|
[8197] | 1920 | //
|
---|
| 1921 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 1922 | bool RTCM3Decoder::DecodeAntennaReceiver(unsigned char* data, int size) {
|
---|
[8234] | 1923 | char *antenna;
|
---|
| 1924 | char *antserialnum;
|
---|
| 1925 | char *receiver;
|
---|
| 1926 | char *recfirmware;
|
---|
| 1927 | char *recserialnum;
|
---|
[8197] | 1928 | int type;
|
---|
[8234] | 1929 | int antsernum = -1;
|
---|
[8197] | 1930 | int antnum = -1;
|
---|
| 1931 | int recnum = -1;
|
---|
[8234] | 1932 | int recsernum = -1;
|
---|
| 1933 | int recfirnum = -1;
|
---|
[8197] | 1934 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 1935 |
|
---|
| 1936 | data += 3; /* header*/
|
---|
| 1937 | size -= 6; /* header + crc */
|
---|
| 1938 |
|
---|
[8198] | 1939 | GETBITS(type, 12)
|
---|
[8234] | 1940 | SKIPBITS(12) /* reference station ID */
|
---|
[8197] | 1941 | GETSTRING(antnum, antenna)
|
---|
[8234] | 1942 | if ((antnum > -1 && antnum < 265) &&
|
---|
| 1943 | (_antType.empty() || strncmp(_antType.back().descriptor, antenna, recnum) != 0)) {
|
---|
| 1944 | _antType.push_back(t_antInfo());
|
---|
| 1945 | memcpy(_antType.back().descriptor, antenna, antnum);
|
---|
| 1946 | _antType.back().descriptor[antnum] = 0;
|
---|
| 1947 | }
|
---|
| 1948 | SKIPBITS(8) /* antenna setup ID */
|
---|
| 1949 | if (type == 1008 || type == 1033 ) {
|
---|
| 1950 | GETSTRING(antsernum, antserialnum)
|
---|
| 1951 | if ((antsernum > -1 && antsernum < 265)) {
|
---|
| 1952 | memcpy(_antType.back().serialnumber, antserialnum, antsernum);
|
---|
| 1953 | _antType.back().serialnumber[antsernum] = 0;
|
---|
[8197] | 1954 | }
|
---|
| 1955 | }
|
---|
[8234] | 1956 |
|
---|
[8197] | 1957 | if (type == 1033) {
|
---|
| 1958 | GETSTRING(recnum, receiver)
|
---|
[8234] | 1959 | GETSTRING(recfirnum, recfirmware)
|
---|
| 1960 | GETSTRING(recsernum, recserialnum)
|
---|
| 1961 | if ((recnum > -1 && recnum < 265) &&
|
---|
| 1962 | (_recType.empty() || strncmp(_recType.back().descriptor, receiver, recnum) != 0)) {
|
---|
| 1963 | _recType.push_back(t_recInfo());
|
---|
| 1964 | memcpy(_recType.back().descriptor, receiver, recnum);
|
---|
| 1965 | _recType.back().descriptor[recnum] = 0;
|
---|
| 1966 | if (recfirnum > -1 && recfirnum < 265) {
|
---|
| 1967 | memcpy(_recType.back().firmware, recfirmware, recfirnum);
|
---|
| 1968 | _recType.back().firmware[recfirnum] = 0;
|
---|
[8197] | 1969 | }
|
---|
[8234] | 1970 | if (recsernum > -1 && recsernum < 265) {
|
---|
| 1971 | memcpy(_recType.back().serialnumber, recserialnum, recsernum);
|
---|
| 1972 | _recType.back().serialnumber[recsernum] = 0;
|
---|
| 1973 | }
|
---|
[8197] | 1974 | }
|
---|
| 1975 | }
|
---|
| 1976 | return true;
|
---|
[6812] | 1977 | }
|
---|
| 1978 |
|
---|
| 1979 | //
|
---|
| 1980 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 1981 | bool RTCM3Decoder::DecodeAntennaPosition(unsigned char* data, int size) {
|
---|
[6812] | 1982 | int type;
|
---|
| 1983 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 1984 | double x, y, z;
|
---|
| 1985 |
|
---|
| 1986 | data += 3; /* header */
|
---|
| 1987 | size -= 6; /* header + crc */
|
---|
| 1988 |
|
---|
| 1989 | GETBITS(type, 12)
|
---|
[8234] | 1990 | _antList.push_back(t_antRefPoint());
|
---|
| 1991 | _antList.back().type = t_antRefPoint::ARP;
|
---|
[6812] | 1992 | SKIPBITS(22)
|
---|
| 1993 | GETBITSSIGN(x, 38)
|
---|
| 1994 | _antList.back().xx = x * 1e-4;
|
---|
| 1995 | SKIPBITS(2)
|
---|
| 1996 | GETBITSSIGN(y, 38)
|
---|
| 1997 | _antList.back().yy = y * 1e-4;
|
---|
| 1998 | SKIPBITS(2)
|
---|
| 1999 | GETBITSSIGN(z, 38)
|
---|
| 2000 | _antList.back().zz = z * 1e-4;
|
---|
[10534] | 2001 | if (type == 1006) {
|
---|
[6812] | 2002 | double h;
|
---|
| 2003 | GETBITS(h, 16)
|
---|
| 2004 | _antList.back().height = h * 1e-4;
|
---|
| 2005 | _antList.back().height_f = true;
|
---|
| 2006 | }
|
---|
[8158] | 2007 | _antList.back().message = type;
|
---|
[6812] | 2008 |
|
---|
| 2009 | return true;
|
---|
| 2010 | }
|
---|
| 2011 |
|
---|
[7753] | 2012 | //
|
---|
[6812] | 2013 | ////////////////////////////////////////////////////////////////////////////
|
---|
[10534] | 2014 | bool RTCM3Decoder::DecodeServiceCRS(unsigned char* data, int size) {
|
---|
| 2015 | t_serviceCrs serviceCrs;
|
---|
| 2016 | int servicecrsnum = -1;
|
---|
| 2017 |
|
---|
| 2018 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 2019 |
|
---|
| 2020 | data += 3; // header
|
---|
| 2021 | size -= 6; // header + crc
|
---|
| 2022 |
|
---|
| 2023 | SKIPBITS(12) // Message Number
|
---|
| 2024 |
|
---|
| 2025 | GETBITS(servicecrsnum, 5)
|
---|
| 2026 | if (servicecrsnum > -1 && servicecrsnum <= 31) {
|
---|
| 2027 | for(int i = 0; i < servicecrsnum; i++) {
|
---|
| 2028 | GETBITS(serviceCrs._name[i], 8);
|
---|
| 2029 | }
|
---|
| 2030 | serviceCrs._name[servicecrsnum] = 0;
|
---|
| 2031 | }
|
---|
| 2032 | if (_serviceCrs.empty() ||
|
---|
| 2033 | (strncmp(_serviceCrs.back()._name, serviceCrs._name, servicecrsnum) != 0)) {
|
---|
| 2034 | _serviceCrs.push_back(serviceCrs);
|
---|
| 2035 | GETFLOAT(_serviceCrs.back()._CE, 16, 1/100.0)
|
---|
| 2036 | _serviceCrs.back().setCoordinateEpochFromCE();
|
---|
[10539] | 2037 | //_serviceCrs.back().print();
|
---|
[10534] | 2038 | }
|
---|
| 2039 | return true;
|
---|
| 2040 |
|
---|
| 2041 | }
|
---|
| 2042 |
|
---|
| 2043 | //
|
---|
| 2044 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 2045 | bool RTCM3Decoder::DecodeRTCMCRS(unsigned char* data, int size) {
|
---|
| 2046 |
|
---|
| 2047 | t_rtcmCrs rtcmCrs;
|
---|
| 2048 | int rtcmcrsnum = -1;
|
---|
| 2049 |
|
---|
| 2050 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 2051 |
|
---|
| 2052 | data += 3; // header
|
---|
| 2053 | size -= 6; // header + crc
|
---|
| 2054 |
|
---|
| 2055 | SKIPBITS(12) // Message Number
|
---|
| 2056 | GETBITS(rtcmcrsnum, 5)
|
---|
| 2057 | if (rtcmcrsnum > -1 && rtcmcrsnum <= 31) {
|
---|
| 2058 | for(int i = 0; i < rtcmcrsnum; i++) {
|
---|
| 2059 | GETBITS(rtcmCrs._name[i], 8);
|
---|
| 2060 | }
|
---|
| 2061 | rtcmCrs._name[rtcmcrsnum] = 0;
|
---|
| 2062 | }
|
---|
| 2063 | if (_rtcmCrs.empty() ||
|
---|
| 2064 | (strncmp(_rtcmCrs.back()._name, rtcmCrs._name, rtcmcrsnum) != 0)) {
|
---|
| 2065 | _rtcmCrs.push_back(rtcmCrs);
|
---|
| 2066 |
|
---|
| 2067 | GETBITS(_rtcmCrs.back()._anchor, 1)
|
---|
| 2068 | GETBITS(_rtcmCrs.back()._plateNumber, 5)
|
---|
| 2069 |
|
---|
| 2070 | int dblinksnum = 0;
|
---|
| 2071 | GETBITS(dblinksnum, 3)
|
---|
| 2072 | for (int i = 0; i < dblinksnum; i++) {
|
---|
| 2073 | int dblinknum = -1;
|
---|
| 2074 | char dblinkname[31];
|
---|
| 2075 | GETBITS(dblinknum, 5)
|
---|
| 2076 | if (dblinknum > -1 && dblinknum <= 31) {
|
---|
| 2077 | for(int i = 0; i < dblinknum; i++) {
|
---|
| 2078 | GETBITS(dblinkname[i], 8);
|
---|
| 2079 | }
|
---|
| 2080 | dblinkname[dblinknum] = 0;
|
---|
| 2081 | _rtcmCrs.back()._databaseLinks.append(QString("%1").arg(dblinkname));
|
---|
| 2082 | }
|
---|
| 2083 | }
|
---|
[10539] | 2084 | //_rtcmCrs.back().print();
|
---|
[10534] | 2085 | }
|
---|
| 2086 |
|
---|
| 2087 | return true;
|
---|
| 2088 | }
|
---|
| 2089 |
|
---|
| 2090 |
|
---|
| 2091 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 2092 | bool RTCM3Decoder::DecodeHelmertTrafoParameters(unsigned char* data, int size) {
|
---|
| 2093 |
|
---|
| 2094 | t_helmertPar helmertPar;
|
---|
| 2095 | int sourcenum = -1;
|
---|
| 2096 | int targetnum = -1;
|
---|
| 2097 |
|
---|
| 2098 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 2099 | data += 3; // header
|
---|
| 2100 | size -= 6; // header + crc
|
---|
| 2101 |
|
---|
| 2102 | SKIPBITS(12) // Message Number
|
---|
| 2103 | GETBITS(sourcenum, 5)
|
---|
| 2104 | if (sourcenum > -1 && sourcenum <= 31) {
|
---|
| 2105 | for(int i = 0; i < sourcenum; i++) {
|
---|
| 2106 | GETBITS(helmertPar._sourceName[i], 8);
|
---|
| 2107 | }
|
---|
| 2108 | helmertPar._sourceName[sourcenum] = 0;
|
---|
| 2109 | }
|
---|
| 2110 | GETBITS(targetnum, 5)
|
---|
| 2111 | if (targetnum > -1 && targetnum <= 31) {
|
---|
| 2112 | for(int i = 0; i < targetnum; i++) {
|
---|
| 2113 | GETBITS(helmertPar._targetName[i], 8);
|
---|
| 2114 | }
|
---|
| 2115 | helmertPar._targetName[targetnum] = 0;
|
---|
| 2116 | }
|
---|
| 2117 | GETBITS(helmertPar._sysIdentNum, 8)
|
---|
| 2118 | GETBITS(helmertPar._utilTrafoMessageIndicator, 10)
|
---|
[10545] | 2119 | GETBITS(helmertPar._mjd, 16)
|
---|
| 2120 | helmertPar._mjd += 44244;
|
---|
[10534] | 2121 |
|
---|
| 2122 | // delete old parameter entries if available
|
---|
| 2123 | if (!_helmertPar.empty()) {
|
---|
| 2124 | QList<t_helmertPar>::iterator it = _helmertPar.begin();
|
---|
| 2125 | while (it != _helmertPar.end()) {
|
---|
| 2126 | (helmertPar == *it) ? it = _helmertPar.erase(it) : ++it;
|
---|
| 2127 | }
|
---|
| 2128 | }
|
---|
| 2129 | _helmertPar.push_back(helmertPar);
|
---|
| 2130 |
|
---|
[10545] | 2131 | GETFLOATSIGN(_helmertPar.back()._dx, 23, 1/1000.0)
|
---|
| 2132 | GETFLOATSIGN(_helmertPar.back()._dy, 23, 1/1000.0)
|
---|
| 2133 | GETFLOATSIGN(_helmertPar.back()._dz, 23, 1/1000.0)
|
---|
[10534] | 2134 |
|
---|
[10545] | 2135 | GETFLOATSIGN(_helmertPar.back()._ox, 32, 1/50000.0)
|
---|
| 2136 | GETFLOATSIGN(_helmertPar.back()._oy, 32, 1/50000.0)
|
---|
| 2137 | GETFLOATSIGN(_helmertPar.back()._oz, 32, 1/50000.0)
|
---|
| 2138 |
|
---|
| 2139 | GETFLOATSIGN(_helmertPar.back()._sc, 25, 1/100000.0)
|
---|
| 2140 |
|
---|
| 2141 | GETFLOATSIGN(_helmertPar.back()._dxr, 17, 1/50000.0)
|
---|
| 2142 | GETFLOATSIGN(_helmertPar.back()._dyr, 17, 1/50000.0)
|
---|
| 2143 | GETFLOATSIGN(_helmertPar.back()._dzr, 17, 1/50000.0)
|
---|
| 2144 |
|
---|
| 2145 | GETFLOATSIGN(_helmertPar.back()._oxr, 17, 1/2500000.0)
|
---|
| 2146 | GETFLOATSIGN(_helmertPar.back()._oyr, 17, 1/2500000.0)
|
---|
| 2147 | GETFLOATSIGN(_helmertPar.back()._ozr, 17, 1/2500000.0)
|
---|
| 2148 |
|
---|
| 2149 | GETFLOATSIGN(_helmertPar.back()._scr, 14, 1/5000000.0)
|
---|
| 2150 |
|
---|
[10539] | 2151 | //_helmertPar.back().print();
|
---|
[10534] | 2152 |
|
---|
| 2153 | return true;
|
---|
| 2154 | }
|
---|
| 2155 |
|
---|
| 2156 |
|
---|
| 2157 | //
|
---|
| 2158 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 2159 | t_irc RTCM3Decoder::Decode(char* buffer, int bufLen, vector<string>& errmsg) {
|
---|
[6812] | 2160 | bool decoded = false;
|
---|
| 2161 |
|
---|
| 2162 | errmsg.clear();
|
---|
| 2163 |
|
---|
[8158] | 2164 | while (bufLen && _MessageSize < sizeof(_Message)) {
|
---|
[6812] | 2165 | int l = sizeof(_Message) - _MessageSize;
|
---|
[8158] | 2166 | if (l > bufLen)
|
---|
[6812] | 2167 | l = bufLen;
|
---|
[8158] | 2168 | memcpy(_Message + _MessageSize, buffer, l);
|
---|
[6812] | 2169 | _MessageSize += l;
|
---|
| 2170 | bufLen -= l;
|
---|
| 2171 | buffer += l;
|
---|
| 2172 | int id;
|
---|
[8158] | 2173 | while ((id = GetMessage())) {
|
---|
[6812] | 2174 | /* reset station ID for file loading as it can change */
|
---|
[8158] | 2175 | if (_rawFile)
|
---|
[6812] | 2176 | _staID = _rawFile->staID();
|
---|
| 2177 | /* store the id into the list of loaded blocks */
|
---|
| 2178 | _typeList.push_back(id);
|
---|
| 2179 |
|
---|
[6856] | 2180 | /* SSR I+II data handled in another function, already pass the
|
---|
[6812] | 2181 | * extracted data block. That does no harm, as it anyway skip everything
|
---|
| 2182 | * else. */
|
---|
[8971] | 2183 | if ((id >= 1057 && id <= 1068) ||
|
---|
[9212] | 2184 | (id >= 1240 && id <= 1270) ||
|
---|
| 2185 | (id == 4076)) {
|
---|
[9048] | 2186 | if (!_coDecoders.contains(_staID.toLatin1())) {
|
---|
| 2187 | _coDecoders[_staID.toLatin1()] = new RTCM3coDecoder(_staID);
|
---|
[9306] | 2188 | if (id == 4076) {
|
---|
| 2189 | _coDecoders[_staID.toLatin1()]->initSsrFormatType(RTCM3coDecoder::IGSssr);
|
---|
| 2190 | }
|
---|
| 2191 | else {
|
---|
| 2192 | _coDecoders[_staID.toLatin1()]->initSsrFormatType(RTCM3coDecoder::RTCMssr);
|
---|
| 2193 | }
|
---|
[9048] | 2194 | }
|
---|
| 2195 | RTCM3coDecoder* coDecoder = _coDecoders[_staID.toLatin1()];
|
---|
[9212] | 2196 | if (coDecoder->Decode(reinterpret_cast<char *>(_Message), _BlockSize, errmsg) == success) {
|
---|
[6812] | 2197 | decoded = true;
|
---|
| 2198 | }
|
---|
| 2199 | }
|
---|
[9285] | 2200 | else if (id >= 1070 && id <= 1237) { /* MSM */
|
---|
[8158] | 2201 | if (DecodeRTCM3MSM(_Message, _BlockSize))
|
---|
[6812] | 2202 | decoded = true;
|
---|
| 2203 | }
|
---|
[8158] | 2204 | else {
|
---|
| 2205 | switch (id) {
|
---|
| 2206 | case 1001:
|
---|
| 2207 | case 1003:
|
---|
[10236] | 2208 | #ifdef BNC_DEBUG_OBS
|
---|
[9210] | 2209 | emit(newMessage(QString("%1: Block %2 contain partial data! Ignored!")
|
---|
| 2210 | .arg(_staID).arg(id).toLatin1(), true));
|
---|
[10236] | 2211 | #endif
|
---|
[8158] | 2212 | break; /* no use decoding partial data ATM, remove break when data can be used */
|
---|
| 2213 | case 1002:
|
---|
| 2214 | case 1004:
|
---|
| 2215 | if (DecodeRTCM3GPS(_Message, _BlockSize))
|
---|
| 2216 | decoded = true;
|
---|
| 2217 | break;
|
---|
| 2218 | case 1009:
|
---|
| 2219 | case 1011:
|
---|
[10236] | 2220 | #ifdef BNC_DEBUG_OBS
|
---|
[9210] | 2221 | emit(newMessage(QString("%1: Block %2 contain partial data! Ignored!")
|
---|
| 2222 | .arg(_staID).arg(id).toLatin1(), true));
|
---|
[10236] | 2223 | #endif
|
---|
[8158] | 2224 | break; /* no use decoding partial data ATM, remove break when data can be used */
|
---|
| 2225 | case 1010:
|
---|
| 2226 | case 1012:
|
---|
| 2227 | if (DecodeRTCM3GLONASS(_Message, _BlockSize))
|
---|
| 2228 | decoded = true;
|
---|
| 2229 | break;
|
---|
| 2230 | case 1019:
|
---|
| 2231 | if (DecodeGPSEphemeris(_Message, _BlockSize))
|
---|
| 2232 | decoded = true;
|
---|
| 2233 | break;
|
---|
| 2234 | case 1020:
|
---|
| 2235 | if (DecodeGLONASSEphemeris(_Message, _BlockSize))
|
---|
| 2236 | decoded = true;
|
---|
| 2237 | break;
|
---|
| 2238 | case 1043:
|
---|
| 2239 | if (DecodeSBASEphemeris(_Message, _BlockSize))
|
---|
| 2240 | decoded = true;
|
---|
| 2241 | break;
|
---|
| 2242 | case 1044:
|
---|
| 2243 | if (DecodeQZSSEphemeris(_Message, _BlockSize))
|
---|
| 2244 | decoded = true;
|
---|
| 2245 | break;
|
---|
[9002] | 2246 | case 1041:
|
---|
[8783] | 2247 | if (DecodeIRNSSEphemeris(_Message, _BlockSize))
|
---|
| 2248 | decoded = true;
|
---|
| 2249 | break;
|
---|
[8158] | 2250 | case 1045:
|
---|
| 2251 | case 1046:
|
---|
| 2252 | if (DecodeGalileoEphemeris(_Message, _BlockSize))
|
---|
| 2253 | decoded = true;
|
---|
| 2254 | break;
|
---|
[9000] | 2255 | case 1042:
|
---|
[8158] | 2256 | if (DecodeBDSEphemeris(_Message, _BlockSize))
|
---|
| 2257 | decoded = true;
|
---|
| 2258 | break;
|
---|
| 2259 | case 1007:
|
---|
| 2260 | case 1008:
|
---|
| 2261 | case 1033:
|
---|
[8197] | 2262 | DecodeAntennaReceiver(_Message, _BlockSize);
|
---|
[8158] | 2263 | break;
|
---|
| 2264 | case 1005:
|
---|
| 2265 | case 1006:
|
---|
| 2266 | DecodeAntennaPosition(_Message, _BlockSize);
|
---|
| 2267 | break;
|
---|
[10534] | 2268 | case 1300:
|
---|
| 2269 | DecodeServiceCRS(_Message, _BlockSize);
|
---|
| 2270 | break;
|
---|
| 2271 | case 1301:
|
---|
| 2272 | DecodeHelmertTrafoParameters(_Message, _BlockSize);
|
---|
| 2273 | break;
|
---|
| 2274 | case 1302:
|
---|
| 2275 | case 35:
|
---|
| 2276 | DecodeRTCMCRS(_Message, _BlockSize);
|
---|
| 2277 | break;
|
---|
[296] | 2278 | }
|
---|
| 2279 | }
|
---|
| 2280 | }
|
---|
[6812] | 2281 | }
|
---|
[10534] | 2282 | /*
|
---|
| 2283 | for (int ii = 0; ii < _helmertParList.size(); ii++) {
|
---|
| 2284 | _helmertParList[ii].print();
|
---|
| 2285 | }*/
|
---|
[6812] | 2286 | return decoded ? success : failure;
|
---|
[8158] | 2287 | }
|
---|
[6812] | 2288 |
|
---|
[7753] | 2289 | //
|
---|
[6812] | 2290 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 2291 | uint32_t RTCM3Decoder::CRC24(long size, const unsigned char *buf) {
|
---|
[6812] | 2292 | uint32_t crc = 0;
|
---|
[9025] | 2293 | int ii;
|
---|
[8158] | 2294 | while (size--) {
|
---|
[6812] | 2295 | crc ^= (*buf++) << (16);
|
---|
[9025] | 2296 | for (ii = 0; ii < 8; ii++) {
|
---|
[6812] | 2297 | crc <<= 1;
|
---|
[8158] | 2298 | if (crc & 0x1000000)
|
---|
[6812] | 2299 | crc ^= 0x01864cfb;
|
---|
[1021] | 2300 | }
|
---|
[296] | 2301 | }
|
---|
[6812] | 2302 | return crc;
|
---|
| 2303 | }
|
---|
[1021] | 2304 |
|
---|
[7753] | 2305 | //
|
---|
[6812] | 2306 | ////////////////////////////////////////////////////////////////////////////
|
---|
[8158] | 2307 | int RTCM3Decoder::GetMessage(void) {
|
---|
[6812] | 2308 | unsigned char *m, *e;
|
---|
| 2309 | int i;
|
---|
| 2310 |
|
---|
[8158] | 2311 | m = _Message + _SkipBytes;
|
---|
| 2312 | e = _Message + _MessageSize;
|
---|
[6812] | 2313 | _NeedBytes = _SkipBytes = 0;
|
---|
[8158] | 2314 | while (e - m >= 3) {
|
---|
| 2315 | if (m[0] == 0xD3) {
|
---|
| 2316 | _BlockSize = ((m[1] & 3) << 8) | m[2];
|
---|
| 2317 | if (e - m >= static_cast<int>(_BlockSize + 6)) {
|
---|
| 2318 | if (static_cast<uint32_t>((m[3 + _BlockSize] << 16)
|
---|
| 2319 | | (m[3 + _BlockSize + 1] << 8)
|
---|
| 2320 | | (m[3 + _BlockSize + 2])) == CRC24(_BlockSize + 3, m)) {
|
---|
| 2321 | _BlockSize += 6;
|
---|
[6812] | 2322 | _SkipBytes = _BlockSize;
|
---|
| 2323 | break;
|
---|
| 2324 | }
|
---|
| 2325 | else
|
---|
| 2326 | ++m;
|
---|
| 2327 | }
|
---|
[8158] | 2328 | else {
|
---|
[6812] | 2329 | _NeedBytes = _BlockSize;
|
---|
| 2330 | break;
|
---|
| 2331 | }
|
---|
| 2332 | }
|
---|
| 2333 | else
|
---|
| 2334 | ++m;
|
---|
[658] | 2335 | }
|
---|
[8158] | 2336 | if (e - m < 3)
|
---|
[6812] | 2337 | _NeedBytes = 3;
|
---|
| 2338 |
|
---|
| 2339 | /* copy buffer to front */
|
---|
| 2340 | i = m - _Message;
|
---|
[8158] | 2341 | if (i && m < e)
|
---|
| 2342 | memmove(_Message, m, static_cast<size_t>(_MessageSize - i));
|
---|
[6812] | 2343 | _MessageSize -= i;
|
---|
| 2344 |
|
---|
[8158] | 2345 | return !_NeedBytes ? ((_Message[3] << 4) | (_Message[4] >> 4)) : 0;
|
---|
[296] | 2346 | }
|
---|
[1807] | 2347 |
|
---|
[3001] | 2348 | // Time of Corrections
|
---|
| 2349 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 2350 | int RTCM3Decoder::corrGPSEpochTime() const {
|
---|
[8158] | 2351 | return
|
---|
| 2352 | _coDecoders.size() > 0 ?
|
---|
| 2353 | _coDecoders.begin().value()->corrGPSEpochTime() : -1;
|
---|
[3001] | 2354 | }
|
---|
[10544] | 2355 |
|
---|
| 2356 |
|
---|
| 2357 |
|
---|
| 2358 |
|
---|