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

Last change on this file since 7179 was 7179, checked in by stuerze, 9 years ago

RINEX v3 filenames can now be formed optionally during RINEX file generation from RTCM observation and navigation streams

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