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

Last change on this file since 10524 was 10221, checked in by stuerze, 13 months ago

minor changes

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