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

Last change on this file since 9770 was 9770, checked in by stuerze, 22 months ago

minor changes to handle RINEX 2,3,4

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