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

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