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