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

Last change on this file since 6151 was 6151, checked in by mervart, 10 years ago
File size: 22.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 <QMessageBox>
43#include <cmath>
44
45#include "bnccore.h"
46#include "bncutils.h"
47#include "bncrinex.h"
48#include "bncsettings.h"
49#include "bncversion.h"
50#include "ephemeris.h"
51#include "rinex/rnxobsfile.h"
52#include "rinex/rnxnavfile.h"
53#include "pppMain.h"
54
55#ifdef USE_COMBINATION
56# include "combination/bnccomb.h"
57#endif
58
59using namespace std;
60
61// Singleton
62////////////////////////////////////////////////////////////////////////////
63t_bncCore* t_bncCore::instance() {
64 static t_bncCore _bncCore;
65 return &_bncCore;
66}
67
68// Constructor
69////////////////////////////////////////////////////////////////////////////
70t_bncCore::t_bncCore() {
71 _GUIenabled = true;
72 _logFileFlag = 0;
73 _logFile = 0;
74 _logStream = 0;
75 _rawFile = 0;
76 _caster = 0;
77#ifdef USE_COMBINATION
78 _bncComb = 0;
79#endif
80
81 // Lists of Ephemeris
82 // ------------------
83 for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) {
84 _gpsEph[ii-PRN_GPS_START] = 0;
85 }
86 for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) {
87 _glonassEph[ii-PRN_GLONASS_START] = 0;
88 }
89 for (int ii = PRN_GALILEO_START; ii <= PRN_GALILEO_END; ii++) {
90 _galileoEph[ii-PRN_GALILEO_START] = 0;
91 }
92
93 // Eph file(s)
94 // -----------
95 _rinexVers = 0;
96 _ephFileGPS = 0;
97 _ephStreamGPS = 0;
98 _ephFileGlonass = 0;
99 _ephStreamGlonass = 0;
100 _ephFileGalileo = 0;
101 _ephStreamGalileo = 0;
102
103 _port = 0;
104 _server = 0;
105 _sockets = 0;
106
107 _portCorr = 0;
108 _serverCorr = 0;
109 _socketsCorr = 0;
110
111 _pgmName = QString(BNCPGMNAME).leftJustified(20, ' ', true);
112#ifdef WIN32
113 _userName = QString("${USERNAME}");
114#else
115 _userName = QString("${USER}");
116#endif
117 expandEnvVar(_userName);
118
119 _userName = _userName.leftJustified(20, ' ', true);
120 _dateAndTimeGPS = 0;
121 _mainWindow = 0;
122
123 _pppMain = new BNC_PPP::t_pppMain();
124 qRegisterMetaType< QVector<double> >("QVector<double>");
125 qRegisterMetaType<bncTime>("bncTime");
126}
127
128// Destructor
129////////////////////////////////////////////////////////////////////////////
130t_bncCore::~t_bncCore() {
131 delete _logStream;
132 delete _logFile;
133 delete _ephStreamGPS;
134 delete _ephFileGPS;
135 delete _server;
136 delete _sockets;
137 delete _serverCorr;
138 delete _socketsCorr;
139 if (_rinexVers == 2) {
140 delete _ephStreamGlonass;
141 delete _ephFileGlonass;
142 }
143 for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) {
144 delete _gpsEph[ii-PRN_GPS_START];
145 }
146 for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) {
147 delete _glonassEph[ii-PRN_GLONASS_START];
148 }
149 for (int ii = PRN_GALILEO_START; ii <= PRN_GALILEO_END; ii++) {
150 delete _galileoEph[ii-PRN_GALILEO_START];
151 }
152
153 delete _dateAndTimeGPS;
154 delete _rawFile;
155
156#ifdef USE_COMBINATION
157 delete _bncComb;
158#endif
159}
160
161// Write a Program Message
162////////////////////////////////////////////////////////////////////////////
163void t_bncCore::slotMessage(QByteArray msg, bool showOnScreen) {
164
165 QMutexLocker locker(&_mutexMessage);
166
167 messagePrivate(msg);
168 emit newMessage(msg, showOnScreen);
169}
170
171// Write a Program Message (private, no lock)
172////////////////////////////////////////////////////////////////////////////
173void t_bncCore::messagePrivate(const QByteArray& msg) {
174
175 // First time resolve the log file name
176 // ------------------------------------
177 QDate currDate = currentDateAndTimeGPS().date();
178 if (_logFileFlag == 0 || _fileDate != currDate) {
179 delete _logStream; _logStream = 0;
180 delete _logFile; _logFile = 0;
181 _logFileFlag = 1;
182 bncSettings settings;
183 QString logFileName = settings.value("logFile").toString();
184 if ( !logFileName.isEmpty() ) {
185 expandEnvVar(logFileName);
186 _logFile = new QFile(logFileName + "_" +
187 currDate.toString("yyMMdd").toAscii().data());
188 _fileDate = currDate;
189 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
190 _logFile->open(QIODevice::WriteOnly | QIODevice::Append);
191 }
192 else {
193 _logFile->open(QIODevice::WriteOnly);
194 }
195 _logStream = new QTextStream();
196 _logStream->setDevice(_logFile);
197 }
198 }
199
200 if (_logStream) {
201 QByteArray msgLocal = msg;
202 if (msg.indexOf('\n') == 0) {
203 *_logStream << endl;
204 msgLocal = msg.mid(1);
205 }
206 *_logStream << currentDateAndTimeGPS().toString("yy-MM-dd hh:mm:ss ").toAscii().data();
207 *_logStream << msgLocal.data() << endl;
208 _logStream->flush();
209 _logFile->flush();
210 }
211}
212
213// New GPS Ephemeris
214////////////////////////////////////////////////////////////////////////////
215void t_bncCore::slotNewGPSEph(gpsephemeris* gpseph) {
216
217 QMutexLocker locker(&_mutex);
218
219 gpsephemeris copy_gpseph = *gpseph;
220 emit newEphGPS(copy_gpseph);
221
222 printEphHeader();
223
224 gpsephemeris** ee = &_gpsEph[gpseph->satellite-1];
225
226 if ( *ee != 0 &&
227 gpseph->GPSweek == (*ee)->GPSweek && gpseph->TOC == (*ee)->TOC ) {
228 checkEphemeris(*ee, gpseph);
229 }
230
231 if ( *ee == 0 ||
232 gpseph->GPSweek > (*ee)->GPSweek ||
233 (gpseph->GPSweek == (*ee)->GPSweek && gpseph->TOC > (*ee)->TOC) ) {
234 delete *ee;
235 *ee = gpseph;
236 printGPSEph(gpseph, true);
237 }
238 else {
239 printGPSEph(gpseph, false);
240 delete gpseph;
241 }
242}
243
244// New Glonass Ephemeris
245////////////////////////////////////////////////////////////////////////////
246void t_bncCore::slotNewGlonassEph(glonassephemeris* glonasseph, const QString& staID) {
247
248 QMutexLocker locker(&_mutex);
249
250 // Check wrong Ephemerides
251 // -----------------------
252 if (glonasseph->x_pos == 0.0 &&
253 glonasseph->y_pos == 0.0 &&
254 glonasseph->z_pos == 0.0) {
255 delete glonasseph;
256 return;
257 }
258
259 glonassephemeris copy_glonasseph = *glonasseph;
260 emit newEphGlonass(copy_glonasseph);
261
262 printEphHeader();
263
264 glonassephemeris** ee = &_glonassEph[glonasseph->almanac_number-1];
265
266 int wwOld, towOld, wwNew, towNew;
267 if (*ee != 0) {
268 wwOld = (*ee)->GPSWeek;
269 towOld = (*ee)->GPSTOW;
270 updatetime(&wwOld, &towOld, (*ee)->tb*1000, 0); // Moscow -> GPS
271
272 wwNew = glonasseph->GPSWeek;
273 towNew = glonasseph->GPSTOW;
274 updatetime(&wwNew, &towNew, glonasseph->tb*1000, 0); // Moscow -> GPS
275 }
276
277 if ( *ee == 0 ||
278 wwNew > wwOld ||
279 (wwNew == wwOld && towNew > towOld) ) {
280 delete *ee;
281 *ee = glonasseph;
282 printGlonassEph(glonasseph, true, staID);
283 }
284 else {
285 printGlonassEph(glonasseph, false, staID);
286 delete glonasseph;
287 }
288}
289
290// New Galileo Ephemeris
291////////////////////////////////////////////////////////////////////////////
292void t_bncCore::slotNewGalileoEph(galileoephemeris* galileoeph) {
293
294 QMutexLocker locker(&_mutex);
295
296 galileoephemeris copy_galileoeph = *galileoeph;
297 emit newEphGalileo(copy_galileoeph);
298
299 printEphHeader();
300
301 int galIndex = galileoeph->satellite;
302 /* GIOVE */
303 if(galIndex == 51) galIndex = 1;
304 else if(galIndex == 52) galIndex = 16;
305 if (galIndex < 0 || galIndex > PRN_GALILEO_END - PRN_GALILEO_START) {
306 emit( newMessage("Wrong Galileo Satellite Number", true) );
307 exit(1);
308 }
309
310 galileoephemeris** ee = &_galileoEph[galIndex];
311
312 if ( *ee == 0 ||
313 galileoeph->Week > (*ee)->Week ||
314 (galileoeph->Week == (*ee)->Week && galileoeph->TOC > (*ee)->TOC) ) {
315 delete *ee;
316 *ee = galileoeph;
317 printGalileoEph(galileoeph, true);
318 }
319 else {
320 printGalileoEph(galileoeph, false);
321 delete galileoeph;
322 }
323}
324
325// Print Header of the output File(s)
326////////////////////////////////////////////////////////////////////////////
327void t_bncCore::printEphHeader() {
328
329 bncSettings settings;
330
331 // Initialization
332 // --------------
333 if (_rinexVers == 0) {
334
335 if ( Qt::CheckState(settings.value("ephV3").toInt()) == Qt::Checked) {
336 _rinexVers = 3;
337 }
338 else {
339 _rinexVers = 2;
340 }
341
342 _ephPath = settings.value("ephPath").toString();
343
344 if ( !_ephPath.isEmpty() ) {
345 if ( _ephPath[_ephPath.length()-1] != QDir::separator() ) {
346 _ephPath += QDir::separator();
347 }
348 expandEnvVar(_ephPath);
349 }
350 }
351
352 // (Re-)Open output File(s)
353 // ------------------------
354 if (!_ephPath.isEmpty()) {
355
356 QDateTime datTim = currentDateAndTimeGPS();
357
358 QString ephFileNameGPS = _ephPath + "BRDC" +
359 QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0'));
360
361 QString hlpStr = bncRinex::nextEpochStr(datTim,
362 settings.value("ephIntr").toString());
363
364 if (_rinexVers == 3) {
365 ephFileNameGPS += hlpStr + datTim.toString(".yyP");
366 }
367 else {
368 ephFileNameGPS += hlpStr + datTim.toString(".yyN");
369 }
370
371 if (_ephFileNameGPS == ephFileNameGPS) {
372 return;
373 }
374 else {
375 _ephFileNameGPS = ephFileNameGPS;
376 }
377
378 for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) {
379 delete _gpsEph[ii-PRN_GPS_START];
380 _gpsEph[ii-PRN_GPS_START] = 0;
381 }
382 for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) {
383 delete _glonassEph[ii-PRN_GLONASS_START];
384 _glonassEph[ii-PRN_GLONASS_START] = 0;
385 }
386 for (int ii = PRN_GALILEO_START; ii <= PRN_GALILEO_END; ii++) {
387 delete _galileoEph[ii-PRN_GALILEO_START];
388 _galileoEph[ii-PRN_GALILEO_START] = 0;
389 }
390
391 delete _ephStreamGPS;
392 delete _ephFileGPS;
393
394 QFlags<QIODevice::OpenModeFlag> appendFlagGPS;
395 QFlags<QIODevice::OpenModeFlag> appendFlagGlonass;
396 QFlags<QIODevice::OpenModeFlag> appendFlagGalileo;
397
398 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
399 QFile::exists(ephFileNameGPS) ) {
400 appendFlagGPS = QIODevice::Append;
401 }
402
403 _ephFileGPS = new QFile(ephFileNameGPS);
404 _ephFileGPS->open(QIODevice::WriteOnly | appendFlagGPS);
405 _ephStreamGPS = new QTextStream();
406 _ephStreamGPS->setDevice(_ephFileGPS);
407
408 if (_rinexVers == 3) {
409 _ephFileGlonass = _ephFileGPS;
410 _ephStreamGlonass = _ephStreamGPS;
411 _ephFileGalileo = _ephFileGPS;
412 _ephStreamGalileo = _ephStreamGPS;
413 }
414 else if (_rinexVers == 2) {
415 QString ephFileNameGlonass = _ephPath + "BRDC" +
416 QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +
417 hlpStr + datTim.toString(".yyG");
418
419 delete _ephStreamGlonass;
420 delete _ephFileGlonass;
421
422 if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
423 QFile::exists(ephFileNameGlonass) ) {
424 appendFlagGlonass = QIODevice::Append;
425 }
426
427 _ephFileGlonass = new QFile(ephFileNameGlonass);
428 _ephFileGlonass->open(QIODevice::WriteOnly | appendFlagGlonass);
429 _ephStreamGlonass = new QTextStream();
430 _ephStreamGlonass->setDevice(_ephFileGlonass);
431 }
432
433 // Header - RINEX Version 3
434 // ------------------------
435 if (_rinexVers == 3) {
436 if ( ! (appendFlagGPS & QIODevice::Append)) {
437 QString line;
438 line.sprintf(
439 "%9.2f%11sN: GNSS NAV DATA M: Mixed%12sRINEX VERSION / TYPE\n",
440 3.0, "", "");
441 *_ephStreamGPS << line;
442
443 QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
444 *_ephStreamGPS << _pgmName.toAscii().data()
445 << _userName.toAscii().data()
446 << hlp.toAscii().data()
447 << "PGM / RUN BY / DATE" << endl;
448
449 line.sprintf("%60sEND OF HEADER\n", "");
450 *_ephStreamGPS << line;
451
452 _ephStreamGPS->flush();
453 }
454 }
455
456 // Headers - RINEX Version 2
457 // -------------------------
458 else if (_rinexVers == 2) {
459 if (! (appendFlagGPS & QIODevice::Append)) {
460 QString line;
461 line.sprintf("%9.2f%11sN: GPS NAV DATA%25sRINEX VERSION / TYPE\n",
462 t_rnxNavFile::defaultRnxNavVersion2, "", "");
463 *_ephStreamGPS << line;
464
465 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
466 *_ephStreamGPS << _pgmName.toAscii().data()
467 << _userName.toAscii().data()
468 << hlp.toAscii().data()
469 << "PGM / RUN BY / DATE" << endl;
470
471 line.sprintf("%60sEND OF HEADER\n", "");
472 *_ephStreamGPS << line;
473
474 _ephStreamGPS->flush();
475 }
476 if (! (appendFlagGlonass & QIODevice::Append)) {
477 QString line;
478 line.sprintf("%9.2f%11sG: GLONASS NAV DATA%21sRINEX VERSION / TYPE\n",
479 t_rnxNavFile::defaultRnxNavVersion2, "", "");
480 *_ephStreamGlonass << line;
481
482 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
483 *_ephStreamGlonass << _pgmName.toAscii().data()
484 << _userName.toAscii().data()
485 << hlp.toAscii().data()
486 << "PGM / RUN BY / DATE" << endl;
487
488 line.sprintf("%60sEND OF HEADER\n", "");
489 *_ephStreamGlonass << line;
490
491 _ephStreamGlonass->flush();
492 }
493 }
494 }
495}
496
497// Print One GPS Ephemeris
498////////////////////////////////////////////////////////////////////////////
499void t_bncCore::printGPSEph(gpsephemeris* ep, bool printFile) {
500
501 t_ephGPS eph;
502 eph.set(ep);
503
504 QString strV2 = eph.toString(t_rnxNavFile::defaultRnxNavVersion2);
505 QString strV3 = eph.toString(t_rnxObsHeader::defaultRnxObsVersion3);
506
507 printOutput(printFile, _ephStreamGPS, strV2, strV3);
508}
509
510// Print One Glonass Ephemeris
511////////////////////////////////////////////////////////////////////////////
512void t_bncCore::printGlonassEph(glonassephemeris* ep, bool printFile, const QString& /* staID */) {
513
514 t_ephGlo eph;
515 eph.set(ep);
516
517 QString strV2 = eph.toString(t_rnxNavFile::defaultRnxNavVersion2);
518 QString strV3 = eph.toString(t_rnxObsHeader::defaultRnxObsVersion3);
519
520 //// beg test Dirk
521 // QString hlp = strV2;
522 // cout << hlp.replace('\n', ' ').toAscii().data() << ' ' << staID.toAscii().data() << endl;
523 //// end test Dirk
524
525 printOutput(printFile, _ephStreamGlonass, strV2, strV3);
526}
527
528// Print One Galileo Ephemeris
529////////////////////////////////////////////////////////////////////////////
530void t_bncCore::printGalileoEph(galileoephemeris* ep, bool printFile) {
531
532 t_ephGal eph;
533 eph.set(ep);
534
535 QString strV2 = eph.toString(t_rnxNavFile::defaultRnxNavVersion2);
536 QString strV3 = eph.toString(t_rnxObsHeader::defaultRnxObsVersion3);
537
538 printOutput(printFile, _ephStreamGalileo, strV2, strV3);
539}
540
541// Output
542////////////////////////////////////////////////////////////////////////////
543void t_bncCore::printOutput(bool printFile, QTextStream* stream,
544 const QString& strV2, const QString& strV3) {
545
546 // Output into file
547 // ----------------
548 if (printFile && stream) {
549 if (_rinexVers == 2) {
550 *stream << strV2.toAscii();
551 }
552 else {
553 *stream << strV3.toAscii();
554 }
555 stream->flush();
556 }
557
558 // Output into the socket
559 // ----------------------
560 if (_sockets) {
561 QMutableListIterator<QTcpSocket*> is(*_sockets);
562 while (is.hasNext()) {
563 QTcpSocket* sock = is.next();
564 if (sock->state() == QAbstractSocket::ConnectedState) {
565 if (sock->write(strV3.toAscii()) == -1) {
566 delete sock;
567 is.remove();
568 }
569 }
570 else if (sock->state() != QAbstractSocket::ConnectingState) {
571 delete sock;
572 is.remove();
573 }
574 }
575 }
576}
577
578// Set Port Number
579////////////////////////////////////////////////////////////////////////////
580void t_bncCore::setPort(int port) {
581 _port = port;
582 if (_port != 0) {
583 delete _server;
584 _server = new QTcpServer;
585 if ( !_server->listen(QHostAddress::Any, _port) ) {
586 slotMessage("t_bncCore: Cannot listen on ephemeris port", true);
587 }
588 connect(_server, SIGNAL(newConnection()), this, SLOT(slotNewConnection()));
589 delete _sockets;
590 _sockets = new QList<QTcpSocket*>;
591 }
592}
593
594// Set Port Number
595////////////////////////////////////////////////////////////////////////////
596void t_bncCore::setPortCorr(int port) {
597 _portCorr = port;
598 if (_portCorr != 0) {
599 delete _serverCorr;
600 _serverCorr = new QTcpServer;
601 if ( !_serverCorr->listen(QHostAddress::Any, _portCorr) ) {
602 slotMessage("t_bncCore: Cannot listen on correction port", true);
603 }
604 connect(_serverCorr, SIGNAL(newConnection()), this, SLOT(slotNewConnectionCorr()));
605 delete _socketsCorr;
606 _socketsCorr = new QList<QTcpSocket*>;
607 }
608}
609
610// New Connection
611////////////////////////////////////////////////////////////////////////////
612void t_bncCore::slotNewConnection() {
613 _sockets->push_back( _server->nextPendingConnection() );
614}
615
616// New Connection
617////////////////////////////////////////////////////////////////////////////
618void t_bncCore::slotNewConnectionCorr() {
619 _socketsCorr->push_back( _serverCorr->nextPendingConnection() );
620}
621
622//
623////////////////////////////////////////////////////////////////////////////
624void t_bncCore::slotQuit() {
625 delete _caster; _caster = 0;
626 qApp->quit();
627}
628
629//
630////////////////////////////////////////////////////////////////////////////
631void t_bncCore::slotNewOrbCorrections(QList<t_orbCorr> orbCorrections) {
632 QMutexLocker locker(&_mutex);
633 emit newOrbCorrections(orbCorrections);
634 if (_socketsCorr) {
635 QListIterator<t_orbCorr> it(orbCorrections);
636 while (it.hasNext()) {
637 const t_orbCorr& corr = it.next();
638 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
639 while (is.hasNext()) {
640 QTcpSocket* sock = is.next();
641 if (sock->state() == QAbstractSocket::ConnectedState) {
642 if (sock->write(corr.toString().c_str()) == -1) {
643 delete sock;
644 is.remove();
645 }
646 }
647 else if (sock->state() != QAbstractSocket::ConnectingState) {
648 delete sock;
649 is.remove();
650 }
651 }
652 }
653 }
654}
655
656//
657////////////////////////////////////////////////////////////////////////////
658void t_bncCore::slotNewClkCorrections(QList<t_clkCorr> clkCorrections) {
659 QMutexLocker locker(&_mutex);
660 emit newClkCorrections(clkCorrections);
661 if (_socketsCorr) {
662 QListIterator<t_clkCorr> it(clkCorrections);
663 while (it.hasNext()) {
664 const t_clkCorr& corr = it.next();
665 QMutableListIterator<QTcpSocket*> is(*_socketsCorr);
666 while (is.hasNext()) {
667 QTcpSocket* sock = is.next();
668 if (sock->state() == QAbstractSocket::ConnectedState) {
669 if (sock->write(corr.toString().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//
684////////////////////////////////////////////////////////////////////////////
685void t_bncCore::setConfFileName(const QString& confFileName) {
686 if (confFileName.isEmpty()) {
687 _confFileName = QDir::homePath() + QDir::separator()
688 + ".config" + QDir::separator()
689 + qApp->organizationName() + QDir::separator()
690 + qApp->applicationName() + ".bnc";
691 }
692 else {
693 _confFileName = confFileName;
694 }
695}
696
697// Raw Output
698////////////////////////////////////////////////////////////////////////////
699void t_bncCore::writeRawData(const QByteArray& data, const QByteArray& staID,
700 const QByteArray& format) {
701
702 QMutexLocker locker(&_mutex);
703
704 if (!_rawFile) {
705 bncSettings settings;
706 QByteArray fileName = settings.value("rawOutFile").toByteArray();
707 if (!fileName.isEmpty()) {
708 _rawFile = new bncRawFile(fileName, staID, bncRawFile::output);
709 }
710 }
711
712 if (_rawFile) {
713 _rawFile->writeRawData(data, staID, format);
714 }
715}
716
717//
718////////////////////////////////////////////////////////////////////////////
719void t_bncCore::initCombination() {
720#ifdef USE_COMBINATION
721 _bncComb = new bncComb();
722 if (_bncComb->nStreams() < 1) {
723 delete _bncComb;
724 _bncComb = 0;
725 }
726#endif
727}
728
729//
730////////////////////////////////////////////////////////////////////////////
731void t_bncCore::stopCombination() {
732#ifdef USE_COMBINATION
733 delete _bncComb;
734 _bncComb = 0;
735#endif
736}
737
738// Check Ephemeris Consistency
739////////////////////////////////////////////////////////////////////////////
740void t_bncCore::checkEphemeris(gpsephemeris* oldEph, gpsephemeris* newEph) {
741 if (oldEph->clock_bias != newEph->clock_bias ||
742 oldEph->clock_drift != newEph->clock_drift ||
743 oldEph->clock_driftrate != newEph->clock_driftrate) {
744 QString msg = currentDateAndTimeGPS().toString(Qt::ISODate) +
745 QString(" %1 EPH DIFFERS\n").arg(oldEph->satellite);
746 messagePrivate(msg.toAscii());
747 }
748}
749
750
751//
752////////////////////////////////////////////////////////////////////////////
753bool t_bncCore::dateAndTimeGPSSet() const {
754 QMutexLocker locker(&_mutexDateAndTimeGPS);
755 if (_dateAndTimeGPS) {
756 return true;
757 }
758 else {
759 return false;
760 }
761}
762
763//
764////////////////////////////////////////////////////////////////////////////
765QDateTime t_bncCore::dateAndTimeGPS() const {
766 QMutexLocker locker(&_mutexDateAndTimeGPS);
767 if (_dateAndTimeGPS) {
768 return *_dateAndTimeGPS;
769 }
770 else {
771 return QDateTime();
772 }
773}
774
775//
776////////////////////////////////////////////////////////////////////////////
777void t_bncCore::setDateAndTimeGPS(QDateTime dateTime) {
778 QMutexLocker locker(&_mutexDateAndTimeGPS);
779 delete _dateAndTimeGPS;
780 _dateAndTimeGPS = new QDateTime(dateTime);
781}
782
783//
784////////////////////////////////////////////////////////////////////////////
785void t_bncCore::startPPP() {
786 _pppMain->start();
787}
788
789//
790////////////////////////////////////////////////////////////////////////////
791void t_bncCore::stopPPP() {
792 _pppMain->stop();
793 emit stopRinexPPP();
794}
Note: See TracBrowser for help on using the repository browser.