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

Last change on this file since 516 was 516, checked in by mervart, 15 years ago

* empty log message *

File size: 5.0 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 <QSettings>
43#include <QMessageBox>
44
45#include "bncapp.h"
46#include "bncutils.h"
47
48using namespace std;
49
50// Constructor
51////////////////////////////////////////////////////////////////////////////
52bncApp::bncApp(int argc, char* argv[], bool GUIenabled) :
53 QApplication(argc, argv, GUIenabled) {
54
55 _logFileFlag = 0;
56 _logFile = 0;
57 _logStream = 0;
58
59 _bncVersion = "BNC 1.4";
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 }
85}
86
87// Destructor
88////////////////////////////////////////////////////////////////////////////
89bncApp::~bncApp() {
90 delete _logStream;
91 delete _logFile;
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 }
100}
101
102// Write a Program Message
103////////////////////////////////////////////////////////////////////////////
104void bncApp::slotMessage(const QByteArray msg) {
105
106 QMutexLocker locker(&_mutex);
107
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() ) {
115 expandEnvVar(logFileName);
116 _logFile = new QFile(logFileName);
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 }
123 _logStream = new QTextStream();
124 _logStream->setDevice(_logFile);
125 }
126 }
127
128 if (_logStream) {
129 *_logStream << QDate::currentDate().toString("yy-MM-dd ").toAscii().data();
130 *_logStream << QTime::currentTime().toString("hh:mm:ss ").toAscii().data();
131 *_logStream << msg.data() << endl;
132 _logStream->flush();
133 }
134}
135
136//
137////////////////////////////////////////////////////////////////////////////
138void bncApp::slotNewGPSEph(gpsephemeris* gpseph) {
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 }
153}
154
155//
156////////////////////////////////////////////////////////////////////////////
157void bncApp::slotNewGlonassEph(glonassephemeris* glonasseph) {
158
159 QMutexLocker locker(&_mutex);
160
161 cout << "GLONASS: " << glonasseph->almanac_number << endl;
162 delete glonasseph;
163}
164
165//
166////////////////////////////////////////////////////////////////////////////
167void bncApp::printEphHeader() {
168
169}
170
171//
172////////////////////////////////////////////////////////////////////////////
173void bncApp::printGPSEph(gpsephemeris* ep) {
174
175}
176
177//
178////////////////////////////////////////////////////////////////////////////
179void bncApp::printGlonassEph(glonassephemeris* ep) {
180
181}
Note: See TracBrowser for help on using the repository browser.