- Timestamp:
- Dec 27, 2014, 7:08:25 PM (10 years ago)
- Location:
- trunk/BNC/src/RTCM3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/RTCM3/RTCM3coDecoder.cpp
r6463 r6467 87 87 BNC_CORE, SLOT(slotMessage(const QByteArray,bool))); 88 88 89 reset(); 90 91 _providerID[0] = -1; 92 _providerID[1] = -1; 93 _providerID[2] = -1; 94 } 95 96 // Destructor 97 //////////////////////////////////////////////////////////////////////////// 98 RTCM3coDecoder::~RTCM3coDecoder() { 99 delete _out; 100 } 101 102 // 103 //////////////////////////////////////////////////////////////////////////// 104 void RTCM3coDecoder::reset() { 89 105 memset(&_clkOrb, 0, sizeof(_clkOrb)); 90 106 memset(&_codeBias, 0, sizeof(_codeBias)); 91 107 memset(&_phaseBias, 0, sizeof(_phaseBias)); 92 108 memset(&_vTEC, 0, sizeof(_vTEC)); 93 94 _providerID[0] = -1;95 _providerID[1] = -1;96 _providerID[2] = -1;97 }98 99 // Destructor100 ////////////////////////////////////////////////////////////////////////////101 RTCM3coDecoder::~RTCM3coDecoder() {102 delete _out;103 109 } 104 110 … … 171 177 172 178 else if (irc < 0) { // error - skip 1 byte and retry 173 memset(&_clkOrb, 0, sizeof(_clkOrb)); 174 memset(&_codeBias, 0, sizeof(_codeBias)); 175 memset(&_phaseBias, 0, sizeof(_phaseBias)); 176 memset(&_vTEC, 0, sizeof(_vTEC)); 179 reset(); 177 180 _buffer = _buffer.mid(bytesused ? bytesused : 1); 178 181 } … … 181 184 _buffer = _buffer.mid(bytesused); 182 185 183 if ( (irc == GCOBR_OK || irc == GCOBR_MESSAGEFOLLOWS ) && 184 (_clkOrb.NumberOfSat[CLOCKORBIT_SATGPS] > 0 || _clkOrb.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0 || 185 _codeBias.NumberOfSat[CLOCKORBIT_SATGPS] > 0 || _codeBias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) ) { 186 187 reopen(); 188 189 // Guess GPS week and sec using system time 190 // ---------------------------------------- 191 int GPSweek; 192 double GPSweeksHlp; 193 currentGPSWeeks(GPSweek, GPSweeksHlp); 194 195 // Correction Epoch from GPSEpochTime 196 // ---------------------------------- 197 if (_clkOrb.NumberOfSat[CLOCKORBIT_SATGPS] > 0 || _codeBias.NumberOfSat[CLOCKORBIT_SATGPS] > 0) { 198 int GPSEpochTime = (_clkOrb.NumberOfSat[CLOCKORBIT_SATGPS] > 0) ? 199 _clkOrb.EpochTime[CLOCKORBIT_SATGPS] : _codeBias.EpochTime[CLOCKORBIT_SATGPS]; 200 if (GPSweeksHlp > GPSEpochTime + 86400.0) { 201 GPSweek += 1; 202 } 203 else if (GPSweeksHlp < GPSEpochTime - 86400.0) { 204 GPSweek -= 1; 205 } 206 _lastTime.set(GPSweek, double(GPSEpochTime)); 186 if (irc == GCOBR_OK || irc == GCOBR_MESSAGEFOLLOWS ) { 187 188 setEpochTime(); // sets _lastTime 189 190 if (_lastTime.valid()) { 191 reopen(); 192 checkProviderID(); 193 sendResults(); 194 retCode = success; 207 195 } 208 209 // Correction Epoch from Glonass Epoch 210 // ----------------------------------- 211 else if (_clkOrb.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0 || _codeBias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0){ 212 int GLONASSEpochTime = (_clkOrb.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) ? 213 _clkOrb.EpochTime[CLOCKORBIT_SATGLONASS] : _codeBias.EpochTime[CLOCKORBIT_SATGLONASS]; 214 215 // Second of day (GPS time) from Glonass Epoch 216 // ------------------------------------------- 217 QDate date = dateAndTimeFromGPSweek(GPSweek, GPSweeksHlp).date(); 218 int leapSecond = gnumleap(date.year(), date.month(), date.day()); 219 int GPSDaySec = GLONASSEpochTime - 3 * 3600 + leapSecond; 220 221 int weekDay = int(GPSweeksHlp/86400.0); 222 int GPSDaySecHlp = int(GPSweeksHlp) - weekDay * 86400; 223 224 // Handle the difference between system clock and correction epoch 225 // --------------------------------------------------------------- 226 if (GPSDaySec < GPSDaySecHlp - 3600) { 227 weekDay += 1; 228 if (weekDay > 6) { 229 weekDay = 0; 230 GPSweek += 1; 231 } 232 } 233 else if (GPSDaySec > GPSDaySecHlp + 3600) { 234 weekDay -= 1; 235 if (weekDay < 0) { 236 weekDay = 6; 237 GPSweek -= 1; 238 } 239 } 240 _lastTime.set(GPSweek, weekDay * 86400.0 + GPSDaySec); 196 else { 197 retCode = failure; 241 198 } 242 199 243 checkProviderID(); 244 245 sendResults(); 246 247 retCode = success; 248 249 memset(&_clkOrb, 0, sizeof(_clkOrb)); 250 memset(&_codeBias, 0, sizeof(_codeBias)); 251 memset(&_phaseBias, 0, sizeof(_phaseBias)); 252 memset(&_vTEC, 0, sizeof(_vTEC)); 200 reset(); 253 201 } 254 202 } … … 406 354 } 407 355 } 356 357 358 // 359 //////////////////////////////////////////////////////////////////////////// 360 void RTCM3coDecoder::setEpochTime() { 361 362 _lastTime.reset(); 363 364 int epoSecGPS = -1; 365 int epoSecGlo = -1; 366 if (_clkOrb.NumberOfSat[CLOCKORBIT_SATGPS] > 0) { 367 epoSecGPS = _clkOrb.EpochTime[CLOCKORBIT_SATGPS]; // 0 .. 604799 s 368 } 369 else if (_codeBias.NumberOfSat[CLOCKORBIT_SATGPS] > 0) { 370 epoSecGPS = _clkOrb.EpochTime[CLOCKORBIT_SATGPS]; // 0 .. 604799 s 371 } 372 else if (_clkOrb.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) { 373 epoSecGlo = _codeBias.EpochTime[CLOCKORBIT_SATGLONASS]; // 0 .. 86399 s (86400 for leap second) 374 } 375 else if (_codeBias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) { 376 epoSecGlo = _codeBias.EpochTime[CLOCKORBIT_SATGLONASS]; // 0 .. 86399 s (86400 for leap second) 377 } 378 379 // Retrieve current time 380 // --------------------- 381 int currentWeek = 0; 382 double currentSec = 0.0; 383 currentGPSWeeks(currentWeek, currentSec); 384 bncTime currentTime(currentWeek, currentSec); 385 386 // Set _lastTime close to currentTime 387 // ---------------------------------- 388 if (epoSecGPS != -1) { 389 _lastTime.set(currentWeek, epoSecGPS); 390 while (_lastTime < currentTime - 7 * 86400.0) { 391 _lastTime = _lastTime + 7 * 86400.0; 392 } 393 while (_lastTime > currentTime + 7 * 86400.0) { 394 _lastTime = _lastTime - 7 * 86400.0; 395 } 396 } 397 else if (epoSecGlo != -1) { 398 QDate date = dateAndTimeFromGPSweek(currentTime.gpsw(), currentTime.gpssec()).date(); 399 epoSecGlo = epoSecGlo - 3 * 3600 + gnumleap(date.year(), date.month(), date.day()); 400 _lastTime.set(currentWeek, epoSecGlo); 401 while (_lastTime < currentTime - 86400.0) { 402 _lastTime = _lastTime + 86400.0; 403 } 404 while (_lastTime > currentTime + 86400.0) { 405 _lastTime = _lastTime - 86400.0; 406 } 407 } 408 } -
trunk/BNC/src/RTCM3/RTCM3coDecoder.h
r6455 r6467 50 50 51 51 private: 52 void reset(); 53 void setEpochTime(); 52 54 void sendResults(); 53 55 void reopen();
Note:
See TracChangeset
for help on using the changeset viewer.