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

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