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

Last change on this file since 9219 was 9219, checked in by stuerze, 3 years ago

minor changes

File size: 23.8 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 *
[7291]37 * Changes:
[82]38 *
39 * -----------------------------------------------------------------------*/
40
[1029]41#include <iostream>
[6461]42#include <sstream>
[150]43#include <QMessageBox>
[519]44#include <cmath>
[82]45
[7291]46#include "bnccore.h"
47#include "bncutils.h"
48#include "bncrinex.h"
49#include "bncsettings.h"
50#include "bncversion.h"
51#include "ephemeris.h"
52#include "rinex/rnxobsfile.h"
53#include "rinex/rnxnavfile.h"
[6051]54#include "pppMain.h"
[7298]55#include "combination/bnccomb.h"
[82]56
57using namespace std;
58
[7291]59// Singleton
[5084]60////////////////////////////////////////////////////////////////////////////
[5861]61t_bncCore* t_bncCore::instance() {
[5084]62 static t_bncCore _bncCore;
[5861]63 return &_bncCore;
[5084]64}
65
[82]66// Constructor
67////////////////////////////////////////////////////////////////////////////
[6441]68t_bncCore::t_bncCore() : _ephUser(false) {
[5084]69 _GUIenabled = true;
[150]70 _logFileFlag = 0;
71 _logFile = 0;
72 _logStream = 0;
[2519]73 _rawFile = 0;
[5729]74 _caster = 0;
[2922]75 _bncComb = 0;
[152]76
[533]77 // Eph file(s)
78 // -----------
[534]79 _rinexVers = 0;
[533]80 _ephFileGPS = 0;
81 _ephStreamGPS = 0;
82 _ephFileGlonass = 0;
83 _ephStreamGlonass = 0;
[2770]84 _ephFileGalileo = 0;
85 _ephStreamGalileo = 0;
[6384]86 _ephFileSBAS = 0;
87 _ephStreamSBAS = 0;
[559]88
[6451]89 _portEph = 0;
90 _serverEph = 0;
91 _socketsEph = 0;
[589]92
[937]93 _portCorr = 0;
94 _serverCorr = 0;
95 _socketsCorr = 0;
96
[2011]97 _pgmName = QString(BNCPGMNAME).leftJustified(20, ' ', true);
[559]98#ifdef WIN32
99 _userName = QString("${USERNAME}");
100#else
101 _userName = QString("${USER}");
102#endif
103 expandEnvVar(_userName);
[973]104
[6151]105 _userName = _userName.leftJustified(20, ' ', true);
[5846]106 _dateAndTimeGPS = 0;
[6151]107 _mainWindow = 0;
[2673]108
[5899]109 _pppMain = new BNC_PPP::t_pppMain();
[6486]110 qRegisterMetaType< QVector<double> > ("QVector<double>");
111 qRegisterMetaType<bncTime> ("bncTime");
112 qRegisterMetaType<t_ephGPS> ("t_ephGPS");
113 qRegisterMetaType<t_ephGlo> ("t_ephGlo");
114 qRegisterMetaType<t_ephGal> ("t_ephGal");
115 qRegisterMetaType<t_ephSBAS> ("t_ephSBAS");
[6598]116 qRegisterMetaType<t_ephBDS> ("t_ephBDS");
[6486]117 qRegisterMetaType<QList<t_orbCorr> > ("QList<t_orbCorr>");
118 qRegisterMetaType<QList<t_clkCorr> > ("QList<t_clkCorr>");
119 qRegisterMetaType<QList<t_satCodeBias> > ("QList<t_satCodeBias>");
120 qRegisterMetaType<QList<t_satPhaseBias> > ("QList<t_satPhaseBias>");
121 qRegisterMetaType<t_vTec> ("t_vTec");
[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 delete _bncComb;
[7856]143 delete _pppMain;
[82]144}
145
146// Write a Program Message
147////////////////////////////////////////////////////////////////////////////
[5072]148void t_bncCore::slotMessage(QByteArray msg, bool showOnScreen) {
[150]149
[1218]150 QMutexLocker locker(&_mutexMessage);
[243]151
[990]152 messagePrivate(msg);
[1299]153 emit newMessage(msg, showOnScreen);
[990]154}
155
156// Write a Program Message (private, no lock)
157////////////////////////////////////////////////////////////////////////////
[5072]158void t_bncCore::messagePrivate(const QByteArray& msg) {
[990]159
[150]160 // First time resolve the log file name
161 // ------------------------------------
[1549]162 QDate currDate = currentDateAndTimeGPS().date();
163 if (_logFileFlag == 0 || _fileDate != currDate) {
[3034]164 delete _logStream; _logStream = 0;
165 delete _logFile; _logFile = 0;
[150]166 _logFileFlag = 1;
[1535]167 bncSettings settings;
[150]168 QString logFileName = settings.value("logFile").toString();
169 if ( !logFileName.isEmpty() ) {
[151]170 expandEnvVar(logFileName);
[7291]171 _logFile = new QFile(logFileName + "_" +
[8127]172 currDate.toString("yyMMdd").toLatin1().data());
[1549]173 _fileDate = currDate;
[275]174 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
175 _logFile->open(QIODevice::WriteOnly | QIODevice::Append);
176 }
177 else {
178 _logFile->open(QIODevice::WriteOnly);
179 }
[150]180 _logStream = new QTextStream();
181 _logStream->setDevice(_logFile);
182 }
183 }
184
[109]185 if (_logStream) {
[3371]186 QByteArray msgLocal = msg;
187 if (msg.indexOf('\n') == 0) {
188 *_logStream << endl;
189 msgLocal = msg.mid(1);
190 }
[8127]191 *_logStream << currentDateAndTimeGPS().toString("yy-MM-dd hh:mm:ss ").toLatin1().data();
[3371]192 *_logStream << msgLocal.data() << endl;
[109]193 _logStream->flush();
[3637]194 _logFile->flush();
[82]195 }
196}
[511]197
[7291]198//
[511]199////////////////////////////////////////////////////////////////////////////
[6520]200t_irc t_bncCore::checkPrintEph(t_eph* eph) {
[516]201 QMutexLocker locker(&_mutex);
[6520]202 t_irc ircPut = _ephUser.putNewEph(eph, true);
[7208]203 if (eph->checkState() == t_eph::bad) {
[9219]204 messagePrivate(QString("%1: WRONG EPHEMERIS: %2")
[9217]205 .arg(eph->receptStaID())
[9213]206 .arg(eph->rinexDateStr(eph->TOC(), eph->prn(), 3.0)).toLatin1());
[6520]207 return failure;
[6519]208 }
[7208]209 else if (eph->checkState() == t_eph::outdated) {
[9219]210 messagePrivate(QString("%1: OUTDATED EPHEMERIS: %2")
[9217]211 .arg(eph->receptStaID())
[9212]212 .arg(eph->rinexDateStr(eph->TOC(), eph->prn(), 3.0)).toLatin1());
[7208]213 return failure;
214 }
[8215]215 else if (eph->checkState() == t_eph::unhealthy) {
[9217]216 messagePrivate(QString("%1: UNHEALTHY EPHEMERIS: %2")
217 .arg(eph->receptStaID())
[9212]218 .arg(eph->rinexDateStr(eph->TOC(), eph->prn(), 3.0)).toLatin1());
[8215]219 }
[9217]220
[534]221 printEphHeader();
[6520]222 printEph(*eph, (ircPut == success));
223 return success;
[511]224}
[6520]225
[7291]226// New GPS Ephemeris
[6520]227////////////////////////////////////////////////////////////////////////////
228void t_bncCore::slotNewGPSEph(t_ephGPS eph) {
229 if (checkPrintEph(&eph) == success) {
230 emit newGPSEph(eph);
231 }
232}
[7291]233
[535]234// New Glonass Ephemeris
[511]235////////////////////////////////////////////////////////////////////////////
[6432]236void t_bncCore::slotNewGlonassEph(t_ephGlo eph) {
[6520]237 if (checkPrintEph(&eph) == success) {
238 emit newGlonassEph(eph);
[6519]239 }
[511]240}
241
[2770]242// New Galileo Ephemeris
243////////////////////////////////////////////////////////////////////////////
[6432]244void t_bncCore::slotNewGalileoEph(t_ephGal eph) {
[6520]245 if (checkPrintEph(&eph) == success) {
246 emit newGalileoEph(eph);
[6519]247 }
[6432]248}
[2772]249
[6432]250// New SBAS Ephemeris
251////////////////////////////////////////////////////////////////////////////
252void t_bncCore::slotNewSBASEph(t_ephSBAS eph) {
[6520]253 if (checkPrintEph(&eph) == success) {
254 emit newSBASEph(eph);
[6519]255 }
[2770]256}
257
[6598]258// New BDS Ephemeris
[6595]259////////////////////////////////////////////////////////////////////////////
[6598]260void t_bncCore::slotNewBDSEph(t_ephBDS eph) {
[6595]261 if (checkPrintEph(&eph) == success) {
[6598]262 emit newBDSEph(eph);
[6595]263 }
264}
[6432]265
[535]266// Print Header of the output File(s)
[516]267////////////////////////////////////////////////////////////////////////////
[5072]268void t_bncCore::printEphHeader() {
[528]269
[1535]270 bncSettings settings;
[7999]271 QStringList comments;
[535]272
[7999]273 QListIterator<QString> it(settings.value("mountPoints").toStringList());
274 while (it.hasNext()) {
275 QStringList hlp = it.next().split(" ");
276 if (hlp.size() < 7)
277 continue;
278 QUrl url(hlp[0]);
279 QString decoder = hlp[1];
280 comments.append("Source: " + decoder +
[8203]281 " " + QUrl::toAce(url.host()) +
[8127]282 "/" + url.path().mid(1).toLatin1());
[7999]283 }
284
[534]285 // Initialization
286 // --------------
287 if (_rinexVers == 0) {
[528]288
[9158]289 if ( Qt::CheckState(settings.value("ephV2").toInt()) == Qt::Checked) {
290 _rinexVers = 2;
[533]291 }
292 else {
[9158]293 _rinexVers = 3;
[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
[7179]312 QString ephFileNameGPS = _ephPath + "BRDC";
[533]313
[9158]314 bool ephV2 = (_rinexVers == 2)? true : false;
[7179]315
[7291]316 QString hlpStr = bncRinex::nextEpochStr(datTim,
[9158]317 settings.value("ephIntr").toString(), ephV2);
[584]318
[575]319 if (_rinexVers == 3) {
[8354]320 QString country = "WRD"; // WORLD
321 QString monNum = "0";
322 QString recNum = "0";
323 ephFileNameGPS += QString("%1").arg(monNum, 1, 10) +
324 QString("%1").arg(recNum, 1, 10) +
325 country +
326 "_S_" + // stream
327 QString("%1").arg(datTim.date().year()) +
328 QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +
329 hlpStr + // HM_period
330 "_MN.rnx"; // mixed BRDC
[575]331 }
[7179]332 else { // RNX v2.11
333 ephFileNameGPS += QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +
334 hlpStr + datTim.toString(".yyN");
[575]335 }
[563]336
[533]337 if (_ephFileNameGPS == ephFileNameGPS) {
338 return;
339 }
340 else {
341 _ephFileNameGPS = ephFileNameGPS;
342 }
343
344 delete _ephStreamGPS;
345 delete _ephFileGPS;
346
[535]347 QFlags<QIODevice::OpenModeFlag> appendFlagGPS;
[536]348 QFlags<QIODevice::OpenModeFlag> appendFlagGlonass;
349
[535]350 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
351 QFile::exists(ephFileNameGPS) ) {
352 appendFlagGPS = QIODevice::Append;
353 }
354
[533]355 _ephFileGPS = new QFile(ephFileNameGPS);
[535]356 _ephFileGPS->open(QIODevice::WriteOnly | appendFlagGPS);
[533]357 _ephStreamGPS = new QTextStream();
358 _ephStreamGPS->setDevice(_ephFileGPS);
359
[534]360 if (_rinexVers == 3) {
[533]361 _ephFileGlonass = _ephFileGPS;
362 _ephStreamGlonass = _ephStreamGPS;
[2770]363 _ephFileGalileo = _ephFileGPS;
364 _ephStreamGalileo = _ephStreamGPS;
[6384]365 _ephFileSBAS = _ephFileGPS;
366 _ephStreamSBAS = _ephStreamGPS;
[533]367 }
[534]368 else if (_rinexVers == 2) {
[583]369 QString ephFileNameGlonass = _ephPath + "BRDC" +
[563]370 QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +
[575]371 hlpStr + datTim.toString(".yyG");
[533]372
373 delete _ephStreamGlonass;
374 delete _ephFileGlonass;
375
[535]376 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
377 QFile::exists(ephFileNameGlonass) ) {
378 appendFlagGlonass = QIODevice::Append;
379 }
380
[533]381 _ephFileGlonass = new QFile(ephFileNameGlonass);
[535]382 _ephFileGlonass->open(QIODevice::WriteOnly | appendFlagGlonass);
[533]383 _ephStreamGlonass = new QTextStream();
384 _ephStreamGlonass->setDevice(_ephFileGlonass);
385 }
386
[534]387 // Header - RINEX Version 3
388 // ------------------------
389 if (_rinexVers == 3) {
[537]390 if ( ! (appendFlagGPS & QIODevice::Append)) {
391 QString line;
392 line.sprintf(
[7291]393 "%9.2f%11sN: GNSS NAV DATA M: Mixed%12sRINEX VERSION / TYPE\n",
[8127]394 defaultRnxNavVersion3, "", "");
[537]395 *_ephStreamGPS << line;
[7291]396
[1154]397 QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
[8127]398 *_ephStreamGPS << _pgmName.toLatin1().data()
399 << _userName.toLatin1().data()
400 << hlp.toLatin1().data()
[559]401 << "PGM / RUN BY / DATE" << endl;
402
[7999]403 QStringListIterator it(comments);
404 while (it.hasNext()) {
405 *_ephStreamGPS << it.next().trimmed().left(60).leftJustified(60) << "COMMENT\n";
406 }
407
[559]408 line.sprintf("%60sEND OF HEADER\n", "");
[537]409 *_ephStreamGPS << line;
[7291]410
[537]411 _ephStreamGPS->flush();
[535]412 }
[533]413 }
414
[536]415 // Headers - RINEX Version 2
416 // -------------------------
[534]417 else if (_rinexVers == 2) {
[536]418 if (! (appendFlagGPS & QIODevice::Append)) {
419 QString line;
[5375]420 line.sprintf("%9.2f%11sN: GPS NAV DATA%25sRINEX VERSION / TYPE\n",
[8127]421 defaultRnxNavVersion2, "", "");
[536]422 *_ephStreamGPS << line;
[7291]423
[1154]424 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
[8127]425 *_ephStreamGPS << _pgmName.toLatin1().data()
426 << _userName.toLatin1().data()
427 << hlp.toLatin1().data()
[559]428 << "PGM / RUN BY / DATE" << endl;
429
[7999]430 QStringListIterator it(comments);
431 while (it.hasNext()) {
432 *_ephStreamGPS << it.next().trimmed().left(60).leftJustified(60) << "COMMENT\n";
433 }
434
[559]435 line.sprintf("%60sEND OF HEADER\n", "");
[536]436 *_ephStreamGPS << line;
[537]437
438 _ephStreamGPS->flush();
[536]439 }
440 if (! (appendFlagGlonass & QIODevice::Append)) {
441 QString line;
[5375]442 line.sprintf("%9.2f%11sG: GLONASS NAV DATA%21sRINEX VERSION / TYPE\n",
[8127]443 defaultRnxNavVersion2, "", "");
[536]444 *_ephStreamGlonass << line;
[7291]445
[1154]446 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
[8127]447 *_ephStreamGlonass << _pgmName.toLatin1().data()
448 << _userName.toLatin1().data()
449 << hlp.toLatin1().data()
[559]450 << "PGM / RUN BY / DATE" << endl;
451
[7999]452 QStringListIterator it(comments);
453 while (it.hasNext()) {
454 *_ephStreamGlonass << it.next().trimmed().left(60).leftJustified(60) << "COMMENT\n";
455 }
456
[559]457 line.sprintf("%60sEND OF HEADER\n", "");
[536]458 *_ephStreamGlonass << line;
[537]459
460 _ephStreamGlonass->flush();
[536]461 }
[533]462 }
463 }
[516]464}
465
[6432]466// Print One Ephemeris
[516]467////////////////////////////////////////////////////////////////////////////
[6432]468void t_bncCore::printEph(const t_eph& eph, bool printFile) {
[519]469
[8127]470 QString strV2 = eph.toString(defaultRnxNavVersion2);
471 QString strV3 = eph.toString(defaultRnxObsVersion3);
[941]472
[7026]473 if (_rinexVers == 2 && eph.type() == t_eph::GLONASS) {
474 printOutputEph(printFile, _ephStreamGlonass, strV2, strV3);
475 }
476 else if(_rinexVers == 2 && eph.type() == t_eph::GPS) {
477 printOutputEph(printFile, _ephStreamGPS, strV2, strV3);
478 }
479 else if (_rinexVers == 3) {
480 printOutputEph(printFile, _ephStreamGPS, strV2, strV3);
481 }
[941]482}
483
484// Output
485////////////////////////////////////////////////////////////////////////////
[6451]486void t_bncCore::printOutputEph(bool printFile, QTextStream* stream,
487 const QString& strV2, const QString& strV3) {
[4020]488
[590]489 // Output into file
490 // ----------------
[943]491 if (printFile && stream) {
[941]492 if (_rinexVers == 2) {
[8127]493 *stream << strV2.toLatin1();
[941]494 }
495 else {
[8127]496 *stream << strV3.toLatin1();
[941]497 }
[943]498 stream->flush();
[517]499 }
[590]500
501 // Output into the socket
502 // ----------------------
[6451]503 if (_socketsEph) {
504 QMutableListIterator<QTcpSocket*> is(*_socketsEph);
[590]505 while (is.hasNext()) {
506 QTcpSocket* sock = is.next();
507 if (sock->state() == QAbstractSocket::ConnectedState) {
[8127]508 if (sock->write(strV3.toLatin1()) == -1) {
[642]509 delete sock;
510 is.remove();
511 }
[590]512 }
[642]513 else if (sock->state() != QAbstractSocket::ConnectingState) {
514 delete sock;
515 is.remove();
516 }
[590]517 }
518 }
[516]519}
[589]520
[591]521// Set Port Number
522////////////////////////////////////////////////////////////////////////////
[6451]523void t_bncCore::setPortEph(int port) {
524 _portEph = port;
525 if (_portEph != 0) {
526 delete _serverEph;
527 _serverEph = new QTcpServer;
[8921]528 _serverEph->setProxy(QNetworkProxy::NoProxy);
[6451]529 if ( !_serverEph->listen(QHostAddress::Any, _portEph) ) {
[8918]530 QString message = "t_bncCore: Cannot listen on ephemeris port "
[8921]531 + QByteArray::number(_portEph) + ": "
532 + _serverEph->errorString();
[8918]533 slotMessage(message.toLatin1(), true);
[1228]534 }
[6451]535 connect(_serverEph, SIGNAL(newConnection()), this, SLOT(slotNewConnectionEph()));
536 delete _socketsEph;
537 _socketsEph = new QList<QTcpSocket*>;
[591]538 }
539}
540
[937]541// Set Port Number
542////////////////////////////////////////////////////////////////////////////
[5072]543void t_bncCore::setPortCorr(int port) {
[937]544 _portCorr = port;
545 if (_portCorr != 0) {
[942]546 delete _serverCorr;
[937]547 _serverCorr = new QTcpServer;
[8921]548 _serverCorr->setProxy(QNetworkProxy::NoProxy);
[1228]549 if ( !_serverCorr->listen(QHostAddress::Any, _portCorr) ) {
[8918]550 QString message = "t_bncCore: Cannot listen on correction port "
[8921]551 + QByteArray::number(_portCorr) + ": "
552 + _serverCorr->errorString();
[8918]553 slotMessage(message.toLatin1(), true);
[1228]554 }
[937]555 connect(_serverCorr, SIGNAL(newConnection()), this, SLOT(slotNewConnectionCorr()));
[942]556 delete _socketsCorr;
[937]557 _socketsCorr = new QList<QTcpSocket*>;
558 }
559}
560
[589]561// New Connection
562////////////////////////////////////////////////////////////////////////////
[6451]563void t_bncCore::slotNewConnectionEph() {
564 _socketsEph->push_back( _serverEph->nextPendingConnection() );
[589]565}
566
[937]567// New Connection
568////////////////////////////////////////////////////////////////////////////
[5072]569void t_bncCore::slotNewConnectionCorr() {
[937]570 _socketsCorr->push_back( _serverCorr->nextPendingConnection() );
571}
572
[7291]573//
[621]574////////////////////////////////////////////////////////////////////////////
[5072]575void t_bncCore::slotQuit() {
[5729]576 delete _caster; _caster = 0;
[5066]577 qApp->quit();
[621]578}
579
[7291]580//
[936]581////////////////////////////////////////////////////////////////////////////
[6141]582void t_bncCore::slotNewOrbCorrections(QList<t_orbCorr> orbCorrections) {
[6151]583 QMutexLocker locker(&_mutex);
[6141]584 emit newOrbCorrections(orbCorrections);
[6151]585 if (_socketsCorr) {
[6455]586 ostringstream out;
[7291]587 t_orbCorr::writeEpoch(&out, orbCorrections);
[6455]588 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
589 while (is.hasNext()) {
590 QTcpSocket* sock = is.next();
591 if (sock->state() == QAbstractSocket::ConnectedState) {
592 if (sock->write(out.str().c_str()) == -1) {
[6151]593 delete sock;
594 is.remove();
595 }
596 }
[6455]597 else if (sock->state() != QAbstractSocket::ConnectingState) {
598 delete sock;
599 is.remove();
600 }
[6151]601 }
602 }
[6141]603}
[974]604
[7291]605//
[6141]606////////////////////////////////////////////////////////////////////////////
607void t_bncCore::slotNewClkCorrections(QList<t_clkCorr> clkCorrections) {
[974]608 QMutexLocker locker(&_mutex);
[6151]609 emit newClkCorrections(clkCorrections);
[3109]610 if (_socketsCorr) {
[6455]611 ostringstream out;
[7291]612 t_clkCorr::writeEpoch(&out, clkCorrections);
[6455]613 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
614 while (is.hasNext()) {
615 QTcpSocket* sock = is.next();
616 if (sock->state() == QAbstractSocket::ConnectedState) {
617 if (sock->write(out.str().c_str()) == -1) {
[3109]618 delete sock;
619 is.remove();
620 }
[937]621 }
[6455]622 else if (sock->state() != QAbstractSocket::ConnectingState) {
623 delete sock;
624 is.remove();
625 }
[937]626 }
627 }
[936]628}
[1538]629
[7291]630//
[1538]631////////////////////////////////////////////////////////////////////////////
[6480]632void t_bncCore::slotNewCodeBiases(QList<t_satCodeBias> codeBiases) {
[6485]633 QMutexLocker locker(&_mutex);
634 emit newCodeBiases(codeBiases);
635 if (_socketsCorr) {
636 ostringstream out;
[7291]637 t_satCodeBias::writeEpoch(&out, codeBiases);
[6485]638 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
639 while (is.hasNext()) {
640 QTcpSocket* sock = is.next();
641 if (sock->state() == QAbstractSocket::ConnectedState) {
642 if (sock->write(out.str().c_str()) == -1) {
643 delete sock;
644 is.remove();
645 }
646 }
647 else if (sock->state() != QAbstractSocket::ConnectingState) {
648 delete sock;
649 is.remove();
650 }
651 }
652 }
[6480]653}
654
[7291]655//
[6480]656////////////////////////////////////////////////////////////////////////////
[6484]657void t_bncCore::slotNewPhaseBiases(QList<t_satPhaseBias> phaseBiases) {
[6485]658 QMutexLocker locker(&_mutex);
659 emit newPhaseBiases(phaseBiases);
660 if (_socketsCorr) {
661 ostringstream out;
[7291]662 t_satPhaseBias::writeEpoch(&out, phaseBiases);
[6485]663 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
664 while (is.hasNext()) {
665 QTcpSocket* sock = is.next();
666 if (sock->state() == QAbstractSocket::ConnectedState) {
667 if (sock->write(out.str().c_str()) == -1) {
668 delete sock;
669 is.remove();
670 }
671 }
672 else if (sock->state() != QAbstractSocket::ConnectingState) {
673 delete sock;
674 is.remove();
675 }
676 }
677 }
[6484]678}
679
[7291]680//
[6484]681////////////////////////////////////////////////////////////////////////////
682void t_bncCore::slotNewTec(t_vTec vTec) {
[6485]683 QMutexLocker locker(&_mutex);
684 emit newTec(vTec);
685 if (_socketsCorr) {
686 ostringstream out;
[7291]687 t_vTec::write(&out, vTec);
[6485]688 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
689 while (is.hasNext()) {
690 QTcpSocket* sock = is.next();
691 if (sock->state() == QAbstractSocket::ConnectedState) {
692 if (sock->write(out.str().c_str()) == -1) {
693 delete sock;
694 is.remove();
695 }
696 }
697 else if (sock->state() != QAbstractSocket::ConnectingState) {
698 delete sock;
699 is.remove();
700 }
701 }
702 }
[6484]703}
704
[7291]705//
[6484]706////////////////////////////////////////////////////////////////////////////
[5072]707void t_bncCore::setConfFileName(const QString& confFileName) {
[4169]708 if (confFileName.isEmpty()) {
[7291]709 _confFileName = QDir::homePath() + QDir::separator()
[4169]710 + ".config" + QDir::separator()
[5066]711 + qApp->organizationName() + QDir::separator()
712 + qApp->applicationName() + ".bnc";
[1538]713 }
[4169]714 else {
715 _confFileName = confFileName;
716 }
[1538]717}
[2385]718
719// Raw Output
720////////////////////////////////////////////////////////////////////////////
[5072]721void t_bncCore::writeRawData(const QByteArray& data, const QByteArray& staID,
[2518]722 const QByteArray& format) {
[2385]723
[2386]724 QMutexLocker locker(&_mutex);
725
[2519]726 if (!_rawFile) {
[2386]727 bncSettings settings;
[2519]728 QByteArray fileName = settings.value("rawOutFile").toByteArray();
729 if (!fileName.isEmpty()) {
[3524]730 _rawFile = new bncRawFile(fileName, staID, bncRawFile::output);
[2407]731 }
[2386]732 }
733
[2519]734 if (_rawFile) {
735 _rawFile->writeRawData(data, staID, format);
[2386]736 }
[2385]737}
[2672]738
[7291]739//
[2909]740////////////////////////////////////////////////////////////////////////////
[5072]741void t_bncCore::initCombination() {
[2909]742 _bncComb = new bncComb();
[3142]743 if (_bncComb->nStreams() < 1) {
[2909]744 delete _bncComb;
745 _bncComb = 0;
746 }
747}
[3231]748
[7291]749//
[3231]750////////////////////////////////////////////////////////////////////////////
[5072]751void t_bncCore::stopCombination() {
[3231]752 delete _bncComb;
753 _bncComb = 0;
754}
[4167]755
[5846]756//
757////////////////////////////////////////////////////////////////////////////
758bool t_bncCore::dateAndTimeGPSSet() const {
759 QMutexLocker locker(&_mutexDateAndTimeGPS);
760 if (_dateAndTimeGPS) {
761 return true;
762 }
763 else {
764 return false;
765 }
766}
767
768//
769////////////////////////////////////////////////////////////////////////////
770QDateTime t_bncCore::dateAndTimeGPS() const {
771 QMutexLocker locker(&_mutexDateAndTimeGPS);
772 if (_dateAndTimeGPS) {
773 return *_dateAndTimeGPS;
774 }
775 else {
776 return QDateTime();
777 }
778}
779
780//
781////////////////////////////////////////////////////////////////////////////
782void t_bncCore::setDateAndTimeGPS(QDateTime dateTime) {
783 QMutexLocker locker(&_mutexDateAndTimeGPS);
784 delete _dateAndTimeGPS;
785 _dateAndTimeGPS = new QDateTime(dateTime);
786}
[5900]787
788//
789////////////////////////////////////////////////////////////////////////////
[5946]790void t_bncCore::startPPP() {
791 _pppMain->start();
[5900]792}
793
794//
795////////////////////////////////////////////////////////////////////////////
796void t_bncCore::stopPPP() {
[5903]797 _pppMain->stop();
[5972]798 emit stopRinexPPP();
[5900]799}
[6383]800
Note: See TracBrowser for help on using the repository browser.