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

Last change on this file since 7393 was 7298, checked in by stuerze, 9 years ago

some restructuring

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