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

Last change on this file since 8184 was 8127, checked in by stoecker, 8 years ago

update qwt and qwtpolar, many QT5 fixes (unfinished)

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