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

Last change on this file since 9822 was 9822, checked in by stuerze, 20 months ago

minor changes

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