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: bncEphUser
|
---|
30 | *
|
---|
31 | * Purpose: Base for Classes that use Ephemerides
|
---|
32 | *
|
---|
33 | * Author: L. Mervart
|
---|
34 | *
|
---|
35 | * Created: 27-Jan-2011
|
---|
36 | *
|
---|
37 | * Changes:
|
---|
38 | *
|
---|
39 | * -----------------------------------------------------------------------*/
|
---|
40 |
|
---|
41 | #include <iostream>
|
---|
42 |
|
---|
43 | #include "bncephuser.h"
|
---|
44 | #include "bncapp.h"
|
---|
45 |
|
---|
46 | using namespace std;
|
---|
47 |
|
---|
48 | // Constructor
|
---|
49 | ////////////////////////////////////////////////////////////////////////////
|
---|
50 | bncEphUser::bncEphUser() {
|
---|
51 |
|
---|
52 | connect(((bncApp*)qApp), SIGNAL(newEphGPS(gpsephemeris)),
|
---|
53 | this, SLOT(slotNewEphGPS(gpsephemeris)));
|
---|
54 |
|
---|
55 | connect(((bncApp*)qApp), SIGNAL(newEphGlonass(glonassephemeris)),
|
---|
56 | this, SLOT(slotNewEphGlonass(glonassephemeris)));
|
---|
57 |
|
---|
58 | connect(((bncApp*)qApp), SIGNAL(newEphGalileo(galileoephemeris)),
|
---|
59 | this, SLOT(slotNewEphGalileo(galileoephemeris)));
|
---|
60 | }
|
---|
61 |
|
---|
62 | // Destructor
|
---|
63 | ////////////////////////////////////////////////////////////////////////////
|
---|
64 | bncEphUser::~bncEphUser() {
|
---|
65 | QMapIterator<QString, t_ephPair*> it(_eph);
|
---|
66 | while (it.hasNext()) {
|
---|
67 | it.next();
|
---|
68 | delete it.value();
|
---|
69 | }
|
---|
70 | }
|
---|
71 |
|
---|
72 | //
|
---|
73 | ////////////////////////////////////////////////////////////////////////////
|
---|
74 | void bncEphUser::slotNewEphGPS(gpsephemeris gpseph) {
|
---|
75 | QMutexLocker locker(&_mutex);
|
---|
76 |
|
---|
77 | QString prn = QString("G%1").arg(gpseph.satellite, 2, 10, QChar('0'));
|
---|
78 |
|
---|
79 | if (_eph.contains(prn)) {
|
---|
80 | t_ephGPS* eLast = static_cast<t_ephGPS*>(_eph.value(prn)->last);
|
---|
81 | if ( (eLast->GPSweek() < gpseph.GPSweek) ||
|
---|
82 | (eLast->GPSweek() == gpseph.GPSweek &&
|
---|
83 | eLast->TOC() < gpseph.TOC) ) {
|
---|
84 | delete static_cast<t_ephGPS*>(_eph.value(prn)->prev);
|
---|
85 | _eph.value(prn)->prev = _eph.value(prn)->last;
|
---|
86 | _eph.value(prn)->last = new t_ephGPS();
|
---|
87 | static_cast<t_ephGPS*>(_eph.value(prn)->last)->set(&gpseph);
|
---|
88 | }
|
---|
89 | }
|
---|
90 | else {
|
---|
91 | t_ephGPS* eLast = new t_ephGPS();
|
---|
92 | eLast->set(&gpseph);
|
---|
93 | _eph.insert(prn, new t_ephPair(eLast));
|
---|
94 | }
|
---|
95 | ephBufferChanged();
|
---|
96 | }
|
---|
97 |
|
---|
98 | //
|
---|
99 | ////////////////////////////////////////////////////////////////////////////
|
---|
100 | void bncEphUser::slotNewEphGlonass(glonassephemeris gloeph) {
|
---|
101 | QMutexLocker locker(&_mutex);
|
---|
102 |
|
---|
103 | QString prn = QString("R%1").arg(gloeph.almanac_number, 2, 10, QChar('0'));
|
---|
104 |
|
---|
105 | if (_eph.contains(prn)) {
|
---|
106 | int ww = gloeph.GPSWeek;
|
---|
107 | int tow = gloeph.GPSTOW;
|
---|
108 | updatetime(&ww, &tow, gloeph.tb*1000, 0); // Moscow -> GPS
|
---|
109 | t_ephGlo* eLast = static_cast<t_ephGlo*>(_eph.value(prn)->last);
|
---|
110 | if (eLast->GPSweek() < ww ||
|
---|
111 | (eLast->GPSweek() == ww && eLast->GPSweeks() < tow)) {
|
---|
112 | delete static_cast<t_ephGlo*>(_eph.value(prn)->prev);
|
---|
113 | _eph.value(prn)->prev = _eph.value(prn)->last;
|
---|
114 | _eph.value(prn)->last = new t_ephGlo();
|
---|
115 | static_cast<t_ephGlo*>(_eph.value(prn)->last)->set(&gloeph);
|
---|
116 | }
|
---|
117 | }
|
---|
118 | else {
|
---|
119 | t_ephGlo* eLast = new t_ephGlo();
|
---|
120 | eLast->set(&gloeph);
|
---|
121 | _eph.insert(prn, new t_ephPair(eLast));
|
---|
122 | }
|
---|
123 | ephBufferChanged();
|
---|
124 | }
|
---|
125 |
|
---|
126 | //
|
---|
127 | ////////////////////////////////////////////////////////////////////////////
|
---|
128 | void bncEphUser::slotNewEphGalileo(galileoephemeris galeph) {
|
---|
129 | QMutexLocker locker(&_mutex);
|
---|
130 |
|
---|
131 | QString prn = QString("E%1").arg(galeph.satellite, 2, 10, QChar('0'));
|
---|
132 |
|
---|
133 | if (_eph.contains(prn)) {
|
---|
134 | t_ephGal* eLast = static_cast<t_ephGal*>(_eph.value(prn)->last);
|
---|
135 | if ( (eLast->GPSweek() < galeph.Week) ||
|
---|
136 | (eLast->GPSweek() == galeph.Week &&
|
---|
137 | eLast->TOC() < galeph.TOC) ) {
|
---|
138 | delete static_cast<t_ephGal*>(_eph.value(prn)->prev);
|
---|
139 | _eph.value(prn)->prev = _eph.value(prn)->last;
|
---|
140 | _eph.value(prn)->last = new t_ephGal();
|
---|
141 | static_cast<t_ephGal*>(_eph.value(prn)->last)->set(&galeph);
|
---|
142 | }
|
---|
143 | }
|
---|
144 | else {
|
---|
145 | t_ephGal* eLast = new t_ephGal();
|
---|
146 | eLast->set(&galeph);
|
---|
147 | _eph.insert(prn, new t_ephPair(eLast));
|
---|
148 | }
|
---|
149 | ephBufferChanged();
|
---|
150 | }
|
---|
151 |
|
---|
152 | //
|
---|
153 | ////////////////////////////////////////////////////////////////////////////
|
---|
154 | t_irc t_corr::readLine(const QString& line) {
|
---|
155 |
|
---|
156 | if (line[0] == '!') {
|
---|
157 | return failure;
|
---|
158 | }
|
---|
159 |
|
---|
160 | QTextStream in(line.toAscii());
|
---|
161 |
|
---|
162 | int messageType;
|
---|
163 | in >> messageType;
|
---|
164 |
|
---|
165 | if (!relevantMessageType(messageType)) {
|
---|
166 | return failure;
|
---|
167 | }
|
---|
168 |
|
---|
169 | if (messageType < 0) {
|
---|
170 | messageType = -messageType;
|
---|
171 | xyzCorr = true; // correction in xyz instead of rao
|
---|
172 | }
|
---|
173 |
|
---|
174 | int updateInterval;
|
---|
175 | int GPSweek;
|
---|
176 | double GPSweeks;
|
---|
177 | in >> updateInterval >> GPSweek >> GPSweeks >> prn;
|
---|
178 |
|
---|
179 | tt.set(GPSweek, GPSweeks);
|
---|
180 |
|
---|
181 | if ( messageType == COTYPE_GPSCOMBINED ||
|
---|
182 | messageType == COTYPE_GLONASSCOMBINED ) {
|
---|
183 | rao.ReSize(3); rao = 0.0;
|
---|
184 | dotRao.ReSize(3); dotRao = 0.0;
|
---|
185 | dotDotRao.ReSize(3); dotDotRao = 0.0;
|
---|
186 | dClk = 0.0;
|
---|
187 | dotDClk = 0.0;
|
---|
188 | dotDotDClk = 0.0;
|
---|
189 | in >> iod
|
---|
190 | >> dClk >> rao[0] >> rao[1] >> rao[2]
|
---|
191 | >> dotDClk >> dotRao[0] >> dotRao[1] >> dotRao[2]
|
---|
192 | >> dotDotDClk >> dotDotRao[0] >> dotDotRao[1] >> dotDotRao[2];
|
---|
193 | dClk /= t_CST::c;
|
---|
194 | dotDClk /= t_CST::c;
|
---|
195 | dotDotDClk /= t_CST::c;
|
---|
196 | raoSet = true;
|
---|
197 | dClkSet = true;
|
---|
198 | }
|
---|
199 | else if ( messageType == COTYPE_GPSORBIT ||
|
---|
200 | messageType == COTYPE_GLONASSORBIT ) {
|
---|
201 | rao.ReSize(3); rao = 0.0;
|
---|
202 | dotRao.ReSize(3); dotRao = 0.0;
|
---|
203 | dotDotRao.ReSize(3); dotDotRao = 0.0;
|
---|
204 | in >> iod
|
---|
205 | >> rao[0] >> rao[1] >> rao[2]
|
---|
206 | >> dotRao[0] >> dotRao[1] >> dotRao[2]
|
---|
207 | >> dotDotRao[0] >> dotDotRao[1] >> dotDotRao[2];
|
---|
208 | raoSet = true;
|
---|
209 | }
|
---|
210 | else if ( messageType == COTYPE_GPSCLOCK ||
|
---|
211 | messageType == COTYPE_GLONASSCLOCK ) {
|
---|
212 | int dummyIOD;
|
---|
213 | dClk = 0.0;
|
---|
214 | dotDClk = 0.0;
|
---|
215 | dotDotDClk = 0.0;
|
---|
216 | in >> dummyIOD >> dClk >> dotDClk >> dotDotDClk;
|
---|
217 | dClk /= t_CST::c;
|
---|
218 | dotDClk /= t_CST::c;
|
---|
219 | dotDotDClk /= t_CST::c;
|
---|
220 | dClkSet = true;
|
---|
221 | }
|
---|
222 | else if ( messageType == COTYPE_GPSHR ||
|
---|
223 | messageType == COTYPE_GLONASSHR ) {
|
---|
224 | int dummyIOD;
|
---|
225 | in >> dummyIOD >> hrClk;
|
---|
226 | hrClk /= t_CST::c;
|
---|
227 | }
|
---|
228 |
|
---|
229 | return success;
|
---|
230 | }
|
---|