source: ntrip/trunk/BNC/bncephuser.cpp@ 3053

Last change on this file since 3053 was 3012, checked in by mervart, 14 years ago
File size: 6.6 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}
96
97//
98////////////////////////////////////////////////////////////////////////////
99void bncEphUser::slotNewEphGlonass(glonassephemeris gloeph) {
100 QMutexLocker locker(&_mutex);
101
102 QString prn = QString("R%1").arg(gloeph.almanac_number, 2, 10, QChar('0'));
103
104 if (_eph.contains(prn)) {
105 int ww = gloeph.GPSWeek;
106 int tow = gloeph.GPSTOW;
107 updatetime(&ww, &tow, gloeph.tb*1000, 0); // Moscow -> GPS
108 t_ephGlo* eLast = static_cast<t_ephGlo*>(_eph.value(prn)->last);
109 if (eLast->GPSweek() < ww ||
110 (eLast->GPSweek() == ww && eLast->GPSweeks() < tow)) {
111 delete static_cast<t_ephGlo*>(_eph.value(prn)->prev);
112 _eph.value(prn)->prev = _eph.value(prn)->last;
113 _eph.value(prn)->last = new t_ephGlo();
114 static_cast<t_ephGlo*>(_eph.value(prn)->last)->set(&gloeph);
115 }
116 }
117 else {
118 t_ephGlo* eLast = new t_ephGlo();
119 eLast->set(&gloeph);
120 _eph.insert(prn, new t_ephPair(eLast));
121 }
122}
123
124//
125////////////////////////////////////////////////////////////////////////////
126void bncEphUser::slotNewEphGalileo(galileoephemeris galeph) {
127 QMutexLocker locker(&_mutex);
128
129 QString prn = QString("E%1").arg(galeph.satellite, 2, 10, QChar('0'));
130
131 if (_eph.contains(prn)) {
132 t_ephGal* eLast = static_cast<t_ephGal*>(_eph.value(prn)->last);
133 if ( (eLast->GPSweek() < galeph.Week) ||
134 (eLast->GPSweek() == galeph.Week &&
135 eLast->TOC() < galeph.TOC) ) {
136 delete static_cast<t_ephGal*>(_eph.value(prn)->prev);
137 _eph.value(prn)->prev = _eph.value(prn)->last;
138 _eph.value(prn)->last = new t_ephGal();
139 static_cast<t_ephGal*>(_eph.value(prn)->last)->set(&galeph);
140 }
141 }
142 else {
143 t_ephGal* eLast = new t_ephGal();
144 eLast->set(&galeph);
145 _eph.insert(prn, new t_ephPair(eLast));
146 }
147}
148
149//
150////////////////////////////////////////////////////////////////////////////
151t_irc t_corr::readLine(const QString& line) {
152
153 if (line[0] == '!') {
154 return failure;
155 }
156
157 QTextStream in(line.toAscii());
158
159 int messageType;
160 in >> messageType;
161
162 if (!relevantMessageType(messageType)) {
163 return failure;
164 }
165
166 int updateInterval;
167 int GPSweek;
168 double GPSweeks;
169 in >> updateInterval >> GPSweek >> GPSweeks >> prn;
170
171 tt.set(GPSweek, GPSweeks);
172
173 if ( messageType == COTYPE_GPSCOMBINED ||
174 messageType == COTYPE_GLONASSCOMBINED ) {
175 rao.ReSize(3); rao = 0.0;
176 dotRao.ReSize(3); dotRao = 0.0;
177 dotDotRao.ReSize(3); dotDotRao = 0.0;
178 dClk = 0.0;
179 dotDClk = 0.0;
180 dotDotDClk = 0.0;
181 in >> iod
182 >> dClk >> rao[0] >> rao[1] >> rao[2]
183 >> dotDClk >> dotRao[0] >> dotRao[1] >> dotRao[2]
184 >> dotDotDClk >> dotDotRao[0] >> dotDotRao[1] >> dotDotRao[2];
185 dClk /= t_CST::c;
186 dotDClk /= t_CST::c;
187 dotDotDClk /= t_CST::c;
188 raoSet = true;
189 dClkSet = true;
190 }
191 else if ( messageType == COTYPE_GPSORBIT ||
192 messageType == COTYPE_GLONASSORBIT ) {
193 rao.ReSize(3); rao = 0.0;
194 dotRao.ReSize(3); dotRao = 0.0;
195 dotDotRao.ReSize(3); dotDotRao = 0.0;
196 in >> iod
197 >> rao[0] >> rao[1] >> rao[2]
198 >> dotRao[0] >> dotRao[1] >> dotRao[2]
199 >> dotDotRao[0] >> dotDotRao[1] >> dotDotRao[2];
200 raoSet = true;
201 }
202 else if ( messageType == COTYPE_GPSCLOCK ||
203 messageType == COTYPE_GLONASSCLOCK ) {
204 int dummyIOD;
205 dClk = 0.0;
206 dotDClk = 0.0;
207 dotDotDClk = 0.0;
208 in >> dummyIOD >> dClk >> dotDClk >> dotDotDClk;
209 dClk /= t_CST::c;
210 dotDClk /= t_CST::c;
211 dotDotDClk /= t_CST::c;
212 dClkSet = true;
213 }
214
215 return success;
216}
Note: See TracBrowser for help on using the repository browser.