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

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