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() {
|
---|
51 | }
|
---|
52 |
|
---|
53 | // Constructor
|
---|
54 | ////////////////////////////////////////////////////////////////////////////
|
---|
55 | bncEphUser::bncEphUser(bool connectSlots) {
|
---|
56 | if (connectSlots) {
|
---|
57 | connect(BNC_CORE, SIGNAL(newEphGPS(t_ephGPS)),
|
---|
58 | this, SLOT(slotNewEphGPS(t_ephGPS)), Qt::DirectConnection);
|
---|
59 |
|
---|
60 | connect(BNC_CORE, SIGNAL(newEphGlonass(t_ephGlo)),
|
---|
61 | this, SLOT(slotNewEphGlonass(t_ephGlo)), Qt::DirectConnection);
|
---|
62 |
|
---|
63 | connect(BNC_CORE, SIGNAL(newEphGalileo(t_ephGal)),
|
---|
64 | this, SLOT(slotNewEphGalileo(t_ephGal)), Qt::DirectConnection);
|
---|
65 |
|
---|
66 | connect(BNC_CORE, SIGNAL(newEphSBAS(t_ephSBAS)),
|
---|
67 | this, SLOT(slotNewEphSBAS(t_ephSBAS)), Qt::DirectConnection);
|
---|
68 | }
|
---|
69 | }
|
---|
70 |
|
---|
71 | // Destructor
|
---|
72 | ////////////////////////////////////////////////////////////////////////////
|
---|
73 | bncEphUser::~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 | ////////////////////////////////////////////////////////////////////////////
|
---|
83 | void bncEphUser::slotNewGPSEph(t_ephGPS eph) {
|
---|
84 | putNewEph(&eph);
|
---|
85 | }
|
---|
86 |
|
---|
87 | // New Glonass Ephemeris
|
---|
88 | ////////////////////////////////////////////////////////////////////////////
|
---|
89 | void bncEphUser::slotNewGlonassEph(t_ephGlo eph) {
|
---|
90 | putNewEph(&eph);
|
---|
91 | }
|
---|
92 |
|
---|
93 | // New Galileo Ephemeris
|
---|
94 | ////////////////////////////////////////////////////////////////////////////
|
---|
95 | void bncEphUser::slotNewGalileoEph(t_ephGal eph) {
|
---|
96 | putNewEph(&eph);
|
---|
97 | }
|
---|
98 |
|
---|
99 | // New SBAS Ephemeris
|
---|
100 | ////////////////////////////////////////////////////////////////////////////
|
---|
101 | void bncEphUser::slotNewSBASEph(t_ephSBAS eph) {
|
---|
102 | putNewEph(&eph);
|
---|
103 | }
|
---|
104 |
|
---|
105 | //
|
---|
106 | ////////////////////////////////////////////////////////////////////////////
|
---|
107 | t_irc bncEphUser::putNewEph(t_eph* newEph) {
|
---|
108 | QMutexLocker locker(&_mutex);
|
---|
109 |
|
---|
110 | t_irc irc = failure;
|
---|
111 |
|
---|
112 | if (newEph == 0) {
|
---|
113 | return irc;
|
---|
114 | }
|
---|
115 |
|
---|
116 | QString prn(newEph->prn().toString().c_str());
|
---|
117 | if (_eph.contains(prn)) {
|
---|
118 | if (newEph->isNewerThan(_eph.value(prn)->last)) {
|
---|
119 | delete _eph.value(prn)->prev;
|
---|
120 | _eph.value(prn)->prev = _eph.value(prn)->last;
|
---|
121 | _eph.value(prn)->last = newEph;
|
---|
122 | ephBufferChanged();
|
---|
123 | irc = success;
|
---|
124 | }
|
---|
125 | }
|
---|
126 | else {
|
---|
127 | _eph.insert(prn, new t_ephPair(newEph));
|
---|
128 | ephBufferChanged();
|
---|
129 | irc = success;
|
---|
130 | }
|
---|
131 |
|
---|
132 | return irc;
|
---|
133 | }
|
---|
134 |
|
---|