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

Last change on this file since 9587 was 9587, checked in by stuerze, 2 years ago

minor changes

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