source: ntrip/trunk/BNC/src/bncephuser.cpp@ 6394

Last change on this file since 6394 was 6394, checked in by mervart, 9 years ago
File size: 4.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 "bnccore.h"
45
46using namespace std;
47
48// Constructor
49////////////////////////////////////////////////////////////////////////////
50bncEphUser::bncEphUser(bool connectSlots) {
51
52 if (connectSlots) {
53 connect(BNC_CORE, SIGNAL(newEphGPS(gpsephemeris)),
54 this, SLOT(slotNewEphGPS(gpsephemeris)), Qt::DirectConnection);
55
56 connect(BNC_CORE, SIGNAL(newEphGlonass(glonassephemeris)),
57 this, SLOT(slotNewEphGlonass(glonassephemeris)), Qt::DirectConnection);
58
59 connect(BNC_CORE, SIGNAL(newEphGalileo(galileoephemeris)),
60 this, SLOT(slotNewEphGalileo(galileoephemeris)), Qt::DirectConnection);
61
62 connect(BNC_CORE, SIGNAL(newEphSBAS(sbasephemeris)),
63 this, SLOT(slotNewEphSBAS(sbasephemeris)), Qt::DirectConnection);
64 }
65}
66
67// Destructor
68////////////////////////////////////////////////////////////////////////////
69bncEphUser::~bncEphUser() {
70 QMapIterator<QString, t_ephPair*> it(_eph);
71 while (it.hasNext()) {
72 it.next();
73 delete it.value();
74 }
75}
76
77//
78////////////////////////////////////////////////////////////////////////////
79void bncEphUser::slotNewEphGPS(gpsephemeris gpseph) {
80 QMutexLocker locker(&_mutex);
81 t_ephGPS* eNew = new t_ephGPS(); eNew->set(&gpseph);
82 newEphHlp(eNew);
83}
84
85//
86////////////////////////////////////////////////////////////////////////////
87void bncEphUser::slotNewEphGlonass(glonassephemeris gloeph) {
88 QMutexLocker locker(&_mutex);
89 t_ephGlo* eNew = new t_ephGlo(); eNew->set(&gloeph);
90 newEphHlp(eNew);
91}
92
93//
94////////////////////////////////////////////////////////////////////////////
95void bncEphUser::slotNewEphGalileo(galileoephemeris galeph) {
96 QMutexLocker locker(&_mutex);
97 t_ephGal* eNew = new t_ephGal(); eNew->set(&galeph);
98 newEphHlp(eNew);
99}
100
101//
102////////////////////////////////////////////////////////////////////////////
103void bncEphUser::slotNewEphSBAS(sbasephemeris sbaseph) {
104 QMutexLocker locker(&_mutex);
105 t_ephSBAS* eNew = new t_ephSBAS(); eNew->set(&sbaseph);
106 newEphHlp(eNew);
107}
108
109//
110////////////////////////////////////////////////////////////////////////////
111void bncEphUser::newEphHlp(t_eph* eNew) {
112 QString prn(eNew->prn().toString().c_str());
113 if (_eph.contains(prn)) {
114 if (eNew->isNewerThan(_eph.value(prn)->last)) {
115 delete _eph.value(prn)->prev;
116 _eph.value(prn)->prev = _eph.value(prn)->last;
117 _eph.value(prn)->last = eNew;
118 ephBufferChanged();
119 }
120 else {
121 delete eNew;
122 }
123 }
124 else {
125 _eph.insert(prn, new t_ephPair(eNew));
126 ephBufferChanged();
127 }
128}
129
130//
131////////////////////////////////////////////////////////////////////////////
132t_irc bncEphUser::putNewEph(t_eph* newEph) {
133
134 QMutexLocker locker(&_mutex);
135
136 if (!newEph) {
137 return failure;
138 }
139
140 QString prn(newEph->prn().toString().c_str());
141
142 t_irc irc = failure;
143
144 if (_eph.contains(prn)) {
145 t_eph* eLast = _eph.value(prn)->last;
146 if (newEph->isNewerThan(eLast)) {
147 delete _eph.value(prn)->prev;
148 _eph.value(prn)->prev = _eph.value(prn)->last;
149 _eph.value(prn)->last = newEph;
150 irc = success;
151 }
152 }
153 else {
154 _eph.insert(prn, new t_ephPair(newEph));
155 irc = success;
156 }
157
158 if (irc == success) {
159 ephBufferChanged();
160 }
161
162 return irc;
163}
Note: See TracBrowser for help on using the repository browser.