[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);
|
---|
[6393] | 61 |
|
---|
| 62 | connect(BNC_CORE, SIGNAL(newEphSBAS(sbasephemeris)),
|
---|
| 63 | this, SLOT(slotNewEphSBAS(sbasephemeris)), Qt::DirectConnection);
|
---|
[3640] | 64 | }
|
---|
[2904] | 65 | }
|
---|
| 66 |
|
---|
| 67 | // Destructor
|
---|
| 68 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 69 | bncEphUser::~bncEphUser() {
|
---|
| 70 | QMapIterator<QString, t_ephPair*> it(_eph);
|
---|
| 71 | while (it.hasNext()) {
|
---|
| 72 | it.next();
|
---|
| 73 | delete it.value();
|
---|
| 74 | }
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | //
|
---|
| 78 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 79 | void bncEphUser::slotNewEphGPS(gpsephemeris gpseph) {
|
---|
[6395] | 80 | t_ephGPS* newEph = new t_ephGPS(); newEph->set(&gpseph);
|
---|
| 81 | if (putNewEph(newEph) != success) {
|
---|
| 82 | delete newEph;
|
---|
| 83 | }
|
---|
[6394] | 84 | }
|
---|
[2904] | 85 |
|
---|
[6394] | 86 | //
|
---|
| 87 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 88 | void bncEphUser::slotNewEphGlonass(glonassephemeris gloeph) {
|
---|
[6395] | 89 | t_ephGlo* newEph = new t_ephGlo(); newEph->set(&gloeph);
|
---|
| 90 | if (putNewEph(newEph) != success) {
|
---|
| 91 | delete newEph;
|
---|
| 92 | }
|
---|
[6394] | 93 | }
|
---|
[5133] | 94 |
|
---|
[6394] | 95 | //
|
---|
| 96 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 97 | void bncEphUser::slotNewEphGalileo(galileoephemeris galeph) {
|
---|
[6395] | 98 | t_ephGal* newEph = new t_ephGal(); newEph->set(&galeph);
|
---|
| 99 | if (putNewEph(newEph) != success) {
|
---|
| 100 | delete newEph;
|
---|
| 101 | }
|
---|
[2904] | 102 | }
|
---|
| 103 |
|
---|
| 104 | //
|
---|
| 105 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6394] | 106 | void bncEphUser::slotNewEphSBAS(sbasephemeris sbaseph) {
|
---|
[6395] | 107 | t_ephSBAS* newEph = new t_ephSBAS(); newEph->set(&sbaseph);
|
---|
| 108 | if (putNewEph(newEph) != success) {
|
---|
| 109 | delete newEph;
|
---|
[2904] | 110 | }
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | //
|
---|
| 114 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3671] | 115 | t_irc bncEphUser::putNewEph(t_eph* newEph) {
|
---|
[3670] | 116 | QMutexLocker locker(&_mutex);
|
---|
| 117 |
|
---|
[6395] | 118 | t_irc irc = failure;
|
---|
| 119 |
|
---|
[3670] | 120 | if (!newEph) {
|
---|
[6395] | 121 | return irc;
|
---|
[3670] | 122 | }
|
---|
| 123 |
|
---|
[5776] | 124 | QString prn(newEph->prn().toString().c_str());
|
---|
[3670] | 125 | if (_eph.contains(prn)) {
|
---|
[6395] | 126 | if (newEph->isNewerThan(_eph.value(prn)->last)) {
|
---|
[3670] | 127 | delete _eph.value(prn)->prev;
|
---|
| 128 | _eph.value(prn)->prev = _eph.value(prn)->last;
|
---|
| 129 | _eph.value(prn)->last = newEph;
|
---|
[6395] | 130 | ephBufferChanged();
|
---|
[3671] | 131 | irc = success;
|
---|
[3670] | 132 | }
|
---|
| 133 | }
|
---|
| 134 | else {
|
---|
| 135 | _eph.insert(prn, new t_ephPair(newEph));
|
---|
[6395] | 136 | ephBufferChanged();
|
---|
[3671] | 137 | irc = success;
|
---|
[3670] | 138 | }
|
---|
[3671] | 139 |
|
---|
[6396] | 140 | return irc;
|
---|
[6395] | 141 | }
|
---|
[3671] | 142 |
|
---|