Changeset 6141 in ntrip for trunk/BNC/src/RTCM3
- Timestamp:
- Sep 13, 2014, 5:08:22 PM (11 years ago)
- Location:
- trunk/BNC/src/RTCM3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/RTCM3/RTCM3coDecoder.cpp
r5665 r6141 69 69 _fileNameSkl = path + staID; 70 70 } 71 _out = 0; 72 _GPSweeks = -1.0; 71 _out = 0; 73 72 74 73 qRegisterMetaType<bncTime>("bncTime"); 75 76 connect(this, SIGNAL(newCorrLine(QString, QString, bncTime)), 77 BNC_CORE, SLOT(slotNewCorrLine(QString, QString, bncTime))); 74 qRegisterMetaType< QList<t_orbCorr> >("QList:t_orbCorr"); 75 qRegisterMetaType< QList<t_clkCorr> >("QList:t_clkCorr"); 76 77 connect(this, SIGNAL(newOrbCorrections(QList<t_orbCorr>)), 78 BNC_CORE, SLOT(slotNewOrbCorrections(QList<t_orbCorr>))); 79 80 connect(this, SIGNAL(newClkCorrections(QList<t_clkCorr>)), 81 BNC_CORE, SLOT(slotNewClkCorrections(QList<t_clkCorr>))); 78 82 79 83 connect(this, SIGNAL(providerIDChanged(QString)), … … 99 103 // Reopen Output File 100 104 //////////////////////////////////////////////////////////////////////// 101 void RTCM3coDecoder::reopen(const QString& fileNameSkl, QString& fileName, 102 ofstream*& out) { 103 104 if (!fileNameSkl.isEmpty()) { 105 void RTCM3coDecoder::reopen() { 106 107 if (!_fileNameSkl.isEmpty()) { 105 108 106 109 bncSettings settings; … … 111 114 settings.value("corrIntr").toString()); 112 115 113 QString fileNameHlp = fileNameSkl 116 QString fileNameHlp = _fileNameSkl 114 117 + QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) 115 118 + hlpStr + datTim.toString(".yyC"); 116 119 117 if (fileName == fileNameHlp) { 120 if (_fileName == fileNameHlp) { 118 121 return; 119 122 } 120 123 else { 121 fileName = fileNameHlp; 122 } 123 124 delete out; 124 _fileName = fileNameHlp; 125 } 126 127 delete _out; 125 128 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) { 126 out = new ofstream( fileName.toAscii().data(), 127 ios_base::out | ios_base::app ); 129 _out = new ofstream( _fileName.toAscii().data(), ios_base::out | ios_base::app ); 128 130 } 129 131 else { 130 out = new ofstream( fileName.toAscii().data() ); 132 _out = new ofstream( _fileName.toAscii().data() ); 131 133 } 132 134 } … … 170 172 _bias.NumberOfSat[CLOCKORBIT_SATGPS] > 0 || _bias.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) ) { 171 173 172 reopen( _fileNameSkl, _fileName, _out);174 reopen(); 173 175 174 176 // Guess GPS week and sec using system time … … 189 191 GPSweek -= 1; 190 192 } 191 _GPSweek s =GPSEpochTime;193 _lastTime.set(GPSweek, double(GPSEpochTime)); 192 194 } 193 195 … … 223 225 } 224 226 } 225 226 _GPSweeks = weekDay * 86400.0 + GPSDaySec; 227 _lastTime.set(GPSweek, weekDay * 86400.0 + GPSDaySec); 227 228 } 228 229 229 230 checkProviderID(); 230 231 231 QStringList asciiLines = corrsToASCIIlines(GPSweek, _GPSweeks, 232 _co, &_bias); 233 234 QStringListIterator it(asciiLines); 235 while (it.hasNext()) { 236 QString line = it.next(); 237 printLine(line, GPSweek, _GPSweeks); 238 } 232 sendResults(); 239 233 240 234 retCode = success; 235 241 236 memset(&_co, 0, sizeof(_co)); 242 237 memset(&_bias, 0, sizeof(_bias)); … … 245 240 } 246 241 247 if (retCode != success) {248 _GPSweeks = -1.0;249 }250 242 return retCode; 251 243 } … … 253 245 // 254 246 //////////////////////////////////////////////////////////////////////////// 255 void RTCM3coDecoder::printLine(const QString& line, int GPSweek, 256 double GPSweeks) { 257 if (_out) { 258 *_out << line.toAscii().data() << endl; 259 _out->flush(); 260 } 261 262 int currWeek; 263 double currSec; 264 currentGPSWeeks(currWeek, currSec); 265 bncTime currTime(currWeek, currSec); 266 267 bncTime coTime(GPSweek, GPSweeks); 268 269 double dt = currTime - coTime; 270 const double MAXDT = 10 * 60.0; 271 if (fabs(dt) > MAXDT) { 272 emit newMessage("suspicious correction: " + _staID.toAscii() + " " 273 + line.toAscii(), false); 274 } 275 else { 276 emit newCorrLine(line, _staID, coTime); 277 } 278 } 279 280 // 281 //////////////////////////////////////////////////////////////////////////// 282 QStringList RTCM3coDecoder::corrsToASCIIlines(int GPSweek, double GPSweeks, 283 const ClockOrbit& co, 284 const CodeBias* bias) { 285 286 QStringList retLines; 247 void RTCM3coDecoder::sendResults() { 248 249 QList<t_orbCorr> orbCorrections; 250 QList<t_clkCorr> clkCorrections; 287 251 288 252 // Loop over all satellites (GPS and Glonass) 289 253 // ------------------------------------------ 290 if (co.NumberOfSat[CLOCKORBIT_SATGPS] > 0 || co.NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) { 291 QString line1; 292 line1.sprintf("! Orbits/Clocks: %d GPS %d Glonass", 293 co.NumberOfSat[CLOCKORBIT_SATGPS], co.NumberOfSat[CLOCKORBIT_SATGLONASS]); 294 retLines << line1; 295 } 296 for (int ii = 0; ii < CLOCKORBIT_NUMGPS+co.NumberOfSat[CLOCKORBIT_SATGLONASS]; ii++) { 254 for (unsigned ii = 0; ii < CLOCKORBIT_NUMGPS + _co.NumberOfSat[CLOCKORBIT_SATGLONASS]; ii++) { 297 255 char sysCh = ' '; 298 if (ii < co.NumberOfSat[CLOCKORBIT_SATGPS]) { 256 if (ii < _co.NumberOfSat[CLOCKORBIT_SATGPS]) { 299 257 sysCh = 'G'; 300 258 } … … 302 260 sysCh = 'R'; 303 261 } 304 305 if (sysCh != ' ') { 306 307 QString linePart; 308 linePart.sprintf("%d %d %d %.1f %c%2.2d", 309 co.messageType, co.UpdateInterval, GPSweek, GPSweeks, 310 sysCh, co.Sat[ii].ID); 311 312 // Combined message (orbit and clock) 313 // ---------------------------------- 314 if ( co.messageType == COTYPE_GPSCOMBINED || 315 co.messageType == COTYPE_GLONASSCOMBINED ) { 316 QString line; 317 line.sprintf(" %3d" 318 " %8.3f %8.3f %8.3f %8.3f" 319 " %10.5f %10.5f %10.5f %10.5f" 320 " %10.5f", 321 co.Sat[ii].IOD, 322 co.Sat[ii].Clock.DeltaA0, 323 co.Sat[ii].Orbit.DeltaRadial, 324 co.Sat[ii].Orbit.DeltaAlongTrack, 325 co.Sat[ii].Orbit.DeltaCrossTrack, 326 co.Sat[ii].Clock.DeltaA1, 327 co.Sat[ii].Orbit.DotDeltaRadial, 328 co.Sat[ii].Orbit.DotDeltaAlongTrack, 329 co.Sat[ii].Orbit.DotDeltaCrossTrack, 330 co.Sat[ii].Clock.DeltaA2); 331 retLines << linePart+line; 262 else { 263 continue; 264 } 265 266 // Orbit correction 267 // ---------------- 268 if ( _co.messageType == COTYPE_GPSCOMBINED || 269 _co.messageType == COTYPE_GLONASSCOMBINED || 270 _co.messageType == COTYPE_GPSORBIT || 271 _co.messageType == COTYPE_GLONASSORBIT ) { 272 273 t_orbCorr orbCorr; 274 orbCorr._prn.set(sysCh, _co.Sat[ii].ID); 275 orbCorr._staID = _staID.toAscii().data(); 276 orbCorr._iod = _co.Sat[ii].IOD; 277 orbCorr._time = _lastTime; 278 orbCorr._system = 'R'; 279 orbCorr._xr[0] = _co.Sat[ii].Orbit.DeltaRadial; 280 orbCorr._xr[1] = _co.Sat[ii].Orbit.DeltaAlongTrack; 281 orbCorr._xr[2] = _co.Sat[ii].Orbit.DeltaCrossTrack; 282 orbCorr._dotXr[0] = _co.Sat[ii].Orbit.DotDeltaRadial; 283 orbCorr._dotXr[1] = _co.Sat[ii].Orbit.DotDeltaAlongTrack; 284 orbCorr._dotXr[2] = _co.Sat[ii].Orbit.DotDeltaCrossTrack; 285 286 orbCorrections.push_back(orbCorr); 287 288 _IODs[orbCorr._prn.toString()] = _co.Sat[ii].IOD; 289 } 290 291 if ( _co.messageType == COTYPE_GPSCOMBINED || 292 _co.messageType == COTYPE_GLONASSCOMBINED || 293 _co.messageType == COTYPE_GPSCLOCK || 294 _co.messageType == COTYPE_GLONASSCLOCK ) { 295 296 t_clkCorr clkCorr; 297 clkCorr._prn.set(sysCh, _co.Sat[ii].ID); 298 clkCorr._staID = _staID.toAscii().data(); 299 clkCorr._time = _lastTime; 300 clkCorr._dClk = _co.Sat[ii].Clock.DeltaA0, 301 clkCorr._dotDClk = _co.Sat[ii].Clock.DeltaA1, 302 clkCorr._dotDotDClk = _co.Sat[ii].Clock.DeltaA2; 303 clkCorr._clkPartial = 0.0; 304 305 if (_IODs.contains(clkCorr._prn.toString())) { 306 clkCorr._iod = _IODs[clkCorr._prn.toString()]; 307 clkCorrections.push_back(clkCorr); 332 308 } 333 334 // Orbits only 335 // ----------- 336 else if ( co.messageType == COTYPE_GPSORBIT || 337 co.messageType == COTYPE_GLONASSORBIT ) { 338 QString line; 339 line.sprintf(" %3d" 340 " %8.3f %8.3f %8.3f" 341 " %10.5f %10.5f %10.5f", 342 co.Sat[ii].IOD, 343 co.Sat[ii].Orbit.DeltaRadial, 344 co.Sat[ii].Orbit.DeltaAlongTrack, 345 co.Sat[ii].Orbit.DeltaCrossTrack, 346 co.Sat[ii].Orbit.DotDeltaRadial, 347 co.Sat[ii].Orbit.DotDeltaAlongTrack, 348 co.Sat[ii].Orbit.DotDeltaCrossTrack); 349 retLines << linePart+line; 350 } 351 352 // Clocks only 353 // ----------- 354 else if ( co.messageType == COTYPE_GPSCLOCK || 355 co.messageType == COTYPE_GLONASSCLOCK ) { 356 QString line; 357 line.sprintf(" %8.3f %10.5f %10.5f", 358 co.Sat[ii].Clock.DeltaA0, 359 co.Sat[ii].Clock.DeltaA1, 360 co.Sat[ii].Clock.DeltaA2); 361 retLines << linePart+line; 362 } 363 364 // User Range Accuracy 365 // ------------------- 366 else if ( co.messageType == COTYPE_GPSURA || 367 co.messageType == COTYPE_GLONASSURA ) { 368 QString line; 369 line.sprintf(" %f", co.Sat[ii].UserRangeAccuracy); 370 retLines << linePart+line; 371 } 372 373 // High-Resolution Clocks 374 // ---------------------- 375 else if ( co.messageType == COTYPE_GPSHR || 376 co.messageType == COTYPE_GLONASSHR ) { 377 QString line; 378 line.sprintf(" %8.3f", co.Sat[ii].hrclock); 379 retLines << linePart+line; 380 } 309 } 310 311 // High-Resolution Clocks 312 // ---------------------- 313 if ( _co.messageType == COTYPE_GPSHR || 314 _co.messageType == COTYPE_GLONASSHR ) { 381 315 } 382 316 } … … 384 318 // Loop over all satellites (GPS and Glonass) 385 319 // ------------------------------------------ 386 if (bias) { 387 if (bias->NumberOfSat[CLOCKORBIT_SATGPS] > 0 || bias->NumberOfSat[CLOCKORBIT_SATGLONASS] > 0) { 388 QString line1; 389 line1.sprintf("! Biases: %d GPS %d Glonass", 390 bias->NumberOfSat[CLOCKORBIT_SATGPS], bias->NumberOfSat[CLOCKORBIT_SATGLONASS]); 391 retLines << line1; 392 } 393 for (int ii = 0; ii < CLOCKORBIT_NUMGPS + bias->NumberOfSat[CLOCKORBIT_SATGLONASS]; ii++) { 394 char sysCh = ' '; 395 int messageType; 396 if (ii < bias->NumberOfSat[CLOCKORBIT_SATGPS]) { 397 sysCh = 'G'; 398 messageType = BTYPE_GPS; 399 } 400 else if (ii >= CLOCKORBIT_NUMGPS) { 401 sysCh = 'R'; 402 messageType = BTYPE_GLONASS; 403 } 404 if (sysCh != ' ') { 405 QString line; 406 line.sprintf("%d %d %d %.1f %c%2.2d %d", 407 messageType, bias->UpdateInterval, GPSweek, GPSweeks, 408 sysCh, bias->Sat[ii].ID, 409 bias->Sat[ii].NumberOfCodeBiases); 410 for (int jj = 0; jj < bias->Sat[ii].NumberOfCodeBiases; jj++) { 411 QString hlp; 412 hlp.sprintf(" %d %8.3f", bias->Sat[ii].Biases[jj].Type, 413 bias->Sat[ii].Biases[jj].Bias); 414 line += hlp; 415 } 416 retLines << line; 417 } 418 } 419 } 420 421 return retLines; 320 QList<t_satBias> satBiases; 321 for (unsigned ii = 0; ii < CLOCKORBIT_NUMGPS + _bias.NumberOfSat[CLOCKORBIT_SATGLONASS]; ii++) { 322 char sysCh = ' '; 323 if (ii < _bias.NumberOfSat[CLOCKORBIT_SATGPS]) { 324 sysCh = 'G'; 325 } 326 else if (ii >= CLOCKORBIT_NUMGPS) { 327 sysCh = 'R'; 328 } 329 else { 330 continue; 331 } 332 t_satBias satBias; 333 satBias._prn.set(sysCh, _bias.Sat[ii].ID); 334 satBias._time = _lastTime; 335 satBias._nx = 0; 336 satBias._jumpCount = 0; 337 for (unsigned jj = 0; jj < _bias.Sat[ii].NumberOfCodeBiases; jj++) { 338 } 339 } 340 341 if (orbCorrections.size() > 0) { 342 emit newOrbCorrections(orbCorrections); 343 } 344 if (clkCorrections.size() > 0) { 345 emit newClkCorrections(clkCorrections); 346 } 347 if (_out) { 348 QListIterator<t_orbCorr> itOrb(orbCorrections); 349 while (itOrb.hasNext()) { 350 const t_orbCorr& orbCorr = itOrb.next(); 351 *_out << "O " << orbCorr.toString() << endl; 352 } 353 QListIterator<t_clkCorr> itClk(clkCorrections); 354 while (itClk.hasNext()) { 355 const t_clkCorr& clkCorr = itClk.next(); 356 *_out << "C " << clkCorr.toString() << endl; 357 } 358 _out->flush(); 359 } 422 360 } 423 361 -
trunk/BNC/src/RTCM3/RTCM3coDecoder.h
r5738 r6141 27 27 28 28 #include <fstream> 29 30 29 #include <QtCore> 31 30 #include <QtNetwork> 32 33 31 #include "GPSDecoder.h" 34 32 35 33 extern "C" { 36 #include "clock_orbit_rtcm.h" 34 # include "clock_orbit_rtcm.h" 37 35 } 38 36 … … 43 41 virtual ~RTCM3coDecoder(); 44 42 virtual t_irc Decode(char* buffer, int bufLen, std::vector<std::string>& errmsg); 45 virtual int corrGPSEpochTime() const {return (int) _GPSweeks;}43 virtual int corrGPSEpochTime() const {return int(_lastTime.gpssec());} 46 44 47 static QStringList corrsToASCIIlines(int GPSweek, double GPSweeks,48 const ClockOrbit& co, const CodeBias* bias);49 static void reopen(const QString& fileNameSkl, QString& fileName,50 std::ofstream*& out);51 45 signals: 52 void newCorrLine(QString line, QString staID, bncTime coTime); 46 void newOrbCorrections(QList<t_orbCorr> orbCorr); 47 void newClkCorrections(QList<t_clkCorr> clkCorr); 48 void newBiases(QList<t_satBias> biases); 53 49 void newMessage(QByteArray msg, bool showOnScreen); 54 50 void providerIDChanged(QString staID); 55 51 56 52 private: 57 void printLine(const QString& line, int GPSweek, double GPSweeks); 53 void sendResults(); 54 void reopen(); 58 55 void checkProviderID(); 59 56 std::ofstream* _out; … … 62 59 QString _fileName; 63 60 QByteArray _buffer; 64 double _GPSweeks;65 61 ClockOrbit _co; 66 62 CodeBias _bias; 67 63 int _providerID[3]; 64 bncTime _lastTime; 65 QMap<std::string, unsigned short> _IODs; 68 66 }; 69 67
Note:
See TracChangeset
for help on using the changeset viewer.