[280] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
[464] | 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
[280] | 3 | //
|
---|
[464] | 4 | // Copyright (C) 2007
|
---|
[280] | 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
[464] | 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
[280] | 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.
|
---|
[82] | 24 |
|
---|
| 25 | /* -------------------------------------------------------------------------
|
---|
[93] | 26 | * BKG NTRIP Client
|
---|
[82] | 27 | * -------------------------------------------------------------------------
|
---|
| 28 | *
|
---|
[5072] | 29 | * Class: t_bncCore
|
---|
[82] | 30 | *
|
---|
| 31 | * Purpose: This class implements the main application
|
---|
| 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 29-Aug-2006
|
---|
| 36 | *
|
---|
| 37 | * Changes:
|
---|
| 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
[1029] | 41 | #include <iostream>
|
---|
[150] | 42 | #include <QMessageBox>
|
---|
[519] | 43 | #include <cmath>
|
---|
[82] | 44 |
|
---|
[5070] | 45 | #include "bnccore.h"
|
---|
[151] | 46 | #include "bncutils.h"
|
---|
[647] | 47 | #include "bncrinex.h"
|
---|
[1535] | 48 | #include "bncsettings.h"
|
---|
[2011] | 49 | #include "bncversion.h"
|
---|
[5738] | 50 | #include "ephemeris.h"
|
---|
[5375] | 51 | #include "rinex/rnxobsfile.h"
|
---|
| 52 | #include "rinex/rnxnavfile.h"
|
---|
[6051] | 53 | #include "pppMain.h"
|
---|
[82] | 54 |
|
---|
[2899] | 55 | #ifdef USE_COMBINATION
|
---|
[6043] | 56 | # include "combination/bnccomb.h"
|
---|
[2899] | 57 | #endif
|
---|
| 58 |
|
---|
[82] | 59 | using namespace std;
|
---|
| 60 |
|
---|
[5084] | 61 | // Singleton
|
---|
| 62 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5861] | 63 | t_bncCore* t_bncCore::instance() {
|
---|
[5084] | 64 | static t_bncCore _bncCore;
|
---|
[5861] | 65 | return &_bncCore;
|
---|
[5084] | 66 | }
|
---|
| 67 |
|
---|
[82] | 68 | // Constructor
|
---|
| 69 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5084] | 70 | t_bncCore::t_bncCore() {
|
---|
| 71 | _GUIenabled = true;
|
---|
[150] | 72 | _logFileFlag = 0;
|
---|
| 73 | _logFile = 0;
|
---|
| 74 | _logStream = 0;
|
---|
[2519] | 75 | _rawFile = 0;
|
---|
[5729] | 76 | _caster = 0;
|
---|
[2922] | 77 | #ifdef USE_COMBINATION
|
---|
| 78 | _bncComb = 0;
|
---|
| 79 | #endif
|
---|
[152] | 80 |
|
---|
[516] | 81 | // Lists of Ephemeris
|
---|
| 82 | // ------------------
|
---|
| 83 | for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) {
|
---|
| 84 | _gpsEph[ii-PRN_GPS_START] = 0;
|
---|
| 85 | }
|
---|
[6372] | 86 | for (int ii = PRN_QZSS_START; ii <= PRN_QZSS_END; ii++) {
|
---|
| 87 | _qzssEph[ii-PRN_QZSS_START] = 0;
|
---|
| 88 | }
|
---|
[516] | 89 | for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) {
|
---|
| 90 | _glonassEph[ii-PRN_GLONASS_START] = 0;
|
---|
| 91 | }
|
---|
[2770] | 92 | for (int ii = PRN_GALILEO_START; ii <= PRN_GALILEO_END; ii++) {
|
---|
| 93 | _galileoEph[ii-PRN_GALILEO_START] = 0;
|
---|
| 94 | }
|
---|
[6384] | 95 | for (int ii = PRN_SBAS_START; ii <= PRN_SBAS_END; ii++) {
|
---|
| 96 | _sbasEph[ii-PRN_SBAS_START] = 0;
|
---|
| 97 | }
|
---|
[516] | 98 |
|
---|
[533] | 99 | // Eph file(s)
|
---|
| 100 | // -----------
|
---|
[534] | 101 | _rinexVers = 0;
|
---|
[533] | 102 | _ephFileGPS = 0;
|
---|
| 103 | _ephStreamGPS = 0;
|
---|
| 104 | _ephFileGlonass = 0;
|
---|
| 105 | _ephStreamGlonass = 0;
|
---|
[2770] | 106 | _ephFileGalileo = 0;
|
---|
| 107 | _ephStreamGalileo = 0;
|
---|
[6384] | 108 | _ephFileSBAS = 0;
|
---|
| 109 | _ephStreamSBAS = 0;
|
---|
[559] | 110 |
|
---|
[591] | 111 | _port = 0;
|
---|
[589] | 112 | _server = 0;
|
---|
| 113 | _sockets = 0;
|
---|
| 114 |
|
---|
[937] | 115 | _portCorr = 0;
|
---|
| 116 | _serverCorr = 0;
|
---|
| 117 | _socketsCorr = 0;
|
---|
| 118 |
|
---|
[2011] | 119 | _pgmName = QString(BNCPGMNAME).leftJustified(20, ' ', true);
|
---|
[559] | 120 | #ifdef WIN32
|
---|
| 121 | _userName = QString("${USERNAME}");
|
---|
| 122 | #else
|
---|
| 123 | _userName = QString("${USER}");
|
---|
| 124 | #endif
|
---|
| 125 | expandEnvVar(_userName);
|
---|
[973] | 126 |
|
---|
[6151] | 127 | _userName = _userName.leftJustified(20, ' ', true);
|
---|
[5846] | 128 | _dateAndTimeGPS = 0;
|
---|
[6151] | 129 | _mainWindow = 0;
|
---|
[2673] | 130 |
|
---|
[5899] | 131 | _pppMain = new BNC_PPP::t_pppMain();
|
---|
[5902] | 132 | qRegisterMetaType< QVector<double> >("QVector<double>");
|
---|
[5938] | 133 | qRegisterMetaType<bncTime>("bncTime");
|
---|
[82] | 134 | }
|
---|
| 135 |
|
---|
| 136 | // Destructor
|
---|
| 137 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 138 | t_bncCore::~t_bncCore() {
|
---|
[109] | 139 | delete _logStream;
|
---|
| 140 | delete _logFile;
|
---|
[533] | 141 | delete _ephStreamGPS;
|
---|
| 142 | delete _ephFileGPS;
|
---|
[589] | 143 | delete _server;
|
---|
| 144 | delete _sockets;
|
---|
[937] | 145 | delete _serverCorr;
|
---|
| 146 | delete _socketsCorr;
|
---|
[534] | 147 | if (_rinexVers == 2) {
|
---|
[533] | 148 | delete _ephStreamGlonass;
|
---|
| 149 | delete _ephFileGlonass;
|
---|
| 150 | }
|
---|
[516] | 151 | for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) {
|
---|
| 152 | delete _gpsEph[ii-PRN_GPS_START];
|
---|
| 153 | }
|
---|
[6372] | 154 | for (int ii = PRN_QZSS_START; ii <= PRN_QZSS_END; ii++) {
|
---|
| 155 | delete _qzssEph[ii-PRN_QZSS_START];
|
---|
| 156 | }
|
---|
[516] | 157 | for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) {
|
---|
| 158 | delete _glonassEph[ii-PRN_GLONASS_START];
|
---|
| 159 | }
|
---|
[2770] | 160 | for (int ii = PRN_GALILEO_START; ii <= PRN_GALILEO_END; ii++) {
|
---|
| 161 | delete _galileoEph[ii-PRN_GALILEO_START];
|
---|
| 162 | }
|
---|
[6384] | 163 | for (int ii = PRN_SBAS_START; ii <= PRN_SBAS_END; ii++) {
|
---|
| 164 | delete _sbasEph[ii-PRN_SBAS_START];
|
---|
| 165 | }
|
---|
[975] | 166 |
|
---|
[5846] | 167 | delete _dateAndTimeGPS;
|
---|
[2519] | 168 | delete _rawFile;
|
---|
[2865] | 169 |
|
---|
[2899] | 170 | #ifdef USE_COMBINATION
|
---|
[2865] | 171 | delete _bncComb;
|
---|
[2899] | 172 | #endif
|
---|
[82] | 173 | }
|
---|
| 174 |
|
---|
| 175 | // Write a Program Message
|
---|
| 176 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 177 | void t_bncCore::slotMessage(QByteArray msg, bool showOnScreen) {
|
---|
[150] | 178 |
|
---|
[1218] | 179 | QMutexLocker locker(&_mutexMessage);
|
---|
[243] | 180 |
|
---|
[990] | 181 | messagePrivate(msg);
|
---|
[1299] | 182 | emit newMessage(msg, showOnScreen);
|
---|
[990] | 183 | }
|
---|
| 184 |
|
---|
| 185 | // Write a Program Message (private, no lock)
|
---|
| 186 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 187 | void t_bncCore::messagePrivate(const QByteArray& msg) {
|
---|
[990] | 188 |
|
---|
[150] | 189 | // First time resolve the log file name
|
---|
| 190 | // ------------------------------------
|
---|
[1549] | 191 | QDate currDate = currentDateAndTimeGPS().date();
|
---|
| 192 | if (_logFileFlag == 0 || _fileDate != currDate) {
|
---|
[3034] | 193 | delete _logStream; _logStream = 0;
|
---|
| 194 | delete _logFile; _logFile = 0;
|
---|
[150] | 195 | _logFileFlag = 1;
|
---|
[1535] | 196 | bncSettings settings;
|
---|
[150] | 197 | QString logFileName = settings.value("logFile").toString();
|
---|
| 198 | if ( !logFileName.isEmpty() ) {
|
---|
[151] | 199 | expandEnvVar(logFileName);
|
---|
[1549] | 200 | _logFile = new QFile(logFileName + "_" +
|
---|
| 201 | currDate.toString("yyMMdd").toAscii().data());
|
---|
| 202 | _fileDate = currDate;
|
---|
[275] | 203 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
|
---|
| 204 | _logFile->open(QIODevice::WriteOnly | QIODevice::Append);
|
---|
| 205 | }
|
---|
| 206 | else {
|
---|
| 207 | _logFile->open(QIODevice::WriteOnly);
|
---|
| 208 | }
|
---|
[150] | 209 | _logStream = new QTextStream();
|
---|
| 210 | _logStream->setDevice(_logFile);
|
---|
| 211 | }
|
---|
| 212 | }
|
---|
| 213 |
|
---|
[109] | 214 | if (_logStream) {
|
---|
[3371] | 215 | QByteArray msgLocal = msg;
|
---|
| 216 | if (msg.indexOf('\n') == 0) {
|
---|
| 217 | *_logStream << endl;
|
---|
| 218 | msgLocal = msg.mid(1);
|
---|
| 219 | }
|
---|
[1154] | 220 | *_logStream << currentDateAndTimeGPS().toString("yy-MM-dd hh:mm:ss ").toAscii().data();
|
---|
[3371] | 221 | *_logStream << msgLocal.data() << endl;
|
---|
[109] | 222 | _logStream->flush();
|
---|
[3637] | 223 | _logFile->flush();
|
---|
[82] | 224 | }
|
---|
| 225 | }
|
---|
[511] | 226 |
|
---|
[535] | 227 | // New GPS Ephemeris
|
---|
[511] | 228 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 229 | void t_bncCore::slotNewGPSEph(gpsephemeris* gpseph) {
|
---|
[516] | 230 |
|
---|
| 231 | QMutexLocker locker(&_mutex);
|
---|
| 232 |
|
---|
[1044] | 233 | gpsephemeris copy_gpseph = *gpseph;
|
---|
| 234 | emit newEphGPS(copy_gpseph);
|
---|
| 235 |
|
---|
[534] | 236 | printEphHeader();
|
---|
| 237 |
|
---|
[532] | 238 | gpsephemeris** ee = &_gpsEph[gpseph->satellite-1];
|
---|
[6372] | 239 | if (PRN_GPS_START <= gpseph->satellite && gpseph->satellite <= PRN_GPS_END) {
|
---|
| 240 | ee = &_gpsEph[gpseph->satellite - PRN_GPS_START];
|
---|
| 241 | }
|
---|
| 242 | else if (PRN_QZSS_START <= gpseph->satellite && gpseph->satellite <= PRN_QZSS_END) {
|
---|
| 243 | ee = &_qzssEph[gpseph->satellite - PRN_QZSS_START];
|
---|
| 244 | }
|
---|
[1218] | 245 |
|
---|
[6372] | 246 | if ( *ee != 0 && gpseph->GPSweek == (*ee)->GPSweek && gpseph->TOC == (*ee)->TOC ) {
|
---|
[4245] | 247 | checkEphemeris(*ee, gpseph);
|
---|
| 248 | }
|
---|
| 249 |
|
---|
[538] | 250 | if ( *ee == 0 ||
|
---|
| 251 | gpseph->GPSweek > (*ee)->GPSweek ||
|
---|
[594] | 252 | (gpseph->GPSweek == (*ee)->GPSweek && gpseph->TOC > (*ee)->TOC) ) {
|
---|
[516] | 253 | delete *ee;
|
---|
| 254 | *ee = gpseph;
|
---|
[600] | 255 | printGPSEph(gpseph, true);
|
---|
[516] | 256 | }
|
---|
| 257 | else {
|
---|
[600] | 258 | printGPSEph(gpseph, false);
|
---|
[516] | 259 | delete gpseph;
|
---|
| 260 | }
|
---|
[511] | 261 | }
|
---|
| 262 |
|
---|
[535] | 263 | // New Glonass Ephemeris
|
---|
[511] | 264 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5206] | 265 | void t_bncCore::slotNewGlonassEph(glonassephemeris* glonasseph, const QString& staID) {
|
---|
[516] | 266 |
|
---|
| 267 | QMutexLocker locker(&_mutex);
|
---|
| 268 |
|
---|
[4747] | 269 | // Check wrong Ephemerides
|
---|
| 270 | // -----------------------
|
---|
| 271 | if (glonasseph->x_pos == 0.0 &&
|
---|
| 272 | glonasseph->y_pos == 0.0 &&
|
---|
| 273 | glonasseph->z_pos == 0.0) {
|
---|
| 274 | delete glonasseph;
|
---|
| 275 | return;
|
---|
| 276 | }
|
---|
| 277 |
|
---|
[1164] | 278 | glonassephemeris copy_glonasseph = *glonasseph;
|
---|
| 279 | emit newEphGlonass(copy_glonasseph);
|
---|
| 280 |
|
---|
[534] | 281 | printEphHeader();
|
---|
| 282 |
|
---|
[532] | 283 | glonassephemeris** ee = &_glonassEph[glonasseph->almanac_number-1];
|
---|
[531] | 284 |
|
---|
[3539] | 285 | int wwOld, towOld, wwNew, towNew;
|
---|
| 286 | if (*ee != 0) {
|
---|
| 287 | wwOld = (*ee)->GPSWeek;
|
---|
| 288 | towOld = (*ee)->GPSTOW;
|
---|
| 289 | updatetime(&wwOld, &towOld, (*ee)->tb*1000, 0); // Moscow -> GPS
|
---|
| 290 |
|
---|
| 291 | wwNew = glonasseph->GPSWeek;
|
---|
| 292 | towNew = glonasseph->GPSTOW;
|
---|
| 293 | updatetime(&wwNew, &towNew, glonasseph->tb*1000, 0); // Moscow -> GPS
|
---|
| 294 | }
|
---|
| 295 |
|
---|
[578] | 296 | if ( *ee == 0 ||
|
---|
[3539] | 297 | wwNew > wwOld ||
|
---|
| 298 | (wwNew == wwOld && towNew > towOld) ) {
|
---|
[531] | 299 | delete *ee;
|
---|
| 300 | *ee = glonasseph;
|
---|
[5206] | 301 | printGlonassEph(glonasseph, true, staID);
|
---|
[531] | 302 | }
|
---|
| 303 | else {
|
---|
[5206] | 304 | printGlonassEph(glonasseph, false, staID);
|
---|
[531] | 305 | delete glonasseph;
|
---|
| 306 | }
|
---|
[511] | 307 | }
|
---|
| 308 |
|
---|
[2770] | 309 | // New Galileo Ephemeris
|
---|
| 310 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 311 | void t_bncCore::slotNewGalileoEph(galileoephemeris* galileoeph) {
|
---|
[2770] | 312 |
|
---|
| 313 | QMutexLocker locker(&_mutex);
|
---|
| 314 |
|
---|
[2772] | 315 | galileoephemeris copy_galileoeph = *galileoeph;
|
---|
| 316 | emit newEphGalileo(copy_galileoeph);
|
---|
| 317 |
|
---|
| 318 | printEphHeader();
|
---|
| 319 |
|
---|
[3734] | 320 | int galIndex = galileoeph->satellite;
|
---|
| 321 | /* GIOVE */
|
---|
| 322 | if(galIndex == 51) galIndex = 1;
|
---|
| 323 | else if(galIndex == 52) galIndex = 16;
|
---|
[2785] | 324 | if (galIndex < 0 || galIndex > PRN_GALILEO_END - PRN_GALILEO_START) {
|
---|
[2773] | 325 | emit( newMessage("Wrong Galileo Satellite Number", true) );
|
---|
| 326 | exit(1);
|
---|
| 327 | }
|
---|
[2772] | 328 |
|
---|
[2773] | 329 | galileoephemeris** ee = &_galileoEph[galIndex];
|
---|
| 330 |
|
---|
| 331 | if ( *ee == 0 ||
|
---|
[2772] | 332 | galileoeph->Week > (*ee)->Week ||
|
---|
| 333 | (galileoeph->Week == (*ee)->Week && galileoeph->TOC > (*ee)->TOC) ) {
|
---|
| 334 | delete *ee;
|
---|
| 335 | *ee = galileoeph;
|
---|
| 336 | printGalileoEph(galileoeph, true);
|
---|
| 337 | }
|
---|
| 338 | else {
|
---|
| 339 | printGalileoEph(galileoeph, false);
|
---|
| 340 | delete galileoeph;
|
---|
| 341 | }
|
---|
[2770] | 342 | }
|
---|
| 343 |
|
---|
[535] | 344 | // Print Header of the output File(s)
|
---|
[516] | 345 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 346 | void t_bncCore::printEphHeader() {
|
---|
[528] | 347 |
|
---|
[1535] | 348 | bncSettings settings;
|
---|
[535] | 349 |
|
---|
[534] | 350 | // Initialization
|
---|
| 351 | // --------------
|
---|
| 352 | if (_rinexVers == 0) {
|
---|
[528] | 353 |
|
---|
[533] | 354 | if ( Qt::CheckState(settings.value("ephV3").toInt()) == Qt::Checked) {
|
---|
[534] | 355 | _rinexVers = 3;
|
---|
[533] | 356 | }
|
---|
| 357 | else {
|
---|
[534] | 358 | _rinexVers = 2;
|
---|
[533] | 359 | }
|
---|
[529] | 360 |
|
---|
[533] | 361 | _ephPath = settings.value("ephPath").toString();
|
---|
| 362 |
|
---|
| 363 | if ( !_ephPath.isEmpty() ) {
|
---|
| 364 | if ( _ephPath[_ephPath.length()-1] != QDir::separator() ) {
|
---|
| 365 | _ephPath += QDir::separator();
|
---|
| 366 | }
|
---|
| 367 | expandEnvVar(_ephPath);
|
---|
| 368 | }
|
---|
[517] | 369 | }
|
---|
[533] | 370 |
|
---|
[534] | 371 | // (Re-)Open output File(s)
|
---|
| 372 | // ------------------------
|
---|
[533] | 373 | if (!_ephPath.isEmpty()) {
|
---|
| 374 |
|
---|
[1154] | 375 | QDateTime datTim = currentDateAndTimeGPS();
|
---|
[533] | 376 |
|
---|
[583] | 377 | QString ephFileNameGPS = _ephPath + "BRDC" +
|
---|
[563] | 378 | QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0'));
|
---|
[533] | 379 |
|
---|
[647] | 380 | QString hlpStr = bncRinex::nextEpochStr(datTim,
|
---|
| 381 | settings.value("ephIntr").toString());
|
---|
[584] | 382 |
|
---|
[575] | 383 | if (_rinexVers == 3) {
|
---|
| 384 | ephFileNameGPS += hlpStr + datTim.toString(".yyP");
|
---|
| 385 | }
|
---|
| 386 | else {
|
---|
| 387 | ephFileNameGPS += hlpStr + datTim.toString(".yyN");
|
---|
| 388 | }
|
---|
[563] | 389 |
|
---|
[533] | 390 | if (_ephFileNameGPS == ephFileNameGPS) {
|
---|
| 391 | return;
|
---|
| 392 | }
|
---|
| 393 | else {
|
---|
| 394 | _ephFileNameGPS = ephFileNameGPS;
|
---|
| 395 | }
|
---|
| 396 |
|
---|
[575] | 397 | for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) {
|
---|
| 398 | delete _gpsEph[ii-PRN_GPS_START];
|
---|
| 399 | _gpsEph[ii-PRN_GPS_START] = 0;
|
---|
| 400 | }
|
---|
[6372] | 401 | for (int ii = PRN_QZSS_START; ii <= PRN_QZSS_END; ii++) {
|
---|
| 402 | delete _qzssEph[ii-PRN_QZSS_START];
|
---|
| 403 | _qzssEph[ii-PRN_QZSS_START] = 0;
|
---|
| 404 | }
|
---|
[575] | 405 | for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) {
|
---|
| 406 | delete _glonassEph[ii-PRN_GLONASS_START];
|
---|
| 407 | _glonassEph[ii-PRN_GLONASS_START] = 0;
|
---|
| 408 | }
|
---|
[2770] | 409 | for (int ii = PRN_GALILEO_START; ii <= PRN_GALILEO_END; ii++) {
|
---|
| 410 | delete _galileoEph[ii-PRN_GALILEO_START];
|
---|
| 411 | _galileoEph[ii-PRN_GALILEO_START] = 0;
|
---|
| 412 | }
|
---|
[6384] | 413 | for (int ii = PRN_SBAS_START; ii <= PRN_SBAS_END; ii++) {
|
---|
| 414 | delete _sbasEph[ii-PRN_SBAS_START];
|
---|
| 415 | _sbasEph[ii-PRN_SBAS_START] = 0;
|
---|
| 416 | }
|
---|
[575] | 417 |
|
---|
[533] | 418 | delete _ephStreamGPS;
|
---|
| 419 | delete _ephFileGPS;
|
---|
| 420 |
|
---|
[535] | 421 | QFlags<QIODevice::OpenModeFlag> appendFlagGPS;
|
---|
[536] | 422 | QFlags<QIODevice::OpenModeFlag> appendFlagGlonass;
|
---|
| 423 |
|
---|
[535] | 424 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
|
---|
| 425 | QFile::exists(ephFileNameGPS) ) {
|
---|
| 426 | appendFlagGPS = QIODevice::Append;
|
---|
| 427 | }
|
---|
| 428 |
|
---|
[533] | 429 | _ephFileGPS = new QFile(ephFileNameGPS);
|
---|
[535] | 430 | _ephFileGPS->open(QIODevice::WriteOnly | appendFlagGPS);
|
---|
[533] | 431 | _ephStreamGPS = new QTextStream();
|
---|
| 432 | _ephStreamGPS->setDevice(_ephFileGPS);
|
---|
| 433 |
|
---|
[534] | 434 | if (_rinexVers == 3) {
|
---|
[533] | 435 | _ephFileGlonass = _ephFileGPS;
|
---|
| 436 | _ephStreamGlonass = _ephStreamGPS;
|
---|
[2770] | 437 | _ephFileGalileo = _ephFileGPS;
|
---|
| 438 | _ephStreamGalileo = _ephStreamGPS;
|
---|
[6384] | 439 | _ephFileSBAS = _ephFileGPS;
|
---|
| 440 | _ephStreamSBAS = _ephStreamGPS;
|
---|
[533] | 441 | }
|
---|
[534] | 442 | else if (_rinexVers == 2) {
|
---|
[583] | 443 | QString ephFileNameGlonass = _ephPath + "BRDC" +
|
---|
[563] | 444 | QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +
|
---|
[575] | 445 | hlpStr + datTim.toString(".yyG");
|
---|
[533] | 446 |
|
---|
| 447 | delete _ephStreamGlonass;
|
---|
| 448 | delete _ephFileGlonass;
|
---|
| 449 |
|
---|
[535] | 450 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
|
---|
| 451 | QFile::exists(ephFileNameGlonass) ) {
|
---|
| 452 | appendFlagGlonass = QIODevice::Append;
|
---|
| 453 | }
|
---|
| 454 |
|
---|
[533] | 455 | _ephFileGlonass = new QFile(ephFileNameGlonass);
|
---|
[535] | 456 | _ephFileGlonass->open(QIODevice::WriteOnly | appendFlagGlonass);
|
---|
[533] | 457 | _ephStreamGlonass = new QTextStream();
|
---|
| 458 | _ephStreamGlonass->setDevice(_ephFileGlonass);
|
---|
| 459 | }
|
---|
| 460 |
|
---|
[534] | 461 | // Header - RINEX Version 3
|
---|
| 462 | // ------------------------
|
---|
| 463 | if (_rinexVers == 3) {
|
---|
[537] | 464 | if ( ! (appendFlagGPS & QIODevice::Append)) {
|
---|
| 465 | QString line;
|
---|
| 466 | line.sprintf(
|
---|
| 467 | "%9.2f%11sN: GNSS NAV DATA M: Mixed%12sRINEX VERSION / TYPE\n",
|
---|
| 468 | 3.0, "", "");
|
---|
| 469 | *_ephStreamGPS << line;
|
---|
| 470 |
|
---|
[1154] | 471 | QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
|
---|
[559] | 472 | *_ephStreamGPS << _pgmName.toAscii().data()
|
---|
| 473 | << _userName.toAscii().data()
|
---|
| 474 | << hlp.toAscii().data()
|
---|
| 475 | << "PGM / RUN BY / DATE" << endl;
|
---|
| 476 |
|
---|
| 477 | line.sprintf("%60sEND OF HEADER\n", "");
|
---|
[537] | 478 | *_ephStreamGPS << line;
|
---|
| 479 |
|
---|
| 480 | _ephStreamGPS->flush();
|
---|
[535] | 481 | }
|
---|
[533] | 482 | }
|
---|
| 483 |
|
---|
[536] | 484 | // Headers - RINEX Version 2
|
---|
| 485 | // -------------------------
|
---|
[534] | 486 | else if (_rinexVers == 2) {
|
---|
[536] | 487 | if (! (appendFlagGPS & QIODevice::Append)) {
|
---|
| 488 | QString line;
|
---|
[5375] | 489 | line.sprintf("%9.2f%11sN: GPS NAV DATA%25sRINEX VERSION / TYPE\n",
|
---|
| 490 | t_rnxNavFile::defaultRnxNavVersion2, "", "");
|
---|
[536] | 491 | *_ephStreamGPS << line;
|
---|
| 492 |
|
---|
[1154] | 493 | QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
|
---|
[559] | 494 | *_ephStreamGPS << _pgmName.toAscii().data()
|
---|
| 495 | << _userName.toAscii().data()
|
---|
| 496 | << hlp.toAscii().data()
|
---|
| 497 | << "PGM / RUN BY / DATE" << endl;
|
---|
| 498 |
|
---|
| 499 | line.sprintf("%60sEND OF HEADER\n", "");
|
---|
[536] | 500 | *_ephStreamGPS << line;
|
---|
[537] | 501 |
|
---|
| 502 | _ephStreamGPS->flush();
|
---|
[536] | 503 | }
|
---|
| 504 | if (! (appendFlagGlonass & QIODevice::Append)) {
|
---|
| 505 | QString line;
|
---|
[5375] | 506 | line.sprintf("%9.2f%11sG: GLONASS NAV DATA%21sRINEX VERSION / TYPE\n",
|
---|
| 507 | t_rnxNavFile::defaultRnxNavVersion2, "", "");
|
---|
[536] | 508 | *_ephStreamGlonass << line;
|
---|
| 509 |
|
---|
[1154] | 510 | QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
|
---|
[559] | 511 | *_ephStreamGlonass << _pgmName.toAscii().data()
|
---|
| 512 | << _userName.toAscii().data()
|
---|
| 513 | << hlp.toAscii().data()
|
---|
| 514 | << "PGM / RUN BY / DATE" << endl;
|
---|
| 515 |
|
---|
| 516 | line.sprintf("%60sEND OF HEADER\n", "");
|
---|
[536] | 517 | *_ephStreamGlonass << line;
|
---|
[537] | 518 |
|
---|
| 519 | _ephStreamGlonass->flush();
|
---|
[536] | 520 | }
|
---|
[533] | 521 | }
|
---|
| 522 | }
|
---|
[516] | 523 | }
|
---|
| 524 |
|
---|
[535] | 525 | // Print One GPS Ephemeris
|
---|
[516] | 526 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 527 | void t_bncCore::printGPSEph(gpsephemeris* ep, bool printFile) {
|
---|
[519] | 528 |
|
---|
[4020] | 529 | t_ephGPS eph;
|
---|
| 530 | eph.set(ep);
|
---|
[533] | 531 |
|
---|
[5375] | 532 | QString strV2 = eph.toString(t_rnxNavFile::defaultRnxNavVersion2);
|
---|
| 533 | QString strV3 = eph.toString(t_rnxObsHeader::defaultRnxObsVersion3);
|
---|
[941] | 534 |
|
---|
[4020] | 535 | printOutput(printFile, _ephStreamGPS, strV2, strV3);
|
---|
[516] | 536 | }
|
---|
| 537 |
|
---|
[535] | 538 | // Print One Glonass Ephemeris
|
---|
[516] | 539 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5375] | 540 | void t_bncCore::printGlonassEph(glonassephemeris* ep, bool printFile, const QString& /* staID */) {
|
---|
[523] | 541 |
|
---|
[4020] | 542 | t_ephGlo eph;
|
---|
[5133] | 543 | eph.set(ep);
|
---|
[523] | 544 |
|
---|
[5375] | 545 | QString strV2 = eph.toString(t_rnxNavFile::defaultRnxNavVersion2);
|
---|
| 546 | QString strV3 = eph.toString(t_rnxObsHeader::defaultRnxObsVersion3);
|
---|
[525] | 547 |
|
---|
[5206] | 548 | //// beg test Dirk
|
---|
[5312] | 549 | // QString hlp = strV2;
|
---|
| 550 | // cout << hlp.replace('\n', ' ').toAscii().data() << ' ' << staID.toAscii().data() << endl;
|
---|
[5206] | 551 | //// end test Dirk
|
---|
| 552 |
|
---|
[4225] | 553 | printOutput(printFile, _ephStreamGlonass, strV2, strV3);
|
---|
[941] | 554 | }
|
---|
| 555 |
|
---|
[2770] | 556 | // Print One Galileo Ephemeris
|
---|
| 557 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 558 | void t_bncCore::printGalileoEph(galileoephemeris* ep, bool printFile) {
|
---|
[2772] | 559 |
|
---|
[4020] | 560 | t_ephGal eph;
|
---|
| 561 | eph.set(ep);
|
---|
[2772] | 562 |
|
---|
[5375] | 563 | QString strV2 = eph.toString(t_rnxNavFile::defaultRnxNavVersion2);
|
---|
| 564 | QString strV3 = eph.toString(t_rnxObsHeader::defaultRnxObsVersion3);
|
---|
[2772] | 565 |
|
---|
[4225] | 566 | printOutput(printFile, _ephStreamGalileo, strV2, strV3);
|
---|
[2770] | 567 | }
|
---|
| 568 |
|
---|
[941] | 569 | // Output
|
---|
| 570 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 571 | void t_bncCore::printOutput(bool printFile, QTextStream* stream,
|
---|
[4020] | 572 | const QString& strV2, const QString& strV3) {
|
---|
| 573 |
|
---|
[590] | 574 | // Output into file
|
---|
| 575 | // ----------------
|
---|
[943] | 576 | if (printFile && stream) {
|
---|
[941] | 577 | if (_rinexVers == 2) {
|
---|
[4020] | 578 | *stream << strV2.toAscii();
|
---|
[941] | 579 | }
|
---|
| 580 | else {
|
---|
[4020] | 581 | *stream << strV3.toAscii();
|
---|
[941] | 582 | }
|
---|
[943] | 583 | stream->flush();
|
---|
[517] | 584 | }
|
---|
[590] | 585 |
|
---|
| 586 | // Output into the socket
|
---|
| 587 | // ----------------------
|
---|
| 588 | if (_sockets) {
|
---|
[642] | 589 | QMutableListIterator<QTcpSocket*> is(*_sockets);
|
---|
[590] | 590 | while (is.hasNext()) {
|
---|
| 591 | QTcpSocket* sock = is.next();
|
---|
| 592 | if (sock->state() == QAbstractSocket::ConnectedState) {
|
---|
[4020] | 593 | if (sock->write(strV3.toAscii()) == -1) {
|
---|
[642] | 594 | delete sock;
|
---|
| 595 | is.remove();
|
---|
| 596 | }
|
---|
[590] | 597 | }
|
---|
[642] | 598 | else if (sock->state() != QAbstractSocket::ConnectingState) {
|
---|
| 599 | delete sock;
|
---|
| 600 | is.remove();
|
---|
| 601 | }
|
---|
[590] | 602 | }
|
---|
| 603 | }
|
---|
[516] | 604 | }
|
---|
[589] | 605 |
|
---|
[591] | 606 | // Set Port Number
|
---|
| 607 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 608 | void t_bncCore::setPort(int port) {
|
---|
[591] | 609 | _port = port;
|
---|
| 610 | if (_port != 0) {
|
---|
[942] | 611 | delete _server;
|
---|
[591] | 612 | _server = new QTcpServer;
|
---|
[1228] | 613 | if ( !_server->listen(QHostAddress::Any, _port) ) {
|
---|
[5072] | 614 | slotMessage("t_bncCore: Cannot listen on ephemeris port", true);
|
---|
[1228] | 615 | }
|
---|
[591] | 616 | connect(_server, SIGNAL(newConnection()), this, SLOT(slotNewConnection()));
|
---|
[942] | 617 | delete _sockets;
|
---|
[591] | 618 | _sockets = new QList<QTcpSocket*>;
|
---|
| 619 | }
|
---|
| 620 | }
|
---|
| 621 |
|
---|
[937] | 622 | // Set Port Number
|
---|
| 623 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 624 | void t_bncCore::setPortCorr(int port) {
|
---|
[937] | 625 | _portCorr = port;
|
---|
| 626 | if (_portCorr != 0) {
|
---|
[942] | 627 | delete _serverCorr;
|
---|
[937] | 628 | _serverCorr = new QTcpServer;
|
---|
[1228] | 629 | if ( !_serverCorr->listen(QHostAddress::Any, _portCorr) ) {
|
---|
[5072] | 630 | slotMessage("t_bncCore: Cannot listen on correction port", true);
|
---|
[1228] | 631 | }
|
---|
[937] | 632 | connect(_serverCorr, SIGNAL(newConnection()), this, SLOT(slotNewConnectionCorr()));
|
---|
[942] | 633 | delete _socketsCorr;
|
---|
[937] | 634 | _socketsCorr = new QList<QTcpSocket*>;
|
---|
| 635 | }
|
---|
| 636 | }
|
---|
| 637 |
|
---|
[589] | 638 | // New Connection
|
---|
| 639 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 640 | void t_bncCore::slotNewConnection() {
|
---|
[589] | 641 | _sockets->push_back( _server->nextPendingConnection() );
|
---|
| 642 | }
|
---|
| 643 |
|
---|
[937] | 644 | // New Connection
|
---|
| 645 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 646 | void t_bncCore::slotNewConnectionCorr() {
|
---|
[937] | 647 | _socketsCorr->push_back( _serverCorr->nextPendingConnection() );
|
---|
| 648 | }
|
---|
| 649 |
|
---|
[621] | 650 | //
|
---|
| 651 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 652 | void t_bncCore::slotQuit() {
|
---|
[5729] | 653 | delete _caster; _caster = 0;
|
---|
[5066] | 654 | qApp->quit();
|
---|
[621] | 655 | }
|
---|
| 656 |
|
---|
[936] | 657 | //
|
---|
| 658 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6141] | 659 | void t_bncCore::slotNewOrbCorrections(QList<t_orbCorr> orbCorrections) {
|
---|
[6151] | 660 | QMutexLocker locker(&_mutex);
|
---|
[6141] | 661 | emit newOrbCorrections(orbCorrections);
|
---|
[6151] | 662 | if (_socketsCorr) {
|
---|
| 663 | QListIterator<t_orbCorr> it(orbCorrections);
|
---|
| 664 | while (it.hasNext()) {
|
---|
| 665 | const t_orbCorr& corr = it.next();
|
---|
| 666 | QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
|
---|
| 667 | while (is.hasNext()) {
|
---|
| 668 | QTcpSocket* sock = is.next();
|
---|
| 669 | if (sock->state() == QAbstractSocket::ConnectedState) {
|
---|
[6175] | 670 | if (sock->write(corr.toLine().c_str()) == -1) {
|
---|
[6151] | 671 | delete sock;
|
---|
| 672 | is.remove();
|
---|
| 673 | }
|
---|
| 674 | }
|
---|
| 675 | else if (sock->state() != QAbstractSocket::ConnectingState) {
|
---|
| 676 | delete sock;
|
---|
| 677 | is.remove();
|
---|
| 678 | }
|
---|
| 679 | }
|
---|
| 680 | }
|
---|
| 681 | }
|
---|
[6141] | 682 | }
|
---|
[974] | 683 |
|
---|
[6141] | 684 | //
|
---|
| 685 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 686 | void t_bncCore::slotNewClkCorrections(QList<t_clkCorr> clkCorrections) {
|
---|
[974] | 687 | QMutexLocker locker(&_mutex);
|
---|
[6151] | 688 | emit newClkCorrections(clkCorrections);
|
---|
[3109] | 689 | if (_socketsCorr) {
|
---|
[6151] | 690 | QListIterator<t_clkCorr> it(clkCorrections);
|
---|
[3109] | 691 | while (it.hasNext()) {
|
---|
[6141] | 692 | const t_clkCorr& corr = it.next();
|
---|
[3109] | 693 | QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
|
---|
| 694 | while (is.hasNext()) {
|
---|
| 695 | QTcpSocket* sock = is.next();
|
---|
| 696 | if (sock->state() == QAbstractSocket::ConnectedState) {
|
---|
[6175] | 697 | if (sock->write(corr.toLine().c_str()) == -1) {
|
---|
[976] | 698 | delete sock;
|
---|
| 699 | is.remove();
|
---|
| 700 | }
|
---|
| 701 | }
|
---|
[3109] | 702 | else if (sock->state() != QAbstractSocket::ConnectingState) {
|
---|
| 703 | delete sock;
|
---|
| 704 | is.remove();
|
---|
| 705 | }
|
---|
[937] | 706 | }
|
---|
| 707 | }
|
---|
| 708 | }
|
---|
[936] | 709 | }
|
---|
[1538] | 710 |
|
---|
| 711 | //
|
---|
| 712 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 713 | void t_bncCore::setConfFileName(const QString& confFileName) {
|
---|
[4169] | 714 | if (confFileName.isEmpty()) {
|
---|
| 715 | _confFileName = QDir::homePath() + QDir::separator()
|
---|
| 716 | + ".config" + QDir::separator()
|
---|
[5066] | 717 | + qApp->organizationName() + QDir::separator()
|
---|
| 718 | + qApp->applicationName() + ".bnc";
|
---|
[1538] | 719 | }
|
---|
[4169] | 720 | else {
|
---|
| 721 | _confFileName = confFileName;
|
---|
| 722 | }
|
---|
[1538] | 723 | }
|
---|
[2385] | 724 |
|
---|
| 725 | // Raw Output
|
---|
| 726 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 727 | void t_bncCore::writeRawData(const QByteArray& data, const QByteArray& staID,
|
---|
[2518] | 728 | const QByteArray& format) {
|
---|
[2385] | 729 |
|
---|
[2386] | 730 | QMutexLocker locker(&_mutex);
|
---|
| 731 |
|
---|
[2519] | 732 | if (!_rawFile) {
|
---|
[2386] | 733 | bncSettings settings;
|
---|
[2519] | 734 | QByteArray fileName = settings.value("rawOutFile").toByteArray();
|
---|
| 735 | if (!fileName.isEmpty()) {
|
---|
[3524] | 736 | _rawFile = new bncRawFile(fileName, staID, bncRawFile::output);
|
---|
[2407] | 737 | }
|
---|
[2386] | 738 | }
|
---|
| 739 |
|
---|
[2519] | 740 | if (_rawFile) {
|
---|
| 741 | _rawFile->writeRawData(data, staID, format);
|
---|
[2386] | 742 | }
|
---|
[2385] | 743 | }
|
---|
[2672] | 744 |
|
---|
[2909] | 745 | //
|
---|
| 746 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 747 | void t_bncCore::initCombination() {
|
---|
[2909] | 748 | #ifdef USE_COMBINATION
|
---|
| 749 | _bncComb = new bncComb();
|
---|
[3142] | 750 | if (_bncComb->nStreams() < 1) {
|
---|
[2909] | 751 | delete _bncComb;
|
---|
| 752 | _bncComb = 0;
|
---|
| 753 | }
|
---|
| 754 | #endif
|
---|
| 755 | }
|
---|
[3231] | 756 |
|
---|
| 757 | //
|
---|
| 758 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 759 | void t_bncCore::stopCombination() {
|
---|
[3231] | 760 | #ifdef USE_COMBINATION
|
---|
| 761 | delete _bncComb;
|
---|
| 762 | _bncComb = 0;
|
---|
| 763 | #endif
|
---|
| 764 | }
|
---|
[4167] | 765 |
|
---|
[4245] | 766 | // Check Ephemeris Consistency
|
---|
| 767 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 768 | void t_bncCore::checkEphemeris(gpsephemeris* oldEph, gpsephemeris* newEph) {
|
---|
[4245] | 769 | if (oldEph->clock_bias != newEph->clock_bias ||
|
---|
| 770 | oldEph->clock_drift != newEph->clock_drift ||
|
---|
| 771 | oldEph->clock_driftrate != newEph->clock_driftrate) {
|
---|
| 772 | QString msg = currentDateAndTimeGPS().toString(Qt::ISODate) +
|
---|
| 773 | QString(" %1 EPH DIFFERS\n").arg(oldEph->satellite);
|
---|
| 774 | messagePrivate(msg.toAscii());
|
---|
| 775 | }
|
---|
| 776 | }
|
---|
[5577] | 777 |
|
---|
[5846] | 778 |
|
---|
| 779 | //
|
---|
| 780 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 781 | bool t_bncCore::dateAndTimeGPSSet() const {
|
---|
| 782 | QMutexLocker locker(&_mutexDateAndTimeGPS);
|
---|
| 783 | if (_dateAndTimeGPS) {
|
---|
| 784 | return true;
|
---|
| 785 | }
|
---|
| 786 | else {
|
---|
| 787 | return false;
|
---|
| 788 | }
|
---|
| 789 | }
|
---|
| 790 |
|
---|
| 791 | //
|
---|
| 792 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 793 | QDateTime t_bncCore::dateAndTimeGPS() const {
|
---|
| 794 | QMutexLocker locker(&_mutexDateAndTimeGPS);
|
---|
| 795 | if (_dateAndTimeGPS) {
|
---|
| 796 | return *_dateAndTimeGPS;
|
---|
| 797 | }
|
---|
| 798 | else {
|
---|
| 799 | return QDateTime();
|
---|
| 800 | }
|
---|
| 801 | }
|
---|
| 802 |
|
---|
| 803 | //
|
---|
| 804 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 805 | void t_bncCore::setDateAndTimeGPS(QDateTime dateTime) {
|
---|
| 806 | QMutexLocker locker(&_mutexDateAndTimeGPS);
|
---|
| 807 | delete _dateAndTimeGPS;
|
---|
| 808 | _dateAndTimeGPS = new QDateTime(dateTime);
|
---|
| 809 | }
|
---|
[5900] | 810 |
|
---|
| 811 | //
|
---|
| 812 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5946] | 813 | void t_bncCore::startPPP() {
|
---|
| 814 | _pppMain->start();
|
---|
[5900] | 815 | }
|
---|
| 816 |
|
---|
| 817 | //
|
---|
| 818 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 819 | void t_bncCore::stopPPP() {
|
---|
[5903] | 820 | _pppMain->stop();
|
---|
[5972] | 821 | emit stopRinexPPP();
|
---|
[5900] | 822 | }
|
---|
[6383] | 823 |
|
---|
| 824 | // New SBAS Ephemeris
|
---|
| 825 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 826 | void t_bncCore::slotNewSBASEph(sbasephemeris* sbaseph) {
|
---|
| 827 | QMutexLocker locker(&_mutex);
|
---|
| 828 |
|
---|
[6384] | 829 | // Check wrong Ephemerides
|
---|
| 830 | // -----------------------
|
---|
| 831 | if (sbaseph->x_pos == 0.0 &&
|
---|
| 832 | sbaseph->y_pos == 0.0 &&
|
---|
| 833 | sbaseph->z_pos == 0.0) {
|
---|
| 834 | delete sbaseph;
|
---|
| 835 | return;
|
---|
| 836 | }
|
---|
| 837 |
|
---|
| 838 | sbasephemeris copy_sbaseph = *sbaseph;
|
---|
| 839 | emit newEphSBAS(copy_sbaseph);
|
---|
| 840 |
|
---|
| 841 | printEphHeader();
|
---|
| 842 |
|
---|
| 843 | sbasephemeris** ee = &_sbasEph[sbaseph->satellite - PRN_SBAS_START];
|
---|
| 844 |
|
---|
| 845 | bool replace = false;
|
---|
| 846 | if (*ee != 0) {
|
---|
| 847 | bncTime oldTime((*ee)->GPSweek_TOE, double((*ee)->TOE));
|
---|
| 848 | bncTime newTime(sbaseph->GPSweek_TOE, double(sbaseph->TOE));
|
---|
| 849 | if (newTime > oldTime) {
|
---|
| 850 | replace = true;
|
---|
| 851 | }
|
---|
| 852 | }
|
---|
| 853 |
|
---|
| 854 | if ( *ee == 0 || replace) {
|
---|
| 855 | delete *ee;
|
---|
| 856 | *ee = sbaseph;
|
---|
| 857 | printSBASEph(sbaseph, true);
|
---|
| 858 | }
|
---|
| 859 | else {
|
---|
| 860 | printSBASEph(sbaseph, false);
|
---|
| 861 | delete sbaseph;
|
---|
| 862 | }
|
---|
[6383] | 863 | }
|
---|
[6384] | 864 |
|
---|
| 865 | // Print One SBAS Ephemeris
|
---|
| 866 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 867 | void t_bncCore::printSBASEph(sbasephemeris* ep, bool printFile) {
|
---|
| 868 |
|
---|
| 869 | t_ephSBAS eph;
|
---|
| 870 | eph.set(ep);
|
---|
| 871 |
|
---|
| 872 | QString strV2 = eph.toString(t_rnxNavFile::defaultRnxNavVersion2);
|
---|
| 873 | QString strV3 = eph.toString(t_rnxObsHeader::defaultRnxObsVersion3);
|
---|
| 874 |
|
---|
| 875 | printOutput(printFile, _ephStreamSBAS, strV2, strV3);
|
---|
| 876 | }
|
---|