[2904] | 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 |
|
---|
[2907] | 41 | #include <iostream>
|
---|
| 42 |
|
---|
[2904] | 43 | #include "bncephuser.h"
|
---|
[5070] | 44 | #include "bnccore.h"
|
---|
[2904] | 45 |
|
---|
| 46 | using namespace std;
|
---|
| 47 |
|
---|
| 48 | // Constructor
|
---|
| 49 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3640] | 50 | bncEphUser::bncEphUser(bool connectSlots) {
|
---|
[2904] | 51 |
|
---|
[3640] | 52 | if (connectSlots) {
|
---|
[5068] | 53 | connect(BNC_CORE, SIGNAL(newEphGPS(gpsephemeris)),
|
---|
[3640] | 54 | this, SLOT(slotNewEphGPS(gpsephemeris)), Qt::DirectConnection);
|
---|
| 55 |
|
---|
[5068] | 56 | connect(BNC_CORE, SIGNAL(newEphGlonass(glonassephemeris)),
|
---|
[3640] | 57 | this, SLOT(slotNewEphGlonass(glonassephemeris)), Qt::DirectConnection);
|
---|
| 58 |
|
---|
[5068] | 59 | connect(BNC_CORE, SIGNAL(newEphGalileo(galileoephemeris)),
|
---|
[3640] | 60 | this, SLOT(slotNewEphGalileo(galileoephemeris)), Qt::DirectConnection);
|
---|
| 61 | }
|
---|
[2904] | 62 | }
|
---|
| 63 |
|
---|
| 64 | // Destructor
|
---|
| 65 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 66 | bncEphUser::~bncEphUser() {
|
---|
| 67 | QMapIterator<QString, t_ephPair*> it(_eph);
|
---|
| 68 | while (it.hasNext()) {
|
---|
| 69 | it.next();
|
---|
| 70 | delete it.value();
|
---|
| 71 | }
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | //
|
---|
| 75 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 76 | void bncEphUser::slotNewEphGPS(gpsephemeris gpseph) {
|
---|
| 77 | QMutexLocker locker(&_mutex);
|
---|
| 78 |
|
---|
[5133] | 79 | t_ephGPS* eNew = new t_ephGPS(); eNew->set(&gpseph);
|
---|
[2904] | 80 |
|
---|
[5776] | 81 | QString prn(eNew->prn().toString().c_str());
|
---|
[5133] | 82 |
|
---|
[2904] | 83 | if (_eph.contains(prn)) {
|
---|
| 84 | t_ephGPS* eLast = static_cast<t_ephGPS*>(_eph.value(prn)->last);
|
---|
[5133] | 85 | if (eNew->isNewerThan(eLast)) {
|
---|
| 86 | delete _eph.value(prn)->prev;
|
---|
[2904] | 87 | _eph.value(prn)->prev = _eph.value(prn)->last;
|
---|
[5133] | 88 | _eph.value(prn)->last = eNew;
|
---|
| 89 | ephBufferChanged();
|
---|
[2904] | 90 | }
|
---|
[5133] | 91 | else {
|
---|
| 92 | delete eNew;
|
---|
| 93 | }
|
---|
[2904] | 94 | }
|
---|
| 95 | else {
|
---|
[5133] | 96 | _eph.insert(prn, new t_ephPair(eNew));
|
---|
| 97 | ephBufferChanged();
|
---|
[2904] | 98 | }
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | //
|
---|
| 102 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 103 | void bncEphUser::slotNewEphGlonass(glonassephemeris gloeph) {
|
---|
| 104 | QMutexLocker locker(&_mutex);
|
---|
| 105 |
|
---|
[5133] | 106 | t_ephGlo* eNew = new t_ephGlo(); eNew->set(&gloeph);
|
---|
[2904] | 107 |
|
---|
[5776] | 108 | QString prn(eNew->prn().toString().c_str());
|
---|
[5133] | 109 |
|
---|
[2904] | 110 | if (_eph.contains(prn)) {
|
---|
| 111 | t_ephGlo* eLast = static_cast<t_ephGlo*>(_eph.value(prn)->last);
|
---|
[5133] | 112 | if (eNew->isNewerThan(eLast)) {
|
---|
| 113 | delete _eph.value(prn)->prev;
|
---|
| 114 | _eph.value(prn)->prev = _eph.value(prn)->last;
|
---|
| 115 | _eph.value(prn)->last = eNew;
|
---|
| 116 | ephBufferChanged();
|
---|
[2904] | 117 | }
|
---|
[4904] | 118 | else {
|
---|
[5133] | 119 | delete eNew;
|
---|
[4904] | 120 | }
|
---|
[2904] | 121 | }
|
---|
[5133] | 122 | else {
|
---|
| 123 | _eph.insert(prn, new t_ephPair(eNew));
|
---|
| 124 | ephBufferChanged();
|
---|
| 125 | }
|
---|
[2904] | 126 | }
|
---|
| 127 |
|
---|
| 128 | //
|
---|
| 129 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 130 | void bncEphUser::slotNewEphGalileo(galileoephemeris galeph) {
|
---|
| 131 | QMutexLocker locker(&_mutex);
|
---|
| 132 |
|
---|
| 133 | QString prn = QString("E%1").arg(galeph.satellite, 2, 10, QChar('0'));
|
---|
| 134 |
|
---|
| 135 | if (_eph.contains(prn)) {
|
---|
| 136 | t_ephGal* eLast = static_cast<t_ephGal*>(_eph.value(prn)->last);
|
---|
[4018] | 137 | bncTime toc(galeph.Week, galeph.TOC);
|
---|
| 138 | if (eLast->TOC() < toc) {
|
---|
[2904] | 139 | delete static_cast<t_ephGal*>(_eph.value(prn)->prev);
|
---|
| 140 | _eph.value(prn)->prev = _eph.value(prn)->last;
|
---|
| 141 | _eph.value(prn)->last = new t_ephGal();
|
---|
| 142 | static_cast<t_ephGal*>(_eph.value(prn)->last)->set(&galeph);
|
---|
| 143 | }
|
---|
| 144 | }
|
---|
| 145 | else {
|
---|
| 146 | t_ephGal* eLast = new t_ephGal();
|
---|
| 147 | eLast->set(&galeph);
|
---|
[3012] | 148 | _eph.insert(prn, new t_ephPair(eLast));
|
---|
[2904] | 149 | }
|
---|
[3246] | 150 | ephBufferChanged();
|
---|
[2904] | 151 | }
|
---|
[2911] | 152 |
|
---|
| 153 | //
|
---|
| 154 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3671] | 155 | t_irc bncEphUser::putNewEph(t_eph* newEph) {
|
---|
[3670] | 156 |
|
---|
| 157 | QMutexLocker locker(&_mutex);
|
---|
| 158 |
|
---|
| 159 | if (!newEph) {
|
---|
[3671] | 160 | return failure;
|
---|
[3670] | 161 | }
|
---|
| 162 |
|
---|
[5776] | 163 | QString prn(newEph->prn().toString().c_str());
|
---|
[3670] | 164 |
|
---|
[3671] | 165 | t_irc irc = failure;
|
---|
| 166 |
|
---|
[3670] | 167 | if (_eph.contains(prn)) {
|
---|
| 168 | t_eph* eLast = _eph.value(prn)->last;
|
---|
| 169 | if (newEph->isNewerThan(eLast)) {
|
---|
| 170 | delete _eph.value(prn)->prev;
|
---|
| 171 | _eph.value(prn)->prev = _eph.value(prn)->last;
|
---|
| 172 | _eph.value(prn)->last = newEph;
|
---|
[3671] | 173 | irc = success;
|
---|
[3670] | 174 | }
|
---|
| 175 | }
|
---|
| 176 | else {
|
---|
| 177 | _eph.insert(prn, new t_ephPair(newEph));
|
---|
[3671] | 178 | irc = success;
|
---|
[3670] | 179 | }
|
---|
[3671] | 180 |
|
---|
| 181 | if (irc == success) {
|
---|
| 182 | ephBufferChanged();
|
---|
| 183 | }
|
---|
| 184 |
|
---|
| 185 | return irc;
|
---|
[3670] | 186 | }
|
---|
| 187 |
|
---|