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

Last change on this file since 9322 was 9219, checked in by stuerze, 4 years ago

minor changes

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