[280] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
[464] | 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
[280] | 3 | //
|
---|
[464] | 4 | // Copyright (C) 2007
|
---|
[280] | 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
[464] | 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
[280] | 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.
|
---|
[82] | 24 |
|
---|
| 25 | /* -------------------------------------------------------------------------
|
---|
[93] | 26 | * BKG NTRIP Client
|
---|
[82] | 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>
|
---|
[149] | 42 | #include <QSettings>
|
---|
[150] | 43 | #include <QMessageBox>
|
---|
[82] | 44 |
|
---|
| 45 | #include "bncapp.h"
|
---|
[151] | 46 | #include "bncutils.h"
|
---|
[82] | 47 |
|
---|
| 48 | using namespace std;
|
---|
| 49 |
|
---|
| 50 | // Constructor
|
---|
| 51 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 52 | bncApp::bncApp(int argc, char* argv[], bool GUIenabled) :
|
---|
| 53 | QApplication(argc, argv, GUIenabled) {
|
---|
[109] | 54 |
|
---|
[150] | 55 | _logFileFlag = 0;
|
---|
| 56 | _logFile = 0;
|
---|
| 57 | _logStream = 0;
|
---|
[152] | 58 |
|
---|
[476] | 59 | _bncVersion = "BNC 1.4";
|
---|
[516] | 60 | // Lists of Ephemeris
|
---|
| 61 | // ------------------
|
---|
| 62 | _ephFile = 0;
|
---|
| 63 | _ephStream = 0;
|
---|
| 64 | for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) {
|
---|
| 65 | _gpsEph[ii-PRN_GPS_START] = 0;
|
---|
| 66 | }
|
---|
| 67 | for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) {
|
---|
| 68 | _glonassEph[ii-PRN_GLONASS_START] = 0;
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | // Eph file
|
---|
| 72 | // --------
|
---|
| 73 | _ephFile = 0;
|
---|
| 74 | _ephStream = 0;
|
---|
| 75 | QString ephFileName = "TEST.EPH";
|
---|
| 76 | //// QString ephFileName = settings.value("ephFile").toString();
|
---|
| 77 | if ( !ephFileName.isEmpty() ) {
|
---|
| 78 | expandEnvVar(ephFileName);
|
---|
| 79 | _ephFile = new QFile(ephFileName);
|
---|
| 80 | _ephFile->open(QIODevice::WriteOnly);
|
---|
| 81 | _ephStream = new QTextStream();
|
---|
| 82 | _ephStream->setDevice(_ephFile);
|
---|
| 83 | printEphHeader();
|
---|
| 84 | }
|
---|
[82] | 85 | }
|
---|
| 86 |
|
---|
| 87 | // Destructor
|
---|
| 88 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 89 | bncApp::~bncApp() {
|
---|
[109] | 90 | delete _logStream;
|
---|
| 91 | delete _logFile;
|
---|
[516] | 92 | delete _ephStream;
|
---|
| 93 | delete _ephFile;
|
---|
| 94 | for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) {
|
---|
| 95 | delete _gpsEph[ii-PRN_GPS_START];
|
---|
| 96 | }
|
---|
| 97 | for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) {
|
---|
| 98 | delete _glonassEph[ii-PRN_GLONASS_START];
|
---|
| 99 | }
|
---|
[82] | 100 | }
|
---|
| 101 |
|
---|
| 102 | // Write a Program Message
|
---|
| 103 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 104 | void bncApp::slotMessage(const QByteArray msg) {
|
---|
[150] | 105 |
|
---|
[243] | 106 | QMutexLocker locker(&_mutex);
|
---|
| 107 |
|
---|
[150] | 108 | // First time resolve the log file name
|
---|
| 109 | // ------------------------------------
|
---|
| 110 | if (_logFileFlag == 0) {
|
---|
| 111 | _logFileFlag = 1;
|
---|
| 112 | QSettings settings;
|
---|
| 113 | QString logFileName = settings.value("logFile").toString();
|
---|
| 114 | if ( !logFileName.isEmpty() ) {
|
---|
[151] | 115 | expandEnvVar(logFileName);
|
---|
[150] | 116 | _logFile = new QFile(logFileName);
|
---|
[275] | 117 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
|
---|
| 118 | _logFile->open(QIODevice::WriteOnly | QIODevice::Append);
|
---|
| 119 | }
|
---|
| 120 | else {
|
---|
| 121 | _logFile->open(QIODevice::WriteOnly);
|
---|
| 122 | }
|
---|
[150] | 123 | _logStream = new QTextStream();
|
---|
| 124 | _logStream->setDevice(_logFile);
|
---|
| 125 | }
|
---|
| 126 | }
|
---|
| 127 |
|
---|
[109] | 128 | if (_logStream) {
|
---|
[335] | 129 | *_logStream << QDate::currentDate().toString("yy-MM-dd ").toAscii().data();
|
---|
[199] | 130 | *_logStream << QTime::currentTime().toString("hh:mm:ss ").toAscii().data();
|
---|
[109] | 131 | *_logStream << msg.data() << endl;
|
---|
| 132 | _logStream->flush();
|
---|
[82] | 133 | }
|
---|
| 134 | }
|
---|
[511] | 135 |
|
---|
| 136 | //
|
---|
| 137 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 138 | void bncApp::slotNewGPSEph(gpsephemeris* gpseph) {
|
---|
[516] | 139 |
|
---|
| 140 | QMutexLocker locker(&_mutex);
|
---|
| 141 |
|
---|
| 142 | gpsephemeris** ee = &_gpsEph[gpseph->satellite-PRN_GPS_START];
|
---|
| 143 | if ( *ee == 0 || (*ee)->IODE != gpseph->IODE ) {
|
---|
| 144 | cout << "new GPS: " << gpseph->satellite << endl;
|
---|
| 145 | delete *ee;
|
---|
| 146 | *ee = gpseph;
|
---|
| 147 | printGPSEph(gpseph);
|
---|
| 148 | }
|
---|
| 149 | else {
|
---|
| 150 | cout << "GPS: " << gpseph->satellite << endl;
|
---|
| 151 | delete gpseph;
|
---|
| 152 | }
|
---|
[511] | 153 | }
|
---|
| 154 |
|
---|
| 155 | //
|
---|
| 156 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 157 | void bncApp::slotNewGlonassEph(glonassephemeris* glonasseph) {
|
---|
[516] | 158 |
|
---|
| 159 | QMutexLocker locker(&_mutex);
|
---|
| 160 |
|
---|
[512] | 161 | cout << "GLONASS: " << glonasseph->almanac_number << endl;
|
---|
| 162 | delete glonasseph;
|
---|
[511] | 163 | }
|
---|
| 164 |
|
---|
[516] | 165 | //
|
---|
| 166 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 167 | void bncApp::printEphHeader() {
|
---|
| 168 |
|
---|
| 169 | }
|
---|
| 170 |
|
---|
| 171 | //
|
---|
| 172 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 173 | void bncApp::printGPSEph(gpsephemeris* ep) {
|
---|
| 174 |
|
---|
| 175 | }
|
---|
| 176 |
|
---|
| 177 | //
|
---|
| 178 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 179 | void bncApp::printGlonassEph(glonassephemeris* ep) {
|
---|
| 180 |
|
---|
| 181 | }
|
---|