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

Last change on this file since 6663 was 6598, checked in by stoecker, 10 years ago

rename Compass to BDS

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