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

Last change on this file since 6568 was 6522, checked in by mervart, 10 years ago
File size: 21.0 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");
121 qRegisterMetaType<t_ephCompass> ("t_ephCompass");
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
[6432]252
[535]253// Print Header of the output File(s)
[516]254////////////////////////////////////////////////////////////////////////////
[5072]255void t_bncCore::printEphHeader() {
[528]256
[1535]257 bncSettings settings;
[535]258
[534]259 // Initialization
260 // --------------
261 if (_rinexVers == 0) {
[528]262
[533]263 if ( Qt::CheckState(settings.value("ephV3").toInt()) == Qt::Checked) {
[534]264 _rinexVers = 3;
[533]265 }
266 else {
[534]267 _rinexVers = 2;
[533]268 }
[529]269
[533]270 _ephPath = settings.value("ephPath").toString();
271
272 if ( !_ephPath.isEmpty() ) {
273 if ( _ephPath[_ephPath.length()-1] != QDir::separator() ) {
274 _ephPath += QDir::separator();
275 }
276 expandEnvVar(_ephPath);
277 }
[517]278 }
[533]279
[534]280 // (Re-)Open output File(s)
281 // ------------------------
[533]282 if (!_ephPath.isEmpty()) {
283
[1154]284 QDateTime datTim = currentDateAndTimeGPS();
[533]285
[583]286 QString ephFileNameGPS = _ephPath + "BRDC" +
[563]287 QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0'));
[533]288
[647]289 QString hlpStr = bncRinex::nextEpochStr(datTim,
290 settings.value("ephIntr").toString());
[584]291
[575]292 if (_rinexVers == 3) {
293 ephFileNameGPS += hlpStr + datTim.toString(".yyP");
294 }
295 else {
296 ephFileNameGPS += hlpStr + datTim.toString(".yyN");
297 }
[563]298
[533]299 if (_ephFileNameGPS == ephFileNameGPS) {
300 return;
301 }
302 else {
303 _ephFileNameGPS = ephFileNameGPS;
304 }
305
306 delete _ephStreamGPS;
307 delete _ephFileGPS;
308
[535]309 QFlags<QIODevice::OpenModeFlag> appendFlagGPS;
[536]310 QFlags<QIODevice::OpenModeFlag> appendFlagGlonass;
311
[535]312 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
313 QFile::exists(ephFileNameGPS) ) {
314 appendFlagGPS = QIODevice::Append;
315 }
316
[533]317 _ephFileGPS = new QFile(ephFileNameGPS);
[535]318 _ephFileGPS->open(QIODevice::WriteOnly | appendFlagGPS);
[533]319 _ephStreamGPS = new QTextStream();
320 _ephStreamGPS->setDevice(_ephFileGPS);
321
[534]322 if (_rinexVers == 3) {
[533]323 _ephFileGlonass = _ephFileGPS;
324 _ephStreamGlonass = _ephStreamGPS;
[2770]325 _ephFileGalileo = _ephFileGPS;
326 _ephStreamGalileo = _ephStreamGPS;
[6384]327 _ephFileSBAS = _ephFileGPS;
328 _ephStreamSBAS = _ephStreamGPS;
[533]329 }
[534]330 else if (_rinexVers == 2) {
[583]331 QString ephFileNameGlonass = _ephPath + "BRDC" +
[563]332 QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +
[575]333 hlpStr + datTim.toString(".yyG");
[533]334
335 delete _ephStreamGlonass;
336 delete _ephFileGlonass;
337
[535]338 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
339 QFile::exists(ephFileNameGlonass) ) {
340 appendFlagGlonass = QIODevice::Append;
341 }
342
[533]343 _ephFileGlonass = new QFile(ephFileNameGlonass);
[535]344 _ephFileGlonass->open(QIODevice::WriteOnly | appendFlagGlonass);
[533]345 _ephStreamGlonass = new QTextStream();
346 _ephStreamGlonass->setDevice(_ephFileGlonass);
347 }
348
[534]349 // Header - RINEX Version 3
350 // ------------------------
351 if (_rinexVers == 3) {
[537]352 if ( ! (appendFlagGPS & QIODevice::Append)) {
353 QString line;
354 line.sprintf(
355 "%9.2f%11sN: GNSS NAV DATA M: Mixed%12sRINEX VERSION / TYPE\n",
356 3.0, "", "");
357 *_ephStreamGPS << line;
358
[1154]359 QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
[559]360 *_ephStreamGPS << _pgmName.toAscii().data()
361 << _userName.toAscii().data()
362 << hlp.toAscii().data()
363 << "PGM / RUN BY / DATE" << endl;
364
365 line.sprintf("%60sEND OF HEADER\n", "");
[537]366 *_ephStreamGPS << line;
367
368 _ephStreamGPS->flush();
[535]369 }
[533]370 }
371
[536]372 // Headers - RINEX Version 2
373 // -------------------------
[534]374 else if (_rinexVers == 2) {
[536]375 if (! (appendFlagGPS & QIODevice::Append)) {
376 QString line;
[5375]377 line.sprintf("%9.2f%11sN: GPS NAV DATA%25sRINEX VERSION / TYPE\n",
378 t_rnxNavFile::defaultRnxNavVersion2, "", "");
[536]379 *_ephStreamGPS << line;
380
[1154]381 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
[559]382 *_ephStreamGPS << _pgmName.toAscii().data()
383 << _userName.toAscii().data()
384 << hlp.toAscii().data()
385 << "PGM / RUN BY / DATE" << endl;
386
387 line.sprintf("%60sEND OF HEADER\n", "");
[536]388 *_ephStreamGPS << line;
[537]389
390 _ephStreamGPS->flush();
[536]391 }
392 if (! (appendFlagGlonass & QIODevice::Append)) {
393 QString line;
[5375]394 line.sprintf("%9.2f%11sG: GLONASS NAV DATA%21sRINEX VERSION / TYPE\n",
395 t_rnxNavFile::defaultRnxNavVersion2, "", "");
[536]396 *_ephStreamGlonass << line;
397
[1154]398 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
[559]399 *_ephStreamGlonass << _pgmName.toAscii().data()
400 << _userName.toAscii().data()
401 << hlp.toAscii().data()
402 << "PGM / RUN BY / DATE" << endl;
403
404 line.sprintf("%60sEND OF HEADER\n", "");
[536]405 *_ephStreamGlonass << line;
[537]406
407 _ephStreamGlonass->flush();
[536]408 }
[533]409 }
410 }
[516]411}
412
[6432]413// Print One Ephemeris
[516]414////////////////////////////////////////////////////////////////////////////
[6432]415void t_bncCore::printEph(const t_eph& eph, bool printFile) {
[519]416
[5375]417 QString strV2 = eph.toString(t_rnxNavFile::defaultRnxNavVersion2);
418 QString strV3 = eph.toString(t_rnxObsHeader::defaultRnxObsVersion3);
[941]419
[6451]420 printOutputEph(printFile, _ephStreamGlonass, strV2, strV3);
[941]421}
422
423// Output
424////////////////////////////////////////////////////////////////////////////
[6451]425void t_bncCore::printOutputEph(bool printFile, QTextStream* stream,
426 const QString& strV2, const QString& strV3) {
[4020]427
[590]428 // Output into file
429 // ----------------
[943]430 if (printFile && stream) {
[941]431 if (_rinexVers == 2) {
[4020]432 *stream << strV2.toAscii();
[941]433 }
434 else {
[4020]435 *stream << strV3.toAscii();
[941]436 }
[943]437 stream->flush();
[517]438 }
[590]439
440 // Output into the socket
441 // ----------------------
[6451]442 if (_socketsEph) {
443 QMutableListIterator<QTcpSocket*> is(*_socketsEph);
[590]444 while (is.hasNext()) {
445 QTcpSocket* sock = is.next();
446 if (sock->state() == QAbstractSocket::ConnectedState) {
[4020]447 if (sock->write(strV3.toAscii()) == -1) {
[642]448 delete sock;
449 is.remove();
450 }
[590]451 }
[642]452 else if (sock->state() != QAbstractSocket::ConnectingState) {
453 delete sock;
454 is.remove();
455 }
[590]456 }
457 }
[516]458}
[589]459
[591]460// Set Port Number
461////////////////////////////////////////////////////////////////////////////
[6451]462void t_bncCore::setPortEph(int port) {
463 _portEph = port;
464 if (_portEph != 0) {
465 delete _serverEph;
466 _serverEph = new QTcpServer;
467 if ( !_serverEph->listen(QHostAddress::Any, _portEph) ) {
[5072]468 slotMessage("t_bncCore: Cannot listen on ephemeris port", true);
[1228]469 }
[6451]470 connect(_serverEph, SIGNAL(newConnection()), this, SLOT(slotNewConnectionEph()));
471 delete _socketsEph;
472 _socketsEph = new QList<QTcpSocket*>;
[591]473 }
474}
475
[937]476// Set Port Number
477////////////////////////////////////////////////////////////////////////////
[5072]478void t_bncCore::setPortCorr(int port) {
[937]479 _portCorr = port;
480 if (_portCorr != 0) {
[942]481 delete _serverCorr;
[937]482 _serverCorr = new QTcpServer;
[1228]483 if ( !_serverCorr->listen(QHostAddress::Any, _portCorr) ) {
[5072]484 slotMessage("t_bncCore: Cannot listen on correction port", true);
[1228]485 }
[937]486 connect(_serverCorr, SIGNAL(newConnection()), this, SLOT(slotNewConnectionCorr()));
[942]487 delete _socketsCorr;
[937]488 _socketsCorr = new QList<QTcpSocket*>;
489 }
490}
491
[589]492// New Connection
493////////////////////////////////////////////////////////////////////////////
[6451]494void t_bncCore::slotNewConnectionEph() {
495 _socketsEph->push_back( _serverEph->nextPendingConnection() );
[589]496}
497
[937]498// New Connection
499////////////////////////////////////////////////////////////////////////////
[5072]500void t_bncCore::slotNewConnectionCorr() {
[937]501 _socketsCorr->push_back( _serverCorr->nextPendingConnection() );
502}
503
[621]504//
505////////////////////////////////////////////////////////////////////////////
[5072]506void t_bncCore::slotQuit() {
[5729]507 delete _caster; _caster = 0;
[5066]508 qApp->quit();
[621]509}
510
[936]511//
512////////////////////////////////////////////////////////////////////////////
[6141]513void t_bncCore::slotNewOrbCorrections(QList<t_orbCorr> orbCorrections) {
[6151]514 QMutexLocker locker(&_mutex);
[6141]515 emit newOrbCorrections(orbCorrections);
[6151]516 if (_socketsCorr) {
[6455]517 ostringstream out;
518 t_orbCorr::writeEpoch(&out, orbCorrections);
519 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
520 while (is.hasNext()) {
521 QTcpSocket* sock = is.next();
522 if (sock->state() == QAbstractSocket::ConnectedState) {
523 if (sock->write(out.str().c_str()) == -1) {
[6151]524 delete sock;
525 is.remove();
526 }
527 }
[6455]528 else if (sock->state() != QAbstractSocket::ConnectingState) {
529 delete sock;
530 is.remove();
531 }
[6151]532 }
533 }
[6141]534}
[974]535
[6141]536//
537////////////////////////////////////////////////////////////////////////////
538void t_bncCore::slotNewClkCorrections(QList<t_clkCorr> clkCorrections) {
[974]539 QMutexLocker locker(&_mutex);
[6151]540 emit newClkCorrections(clkCorrections);
[3109]541 if (_socketsCorr) {
[6455]542 ostringstream out;
543 t_clkCorr::writeEpoch(&out, clkCorrections);
544 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
545 while (is.hasNext()) {
546 QTcpSocket* sock = is.next();
547 if (sock->state() == QAbstractSocket::ConnectedState) {
548 if (sock->write(out.str().c_str()) == -1) {
[3109]549 delete sock;
550 is.remove();
551 }
[937]552 }
[6455]553 else if (sock->state() != QAbstractSocket::ConnectingState) {
554 delete sock;
555 is.remove();
556 }
[937]557 }
558 }
[936]559}
[1538]560
561//
562////////////////////////////////////////////////////////////////////////////
[6480]563void t_bncCore::slotNewCodeBiases(QList<t_satCodeBias> codeBiases) {
[6485]564 QMutexLocker locker(&_mutex);
565 emit newCodeBiases(codeBiases);
566 if (_socketsCorr) {
567 ostringstream out;
568 t_satCodeBias::writeEpoch(&out, codeBiases);
569 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
570 while (is.hasNext()) {
571 QTcpSocket* sock = is.next();
572 if (sock->state() == QAbstractSocket::ConnectedState) {
573 if (sock->write(out.str().c_str()) == -1) {
574 delete sock;
575 is.remove();
576 }
577 }
578 else if (sock->state() != QAbstractSocket::ConnectingState) {
579 delete sock;
580 is.remove();
581 }
582 }
583 }
[6480]584}
585
586//
587////////////////////////////////////////////////////////////////////////////
[6484]588void t_bncCore::slotNewPhaseBiases(QList<t_satPhaseBias> phaseBiases) {
[6485]589 QMutexLocker locker(&_mutex);
590 emit newPhaseBiases(phaseBiases);
591 if (_socketsCorr) {
592 ostringstream out;
593 t_satPhaseBias::writeEpoch(&out, phaseBiases);
594 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
595 while (is.hasNext()) {
596 QTcpSocket* sock = is.next();
597 if (sock->state() == QAbstractSocket::ConnectedState) {
598 if (sock->write(out.str().c_str()) == -1) {
599 delete sock;
600 is.remove();
601 }
602 }
603 else if (sock->state() != QAbstractSocket::ConnectingState) {
604 delete sock;
605 is.remove();
606 }
607 }
608 }
[6484]609}
610
611//
612////////////////////////////////////////////////////////////////////////////
613void t_bncCore::slotNewTec(t_vTec vTec) {
[6485]614 QMutexLocker locker(&_mutex);
615 emit newTec(vTec);
616 if (_socketsCorr) {
617 ostringstream out;
618 t_vTec::write(&out, vTec);
619 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
620 while (is.hasNext()) {
621 QTcpSocket* sock = is.next();
622 if (sock->state() == QAbstractSocket::ConnectedState) {
623 if (sock->write(out.str().c_str()) == -1) {
624 delete sock;
625 is.remove();
626 }
627 }
628 else if (sock->state() != QAbstractSocket::ConnectingState) {
629 delete sock;
630 is.remove();
631 }
632 }
633 }
[6484]634}
635
636//
637////////////////////////////////////////////////////////////////////////////
[5072]638void t_bncCore::setConfFileName(const QString& confFileName) {
[4169]639 if (confFileName.isEmpty()) {
640 _confFileName = QDir::homePath() + QDir::separator()
641 + ".config" + QDir::separator()
[5066]642 + qApp->organizationName() + QDir::separator()
643 + qApp->applicationName() + ".bnc";
[1538]644 }
[4169]645 else {
646 _confFileName = confFileName;
647 }
[1538]648}
[2385]649
650// Raw Output
651////////////////////////////////////////////////////////////////////////////
[5072]652void t_bncCore::writeRawData(const QByteArray& data, const QByteArray& staID,
[2518]653 const QByteArray& format) {
[2385]654
[2386]655 QMutexLocker locker(&_mutex);
656
[2519]657 if (!_rawFile) {
[2386]658 bncSettings settings;
[2519]659 QByteArray fileName = settings.value("rawOutFile").toByteArray();
660 if (!fileName.isEmpty()) {
[3524]661 _rawFile = new bncRawFile(fileName, staID, bncRawFile::output);
[2407]662 }
[2386]663 }
664
[2519]665 if (_rawFile) {
666 _rawFile->writeRawData(data, staID, format);
[2386]667 }
[2385]668}
[2672]669
[2909]670//
671////////////////////////////////////////////////////////////////////////////
[5072]672void t_bncCore::initCombination() {
[2909]673#ifdef USE_COMBINATION
674 _bncComb = new bncComb();
[3142]675 if (_bncComb->nStreams() < 1) {
[2909]676 delete _bncComb;
677 _bncComb = 0;
678 }
679#endif
680}
[3231]681
682//
683////////////////////////////////////////////////////////////////////////////
[5072]684void t_bncCore::stopCombination() {
[3231]685#ifdef USE_COMBINATION
686 delete _bncComb;
687 _bncComb = 0;
688#endif
689}
[4167]690
[5846]691//
692////////////////////////////////////////////////////////////////////////////
693bool t_bncCore::dateAndTimeGPSSet() const {
694 QMutexLocker locker(&_mutexDateAndTimeGPS);
695 if (_dateAndTimeGPS) {
696 return true;
697 }
698 else {
699 return false;
700 }
701}
702
703//
704////////////////////////////////////////////////////////////////////////////
705QDateTime t_bncCore::dateAndTimeGPS() const {
706 QMutexLocker locker(&_mutexDateAndTimeGPS);
707 if (_dateAndTimeGPS) {
708 return *_dateAndTimeGPS;
709 }
710 else {
711 return QDateTime();
712 }
713}
714
715//
716////////////////////////////////////////////////////////////////////////////
717void t_bncCore::setDateAndTimeGPS(QDateTime dateTime) {
718 QMutexLocker locker(&_mutexDateAndTimeGPS);
719 delete _dateAndTimeGPS;
720 _dateAndTimeGPS = new QDateTime(dateTime);
721}
[5900]722
723//
724////////////////////////////////////////////////////////////////////////////
[5946]725void t_bncCore::startPPP() {
726 _pppMain->start();
[5900]727}
728
729//
730////////////////////////////////////////////////////////////////////////////
731void t_bncCore::stopPPP() {
[5903]732 _pppMain->stop();
[5972]733 emit stopRinexPPP();
[5900]734}
[6383]735
Note: See TracBrowser for help on using the repository browser.