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

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

same changes for future developments towards station individual navigation files

File size: 24.9 KB
Line 
1// Part of BNC, a utility for retrieving decoding and
2// converting GNSS data streams from NTRIP broadcasters.
3//
4// Copyright (C) 2007
5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
7// Czech Technical University Prague, Department of Geodesy
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.
24
25/* -------------------------------------------------------------------------
26 * BKG NTRIP Client
27 * -------------------------------------------------------------------------
28 *
29 * Class: t_bncCore
30 *
31 * Purpose: This class implements the main application
32 *
33 * Author: L. Mervart
34 *
35 * Created: 29-Aug-2006
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iostream>
42#include <sstream>
43#include <QMessageBox>
44#include <cmath>
45
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"
54#include "pppMain.h"
55#include "combination/bnccomb.h"
56
57using namespace std;
58
59// Singleton
60////////////////////////////////////////////////////////////////////////////
61t_bncCore* t_bncCore::instance() {
62 static t_bncCore _bncCore;
63 return &_bncCore;
64}
65
66// Constructor
67////////////////////////////////////////////////////////////////////////////
68t_bncCore::t_bncCore() : _ephUser(false) {
69 _logFileFlag = 0;
70 _logFile = 0;
71 _logStream = 0;
72 _rawFile = 0;
73 _caster = 0;
74
75 // Eph file(s)
76 // -----------
77 _rinexVers = 0;
78 _ephFileGPS = 0;
79 _ephStreamGPS = 0;
80 _ephFileGlonass = 0;
81 _ephStreamGlonass = 0;
82 _ephFileGalileo = 0;
83 _ephStreamGalileo = 0;
84 _ephFileSBAS = 0;
85 _ephStreamSBAS = 0;
86
87 _portEph = 0;
88 _serverEph = 0;
89 _socketsEph = 0;
90
91 _portCorr = 0;
92 _serverCorr = 0;
93 _socketsCorr = 0;
94
95 _pgmName = QString(BNCPGMNAME).leftJustified(20, ' ', true);
96#ifdef WIN32
97 _userName = QString("${USERNAME}");
98#else
99 _userName = QString("${USER}");
100#endif
101 expandEnvVar(_userName);
102
103 _userName = _userName.leftJustified(20, ' ', true);
104 _dateAndTimeGPS = 0;
105 _mainWindow = 0;
106
107 _pppMain = new BNC_PPP::t_pppMain();
108 qRegisterMetaType< QVector<double> > ("QVector<double>");
109 qRegisterMetaType<bncTime> ("bncTime");
110 qRegisterMetaType<t_ephGPS> ("t_ephGPS");
111 qRegisterMetaType<t_ephGlo> ("t_ephGlo");
112 qRegisterMetaType<t_ephGal> ("t_ephGal");
113 qRegisterMetaType<t_ephSBAS> ("t_ephSBAS");
114 qRegisterMetaType<t_ephBDS> ("t_ephBDS");
115 qRegisterMetaType<QList<t_orbCorr> > ("QList<t_orbCorr>");
116 qRegisterMetaType<QList<t_clkCorr> > ("QList<t_clkCorr>");
117 qRegisterMetaType<QList<t_satCodeBias> > ("QList<t_satCodeBias>");
118 qRegisterMetaType<QList<t_satPhaseBias> > ("QList<t_satPhaseBias>");
119 qRegisterMetaType<t_vTec> ("t_vTec");
120}
121
122// Destructor
123////////////////////////////////////////////////////////////////////////////
124t_bncCore::~t_bncCore() {
125 delete _logStream;
126 delete _logFile;
127 delete _ephStreamGPS;
128 delete _ephFileGPS;
129 delete _serverEph;
130 delete _socketsEph;
131 delete _serverCorr;
132 delete _socketsCorr;
133 if (_rinexVers == 2) {
134 delete _ephStreamGlonass;
135 delete _ephFileGlonass;
136 }
137
138 delete _dateAndTimeGPS;
139 if (_rawFile) {
140 delete _rawFile;
141 }
142
143 bncComb::destruct();
144
145 delete _pppMain;
146}
147
148// Write a Program Message
149////////////////////////////////////////////////////////////////////////////
150void t_bncCore::slotMessage(QByteArray msg, bool showOnScreen) {
151 if (msg.isEmpty()) {
152 return;
153 }
154 QMutexLocker locker(&_mutexMessage);
155
156 messagePrivate(msg);
157 emit newMessage(msg, showOnScreen);
158}
159
160// Write a Program Message (private, no lock)
161////////////////////////////////////////////////////////////////////////////
162void t_bncCore::messagePrivate(const QByteArray& msg) {
163
164 // First time resolve the log file name
165 // ------------------------------------
166 QDate currDate = currentDateAndTimeGPS().date();
167 if (_logFileFlag == 0 || _fileDate != currDate) {
168 delete _logStream; _logStream = 0;
169 delete _logFile; _logFile = 0;
170 _logFileFlag = 1;
171 bncSettings settings;
172 QString logFileName = settings.value("logFile").toString();
173 if ( !logFileName.isEmpty() ) {
174 expandEnvVar(logFileName);
175 _logFile = new QFile(logFileName + "_" +
176 currDate.toString("yyMMdd").toLatin1().data());
177 _fileDate = currDate;
178 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
179 _logFile->open(QIODevice::WriteOnly | QIODevice::Append);
180 }
181 else {
182 _logFile->open(QIODevice::WriteOnly);
183 }
184 _logStream = new QTextStream();
185 _logStream->setDevice(_logFile);
186 }
187 }
188
189 if (_logStream) {
190 QByteArray msgLocal = msg;
191 if (msg.indexOf('\n') == 0) {
192 *_logStream << "\r\n";
193 msgLocal = msg.mid(1);
194 }
195 *_logStream << currentDateAndTimeGPS().toString("yy-MM-dd hh:mm:ss ").toLatin1().data();
196 *_logStream << msgLocal.data() << "\r\n";
197 _logStream->flush();
198 _logFile->flush();
199 }
200}
201
202//
203////////////////////////////////////////////////////////////////////////////
204t_irc t_bncCore::checkPrintEph(t_eph* eph) {
205 QMutexLocker locker(&_mutex);
206 t_irc ircPut = _ephUser.putNewEph(eph, true);
207#ifdef BNC_DEBUG_BCEP
208 if (eph->checkState() == t_eph::unhealthy) {
209 messagePrivate(QString("%1: UNHEALTHY %2:%3")
210 .arg(eph->receptStaID())
211 .arg(eph->navTypeString(eph->navType(), eph->prn(), 99.0))
212 .arg(eph->rinexDateStr(eph->TOC(), eph->prn(), 99.0)).toLatin1());
213 }
214 if (eph->checkState() == t_eph::bad) {
215 messagePrivate(QString("%1: WRONG %2:%3")
216 .arg(eph->receptStaID())
217 .arg(eph->navTypeString(eph->navType(), eph->prn(), 99.0))
218 .arg(eph->rinexDateStr(eph->TOC(), eph->prn(), 99.0)).toLatin1());
219 }
220 if (eph->checkState() == t_eph::outdated) {
221 messagePrivate(QString("%1: OUTDATED %2:%3")
222 .arg(eph->receptStaID())
223 .arg(eph->navTypeString(eph->navType(), eph->prn(), 99.0))
224 .arg(eph->rinexDateStr(eph->TOC(), eph->prn(), 99.0)).toLatin1());
225 }
226#endif
227 printEphHeader();
228 //printEphHeader(eph->receptStaID());
229 printEph(*eph, (ircPut == success));
230 return success;
231}
232
233// New GPS Ephemeris
234////////////////////////////////////////////////////////////////////////////
235void t_bncCore::slotNewGPSEph(t_ephGPS eph) {
236 if (checkPrintEph(&eph) == success) {
237 emit newGPSEph(eph);
238 }
239}
240
241// New Glonass Ephemeris
242////////////////////////////////////////////////////////////////////////////
243void t_bncCore::slotNewGlonassEph(t_ephGlo eph) {
244 if (checkPrintEph(&eph) == success) {
245 emit newGlonassEph(eph);
246 }
247}
248
249// New Galileo Ephemeris
250////////////////////////////////////////////////////////////////////////////
251void t_bncCore::slotNewGalileoEph(t_ephGal eph) {
252 if (checkPrintEph(&eph) == success) {
253 emit newGalileoEph(eph);
254 }
255}
256
257// New SBAS Ephemeris
258////////////////////////////////////////////////////////////////////////////
259void t_bncCore::slotNewSBASEph(t_ephSBAS eph) {
260 if (checkPrintEph(&eph) == success) {
261 emit newSBASEph(eph);
262 }
263}
264
265// New BDS Ephemeris
266////////////////////////////////////////////////////////////////////////////
267void t_bncCore::slotNewBDSEph(t_ephBDS eph) {
268 if (checkPrintEph(&eph) == success) {
269 emit newBDSEph(eph);
270 }
271}
272
273// Print Header of the output File(s)
274////////////////////////////////////////////////////////////////////////////
275void t_bncCore::printEphHeader(QString receptStaID) {
276
277 bncSettings settings;
278 QStringList comments;
279 bool separateFiles = false;// Qt::CheckState(settings.value("ephFilePerStation").toInt());
280
281 QListIterator<QString> it(settings.value("mountPoints").toStringList());
282 while (it.hasNext()) {
283 QStringList hlp = it.next().split(" ");
284 if (hlp.size() < 7)
285 continue;
286 QUrl url(hlp[0]);
287 QString decoder = hlp[1];
288 if (!separateFiles) {
289 comments.append("Source: " + decoder +
290 " " + QUrl::toAce(url.host()) +
291 "/" + url.path().mid(1).toLatin1());
292 }
293 }
294
295 // Initialization
296 // --------------
297 if (_rinexVers == 0) {
298
299 _rinexVers = settings.value("ephVersion").toInt();
300
301 _ephPath = settings.value("ephPath").toString();
302
303 if ( !_ephPath.isEmpty() ) {
304 if ( _ephPath[_ephPath.length()-1] != QDir::separator() ) {
305 _ephPath += QDir::separator();
306 }
307 expandEnvVar(_ephPath);
308 }
309 }
310
311 // (Re-)Open output File(s)
312 // ------------------------
313 if (!_ephPath.isEmpty()) {
314
315 QDateTime datTim = currentDateAndTimeGPS();
316
317 QString ephFileNameGPS = _ephPath; // + "BRDC";
318
319 (separateFiles) ? ephFileNameGPS += receptStaID.left(4) :
320 ephFileNameGPS += "BRDC";
321
322 QString hlpStr = bncRinex::nextEpochStr(datTim,
323 settings.value("ephIntr").toString(), _rinexVers);
324
325 if (_rinexVers > 2) {
326 QString country = "WRD"; // WORLD
327 QString monNum = "0";
328 QString recNum = "0";
329 if (separateFiles && receptStaID.size() >= 9) {
330 monNum = receptStaID.mid(4,1);
331 recNum = receptStaID.mid(5,1);
332 country = receptStaID.mid(6,3);
333 }
334 ephFileNameGPS += QString("%1").arg(monNum, 1, 10) +
335 QString("%1").arg(recNum, 1, 10) +
336 country +
337 "_S_" + // stream
338 QString("%1").arg(datTim.date().year()) +
339 QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +
340 hlpStr + // HM_period
341 "_MN.rnx"; // mixed BRDC
342 }
343 else { // RNX v2.11
344 ephFileNameGPS += QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +
345 hlpStr + datTim.toString(".yyN");
346 }
347
348 if (_ephFileNameGPS == ephFileNameGPS) {
349 return;
350 }
351 else {
352 _ephFileNameGPS = ephFileNameGPS;
353 }
354
355 delete _ephStreamGPS;
356 delete _ephFileGPS;
357
358 QFlags<QIODevice::OpenModeFlag> appendFlagGPS;
359 QFlags<QIODevice::OpenModeFlag> appendFlagGlonass;
360
361 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
362 QFile::exists(ephFileNameGPS) ) {
363 appendFlagGPS = QIODevice::Append;
364 }
365
366 _ephFileGPS = new QFile(ephFileNameGPS);
367 _ephFileGPS->open(QIODevice::WriteOnly | appendFlagGPS);
368 _ephStreamGPS = new QTextStream();
369 _ephStreamGPS->setDevice(_ephFileGPS);
370
371 if (_rinexVers > 2) {
372 _ephFileGlonass = _ephFileGPS;
373 _ephStreamGlonass = _ephStreamGPS;
374 _ephFileGalileo = _ephFileGPS;
375 _ephStreamGalileo = _ephStreamGPS;
376 _ephFileSBAS = _ephFileGPS;
377 _ephStreamSBAS = _ephStreamGPS;
378 }
379 else {
380 QString ephFileNameGlonass = _ephPath + "BRDC" +
381 QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +
382 hlpStr + datTim.toString(".yyG");
383
384 delete _ephStreamGlonass;
385 delete _ephFileGlonass;
386
387 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
388 QFile::exists(ephFileNameGlonass) ) {
389 appendFlagGlonass = QIODevice::Append;
390 }
391
392 _ephFileGlonass = new QFile(ephFileNameGlonass);
393 _ephFileGlonass->open(QIODevice::WriteOnly | appendFlagGlonass);
394 _ephStreamGlonass = new QTextStream();
395 _ephStreamGlonass->setDevice(_ephFileGlonass);
396 }
397
398 // Header - RINEX Version 3
399 // ------------------------
400 if (_rinexVers > 2) {
401 if ( ! (appendFlagGPS & QIODevice::Append)) {
402 double rinexVersion = defaultRnxNavVersion4;
403 if (_rinexVers < 4.0) {
404 rinexVersion = defaultRnxNavVersion3;
405 }
406 QString line = QString().asprintf("%9.2f%11sN: GNSS NAV DATA M: Mixed%12sRINEX VERSION / TYPE\n",
407 rinexVersion, "", "");
408 *_ephStreamGPS << line;
409 line.clear();
410
411 QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
412 *_ephStreamGPS << _pgmName.toLatin1().data()
413 << _userName.toLatin1().data()
414 << hlp.toLatin1().data()
415 << "PGM / RUN BY / DATE\n";
416
417 QStringListIterator it(comments);
418 while (it.hasNext()) {
419 *_ephStreamGPS << it.next().trimmed().left(60).leftJustified(60) << "COMMENT\n";
420 }
421
422 if (_rinexVers == 4) {
423 int leapSecs = gnumleap(datTim.date().year(), datTim.date().month(), datTim.date().day());
424 *_ephStreamGPS << QString("%1").arg(leapSecs, 6, 10, QLatin1Char(' ')).left(60).leftJustified(60)
425 << "LEAP SECONDS\n";
426 }
427
428 line = QString().asprintf("%60sEND OF HEADER\n", "");
429 *_ephStreamGPS << line;
430
431 _ephStreamGPS->flush();
432 }
433 }
434
435 // Headers - RINEX Version 2
436 // -------------------------
437 else {
438 if (! (appendFlagGPS & QIODevice::Append)) {
439 QString line = QString().asprintf("%9.2f%11sN: GPS NAV DATA%25sRINEX VERSION / TYPE\n",
440 defaultRnxNavVersion2, "", "");
441 *_ephStreamGPS << line;
442 line.clear();
443
444 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
445 *_ephStreamGPS << _pgmName.toLatin1().data()
446 << _userName.toLatin1().data()
447 << hlp.toLatin1().data()
448 << "PGM / RUN BY / DATE\n";
449
450 QStringListIterator it(comments);
451 while (it.hasNext()) {
452 *_ephStreamGPS << it.next().trimmed().left(60).leftJustified(60) << "COMMENT\n";
453 }
454
455 line = QString().asprintf("%60sEND OF HEADER\n", "");
456 *_ephStreamGPS << line;
457
458 _ephStreamGPS->flush();
459 }
460 if (! (appendFlagGlonass & QIODevice::Append)) {
461 QString line = QString().asprintf("%9.2f%11sG: GLONASS NAV DATA%21sRINEX VERSION / TYPE\n",
462 defaultRnxNavVersion2, "", "");
463 *_ephStreamGlonass << line;
464 line.clear();
465
466 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
467 *_ephStreamGlonass << _pgmName.toLatin1().data()
468 << _userName.toLatin1().data()
469 << hlp.toLatin1().data()
470 << "PGM / RUN BY / DATE\n";
471
472 QStringListIterator it(comments);
473 while (it.hasNext()) {
474 *_ephStreamGlonass << it.next().trimmed().left(60).leftJustified(60) << "COMMENT\n";
475 }
476
477 line = QString().asprintf("%60sEND OF HEADER\n", "");
478 *_ephStreamGlonass << line;
479
480 _ephStreamGlonass->flush();
481 }
482 }
483 }
484}
485
486// Print One Ephemeris
487////////////////////////////////////////////////////////////////////////////
488void t_bncCore::printEph(const t_eph& eph, bool printFile) {
489
490 QString strV2 = eph.toString(defaultRnxNavVersion2);
491 QString strV3 = eph.toString(defaultRnxNavVersion3);
492 QString strV4 = eph.toString(defaultRnxNavVersion4);
493
494 if (_rinexVers == 2 && eph.type() == t_eph::GLONASS) {
495 printOutputEph(printFile, _ephStreamGlonass, strV2, strV3, strV4);
496 }
497 else if(_rinexVers == 2 && eph.type() == t_eph::GPS) {
498 printOutputEph(printFile, _ephStreamGPS, strV2, strV3, strV4);
499 }
500 else if (_rinexVers >= 3) {
501 printOutputEph(printFile, _ephStreamGPS, strV2, strV3, strV4);
502 }
503}
504
505// Output
506////////////////////////////////////////////////////////////////////////////
507void t_bncCore::printOutputEph(bool printFile, QTextStream* stream,
508 const QString& strV2, const QString& strV3,
509 const QString& strV4) {
510 QString strVx;
511 if (_rinexVers == 2) {
512 strVx = strV2;
513 }
514 else if (_rinexVers == 3) {
515 strVx = strV3;
516 }
517 else if (_rinexVers == 4) {
518 strVx = strV4;
519 }
520
521 // Output into file
522 // ----------------
523 if (printFile && stream) {
524 *stream << strVx.toLatin1();
525 stream->flush();
526 }
527
528 // Output into the socket
529 // ----------------------
530 if (_socketsEph) {
531 QMutableListIterator<QTcpSocket*> is(*_socketsEph);
532 while (is.hasNext()) {
533 QTcpSocket* sock = is.next();
534 if (sock->state() == QAbstractSocket::ConnectedState) {
535 if (sock->write(strVx.toLatin1()) == -1) {
536 delete sock;
537 is.remove();
538 }
539 }
540 else if (sock->state() != QAbstractSocket::ConnectingState) {
541 delete sock;
542 is.remove();
543 }
544 }
545 }
546}
547
548// Set Port Number
549////////////////////////////////////////////////////////////////////////////
550void t_bncCore::setPortEph(int port) {
551 _portEph = port;
552 if (_portEph != 0) {
553 delete _serverEph;
554 _serverEph = new QTcpServer;
555 _serverEph->setProxy(QNetworkProxy::NoProxy);
556 if ( !_serverEph->listen(QHostAddress::Any, _portEph) ) {
557 QString message = "t_bncCore: Cannot listen on ephemeris port "
558 + QByteArray::number(_portEph) + ": "
559 + _serverEph->errorString();
560 slotMessage(message.toLatin1(), true);
561 }
562 connect(_serverEph, SIGNAL(newConnection()), this, SLOT(slotNewConnectionEph()));
563 delete _socketsEph;
564 _socketsEph = new QList<QTcpSocket*>;
565 }
566}
567
568// Set Port Number
569////////////////////////////////////////////////////////////////////////////
570void t_bncCore::setPortCorr(int port) {
571 _portCorr = port;
572 if (_portCorr != 0) {
573 delete _serverCorr;
574 _serverCorr = new QTcpServer;
575 _serverCorr->setProxy(QNetworkProxy::NoProxy);
576 if ( !_serverCorr->listen(QHostAddress::Any, _portCorr) ) {
577 QString message = "t_bncCore: Cannot listen on correction port "
578 + QByteArray::number(_portCorr) + ": "
579 + _serverCorr->errorString();
580 slotMessage(message.toLatin1(), true);
581 }
582 connect(_serverCorr, SIGNAL(newConnection()), this, SLOT(slotNewConnectionCorr()));
583 delete _socketsCorr;
584 _socketsCorr = new QList<QTcpSocket*>;
585 }
586}
587
588// New Connection
589////////////////////////////////////////////////////////////////////////////
590void t_bncCore::slotNewConnectionEph() {
591 _socketsEph->push_back( _serverEph->nextPendingConnection() );
592}
593
594// New Connection
595////////////////////////////////////////////////////////////////////////////
596void t_bncCore::slotNewConnectionCorr() {
597 _socketsCorr->push_back( _serverCorr->nextPendingConnection() );
598}
599
600//
601////////////////////////////////////////////////////////////////////////////
602void t_bncCore::slotQuit() {
603 delete _caster; _caster = 0;
604 qApp->quit();
605}
606
607//
608////////////////////////////////////////////////////////////////////////////
609void t_bncCore::slotNewOrbCorrections(QList<t_orbCorr> orbCorrections) {
610 QMutexLocker locker(&_mutex);
611 emit newOrbCorrections(orbCorrections);
612 if (_socketsCorr) {
613 ostringstream out;
614 t_orbCorr::writeEpoch(&out, orbCorrections);
615 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
616 while (is.hasNext()) {
617 QTcpSocket* sock = is.next();
618 if (sock->state() == QAbstractSocket::ConnectedState) {
619 if (sock->write(out.str().c_str()) == -1) {
620 delete sock;
621 is.remove();
622 }
623 }
624 else if (sock->state() != QAbstractSocket::ConnectingState) {
625 delete sock;
626 is.remove();
627 }
628 }
629 }
630}
631
632//
633////////////////////////////////////////////////////////////////////////////
634void t_bncCore::slotNewClkCorrections(QList<t_clkCorr> clkCorrections) {
635 QMutexLocker locker(&_mutex);
636 emit newClkCorrections(clkCorrections);
637 if (_socketsCorr) {
638 ostringstream out;
639 t_clkCorr::writeEpoch(&out, clkCorrections);
640 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
641 while (is.hasNext()) {
642 QTcpSocket* sock = is.next();
643 if (sock->state() == QAbstractSocket::ConnectedState) {
644 if (sock->write(out.str().c_str()) == -1) {
645 delete sock;
646 is.remove();
647 }
648 }
649 else if (sock->state() != QAbstractSocket::ConnectingState) {
650 delete sock;
651 is.remove();
652 }
653 }
654 }
655}
656
657//
658////////////////////////////////////////////////////////////////////////////
659void t_bncCore::slotNewCodeBiases(QList<t_satCodeBias> codeBiases) {
660 QMutexLocker locker(&_mutex);
661 emit newCodeBiases(codeBiases);
662 if (_socketsCorr) {
663 ostringstream out;
664 t_satCodeBias::writeEpoch(&out, codeBiases);
665 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
666 while (is.hasNext()) {
667 QTcpSocket* sock = is.next();
668 if (sock->state() == QAbstractSocket::ConnectedState) {
669 if (sock->write(out.str().c_str()) == -1) {
670 delete sock;
671 is.remove();
672 }
673 }
674 else if (sock->state() != QAbstractSocket::ConnectingState) {
675 delete sock;
676 is.remove();
677 }
678 }
679 }
680}
681
682//
683////////////////////////////////////////////////////////////////////////////
684void t_bncCore::slotNewPhaseBiases(QList<t_satPhaseBias> phaseBiases) {
685 QMutexLocker locker(&_mutex);
686 emit newPhaseBiases(phaseBiases);
687 if (_socketsCorr) {
688 ostringstream out;
689 t_satPhaseBias::writeEpoch(&out, phaseBiases);
690 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
691 while (is.hasNext()) {
692 QTcpSocket* sock = is.next();
693 if (sock->state() == QAbstractSocket::ConnectedState) {
694 if (sock->write(out.str().c_str()) == -1) {
695 delete sock;
696 is.remove();
697 }
698 }
699 else if (sock->state() != QAbstractSocket::ConnectingState) {
700 delete sock;
701 is.remove();
702 }
703 }
704 }
705}
706
707//
708////////////////////////////////////////////////////////////////////////////
709void t_bncCore::slotNewTec(t_vTec vTec) {
710 QMutexLocker locker(&_mutex);
711 emit newTec(vTec);
712 if (_socketsCorr) {
713 ostringstream out;
714 t_vTec::write(&out, vTec);
715 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
716 while (is.hasNext()) {
717 QTcpSocket* sock = is.next();
718 if (sock->state() == QAbstractSocket::ConnectedState) {
719 if (sock->write(out.str().c_str()) == -1) {
720 delete sock;
721 is.remove();
722 }
723 }
724 else if (sock->state() != QAbstractSocket::ConnectingState) {
725 delete sock;
726 is.remove();
727 }
728 }
729 }
730}
731
732//
733////////////////////////////////////////////////////////////////////////////
734void t_bncCore::setConfFileName(const QString& confFileName) {
735 if (confFileName.isEmpty()) {
736 _confFileName = QDir::homePath() + QDir::separator()
737 + ".config" + QDir::separator()
738 + qApp->organizationName() + QDir::separator()
739 + qApp->applicationName() + ".bnc";
740 }
741 else {
742 _confFileName = confFileName;
743 }
744}
745
746// Raw Output
747////////////////////////////////////////////////////////////////////////////
748void t_bncCore::writeRawData(const QByteArray& data, const QByteArray& staID,
749 const QByteArray& format) {
750
751 QMutexLocker locker(&_mutex);
752
753 if (!_rawFile) {
754 bncSettings settings;
755 QByteArray fileName = settings.value("rawOutFile").toByteArray();
756 if (!fileName.isEmpty()) {
757 _rawFile = new bncRawFile(fileName, staID, bncRawFile::output);
758 }
759 }
760
761 if (_rawFile) {
762 _rawFile->writeRawData(data, staID, format);
763 }
764}
765
766//
767////////////////////////////////////////////////////////////////////////////
768void t_bncCore::initCombination() {
769 bncComb::getInstance();
770 if (BNC_CMB->nStreams() < 1) {
771 bncComb::destruct();
772 }
773}
774
775//
776////////////////////////////////////////////////////////////////////////////
777void t_bncCore::stopCombination() {
778 bncComb::destruct();
779}
780
781//
782////////////////////////////////////////////////////////////////////////////
783bool t_bncCore::dateAndTimeGPSSet() const {
784 QMutexLocker locker(&_mutexDateAndTimeGPS);
785 if (_dateAndTimeGPS) {
786 return true;
787 }
788 else {
789 return false;
790 }
791}
792
793//
794////////////////////////////////////////////////////////////////////////////
795QDateTime t_bncCore::dateAndTimeGPS() const {
796 QMutexLocker locker(&_mutexDateAndTimeGPS);
797 if (_dateAndTimeGPS) {
798 return *_dateAndTimeGPS;
799 }
800 else {
801 return QDateTime();
802 }
803}
804
805//
806////////////////////////////////////////////////////////////////////////////
807void t_bncCore::setDateAndTimeGPS(QDateTime dateTime) {
808 QMutexLocker locker(&_mutexDateAndTimeGPS);
809 delete _dateAndTimeGPS;
810 _dateAndTimeGPS = new QDateTime(dateTime);
811}
812
813//
814////////////////////////////////////////////////////////////////////////////
815void t_bncCore::startPPP() {
816 _pppMain->start();
817}
818
819//
820////////////////////////////////////////////////////////////////////////////
821void t_bncCore::stopPPP() {
822 _pppMain->stop();
823 emit stopRinexPPP();
824}
825
Note: See TracBrowser for help on using the repository browser.