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

Last change on this file since 2907 was 2907, checked in by mervart, 13 years ago
File size: 5.0 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 cout << "newEph " << prn.toAscii().data() << endl;
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);
95 _eph.insert(prn, new t_ephPair());
96 _eph[prn]->last = eLast;
97 }
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 cout << "newEph " << prn.toAscii().data() << endl;
108
109 if (_eph.contains(prn)) {
110 int ww = gloeph.GPSWeek;
111 int tow = gloeph.GPSTOW;
112 updatetime(&ww, &tow, gloeph.tb*1000, 0); // Moscow -> GPS
113 t_ephGlo* eLast = static_cast<t_ephGlo*>(_eph.value(prn)->last);
114 if (eLast->GPSweek() < ww ||
115 (eLast->GPSweek() == ww && eLast->GPSweeks() < tow)) {
116 delete static_cast<t_ephGlo*>(_eph.value(prn)->prev);
117 _eph.value(prn)->prev = _eph.value(prn)->last;
118 _eph.value(prn)->last = new t_ephGlo();
119 static_cast<t_ephGlo*>(_eph.value(prn)->last)->set(&gloeph);
120 }
121 }
122 else {
123 t_ephGlo* eLast = new t_ephGlo();
124 eLast->set(&gloeph);
125 _eph.insert(prn, new t_ephPair());
126 _eph[prn]->last = eLast;
127 }
128}
129
130//
131////////////////////////////////////////////////////////////////////////////
132void bncEphUser::slotNewEphGalileo(galileoephemeris galeph) {
133 QMutexLocker locker(&_mutex);
134
135 QString prn = QString("E%1").arg(galeph.satellite, 2, 10, QChar('0'));
136
137 cout << "newEph " << prn.toAscii().data() << endl;
138
139 if (_eph.contains(prn)) {
140 t_ephGal* eLast = static_cast<t_ephGal*>(_eph.value(prn)->last);
141 if ( (eLast->GPSweek() < galeph.Week) ||
142 (eLast->GPSweek() == galeph.Week &&
143 eLast->TOC() < galeph.TOC) ) {
144 delete static_cast<t_ephGal*>(_eph.value(prn)->prev);
145 _eph.value(prn)->prev = _eph.value(prn)->last;
146 _eph.value(prn)->last = new t_ephGal();
147 static_cast<t_ephGal*>(_eph.value(prn)->last)->set(&galeph);
148 }
149 }
150 else {
151 t_ephGal* eLast = new t_ephGal();
152 eLast->set(&galeph);
153 _eph.insert(prn, new t_ephPair());
154 _eph[prn]->last = eLast;
155 }
156}
Note: See TracBrowser for help on using the repository browser.