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

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

minor fixes to allow seperate GPS-only and GLONASS-only data sets in RINEX version 2 navigation files

File size: 21.5 KB
RevLine 
[280]1// Part of BNC, a utility for retrieving decoding and
[464]2// converting GNSS data streams from NTRIP broadcasters.
[280]3//
[464]4// Copyright (C) 2007
[280]5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
[464]7// Czech Technical University Prague, Department of Geodesy
[280]8// http://www.fsv.cvut.cz
9//
10// Email: euref-ip@bkg.bund.de
11//
12// This program is free software; you can redistribute it and/or
13// modify it under the terms of the GNU General Public License
14// as published by the Free Software Foundation, version 2.
15//
16// This program is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program; if not, write to the Free Software
23// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
[82]24
25/* -------------------------------------------------------------------------
[93]26 * BKG NTRIP Client
[82]27 * -------------------------------------------------------------------------
28 *
[5072]29 * Class: t_bncCore
[82]30 *
31 * Purpose: This class implements the main application
32 *
33 * Author: L. Mervart
34 *
35 * Created: 29-Aug-2006
36 *
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
[7026]427 if (_rinexVers == 2 && eph.type() == t_eph::GLONASS) {
428 printOutputEph(printFile, _ephStreamGlonass, strV2, strV3);
429 }
430 else if(_rinexVers == 2 && eph.type() == t_eph::GPS) {
431 printOutputEph(printFile, _ephStreamGPS, strV2, strV3);
432 }
433 else if (_rinexVers == 3) {
434 printOutputEph(printFile, _ephStreamGPS, strV2, strV3);
435 }
[941]436}
437
438// Output
439////////////////////////////////////////////////////////////////////////////
[6451]440void t_bncCore::printOutputEph(bool printFile, QTextStream* stream,
441 const QString& strV2, const QString& strV3) {
[4020]442
[590]443 // Output into file
444 // ----------------
[943]445 if (printFile && stream) {
[941]446 if (_rinexVers == 2) {
[4020]447 *stream << strV2.toAscii();
[941]448 }
449 else {
[4020]450 *stream << strV3.toAscii();
[941]451 }
[943]452 stream->flush();
[517]453 }
[590]454
455 // Output into the socket
456 // ----------------------
[6451]457 if (_socketsEph) {
458 QMutableListIterator<QTcpSocket*> is(*_socketsEph);
[590]459 while (is.hasNext()) {
460 QTcpSocket* sock = is.next();
461 if (sock->state() == QAbstractSocket::ConnectedState) {
[4020]462 if (sock->write(strV3.toAscii()) == -1) {
[642]463 delete sock;
464 is.remove();
465 }
[590]466 }
[642]467 else if (sock->state() != QAbstractSocket::ConnectingState) {
468 delete sock;
469 is.remove();
470 }
[590]471 }
472 }
[516]473}
[589]474
[591]475// Set Port Number
476////////////////////////////////////////////////////////////////////////////
[6451]477void t_bncCore::setPortEph(int port) {
478 _portEph = port;
479 if (_portEph != 0) {
480 delete _serverEph;
481 _serverEph = new QTcpServer;
482 if ( !_serverEph->listen(QHostAddress::Any, _portEph) ) {
[5072]483 slotMessage("t_bncCore: Cannot listen on ephemeris port", true);
[1228]484 }
[6451]485 connect(_serverEph, SIGNAL(newConnection()), this, SLOT(slotNewConnectionEph()));
486 delete _socketsEph;
487 _socketsEph = new QList<QTcpSocket*>;
[591]488 }
489}
490
[937]491// Set Port Number
492////////////////////////////////////////////////////////////////////////////
[5072]493void t_bncCore::setPortCorr(int port) {
[937]494 _portCorr = port;
495 if (_portCorr != 0) {
[942]496 delete _serverCorr;
[937]497 _serverCorr = new QTcpServer;
[1228]498 if ( !_serverCorr->listen(QHostAddress::Any, _portCorr) ) {
[5072]499 slotMessage("t_bncCore: Cannot listen on correction port", true);
[1228]500 }
[937]501 connect(_serverCorr, SIGNAL(newConnection()), this, SLOT(slotNewConnectionCorr()));
[942]502 delete _socketsCorr;
[937]503 _socketsCorr = new QList<QTcpSocket*>;
504 }
505}
506
[589]507// New Connection
508////////////////////////////////////////////////////////////////////////////
[6451]509void t_bncCore::slotNewConnectionEph() {
510 _socketsEph->push_back( _serverEph->nextPendingConnection() );
[589]511}
512
[937]513// New Connection
514////////////////////////////////////////////////////////////////////////////
[5072]515void t_bncCore::slotNewConnectionCorr() {
[937]516 _socketsCorr->push_back( _serverCorr->nextPendingConnection() );
517}
518
[621]519//
520////////////////////////////////////////////////////////////////////////////
[5072]521void t_bncCore::slotQuit() {
[5729]522 delete _caster; _caster = 0;
[5066]523 qApp->quit();
[621]524}
525
[936]526//
527////////////////////////////////////////////////////////////////////////////
[6141]528void t_bncCore::slotNewOrbCorrections(QList<t_orbCorr> orbCorrections) {
[6151]529 QMutexLocker locker(&_mutex);
[6141]530 emit newOrbCorrections(orbCorrections);
[6151]531 if (_socketsCorr) {
[6455]532 ostringstream out;
533 t_orbCorr::writeEpoch(&out, orbCorrections);
534 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
535 while (is.hasNext()) {
536 QTcpSocket* sock = is.next();
537 if (sock->state() == QAbstractSocket::ConnectedState) {
538 if (sock->write(out.str().c_str()) == -1) {
[6151]539 delete sock;
540 is.remove();
541 }
542 }
[6455]543 else if (sock->state() != QAbstractSocket::ConnectingState) {
544 delete sock;
545 is.remove();
546 }
[6151]547 }
548 }
[6141]549}
[974]550
[6141]551//
552////////////////////////////////////////////////////////////////////////////
553void t_bncCore::slotNewClkCorrections(QList<t_clkCorr> clkCorrections) {
[974]554 QMutexLocker locker(&_mutex);
[6151]555 emit newClkCorrections(clkCorrections);
[3109]556 if (_socketsCorr) {
[6455]557 ostringstream out;
558 t_clkCorr::writeEpoch(&out, clkCorrections);
559 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
560 while (is.hasNext()) {
561 QTcpSocket* sock = is.next();
562 if (sock->state() == QAbstractSocket::ConnectedState) {
563 if (sock->write(out.str().c_str()) == -1) {
[3109]564 delete sock;
565 is.remove();
566 }
[937]567 }
[6455]568 else if (sock->state() != QAbstractSocket::ConnectingState) {
569 delete sock;
570 is.remove();
571 }
[937]572 }
573 }
[936]574}
[1538]575
576//
577////////////////////////////////////////////////////////////////////////////
[6480]578void t_bncCore::slotNewCodeBiases(QList<t_satCodeBias> codeBiases) {
[6485]579 QMutexLocker locker(&_mutex);
580 emit newCodeBiases(codeBiases);
581 if (_socketsCorr) {
582 ostringstream out;
583 t_satCodeBias::writeEpoch(&out, codeBiases);
584 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
585 while (is.hasNext()) {
586 QTcpSocket* sock = is.next();
587 if (sock->state() == QAbstractSocket::ConnectedState) {
588 if (sock->write(out.str().c_str()) == -1) {
589 delete sock;
590 is.remove();
591 }
592 }
593 else if (sock->state() != QAbstractSocket::ConnectingState) {
594 delete sock;
595 is.remove();
596 }
597 }
598 }
[6480]599}
600
601//
602////////////////////////////////////////////////////////////////////////////
[6484]603void t_bncCore::slotNewPhaseBiases(QList<t_satPhaseBias> phaseBiases) {
[6485]604 QMutexLocker locker(&_mutex);
605 emit newPhaseBiases(phaseBiases);
606 if (_socketsCorr) {
607 ostringstream out;
608 t_satPhaseBias::writeEpoch(&out, phaseBiases);
609 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
610 while (is.hasNext()) {
611 QTcpSocket* sock = is.next();
612 if (sock->state() == QAbstractSocket::ConnectedState) {
613 if (sock->write(out.str().c_str()) == -1) {
614 delete sock;
615 is.remove();
616 }
617 }
618 else if (sock->state() != QAbstractSocket::ConnectingState) {
619 delete sock;
620 is.remove();
621 }
622 }
623 }
[6484]624}
625
626//
627////////////////////////////////////////////////////////////////////////////
628void t_bncCore::slotNewTec(t_vTec vTec) {
[6485]629 QMutexLocker locker(&_mutex);
630 emit newTec(vTec);
631 if (_socketsCorr) {
632 ostringstream out;
633 t_vTec::write(&out, vTec);
634 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
635 while (is.hasNext()) {
636 QTcpSocket* sock = is.next();
637 if (sock->state() == QAbstractSocket::ConnectedState) {
638 if (sock->write(out.str().c_str()) == -1) {
639 delete sock;
640 is.remove();
641 }
642 }
643 else if (sock->state() != QAbstractSocket::ConnectingState) {
644 delete sock;
645 is.remove();
646 }
647 }
648 }
[6484]649}
650
651//
652////////////////////////////////////////////////////////////////////////////
[5072]653void t_bncCore::setConfFileName(const QString& confFileName) {
[4169]654 if (confFileName.isEmpty()) {
655 _confFileName = QDir::homePath() + QDir::separator()
656 + ".config" + QDir::separator()
[5066]657 + qApp->organizationName() + QDir::separator()
658 + qApp->applicationName() + ".bnc";
[1538]659 }
[4169]660 else {
661 _confFileName = confFileName;
662 }
[1538]663}
[2385]664
665// Raw Output
666////////////////////////////////////////////////////////////////////////////
[5072]667void t_bncCore::writeRawData(const QByteArray& data, const QByteArray& staID,
[2518]668 const QByteArray& format) {
[2385]669
[2386]670 QMutexLocker locker(&_mutex);
671
[2519]672 if (!_rawFile) {
[2386]673 bncSettings settings;
[2519]674 QByteArray fileName = settings.value("rawOutFile").toByteArray();
675 if (!fileName.isEmpty()) {
[3524]676 _rawFile = new bncRawFile(fileName, staID, bncRawFile::output);
[2407]677 }
[2386]678 }
679
[2519]680 if (_rawFile) {
681 _rawFile->writeRawData(data, staID, format);
[2386]682 }
[2385]683}
[2672]684
[2909]685//
686////////////////////////////////////////////////////////////////////////////
[5072]687void t_bncCore::initCombination() {
[2909]688#ifdef USE_COMBINATION
689 _bncComb = new bncComb();
[3142]690 if (_bncComb->nStreams() < 1) {
[2909]691 delete _bncComb;
692 _bncComb = 0;
693 }
694#endif
695}
[3231]696
697//
698////////////////////////////////////////////////////////////////////////////
[5072]699void t_bncCore::stopCombination() {
[3231]700#ifdef USE_COMBINATION
701 delete _bncComb;
702 _bncComb = 0;
703#endif
704}
[4167]705
[5846]706//
707////////////////////////////////////////////////////////////////////////////
708bool t_bncCore::dateAndTimeGPSSet() const {
709 QMutexLocker locker(&_mutexDateAndTimeGPS);
710 if (_dateAndTimeGPS) {
711 return true;
712 }
713 else {
714 return false;
715 }
716}
717
718//
719////////////////////////////////////////////////////////////////////////////
720QDateTime t_bncCore::dateAndTimeGPS() const {
721 QMutexLocker locker(&_mutexDateAndTimeGPS);
722 if (_dateAndTimeGPS) {
723 return *_dateAndTimeGPS;
724 }
725 else {
726 return QDateTime();
727 }
728}
729
730//
731////////////////////////////////////////////////////////////////////////////
732void t_bncCore::setDateAndTimeGPS(QDateTime dateTime) {
733 QMutexLocker locker(&_mutexDateAndTimeGPS);
734 delete _dateAndTimeGPS;
735 _dateAndTimeGPS = new QDateTime(dateTime);
736}
[5900]737
738//
739////////////////////////////////////////////////////////////////////////////
[5946]740void t_bncCore::startPPP() {
741 _pppMain->start();
[5900]742}
743
744//
745////////////////////////////////////////////////////////////////////////////
746void t_bncCore::stopPPP() {
[5903]747 _pppMain->stop();
[5972]748 emit stopRinexPPP();
[5900]749}
[6383]750
Note: See TracBrowser for help on using the repository browser.