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

Last change on this file since 8000 was 8000, checked in by stuerze, 8 years ago

some informations about the data source of RINEX navigation files is added into the RINEX header

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