source: ntrip/branches/BNC_LM/bncephuser.cpp@ 6199

Last change on this file since 6199 was 3571, checked in by mervart, 13 years ago
File size: 6.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: 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
46using namespace std;
47
48// Constructor
49////////////////////////////////////////////////////////////////////////////
50bncEphUser::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////////////////////////////////////////////////////////////////////////////
64bncEphUser::~bncEphUser() {
65 QMapIterator<QString, t_ephPair*> it(_eph);
66 while (it.hasNext()) {
67 it.next();
68 delete it.value();
69 }
70}
71
72//
73////////////////////////////////////////////////////////////////////////////
74void 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////////////////////////////////////////////////////////////////////////////
100void 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////////////////////////////////////////////////////////////////////////////
128void 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////////////////////////////////////////////////////////////////////////////
154t_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 int updateInterval;
170 int GPSweek;
171 double GPSweeks;
172 in >> updateInterval >> GPSweek >> GPSweeks >> prn;
173
174 tt.set(GPSweek, GPSweeks);
175
176 if ( messageType == COTYPE_GPSCOMBINED ||
177 messageType == COTYPE_GLONASSCOMBINED ) {
178 rao.ReSize(3); rao = 0.0;
179 dotRao.ReSize(3); dotRao = 0.0;
180 dotDotRao.ReSize(3); dotDotRao = 0.0;
181 dClk = 0.0;
182 dotDClk = 0.0;
183 dotDotDClk = 0.0;
184 in >> iod
185 >> dClk >> rao[0] >> rao[1] >> rao[2]
186 >> dotDClk >> dotRao[0] >> dotRao[1] >> dotRao[2]
187 >> dotDotDClk >> dotDotRao[0] >> dotDotRao[1] >> dotDotRao[2];
188 dClk /= t_CST::c;
189 dotDClk /= t_CST::c;
190 dotDotDClk /= t_CST::c;
191 raoSet = true;
192 dClkSet = true;
193 }
194 else if ( messageType == COTYPE_GPSORBIT ||
195 messageType == COTYPE_GLONASSORBIT ) {
196 rao.ReSize(3); rao = 0.0;
197 dotRao.ReSize(3); dotRao = 0.0;
198 dotDotRao.ReSize(3); dotDotRao = 0.0;
199 in >> iod
200 >> rao[0] >> rao[1] >> rao[2]
201 >> dotRao[0] >> dotRao[1] >> dotRao[2]
202 >> dotDotRao[0] >> dotDotRao[1] >> dotDotRao[2];
203 raoSet = true;
204 }
205 else if ( messageType == COTYPE_GPSCLOCK ||
206 messageType == COTYPE_GLONASSCLOCK ) {
207 int dummyIOD;
208 dClk = 0.0;
209 dotDClk = 0.0;
210 dotDotDClk = 0.0;
211 in >> dummyIOD >> dClk >> dotDClk >> dotDotDClk;
212 dClk /= t_CST::c;
213 dotDClk /= t_CST::c;
214 dotDotDClk /= t_CST::c;
215 dClkSet = true;
216 }
217 else if ( messageType == COTYPE_GPSHR ||
218 messageType == COTYPE_GLONASSHR ) {
219 int dummyIOD;
220 in >> dummyIOD >> hrClk;
221 hrClk /= t_CST::c;
222 }
223
224 return success;
225}
Note: See TracBrowser for help on using the repository browser.