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

Last change on this file since 9772 was 9772, checked in by stuerze, 23 months ago

eph checkstate is marked as debug output

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