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

Last change on this file since 10027 was 10027, checked in by stuerze, 15 months ago

minor changes

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