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

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