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

Last change on this file since 10039 was 10039, checked in by stuerze, 11 months ago

revert some changes temporary

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