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