source: ntrip/trunk/BNC/bncapp.cpp@ 4117

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