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

Last change on this file since 6435 was 6435, checked in by mervart, 9 years ago
File size: 4.5 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() {
51}
52
53// Constructor
54////////////////////////////////////////////////////////////////////////////
55bncEphUser::bncEphUser(bool connectSlots) {
56 if (connectSlots) {
57 connect(BNC_CORE, SIGNAL(newGPSEph(t_ephGPS)),
58 this, SLOT(slotNewGPSEph(t_ephGPS)), Qt::DirectConnection);
59
60 connect(BNC_CORE, SIGNAL(newGlonassEph(t_ephGlo)),
61 this, SLOT(slotNewGlonassEph(t_ephGlo)), Qt::DirectConnection);
62
63 connect(BNC_CORE, SIGNAL(newGalileoEph(t_ephGal)),
64 this, SLOT(slotNewGalileoEph(t_ephGal)), Qt::DirectConnection);
65
66 connect(BNC_CORE, SIGNAL(newSBASEph(t_ephSBAS)),
67 this, SLOT(slotNewSBASEph(t_ephSBAS)), Qt::DirectConnection);
68 }
69}
70
71// Destructor
72////////////////////////////////////////////////////////////////////////////
73bncEphUser::~bncEphUser() {
74 QMapIterator<QString, t_ephPair*> it(_eph);
75 while (it.hasNext()) {
76 it.next();
77 delete it.value();
78 }
79}
80
81// New GPS Ephemeris
82////////////////////////////////////////////////////////////////////////////
83void bncEphUser::slotNewGPSEph(t_ephGPS eph) {
84 putNewEph(&eph);
85}
86
87// New Glonass Ephemeris
88////////////////////////////////////////////////////////////////////////////
89void bncEphUser::slotNewGlonassEph(t_ephGlo eph) {
90 putNewEph(&eph);
91}
92
93// New Galileo Ephemeris
94////////////////////////////////////////////////////////////////////////////
95void bncEphUser::slotNewGalileoEph(t_ephGal eph) {
96 putNewEph(&eph);
97}
98
99// New SBAS Ephemeris
100////////////////////////////////////////////////////////////////////////////
101void bncEphUser::slotNewSBASEph(t_ephSBAS eph) {
102 putNewEph(&eph);
103}
104
105//
106////////////////////////////////////////////////////////////////////////////
107t_irc bncEphUser::putNewEph(const t_eph* eph) {
108
109 QMutexLocker locker(&_mutex);
110
111 if (eph == 0) {
112 return failure;
113 }
114
115 const t_ephGPS* ephGPS = dynamic_cast<const t_ephGPS*>(eph);
116 const t_ephGlo* ephGlo = dynamic_cast<const t_ephGlo*>(eph);
117 const t_ephGal* ephGal = dynamic_cast<const t_ephGal*>(eph);
118 const t_ephSBAS* ephSBAS = dynamic_cast<const t_ephSBAS*>(eph);
119 const t_ephCompass* ephCompass = dynamic_cast<const t_ephCompass*>(eph);
120
121 t_eph* newEph = 0;
122
123 if (ephGPS) {
124 newEph = new t_ephGPS(*ephGPS);
125 }
126 else if (ephGlo) {
127 newEph = new t_ephGlo(*ephGlo);
128 }
129 else if (ephGal) {
130 newEph = new t_ephGal(*ephGal);
131 }
132 else if (ephSBAS) {
133 newEph = new t_ephSBAS(*ephSBAS);
134 }
135 else if (ephCompass) {
136 newEph = new t_ephCompass(*ephCompass);
137 }
138 else {
139 return failure;
140 }
141
142 QString prn(newEph->prn().toString().c_str());
143
144 if (_eph.contains(prn)) {
145 if (newEph->isNewerThan(_eph.value(prn)->last)) {
146 delete _eph.value(prn)->prev;
147 _eph.value(prn)->prev = _eph.value(prn)->last;
148 _eph.value(prn)->last = newEph;
149 ephBufferChanged();
150 return success;
151 }
152 }
153 else {
154 _eph.insert(prn, new t_ephPair(newEph));
155 ephBufferChanged();
156 return success;
157 }
158
159 return failure;
160}
161
Note: See TracBrowser for help on using the repository browser.