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

Last change on this file since 10040 was 10040, checked in by stuerze, 2 years ago

minor changes

File size: 24.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 *
[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;
[152]75
[533]76 // Eph file(s)
77 // -----------
[534]78 _rinexVers = 0;
[533]79 _ephFileGPS = 0;
80 _ephStreamGPS = 0;
81 _ephFileGlonass = 0;
82 _ephStreamGlonass = 0;
[2770]83 _ephFileGalileo = 0;
84 _ephStreamGalileo = 0;
[6384]85 _ephFileSBAS = 0;
86 _ephStreamSBAS = 0;
[559]87
[6451]88 _portEph = 0;
89 _serverEph = 0;
90 _socketsEph = 0;
[589]91
[937]92 _portCorr = 0;
93 _serverCorr = 0;
94 _socketsCorr = 0;
95
[2011]96 _pgmName = QString(BNCPGMNAME).leftJustified(20, ' ', true);
[559]97#ifdef WIN32
98 _userName = QString("${USERNAME}");
99#else
100 _userName = QString("${USER}");
101#endif
102 expandEnvVar(_userName);
[973]103
[6151]104 _userName = _userName.leftJustified(20, ' ', true);
[5846]105 _dateAndTimeGPS = 0;
[6151]106 _mainWindow = 0;
[2673]107
[5899]108 _pppMain = new BNC_PPP::t_pppMain();
[6486]109 qRegisterMetaType< QVector<double> > ("QVector<double>");
110 qRegisterMetaType<bncTime> ("bncTime");
111 qRegisterMetaType<t_ephGPS> ("t_ephGPS");
112 qRegisterMetaType<t_ephGlo> ("t_ephGlo");
113 qRegisterMetaType<t_ephGal> ("t_ephGal");
114 qRegisterMetaType<t_ephSBAS> ("t_ephSBAS");
[6598]115 qRegisterMetaType<t_ephBDS> ("t_ephBDS");
[6486]116 qRegisterMetaType<QList<t_orbCorr> > ("QList<t_orbCorr>");
117 qRegisterMetaType<QList<t_clkCorr> > ("QList<t_clkCorr>");
118 qRegisterMetaType<QList<t_satCodeBias> > ("QList<t_satCodeBias>");
119 qRegisterMetaType<QList<t_satPhaseBias> > ("QList<t_satPhaseBias>");
120 qRegisterMetaType<t_vTec> ("t_vTec");
[82]121}
122
123// Destructor
124////////////////////////////////////////////////////////////////////////////
[5072]125t_bncCore::~t_bncCore() {
[109]126 delete _logStream;
127 delete _logFile;
[533]128 delete _ephStreamGPS;
129 delete _ephFileGPS;
[6451]130 delete _serverEph;
131 delete _socketsEph;
[937]132 delete _serverCorr;
133 delete _socketsCorr;
[534]134 if (_rinexVers == 2) {
[533]135 delete _ephStreamGlonass;
136 delete _ephFileGlonass;
137 }
[975]138
[5846]139 delete _dateAndTimeGPS;
[9822]140 if (_rawFile) {
141 delete _rawFile;
142 }
143
[10040]144 bncComb::destruct();
145
[7856]146 delete _pppMain;
[82]147}
148
149// Write a Program Message
150////////////////////////////////////////////////////////////////////////////
[5072]151void t_bncCore::slotMessage(QByteArray msg, bool showOnScreen) {
[10027]152 if (msg.isEmpty()) {
153 return;
154 }
[1218]155 QMutexLocker locker(&_mutexMessage);
[243]156
[990]157 messagePrivate(msg);
[1299]158 emit newMessage(msg, showOnScreen);
[990]159}
160
161// Write a Program Message (private, no lock)
162////////////////////////////////////////////////////////////////////////////
[5072]163void t_bncCore::messagePrivate(const QByteArray& msg) {
[990]164
[150]165 // First time resolve the log file name
166 // ------------------------------------
[1549]167 QDate currDate = currentDateAndTimeGPS().date();
168 if (_logFileFlag == 0 || _fileDate != currDate) {
[3034]169 delete _logStream; _logStream = 0;
170 delete _logFile; _logFile = 0;
[150]171 _logFileFlag = 1;
[1535]172 bncSettings settings;
[150]173 QString logFileName = settings.value("logFile").toString();
174 if ( !logFileName.isEmpty() ) {
[151]175 expandEnvVar(logFileName);
[7291]176 _logFile = new QFile(logFileName + "_" +
[8127]177 currDate.toString("yyMMdd").toLatin1().data());
[1549]178 _fileDate = currDate;
[275]179 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
180 _logFile->open(QIODevice::WriteOnly | QIODevice::Append);
181 }
182 else {
183 _logFile->open(QIODevice::WriteOnly);
184 }
[150]185 _logStream = new QTextStream();
186 _logStream->setDevice(_logFile);
187 }
188 }
189
[109]190 if (_logStream) {
[3371]191 QByteArray msgLocal = msg;
192 if (msg.indexOf('\n') == 0) {
[9819]193 *_logStream << "\r\n";
[3371]194 msgLocal = msg.mid(1);
195 }
[8127]196 *_logStream << currentDateAndTimeGPS().toString("yy-MM-dd hh:mm:ss ").toLatin1().data();
[9819]197 *_logStream << msgLocal.data() << "\r\n";
[109]198 _logStream->flush();
[3637]199 _logFile->flush();
[82]200 }
201}
[511]202
[7291]203//
[511]204////////////////////////////////////////////////////////////////////////////
[6520]205t_irc t_bncCore::checkPrintEph(t_eph* eph) {
[516]206 QMutexLocker locker(&_mutex);
[6520]207 t_irc ircPut = _ephUser.putNewEph(eph, true);
[9772]208#ifdef BNC_DEBUG_BCEP
[9767]209 if (eph->checkState() == t_eph::unhealthy) {
210 messagePrivate(QString("%1: UNHEALTHY %2:%3")
[9217]211 .arg(eph->receptStaID())
[9765]212 .arg(eph->navTypeString(eph->navType(), eph->prn(), 99.0))
213 .arg(eph->rinexDateStr(eph->TOC(), eph->prn(), 99.0)).toLatin1());
[6519]214 }
[9768]215 if (eph->checkState() == t_eph::bad) {
[9767]216 messagePrivate(QString("%1: WRONG %2:%3")
[9217]217 .arg(eph->receptStaID())
[9765]218 .arg(eph->navTypeString(eph->navType(), eph->prn(), 99.0))
219 .arg(eph->rinexDateStr(eph->TOC(), eph->prn(), 99.0)).toLatin1());
[7208]220 }
[9772]221 if (eph->checkState() == t_eph::outdated) {
[9767]222 messagePrivate(QString("%1: OUTDATED %2:%3")
[9217]223 .arg(eph->receptStaID())
[9765]224 .arg(eph->navTypeString(eph->navType(), eph->prn(), 99.0))
225 .arg(eph->rinexDateStr(eph->TOC(), eph->prn(), 99.0)).toLatin1());
[8215]226 }
[9379]227#endif
[534]228 printEphHeader();
[6520]229 printEph(*eph, (ircPut == success));
230 return success;
[511]231}
[6520]232
[7291]233// New GPS Ephemeris
[6520]234////////////////////////////////////////////////////////////////////////////
235void t_bncCore::slotNewGPSEph(t_ephGPS eph) {
236 if (checkPrintEph(&eph) == success) {
237 emit newGPSEph(eph);
238 }
239}
[7291]240
[535]241// New Glonass Ephemeris
[511]242////////////////////////////////////////////////////////////////////////////
[6432]243void t_bncCore::slotNewGlonassEph(t_ephGlo eph) {
[6520]244 if (checkPrintEph(&eph) == success) {
245 emit newGlonassEph(eph);
[6519]246 }
[511]247}
248
[2770]249// New Galileo Ephemeris
250////////////////////////////////////////////////////////////////////////////
[6432]251void t_bncCore::slotNewGalileoEph(t_ephGal eph) {
[6520]252 if (checkPrintEph(&eph) == success) {
253 emit newGalileoEph(eph);
[6519]254 }
[6432]255}
[2772]256
[6432]257// New SBAS Ephemeris
258////////////////////////////////////////////////////////////////////////////
259void t_bncCore::slotNewSBASEph(t_ephSBAS eph) {
[6520]260 if (checkPrintEph(&eph) == success) {
261 emit newSBASEph(eph);
[6519]262 }
[2770]263}
264
[6598]265// New BDS Ephemeris
[6595]266////////////////////////////////////////////////////////////////////////////
[6598]267void t_bncCore::slotNewBDSEph(t_ephBDS eph) {
[6595]268 if (checkPrintEph(&eph) == success) {
[6598]269 emit newBDSEph(eph);
[6595]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;
[7999]278 QStringList comments;
[535]279
[7999]280 QListIterator<QString> it(settings.value("mountPoints").toStringList());
281 while (it.hasNext()) {
282 QStringList hlp = it.next().split(" ");
283 if (hlp.size() < 7)
284 continue;
285 QUrl url(hlp[0]);
286 QString decoder = hlp[1];
287 comments.append("Source: " + decoder +
[8203]288 " " + QUrl::toAce(url.host()) +
[8127]289 "/" + url.path().mid(1).toLatin1());
[7999]290 }
291
[534]292 // Initialization
293 // --------------
294 if (_rinexVers == 0) {
[528]295
[9760]296 _rinexVers = settings.value("ephVersion").toInt();
[529]297
[533]298 _ephPath = settings.value("ephPath").toString();
299
300 if ( !_ephPath.isEmpty() ) {
301 if ( _ephPath[_ephPath.length()-1] != QDir::separator() ) {
302 _ephPath += QDir::separator();
303 }
304 expandEnvVar(_ephPath);
305 }
[517]306 }
[533]307
[534]308 // (Re-)Open output File(s)
309 // ------------------------
[533]310 if (!_ephPath.isEmpty()) {
311
[1154]312 QDateTime datTim = currentDateAndTimeGPS();
[533]313
[7179]314 QString ephFileNameGPS = _ephPath + "BRDC";
[533]315
[7291]316 QString hlpStr = bncRinex::nextEpochStr(datTim,
[9760]317 settings.value("ephIntr").toString(), _rinexVers);
[584]318
[9760]319 if (_rinexVers > 2) {
[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
[9760]360 if (_rinexVers > 2) {
[533]361 _ephFileGlonass = _ephFileGPS;
362 _ephStreamGlonass = _ephStreamGPS;
[2770]363 _ephFileGalileo = _ephFileGPS;
364 _ephStreamGalileo = _ephStreamGPS;
[6384]365 _ephFileSBAS = _ephFileGPS;
366 _ephStreamSBAS = _ephStreamGPS;
[533]367 }
[9760]368 else {
[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 // ------------------------
[9760]389 if (_rinexVers > 2) {
[537]390 if ( ! (appendFlagGPS & QIODevice::Append)) {
[9765]391 double rinexVersion = defaultRnxNavVersion4;
392 if (_rinexVers < 4.0) {
393 rinexVersion = defaultRnxNavVersion3;
394 }
[9675]395 QString line = QString().asprintf("%9.2f%11sN: GNSS NAV DATA M: Mixed%12sRINEX VERSION / TYPE\n",
[9765]396 rinexVersion, "", "");
[537]397 *_ephStreamGPS << line;
[9675]398 line.clear();
[7291]399
[1154]400 QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
[8127]401 *_ephStreamGPS << _pgmName.toLatin1().data()
402 << _userName.toLatin1().data()
403 << hlp.toLatin1().data()
[9675]404 << "PGM / RUN BY / DATE\n";
[559]405
[7999]406 QStringListIterator it(comments);
407 while (it.hasNext()) {
408 *_ephStreamGPS << it.next().trimmed().left(60).leftJustified(60) << "COMMENT\n";
409 }
410
[9765]411 if (_rinexVers == 4) {
412 int leapSecs = gnumleap(datTim.date().year(), datTim.date().month(), datTim.date().day());
413 *_ephStreamGPS << QString("%1").arg(leapSecs, 6, 10, QLatin1Char(' ')).left(60).leftJustified(60)
414 << "LEAP SECONDS\n";
415 }
416
[9675]417 line = QString().asprintf("%60sEND OF HEADER\n", "");
[537]418 *_ephStreamGPS << line;
[7291]419
[537]420 _ephStreamGPS->flush();
[535]421 }
[533]422 }
423
[536]424 // Headers - RINEX Version 2
425 // -------------------------
[9760]426 else {
[536]427 if (! (appendFlagGPS & QIODevice::Append)) {
[9675]428 QString line = QString().asprintf("%9.2f%11sN: GPS NAV DATA%25sRINEX VERSION / TYPE\n",
[8127]429 defaultRnxNavVersion2, "", "");
[536]430 *_ephStreamGPS << line;
[9675]431 line.clear();
[7291]432
[1154]433 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
[8127]434 *_ephStreamGPS << _pgmName.toLatin1().data()
435 << _userName.toLatin1().data()
436 << hlp.toLatin1().data()
[9675]437 << "PGM / RUN BY / DATE\n";
[559]438
[7999]439 QStringListIterator it(comments);
440 while (it.hasNext()) {
441 *_ephStreamGPS << it.next().trimmed().left(60).leftJustified(60) << "COMMENT\n";
442 }
443
[9675]444 line = QString().asprintf("%60sEND OF HEADER\n", "");
[536]445 *_ephStreamGPS << line;
[537]446
447 _ephStreamGPS->flush();
[536]448 }
449 if (! (appendFlagGlonass & QIODevice::Append)) {
[9675]450 QString line = QString().asprintf("%9.2f%11sG: GLONASS NAV DATA%21sRINEX VERSION / TYPE\n",
[8127]451 defaultRnxNavVersion2, "", "");
[536]452 *_ephStreamGlonass << line;
[9675]453 line.clear();
[7291]454
[1154]455 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
[8127]456 *_ephStreamGlonass << _pgmName.toLatin1().data()
457 << _userName.toLatin1().data()
458 << hlp.toLatin1().data()
[9675]459 << "PGM / RUN BY / DATE\n";
[559]460
[7999]461 QStringListIterator it(comments);
462 while (it.hasNext()) {
463 *_ephStreamGlonass << it.next().trimmed().left(60).leftJustified(60) << "COMMENT\n";
464 }
465
[9675]466 line = QString().asprintf("%60sEND OF HEADER\n", "");
[536]467 *_ephStreamGlonass << line;
[537]468
469 _ephStreamGlonass->flush();
[536]470 }
[533]471 }
472 }
[516]473}
474
[6432]475// Print One Ephemeris
[516]476////////////////////////////////////////////////////////////////////////////
[6432]477void t_bncCore::printEph(const t_eph& eph, bool printFile) {
[519]478
[8127]479 QString strV2 = eph.toString(defaultRnxNavVersion2);
[9483]480 QString strV3 = eph.toString(defaultRnxNavVersion3);
[9760]481 QString strV4 = eph.toString(defaultRnxNavVersion4);
[941]482
[7026]483 if (_rinexVers == 2 && eph.type() == t_eph::GLONASS) {
[9760]484 printOutputEph(printFile, _ephStreamGlonass, strV2, strV3, strV4);
[7026]485 }
486 else if(_rinexVers == 2 && eph.type() == t_eph::GPS) {
[9760]487 printOutputEph(printFile, _ephStreamGPS, strV2, strV3, strV4);
[7026]488 }
[9765]489 else if (_rinexVers >= 3) {
[9760]490 printOutputEph(printFile, _ephStreamGPS, strV2, strV3, strV4);
[7026]491 }
[941]492}
493
494// Output
495////////////////////////////////////////////////////////////////////////////
[6451]496void t_bncCore::printOutputEph(bool printFile, QTextStream* stream,
[9760]497 const QString& strV2, const QString& strV3,
498 const QString& strV4) {
[9770]499 QString strVx;
500 if (_rinexVers == 2) {
501 strVx = strV2;
502 }
503 else if (_rinexVers == 3) {
504 strVx = strV3;
505 }
506 else if (_rinexVers == 4) {
507 strVx = strV4;
508 }
[4020]509
[590]510 // Output into file
511 // ----------------
[943]512 if (printFile && stream) {
[9770]513 *stream << strVx.toLatin1();
[943]514 stream->flush();
[517]515 }
[590]516
517 // Output into the socket
518 // ----------------------
[6451]519 if (_socketsEph) {
520 QMutableListIterator<QTcpSocket*> is(*_socketsEph);
[590]521 while (is.hasNext()) {
522 QTcpSocket* sock = is.next();
523 if (sock->state() == QAbstractSocket::ConnectedState) {
[9770]524 if (sock->write(strVx.toLatin1()) == -1) {
[642]525 delete sock;
526 is.remove();
527 }
[590]528 }
[642]529 else if (sock->state() != QAbstractSocket::ConnectingState) {
530 delete sock;
531 is.remove();
532 }
[590]533 }
534 }
[516]535}
[589]536
[591]537// Set Port Number
538////////////////////////////////////////////////////////////////////////////
[6451]539void t_bncCore::setPortEph(int port) {
540 _portEph = port;
541 if (_portEph != 0) {
542 delete _serverEph;
543 _serverEph = new QTcpServer;
[8921]544 _serverEph->setProxy(QNetworkProxy::NoProxy);
[6451]545 if ( !_serverEph->listen(QHostAddress::Any, _portEph) ) {
[8918]546 QString message = "t_bncCore: Cannot listen on ephemeris port "
[8921]547 + QByteArray::number(_portEph) + ": "
548 + _serverEph->errorString();
[8918]549 slotMessage(message.toLatin1(), true);
[1228]550 }
[6451]551 connect(_serverEph, SIGNAL(newConnection()), this, SLOT(slotNewConnectionEph()));
552 delete _socketsEph;
553 _socketsEph = new QList<QTcpSocket*>;
[591]554 }
555}
556
[937]557// Set Port Number
558////////////////////////////////////////////////////////////////////////////
[5072]559void t_bncCore::setPortCorr(int port) {
[937]560 _portCorr = port;
561 if (_portCorr != 0) {
[942]562 delete _serverCorr;
[937]563 _serverCorr = new QTcpServer;
[8921]564 _serverCorr->setProxy(QNetworkProxy::NoProxy);
[1228]565 if ( !_serverCorr->listen(QHostAddress::Any, _portCorr) ) {
[8918]566 QString message = "t_bncCore: Cannot listen on correction port "
[8921]567 + QByteArray::number(_portCorr) + ": "
568 + _serverCorr->errorString();
[8918]569 slotMessage(message.toLatin1(), true);
[1228]570 }
[937]571 connect(_serverCorr, SIGNAL(newConnection()), this, SLOT(slotNewConnectionCorr()));
[942]572 delete _socketsCorr;
[937]573 _socketsCorr = new QList<QTcpSocket*>;
574 }
575}
576
[589]577// New Connection
578////////////////////////////////////////////////////////////////////////////
[6451]579void t_bncCore::slotNewConnectionEph() {
580 _socketsEph->push_back( _serverEph->nextPendingConnection() );
[589]581}
582
[937]583// New Connection
584////////////////////////////////////////////////////////////////////////////
[5072]585void t_bncCore::slotNewConnectionCorr() {
[937]586 _socketsCorr->push_back( _serverCorr->nextPendingConnection() );
587}
588
[7291]589//
[621]590////////////////////////////////////////////////////////////////////////////
[5072]591void t_bncCore::slotQuit() {
[5729]592 delete _caster; _caster = 0;
[5066]593 qApp->quit();
[621]594}
595
[7291]596//
[936]597////////////////////////////////////////////////////////////////////////////
[6141]598void t_bncCore::slotNewOrbCorrections(QList<t_orbCorr> orbCorrections) {
[6151]599 QMutexLocker locker(&_mutex);
[6141]600 emit newOrbCorrections(orbCorrections);
[6151]601 if (_socketsCorr) {
[6455]602 ostringstream out;
[7291]603 t_orbCorr::writeEpoch(&out, orbCorrections);
[6455]604 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
605 while (is.hasNext()) {
606 QTcpSocket* sock = is.next();
607 if (sock->state() == QAbstractSocket::ConnectedState) {
608 if (sock->write(out.str().c_str()) == -1) {
[6151]609 delete sock;
610 is.remove();
611 }
612 }
[6455]613 else if (sock->state() != QAbstractSocket::ConnectingState) {
614 delete sock;
615 is.remove();
616 }
[6151]617 }
618 }
[6141]619}
[974]620
[7291]621//
[6141]622////////////////////////////////////////////////////////////////////////////
623void t_bncCore::slotNewClkCorrections(QList<t_clkCorr> clkCorrections) {
[974]624 QMutexLocker locker(&_mutex);
[6151]625 emit newClkCorrections(clkCorrections);
[3109]626 if (_socketsCorr) {
[6455]627 ostringstream out;
[7291]628 t_clkCorr::writeEpoch(&out, clkCorrections);
[6455]629 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
630 while (is.hasNext()) {
631 QTcpSocket* sock = is.next();
632 if (sock->state() == QAbstractSocket::ConnectedState) {
633 if (sock->write(out.str().c_str()) == -1) {
[3109]634 delete sock;
635 is.remove();
636 }
[937]637 }
[6455]638 else if (sock->state() != QAbstractSocket::ConnectingState) {
639 delete sock;
640 is.remove();
641 }
[937]642 }
643 }
[936]644}
[1538]645
[7291]646//
[1538]647////////////////////////////////////////////////////////////////////////////
[6480]648void t_bncCore::slotNewCodeBiases(QList<t_satCodeBias> codeBiases) {
[6485]649 QMutexLocker locker(&_mutex);
650 emit newCodeBiases(codeBiases);
651 if (_socketsCorr) {
652 ostringstream out;
[7291]653 t_satCodeBias::writeEpoch(&out, codeBiases);
[6485]654 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
655 while (is.hasNext()) {
656 QTcpSocket* sock = is.next();
657 if (sock->state() == QAbstractSocket::ConnectedState) {
658 if (sock->write(out.str().c_str()) == -1) {
659 delete sock;
660 is.remove();
661 }
662 }
663 else if (sock->state() != QAbstractSocket::ConnectingState) {
664 delete sock;
665 is.remove();
666 }
667 }
668 }
[6480]669}
670
[7291]671//
[6480]672////////////////////////////////////////////////////////////////////////////
[6484]673void t_bncCore::slotNewPhaseBiases(QList<t_satPhaseBias> phaseBiases) {
[6485]674 QMutexLocker locker(&_mutex);
675 emit newPhaseBiases(phaseBiases);
676 if (_socketsCorr) {
677 ostringstream out;
[7291]678 t_satPhaseBias::writeEpoch(&out, phaseBiases);
[6485]679 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
680 while (is.hasNext()) {
681 QTcpSocket* sock = is.next();
682 if (sock->state() == QAbstractSocket::ConnectedState) {
683 if (sock->write(out.str().c_str()) == -1) {
684 delete sock;
685 is.remove();
686 }
687 }
688 else if (sock->state() != QAbstractSocket::ConnectingState) {
689 delete sock;
690 is.remove();
691 }
692 }
693 }
[6484]694}
695
[7291]696//
[6484]697////////////////////////////////////////////////////////////////////////////
698void t_bncCore::slotNewTec(t_vTec vTec) {
[6485]699 QMutexLocker locker(&_mutex);
700 emit newTec(vTec);
701 if (_socketsCorr) {
702 ostringstream out;
[7291]703 t_vTec::write(&out, vTec);
[6485]704 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
705 while (is.hasNext()) {
706 QTcpSocket* sock = is.next();
707 if (sock->state() == QAbstractSocket::ConnectedState) {
708 if (sock->write(out.str().c_str()) == -1) {
709 delete sock;
710 is.remove();
711 }
712 }
713 else if (sock->state() != QAbstractSocket::ConnectingState) {
714 delete sock;
715 is.remove();
716 }
717 }
718 }
[6484]719}
720
[7291]721//
[6484]722////////////////////////////////////////////////////////////////////////////
[5072]723void t_bncCore::setConfFileName(const QString& confFileName) {
[4169]724 if (confFileName.isEmpty()) {
[7291]725 _confFileName = QDir::homePath() + QDir::separator()
[4169]726 + ".config" + QDir::separator()
[5066]727 + qApp->organizationName() + QDir::separator()
728 + qApp->applicationName() + ".bnc";
[1538]729 }
[4169]730 else {
731 _confFileName = confFileName;
732 }
[1538]733}
[2385]734
735// Raw Output
736////////////////////////////////////////////////////////////////////////////
[5072]737void t_bncCore::writeRawData(const QByteArray& data, const QByteArray& staID,
[2518]738 const QByteArray& format) {
[2385]739
[2386]740 QMutexLocker locker(&_mutex);
741
[2519]742 if (!_rawFile) {
[2386]743 bncSettings settings;
[2519]744 QByteArray fileName = settings.value("rawOutFile").toByteArray();
745 if (!fileName.isEmpty()) {
[3524]746 _rawFile = new bncRawFile(fileName, staID, bncRawFile::output);
[2407]747 }
[2386]748 }
749
[2519]750 if (_rawFile) {
751 _rawFile->writeRawData(data, staID, format);
[2386]752 }
[2385]753}
[2672]754
[7291]755//
[2909]756////////////////////////////////////////////////////////////////////////////
[10040]757void t_bncCore::initCombination() {
758 bncComb::getInstance();
759 if (BNC_CMB->nStreams() < 1) {
760 bncComb::destruct();
[2909]761 }
762}
[3231]763
[7291]764//
[3231]765////////////////////////////////////////////////////////////////////////////
[5072]766void t_bncCore::stopCombination() {
[10040]767 bncComb::destruct();
[3231]768}
[4167]769
[5846]770//
771////////////////////////////////////////////////////////////////////////////
772bool t_bncCore::dateAndTimeGPSSet() const {
773 QMutexLocker locker(&_mutexDateAndTimeGPS);
774 if (_dateAndTimeGPS) {
775 return true;
776 }
777 else {
778 return false;
779 }
780}
781
782//
783////////////////////////////////////////////////////////////////////////////
784QDateTime t_bncCore::dateAndTimeGPS() const {
785 QMutexLocker locker(&_mutexDateAndTimeGPS);
786 if (_dateAndTimeGPS) {
787 return *_dateAndTimeGPS;
788 }
789 else {
790 return QDateTime();
791 }
792}
793
794//
795////////////////////////////////////////////////////////////////////////////
796void t_bncCore::setDateAndTimeGPS(QDateTime dateTime) {
797 QMutexLocker locker(&_mutexDateAndTimeGPS);
798 delete _dateAndTimeGPS;
799 _dateAndTimeGPS = new QDateTime(dateTime);
800}
[5900]801
802//
803////////////////////////////////////////////////////////////////////////////
[5946]804void t_bncCore::startPPP() {
805 _pppMain->start();
[5900]806}
807
808//
809////////////////////////////////////////////////////////////////////////////
810void t_bncCore::stopPPP() {
[5903]811 _pppMain->stop();
[5972]812 emit stopRinexPPP();
[5900]813}
[6383]814
Note: See TracBrowser for help on using the repository browser.