[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 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6441] | 70 | t_bncCore::t_bncCore() : _ephUser(false) {
|
---|
[5084] | 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 |
|
---|
[533] | 81 | // Eph file(s)
|
---|
| 82 | // -----------
|
---|
[534] | 83 | _rinexVers = 0;
|
---|
[533] | 84 | _ephFileGPS = 0;
|
---|
| 85 | _ephStreamGPS = 0;
|
---|
| 86 | _ephFileGlonass = 0;
|
---|
| 87 | _ephStreamGlonass = 0;
|
---|
[2770] | 88 | _ephFileGalileo = 0;
|
---|
| 89 | _ephStreamGalileo = 0;
|
---|
[6384] | 90 | _ephFileSBAS = 0;
|
---|
| 91 | _ephStreamSBAS = 0;
|
---|
[559] | 92 |
|
---|
[591] | 93 | _port = 0;
|
---|
[589] | 94 | _server = 0;
|
---|
| 95 | _sockets = 0;
|
---|
| 96 |
|
---|
[937] | 97 | _portCorr = 0;
|
---|
| 98 | _serverCorr = 0;
|
---|
| 99 | _socketsCorr = 0;
|
---|
| 100 |
|
---|
[2011] | 101 | _pgmName = QString(BNCPGMNAME).leftJustified(20, ' ', true);
|
---|
[559] | 102 | #ifdef WIN32
|
---|
| 103 | _userName = QString("${USERNAME}");
|
---|
| 104 | #else
|
---|
| 105 | _userName = QString("${USER}");
|
---|
| 106 | #endif
|
---|
| 107 | expandEnvVar(_userName);
|
---|
[973] | 108 |
|
---|
[6151] | 109 | _userName = _userName.leftJustified(20, ' ', true);
|
---|
[5846] | 110 | _dateAndTimeGPS = 0;
|
---|
[6151] | 111 | _mainWindow = 0;
|
---|
[2673] | 112 |
|
---|
[5899] | 113 | _pppMain = new BNC_PPP::t_pppMain();
|
---|
[5902] | 114 | qRegisterMetaType< QVector<double> >("QVector<double>");
|
---|
[5938] | 115 | qRegisterMetaType<bncTime>("bncTime");
|
---|
[6432] | 116 | qRegisterMetaType<t_ephGPS>("t_ephGPS");
|
---|
| 117 | qRegisterMetaType<t_ephGlo>("t_ephGlo");
|
---|
| 118 | qRegisterMetaType<t_ephGal>("t_ephGal");
|
---|
| 119 | qRegisterMetaType<t_ephSBAS>("t_ephSBAS");
|
---|
| 120 | qRegisterMetaType<t_ephCompass>("t_ephCompass");
|
---|
[82] | 121 | }
|
---|
| 122 |
|
---|
| 123 | // Destructor
|
---|
| 124 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 125 | t_bncCore::~t_bncCore() {
|
---|
[109] | 126 | delete _logStream;
|
---|
| 127 | delete _logFile;
|
---|
[533] | 128 | delete _ephStreamGPS;
|
---|
| 129 | delete _ephFileGPS;
|
---|
[589] | 130 | delete _server;
|
---|
| 131 | delete _sockets;
|
---|
[937] | 132 | delete _serverCorr;
|
---|
| 133 | delete _socketsCorr;
|
---|
[534] | 134 | if (_rinexVers == 2) {
|
---|
[533] | 135 | delete _ephStreamGlonass;
|
---|
| 136 | delete _ephFileGlonass;
|
---|
| 137 | }
|
---|
[975] | 138 |
|
---|
[5846] | 139 | delete _dateAndTimeGPS;
|
---|
[2519] | 140 | delete _rawFile;
|
---|
[2865] | 141 |
|
---|
[2899] | 142 | #ifdef USE_COMBINATION
|
---|
[2865] | 143 | delete _bncComb;
|
---|
[2899] | 144 | #endif
|
---|
[82] | 145 | }
|
---|
| 146 |
|
---|
| 147 | // Write a Program Message
|
---|
| 148 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 149 | void t_bncCore::slotMessage(QByteArray msg, bool showOnScreen) {
|
---|
[150] | 150 |
|
---|
[1218] | 151 | QMutexLocker locker(&_mutexMessage);
|
---|
[243] | 152 |
|
---|
[990] | 153 | messagePrivate(msg);
|
---|
[1299] | 154 | emit newMessage(msg, showOnScreen);
|
---|
[990] | 155 | }
|
---|
| 156 |
|
---|
| 157 | // Write a Program Message (private, no lock)
|
---|
| 158 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 159 | void t_bncCore::messagePrivate(const QByteArray& msg) {
|
---|
[990] | 160 |
|
---|
[150] | 161 | // First time resolve the log file name
|
---|
| 162 | // ------------------------------------
|
---|
[1549] | 163 | QDate currDate = currentDateAndTimeGPS().date();
|
---|
| 164 | if (_logFileFlag == 0 || _fileDate != currDate) {
|
---|
[3034] | 165 | delete _logStream; _logStream = 0;
|
---|
| 166 | delete _logFile; _logFile = 0;
|
---|
[150] | 167 | _logFileFlag = 1;
|
---|
[1535] | 168 | bncSettings settings;
|
---|
[150] | 169 | QString logFileName = settings.value("logFile").toString();
|
---|
| 170 | if ( !logFileName.isEmpty() ) {
|
---|
[151] | 171 | expandEnvVar(logFileName);
|
---|
[1549] | 172 | _logFile = new QFile(logFileName + "_" +
|
---|
| 173 | currDate.toString("yyMMdd").toAscii().data());
|
---|
| 174 | _fileDate = currDate;
|
---|
[275] | 175 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
|
---|
| 176 | _logFile->open(QIODevice::WriteOnly | QIODevice::Append);
|
---|
| 177 | }
|
---|
| 178 | else {
|
---|
| 179 | _logFile->open(QIODevice::WriteOnly);
|
---|
| 180 | }
|
---|
[150] | 181 | _logStream = new QTextStream();
|
---|
| 182 | _logStream->setDevice(_logFile);
|
---|
| 183 | }
|
---|
| 184 | }
|
---|
| 185 |
|
---|
[109] | 186 | if (_logStream) {
|
---|
[3371] | 187 | QByteArray msgLocal = msg;
|
---|
| 188 | if (msg.indexOf('\n') == 0) {
|
---|
| 189 | *_logStream << endl;
|
---|
| 190 | msgLocal = msg.mid(1);
|
---|
| 191 | }
|
---|
[1154] | 192 | *_logStream << currentDateAndTimeGPS().toString("yy-MM-dd hh:mm:ss ").toAscii().data();
|
---|
[3371] | 193 | *_logStream << msgLocal.data() << endl;
|
---|
[109] | 194 | _logStream->flush();
|
---|
[3637] | 195 | _logFile->flush();
|
---|
[82] | 196 | }
|
---|
| 197 | }
|
---|
[511] | 198 |
|
---|
[535] | 199 | // New GPS Ephemeris
|
---|
[511] | 200 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6432] | 201 | void t_bncCore::slotNewGPSEph(t_ephGPS eph) {
|
---|
[516] | 202 |
|
---|
| 203 | QMutexLocker locker(&_mutex);
|
---|
| 204 |
|
---|
[6432] | 205 | emit newGPSEph(eph);
|
---|
[1044] | 206 |
|
---|
[534] | 207 | printEphHeader();
|
---|
| 208 |
|
---|
[6432] | 209 | if (_ephUser.putNewEph(&eph) == success) {
|
---|
| 210 | printEph(eph, true);
|
---|
[6372] | 211 | }
|
---|
[516] | 212 | else {
|
---|
[6432] | 213 | printEph(eph, false);
|
---|
[516] | 214 | }
|
---|
[511] | 215 | }
|
---|
| 216 |
|
---|
[535] | 217 | // New Glonass Ephemeris
|
---|
[511] | 218 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6432] | 219 | void t_bncCore::slotNewGlonassEph(t_ephGlo eph) {
|
---|
[516] | 220 |
|
---|
| 221 | QMutexLocker locker(&_mutex);
|
---|
| 222 |
|
---|
[6432] | 223 | emit newGlonassEph(eph);
|
---|
[4747] | 224 |
|
---|
[534] | 225 | printEphHeader();
|
---|
| 226 |
|
---|
[6432] | 227 | if (_ephUser.putNewEph(&eph) == success) {
|
---|
| 228 | printEph(eph, true);
|
---|
[3539] | 229 | }
|
---|
[531] | 230 | else {
|
---|
[6432] | 231 | printEph(eph, false);
|
---|
[531] | 232 | }
|
---|
[511] | 233 | }
|
---|
| 234 |
|
---|
[2770] | 235 | // New Galileo Ephemeris
|
---|
| 236 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6432] | 237 | void t_bncCore::slotNewGalileoEph(t_ephGal eph) {
|
---|
[2770] | 238 |
|
---|
| 239 | QMutexLocker locker(&_mutex);
|
---|
| 240 |
|
---|
[6432] | 241 | emit newGalileoEph(eph);
|
---|
[2772] | 242 |
|
---|
| 243 | printEphHeader();
|
---|
| 244 |
|
---|
[6432] | 245 | if (_ephUser.putNewEph(&eph) == success) {
|
---|
| 246 | printEph(eph, true);
|
---|
[2773] | 247 | }
|
---|
[6432] | 248 | else {
|
---|
| 249 | printEph(eph, false);
|
---|
| 250 | }
|
---|
| 251 | }
|
---|
[2772] | 252 |
|
---|
[6432] | 253 | // New SBAS Ephemeris
|
---|
| 254 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 255 | void t_bncCore::slotNewSBASEph(t_ephSBAS eph) {
|
---|
[2773] | 256 |
|
---|
[6432] | 257 | QMutexLocker locker(&_mutex);
|
---|
| 258 |
|
---|
| 259 | emit newSBASEph(eph);
|
---|
| 260 |
|
---|
| 261 | printEphHeader();
|
---|
| 262 |
|
---|
| 263 | if (_ephUser.putNewEph(&eph) == success) {
|
---|
| 264 | printEph(eph, true);
|
---|
[2772] | 265 | }
|
---|
| 266 | else {
|
---|
[6432] | 267 | printEph(eph, false);
|
---|
[2772] | 268 | }
|
---|
[2770] | 269 | }
|
---|
| 270 |
|
---|
[6432] | 271 |
|
---|
[535] | 272 | // Print Header of the output File(s)
|
---|
[516] | 273 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 274 | void t_bncCore::printEphHeader() {
|
---|
[528] | 275 |
|
---|
[1535] | 276 | bncSettings settings;
|
---|
[535] | 277 |
|
---|
[534] | 278 | // Initialization
|
---|
| 279 | // --------------
|
---|
| 280 | if (_rinexVers == 0) {
|
---|
[528] | 281 |
|
---|
[533] | 282 | if ( Qt::CheckState(settings.value("ephV3").toInt()) == Qt::Checked) {
|
---|
[534] | 283 | _rinexVers = 3;
|
---|
[533] | 284 | }
|
---|
| 285 | else {
|
---|
[534] | 286 | _rinexVers = 2;
|
---|
[533] | 287 | }
|
---|
[529] | 288 |
|
---|
[533] | 289 | _ephPath = settings.value("ephPath").toString();
|
---|
| 290 |
|
---|
| 291 | if ( !_ephPath.isEmpty() ) {
|
---|
| 292 | if ( _ephPath[_ephPath.length()-1] != QDir::separator() ) {
|
---|
| 293 | _ephPath += QDir::separator();
|
---|
| 294 | }
|
---|
| 295 | expandEnvVar(_ephPath);
|
---|
| 296 | }
|
---|
[517] | 297 | }
|
---|
[533] | 298 |
|
---|
[534] | 299 | // (Re-)Open output File(s)
|
---|
| 300 | // ------------------------
|
---|
[533] | 301 | if (!_ephPath.isEmpty()) {
|
---|
| 302 |
|
---|
[1154] | 303 | QDateTime datTim = currentDateAndTimeGPS();
|
---|
[533] | 304 |
|
---|
[583] | 305 | QString ephFileNameGPS = _ephPath + "BRDC" +
|
---|
[563] | 306 | QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0'));
|
---|
[533] | 307 |
|
---|
[647] | 308 | QString hlpStr = bncRinex::nextEpochStr(datTim,
|
---|
| 309 | settings.value("ephIntr").toString());
|
---|
[584] | 310 |
|
---|
[575] | 311 | if (_rinexVers == 3) {
|
---|
| 312 | ephFileNameGPS += hlpStr + datTim.toString(".yyP");
|
---|
| 313 | }
|
---|
| 314 | else {
|
---|
| 315 | ephFileNameGPS += hlpStr + datTim.toString(".yyN");
|
---|
| 316 | }
|
---|
[563] | 317 |
|
---|
[533] | 318 | if (_ephFileNameGPS == ephFileNameGPS) {
|
---|
| 319 | return;
|
---|
| 320 | }
|
---|
| 321 | else {
|
---|
| 322 | _ephFileNameGPS = ephFileNameGPS;
|
---|
| 323 | }
|
---|
| 324 |
|
---|
| 325 | delete _ephStreamGPS;
|
---|
| 326 | delete _ephFileGPS;
|
---|
| 327 |
|
---|
[535] | 328 | QFlags<QIODevice::OpenModeFlag> appendFlagGPS;
|
---|
[536] | 329 | QFlags<QIODevice::OpenModeFlag> appendFlagGlonass;
|
---|
| 330 |
|
---|
[535] | 331 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
|
---|
| 332 | QFile::exists(ephFileNameGPS) ) {
|
---|
| 333 | appendFlagGPS = QIODevice::Append;
|
---|
| 334 | }
|
---|
| 335 |
|
---|
[533] | 336 | _ephFileGPS = new QFile(ephFileNameGPS);
|
---|
[535] | 337 | _ephFileGPS->open(QIODevice::WriteOnly | appendFlagGPS);
|
---|
[533] | 338 | _ephStreamGPS = new QTextStream();
|
---|
| 339 | _ephStreamGPS->setDevice(_ephFileGPS);
|
---|
| 340 |
|
---|
[534] | 341 | if (_rinexVers == 3) {
|
---|
[533] | 342 | _ephFileGlonass = _ephFileGPS;
|
---|
| 343 | _ephStreamGlonass = _ephStreamGPS;
|
---|
[2770] | 344 | _ephFileGalileo = _ephFileGPS;
|
---|
| 345 | _ephStreamGalileo = _ephStreamGPS;
|
---|
[6384] | 346 | _ephFileSBAS = _ephFileGPS;
|
---|
| 347 | _ephStreamSBAS = _ephStreamGPS;
|
---|
[533] | 348 | }
|
---|
[534] | 349 | else if (_rinexVers == 2) {
|
---|
[583] | 350 | QString ephFileNameGlonass = _ephPath + "BRDC" +
|
---|
[563] | 351 | QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +
|
---|
[575] | 352 | hlpStr + datTim.toString(".yyG");
|
---|
[533] | 353 |
|
---|
| 354 | delete _ephStreamGlonass;
|
---|
| 355 | delete _ephFileGlonass;
|
---|
| 356 |
|
---|
[535] | 357 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
|
---|
| 358 | QFile::exists(ephFileNameGlonass) ) {
|
---|
| 359 | appendFlagGlonass = QIODevice::Append;
|
---|
| 360 | }
|
---|
| 361 |
|
---|
[533] | 362 | _ephFileGlonass = new QFile(ephFileNameGlonass);
|
---|
[535] | 363 | _ephFileGlonass->open(QIODevice::WriteOnly | appendFlagGlonass);
|
---|
[533] | 364 | _ephStreamGlonass = new QTextStream();
|
---|
| 365 | _ephStreamGlonass->setDevice(_ephFileGlonass);
|
---|
| 366 | }
|
---|
| 367 |
|
---|
[534] | 368 | // Header - RINEX Version 3
|
---|
| 369 | // ------------------------
|
---|
| 370 | if (_rinexVers == 3) {
|
---|
[537] | 371 | if ( ! (appendFlagGPS & QIODevice::Append)) {
|
---|
| 372 | QString line;
|
---|
| 373 | line.sprintf(
|
---|
| 374 | "%9.2f%11sN: GNSS NAV DATA M: Mixed%12sRINEX VERSION / TYPE\n",
|
---|
| 375 | 3.0, "", "");
|
---|
| 376 | *_ephStreamGPS << line;
|
---|
| 377 |
|
---|
[1154] | 378 | QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
|
---|
[559] | 379 | *_ephStreamGPS << _pgmName.toAscii().data()
|
---|
| 380 | << _userName.toAscii().data()
|
---|
| 381 | << hlp.toAscii().data()
|
---|
| 382 | << "PGM / RUN BY / DATE" << endl;
|
---|
| 383 |
|
---|
| 384 | line.sprintf("%60sEND OF HEADER\n", "");
|
---|
[537] | 385 | *_ephStreamGPS << line;
|
---|
| 386 |
|
---|
| 387 | _ephStreamGPS->flush();
|
---|
[535] | 388 | }
|
---|
[533] | 389 | }
|
---|
| 390 |
|
---|
[536] | 391 | // Headers - RINEX Version 2
|
---|
| 392 | // -------------------------
|
---|
[534] | 393 | else if (_rinexVers == 2) {
|
---|
[536] | 394 | if (! (appendFlagGPS & QIODevice::Append)) {
|
---|
| 395 | QString line;
|
---|
[5375] | 396 | line.sprintf("%9.2f%11sN: GPS NAV DATA%25sRINEX VERSION / TYPE\n",
|
---|
| 397 | t_rnxNavFile::defaultRnxNavVersion2, "", "");
|
---|
[536] | 398 | *_ephStreamGPS << line;
|
---|
| 399 |
|
---|
[1154] | 400 | QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
|
---|
[559] | 401 | *_ephStreamGPS << _pgmName.toAscii().data()
|
---|
| 402 | << _userName.toAscii().data()
|
---|
| 403 | << hlp.toAscii().data()
|
---|
| 404 | << "PGM / RUN BY / DATE" << endl;
|
---|
| 405 |
|
---|
| 406 | line.sprintf("%60sEND OF HEADER\n", "");
|
---|
[536] | 407 | *_ephStreamGPS << line;
|
---|
[537] | 408 |
|
---|
| 409 | _ephStreamGPS->flush();
|
---|
[536] | 410 | }
|
---|
| 411 | if (! (appendFlagGlonass & QIODevice::Append)) {
|
---|
| 412 | QString line;
|
---|
[5375] | 413 | line.sprintf("%9.2f%11sG: GLONASS NAV DATA%21sRINEX VERSION / TYPE\n",
|
---|
| 414 | t_rnxNavFile::defaultRnxNavVersion2, "", "");
|
---|
[536] | 415 | *_ephStreamGlonass << line;
|
---|
| 416 |
|
---|
[1154] | 417 | QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
|
---|
[559] | 418 | *_ephStreamGlonass << _pgmName.toAscii().data()
|
---|
| 419 | << _userName.toAscii().data()
|
---|
| 420 | << hlp.toAscii().data()
|
---|
| 421 | << "PGM / RUN BY / DATE" << endl;
|
---|
| 422 |
|
---|
| 423 | line.sprintf("%60sEND OF HEADER\n", "");
|
---|
[536] | 424 | *_ephStreamGlonass << line;
|
---|
[537] | 425 |
|
---|
| 426 | _ephStreamGlonass->flush();
|
---|
[536] | 427 | }
|
---|
[533] | 428 | }
|
---|
| 429 | }
|
---|
[516] | 430 | }
|
---|
| 431 |
|
---|
[6432] | 432 | // Print One Ephemeris
|
---|
[516] | 433 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6432] | 434 | void t_bncCore::printEph(const t_eph& eph, bool printFile) {
|
---|
[519] | 435 |
|
---|
[5375] | 436 | QString strV2 = eph.toString(t_rnxNavFile::defaultRnxNavVersion2);
|
---|
| 437 | QString strV3 = eph.toString(t_rnxObsHeader::defaultRnxObsVersion3);
|
---|
[941] | 438 |
|
---|
[4225] | 439 | printOutput(printFile, _ephStreamGlonass, strV2, strV3);
|
---|
[941] | 440 | }
|
---|
| 441 |
|
---|
| 442 | // Output
|
---|
| 443 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 444 | void t_bncCore::printOutput(bool printFile, QTextStream* stream,
|
---|
[4020] | 445 | const QString& strV2, const QString& strV3) {
|
---|
| 446 |
|
---|
[590] | 447 | // Output into file
|
---|
| 448 | // ----------------
|
---|
[943] | 449 | if (printFile && stream) {
|
---|
[941] | 450 | if (_rinexVers == 2) {
|
---|
[4020] | 451 | *stream << strV2.toAscii();
|
---|
[941] | 452 | }
|
---|
| 453 | else {
|
---|
[4020] | 454 | *stream << strV3.toAscii();
|
---|
[941] | 455 | }
|
---|
[943] | 456 | stream->flush();
|
---|
[517] | 457 | }
|
---|
[590] | 458 |
|
---|
| 459 | // Output into the socket
|
---|
| 460 | // ----------------------
|
---|
| 461 | if (_sockets) {
|
---|
[642] | 462 | QMutableListIterator<QTcpSocket*> is(*_sockets);
|
---|
[590] | 463 | while (is.hasNext()) {
|
---|
| 464 | QTcpSocket* sock = is.next();
|
---|
| 465 | if (sock->state() == QAbstractSocket::ConnectedState) {
|
---|
[4020] | 466 | if (sock->write(strV3.toAscii()) == -1) {
|
---|
[642] | 467 | delete sock;
|
---|
| 468 | is.remove();
|
---|
| 469 | }
|
---|
[590] | 470 | }
|
---|
[642] | 471 | else if (sock->state() != QAbstractSocket::ConnectingState) {
|
---|
| 472 | delete sock;
|
---|
| 473 | is.remove();
|
---|
| 474 | }
|
---|
[590] | 475 | }
|
---|
| 476 | }
|
---|
[516] | 477 | }
|
---|
[589] | 478 |
|
---|
[591] | 479 | // Set Port Number
|
---|
| 480 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 481 | void t_bncCore::setPort(int port) {
|
---|
[591] | 482 | _port = port;
|
---|
| 483 | if (_port != 0) {
|
---|
[942] | 484 | delete _server;
|
---|
[591] | 485 | _server = new QTcpServer;
|
---|
[1228] | 486 | if ( !_server->listen(QHostAddress::Any, _port) ) {
|
---|
[5072] | 487 | slotMessage("t_bncCore: Cannot listen on ephemeris port", true);
|
---|
[1228] | 488 | }
|
---|
[591] | 489 | connect(_server, SIGNAL(newConnection()), this, SLOT(slotNewConnection()));
|
---|
[942] | 490 | delete _sockets;
|
---|
[591] | 491 | _sockets = new QList<QTcpSocket*>;
|
---|
| 492 | }
|
---|
| 493 | }
|
---|
| 494 |
|
---|
[937] | 495 | // Set Port Number
|
---|
| 496 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 497 | void t_bncCore::setPortCorr(int port) {
|
---|
[937] | 498 | _portCorr = port;
|
---|
| 499 | if (_portCorr != 0) {
|
---|
[942] | 500 | delete _serverCorr;
|
---|
[937] | 501 | _serverCorr = new QTcpServer;
|
---|
[1228] | 502 | if ( !_serverCorr->listen(QHostAddress::Any, _portCorr) ) {
|
---|
[5072] | 503 | slotMessage("t_bncCore: Cannot listen on correction port", true);
|
---|
[1228] | 504 | }
|
---|
[937] | 505 | connect(_serverCorr, SIGNAL(newConnection()), this, SLOT(slotNewConnectionCorr()));
|
---|
[942] | 506 | delete _socketsCorr;
|
---|
[937] | 507 | _socketsCorr = new QList<QTcpSocket*>;
|
---|
| 508 | }
|
---|
| 509 | }
|
---|
| 510 |
|
---|
[589] | 511 | // New Connection
|
---|
| 512 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 513 | void t_bncCore::slotNewConnection() {
|
---|
[589] | 514 | _sockets->push_back( _server->nextPendingConnection() );
|
---|
| 515 | }
|
---|
| 516 |
|
---|
[937] | 517 | // New Connection
|
---|
| 518 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 519 | void t_bncCore::slotNewConnectionCorr() {
|
---|
[937] | 520 | _socketsCorr->push_back( _serverCorr->nextPendingConnection() );
|
---|
| 521 | }
|
---|
| 522 |
|
---|
[621] | 523 | //
|
---|
| 524 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 525 | void t_bncCore::slotQuit() {
|
---|
[5729] | 526 | delete _caster; _caster = 0;
|
---|
[5066] | 527 | qApp->quit();
|
---|
[621] | 528 | }
|
---|
| 529 |
|
---|
[936] | 530 | //
|
---|
| 531 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6141] | 532 | void t_bncCore::slotNewOrbCorrections(QList<t_orbCorr> orbCorrections) {
|
---|
[6151] | 533 | QMutexLocker locker(&_mutex);
|
---|
[6141] | 534 | emit newOrbCorrections(orbCorrections);
|
---|
[6151] | 535 | if (_socketsCorr) {
|
---|
| 536 | QListIterator<t_orbCorr> it(orbCorrections);
|
---|
| 537 | while (it.hasNext()) {
|
---|
| 538 | const t_orbCorr& corr = it.next();
|
---|
| 539 | QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
|
---|
| 540 | while (is.hasNext()) {
|
---|
| 541 | QTcpSocket* sock = is.next();
|
---|
| 542 | if (sock->state() == QAbstractSocket::ConnectedState) {
|
---|
[6175] | 543 | if (sock->write(corr.toLine().c_str()) == -1) {
|
---|
[6151] | 544 | delete sock;
|
---|
| 545 | is.remove();
|
---|
| 546 | }
|
---|
| 547 | }
|
---|
| 548 | else if (sock->state() != QAbstractSocket::ConnectingState) {
|
---|
| 549 | delete sock;
|
---|
| 550 | is.remove();
|
---|
| 551 | }
|
---|
| 552 | }
|
---|
| 553 | }
|
---|
| 554 | }
|
---|
[6141] | 555 | }
|
---|
[974] | 556 |
|
---|
[6141] | 557 | //
|
---|
| 558 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 559 | void t_bncCore::slotNewClkCorrections(QList<t_clkCorr> clkCorrections) {
|
---|
[974] | 560 | QMutexLocker locker(&_mutex);
|
---|
[6151] | 561 | emit newClkCorrections(clkCorrections);
|
---|
[3109] | 562 | if (_socketsCorr) {
|
---|
[6151] | 563 | QListIterator<t_clkCorr> it(clkCorrections);
|
---|
[3109] | 564 | while (it.hasNext()) {
|
---|
[6141] | 565 | const t_clkCorr& corr = it.next();
|
---|
[3109] | 566 | QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
|
---|
| 567 | while (is.hasNext()) {
|
---|
| 568 | QTcpSocket* sock = is.next();
|
---|
| 569 | if (sock->state() == QAbstractSocket::ConnectedState) {
|
---|
[6175] | 570 | if (sock->write(corr.toLine().c_str()) == -1) {
|
---|
[976] | 571 | delete sock;
|
---|
| 572 | is.remove();
|
---|
| 573 | }
|
---|
| 574 | }
|
---|
[3109] | 575 | else if (sock->state() != QAbstractSocket::ConnectingState) {
|
---|
| 576 | delete sock;
|
---|
| 577 | is.remove();
|
---|
| 578 | }
|
---|
[937] | 579 | }
|
---|
| 580 | }
|
---|
| 581 | }
|
---|
[936] | 582 | }
|
---|
[1538] | 583 |
|
---|
| 584 | //
|
---|
| 585 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 586 | void t_bncCore::setConfFileName(const QString& confFileName) {
|
---|
[4169] | 587 | if (confFileName.isEmpty()) {
|
---|
| 588 | _confFileName = QDir::homePath() + QDir::separator()
|
---|
| 589 | + ".config" + QDir::separator()
|
---|
[5066] | 590 | + qApp->organizationName() + QDir::separator()
|
---|
| 591 | + qApp->applicationName() + ".bnc";
|
---|
[1538] | 592 | }
|
---|
[4169] | 593 | else {
|
---|
| 594 | _confFileName = confFileName;
|
---|
| 595 | }
|
---|
[1538] | 596 | }
|
---|
[2385] | 597 |
|
---|
| 598 | // Raw Output
|
---|
| 599 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 600 | void t_bncCore::writeRawData(const QByteArray& data, const QByteArray& staID,
|
---|
[2518] | 601 | const QByteArray& format) {
|
---|
[2385] | 602 |
|
---|
[2386] | 603 | QMutexLocker locker(&_mutex);
|
---|
| 604 |
|
---|
[2519] | 605 | if (!_rawFile) {
|
---|
[2386] | 606 | bncSettings settings;
|
---|
[2519] | 607 | QByteArray fileName = settings.value("rawOutFile").toByteArray();
|
---|
| 608 | if (!fileName.isEmpty()) {
|
---|
[3524] | 609 | _rawFile = new bncRawFile(fileName, staID, bncRawFile::output);
|
---|
[2407] | 610 | }
|
---|
[2386] | 611 | }
|
---|
| 612 |
|
---|
[2519] | 613 | if (_rawFile) {
|
---|
| 614 | _rawFile->writeRawData(data, staID, format);
|
---|
[2386] | 615 | }
|
---|
[2385] | 616 | }
|
---|
[2672] | 617 |
|
---|
[2909] | 618 | //
|
---|
| 619 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 620 | void t_bncCore::initCombination() {
|
---|
[2909] | 621 | #ifdef USE_COMBINATION
|
---|
| 622 | _bncComb = new bncComb();
|
---|
[3142] | 623 | if (_bncComb->nStreams() < 1) {
|
---|
[2909] | 624 | delete _bncComb;
|
---|
| 625 | _bncComb = 0;
|
---|
| 626 | }
|
---|
| 627 | #endif
|
---|
| 628 | }
|
---|
[3231] | 629 |
|
---|
| 630 | //
|
---|
| 631 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5072] | 632 | void t_bncCore::stopCombination() {
|
---|
[3231] | 633 | #ifdef USE_COMBINATION
|
---|
| 634 | delete _bncComb;
|
---|
| 635 | _bncComb = 0;
|
---|
| 636 | #endif
|
---|
| 637 | }
|
---|
[4167] | 638 |
|
---|
[5846] | 639 | //
|
---|
| 640 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 641 | bool t_bncCore::dateAndTimeGPSSet() const {
|
---|
| 642 | QMutexLocker locker(&_mutexDateAndTimeGPS);
|
---|
| 643 | if (_dateAndTimeGPS) {
|
---|
| 644 | return true;
|
---|
| 645 | }
|
---|
| 646 | else {
|
---|
| 647 | return false;
|
---|
| 648 | }
|
---|
| 649 | }
|
---|
| 650 |
|
---|
| 651 | //
|
---|
| 652 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 653 | QDateTime t_bncCore::dateAndTimeGPS() const {
|
---|
| 654 | QMutexLocker locker(&_mutexDateAndTimeGPS);
|
---|
| 655 | if (_dateAndTimeGPS) {
|
---|
| 656 | return *_dateAndTimeGPS;
|
---|
| 657 | }
|
---|
| 658 | else {
|
---|
| 659 | return QDateTime();
|
---|
| 660 | }
|
---|
| 661 | }
|
---|
| 662 |
|
---|
| 663 | //
|
---|
| 664 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 665 | void t_bncCore::setDateAndTimeGPS(QDateTime dateTime) {
|
---|
| 666 | QMutexLocker locker(&_mutexDateAndTimeGPS);
|
---|
| 667 | delete _dateAndTimeGPS;
|
---|
| 668 | _dateAndTimeGPS = new QDateTime(dateTime);
|
---|
| 669 | }
|
---|
[5900] | 670 |
|
---|
| 671 | //
|
---|
| 672 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5946] | 673 | void t_bncCore::startPPP() {
|
---|
| 674 | _pppMain->start();
|
---|
[5900] | 675 | }
|
---|
| 676 |
|
---|
| 677 | //
|
---|
| 678 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 679 | void t_bncCore::stopPPP() {
|
---|
[5903] | 680 | _pppMain->stop();
|
---|
[5972] | 681 | emit stopRinexPPP();
|
---|
[5900] | 682 | }
|
---|
[6383] | 683 |
|
---|