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

Last change on this file since 7267 was 7208, checked in by stuerze, 10 years ago

minor changes to decide between erroneous and outdated ephemerides during the ephemeris check

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