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

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