source: ntrip/trunk/BNC/src/bnccore.cpp@ 10573

Last change on this file since 10573 was 10549, checked in by stuerze, 6 weeks ago

replacement of obsolete qt-class members: at least Qt version 5.15.0 is required, warnung is added

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