source: ntrip/branches/BNC_2.12/src/bnccore.cpp@ 9218

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

minor changes

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