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

Last change on this file since 2904 was 2904, checked in by mervart, 13 years ago
File size: 4.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 "bncephuser.h"
42#include "bncapp.h"
43
44using namespace std;
45
46// Constructor
47////////////////////////////////////////////////////////////////////////////
48bncEphUser::bncEphUser() {
49
50 connect(((bncApp*)qApp), SIGNAL(newEphGPS(gpsephemeris)),
51 this, SLOT(slotNewEphGPS(gpsephemeris)));
52
53 connect(((bncApp*)qApp), SIGNAL(newEphGlonass(glonassephemeris)),
54 this, SLOT(slotNewEphGlonass(glonassephemeris)));
55
56 connect(((bncApp*)qApp), SIGNAL(newEphGalileo(galileoephemeris)),
57 this, SLOT(slotNewEphGalileo(galileoephemeris)));
58}
59
60// Destructor
61////////////////////////////////////////////////////////////////////////////
62bncEphUser::~bncEphUser() {
63 QMapIterator<QString, t_ephPair*> it(_eph);
64 while (it.hasNext()) {
65 it.next();
66 delete it.value();
67 }
68}
69
70//
71////////////////////////////////////////////////////////////////////////////
72void bncEphUser::slotNewEphGPS(gpsephemeris gpseph) {
73 QMutexLocker locker(&_mutex);
74
75 QString prn = QString("G%1").arg(gpseph.satellite, 2, 10, QChar('0'));
76
77 if (_eph.contains(prn)) {
78 t_ephGPS* eLast = static_cast<t_ephGPS*>(_eph.value(prn)->last);
79 if ( (eLast->GPSweek() < gpseph.GPSweek) ||
80 (eLast->GPSweek() == gpseph.GPSweek &&
81 eLast->TOC() < gpseph.TOC) ) {
82 delete static_cast<t_ephGPS*>(_eph.value(prn)->prev);
83 _eph.value(prn)->prev = _eph.value(prn)->last;
84 _eph.value(prn)->last = new t_ephGPS();
85 static_cast<t_ephGPS*>(_eph.value(prn)->last)->set(&gpseph);
86 }
87 }
88 else {
89 t_ephGPS* eLast = new t_ephGPS();
90 eLast->set(&gpseph);
91 _eph.insert(prn, new t_ephPair());
92 _eph[prn]->last = eLast;
93 }
94}
95
96//
97////////////////////////////////////////////////////////////////////////////
98void bncEphUser::slotNewEphGlonass(glonassephemeris gloeph) {
99 QMutexLocker locker(&_mutex);
100
101 QString prn = QString("R%1").arg(gloeph.almanac_number, 2, 10, QChar('0'));
102
103 if (_eph.contains(prn)) {
104 int ww = gloeph.GPSWeek;
105 int tow = gloeph.GPSTOW;
106 updatetime(&ww, &tow, gloeph.tb*1000, 0); // Moscow -> GPS
107 t_ephGlo* eLast = static_cast<t_ephGlo*>(_eph.value(prn)->last);
108 if (eLast->GPSweek() < ww ||
109 (eLast->GPSweek() == ww && eLast->GPSweeks() < tow)) {
110 delete static_cast<t_ephGlo*>(_eph.value(prn)->prev);
111 _eph.value(prn)->prev = _eph.value(prn)->last;
112 _eph.value(prn)->last = new t_ephGlo();
113 static_cast<t_ephGlo*>(_eph.value(prn)->last)->set(&gloeph);
114 }
115 }
116 else {
117 t_ephGlo* eLast = new t_ephGlo();
118 eLast->set(&gloeph);
119 _eph.insert(prn, new t_ephPair());
120 _eph[prn]->last = 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());
146 _eph[prn]->last = eLast;
147 }
148}
Note: See TracBrowser for help on using the repository browser.