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

Last change on this file since 6398 was 6396, checked in by mervart, 10 years ago
File size: 4.1 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 t_ephGPS* newEph = new t_ephGPS(); newEph->set(&gpseph);
81 if (putNewEph(newEph) != success) {
82 delete newEph;
83 }
84}
85
86//
87////////////////////////////////////////////////////////////////////////////
88void bncEphUser::slotNewEphGlonass(glonassephemeris gloeph) {
89 t_ephGlo* newEph = new t_ephGlo(); newEph->set(&gloeph);
90 if (putNewEph(newEph) != success) {
91 delete newEph;
92 }
93}
94
95//
96////////////////////////////////////////////////////////////////////////////
97void bncEphUser::slotNewEphGalileo(galileoephemeris galeph) {
98 t_ephGal* newEph = new t_ephGal(); newEph->set(&galeph);
99 if (putNewEph(newEph) != success) {
100 delete newEph;
101 }
102}
103
104//
105////////////////////////////////////////////////////////////////////////////
106void bncEphUser::slotNewEphSBAS(sbasephemeris sbaseph) {
107 t_ephSBAS* newEph = new t_ephSBAS(); newEph->set(&sbaseph);
108 if (putNewEph(newEph) != success) {
109 delete newEph;
110 }
111}
112
113//
114////////////////////////////////////////////////////////////////////////////
115t_irc bncEphUser::putNewEph(t_eph* newEph) {
116 QMutexLocker locker(&_mutex);
117
118 t_irc irc = failure;
119
120 if (!newEph) {
121 return irc;
122 }
123
124 QString prn(newEph->prn().toString().c_str());
125 if (_eph.contains(prn)) {
126 if (newEph->isNewerThan(_eph.value(prn)->last)) {
127 delete _eph.value(prn)->prev;
128 _eph.value(prn)->prev = _eph.value(prn)->last;
129 _eph.value(prn)->last = newEph;
130 ephBufferChanged();
131 irc = success;
132 }
133 }
134 else {
135 _eph.insert(prn, new t_ephPair(newEph));
136 ephBufferChanged();
137 irc = success;
138 }
139
140 return irc;
141}
142
Note: See TracBrowser for help on using the repository browser.