[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 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6432] | 50 | bncEphUser::bncEphUser() {
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | // Constructor
|
---|
| 54 | ////////////////////////////////////////////////////////////////////////////
|
---|
[3640] | 55 | bncEphUser::bncEphUser(bool connectSlots) {
|
---|
| 56 | if (connectSlots) {
|
---|
[6434] | 57 | connect(BNC_CORE, SIGNAL(newGPSEph(t_ephGPS)),
|
---|
| 58 | this, SLOT(slotNewGPSEph(t_ephGPS)), Qt::DirectConnection);
|
---|
[6432] | 59 |
|
---|
[6434] | 60 | connect(BNC_CORE, SIGNAL(newGlonassEph(t_ephGlo)),
|
---|
| 61 | this, SLOT(slotNewGlonassEph(t_ephGlo)), Qt::DirectConnection);
|
---|
[6432] | 62 |
|
---|
[6434] | 63 | connect(BNC_CORE, SIGNAL(newGalileoEph(t_ephGal)),
|
---|
| 64 | this, SLOT(slotNewGalileoEph(t_ephGal)), Qt::DirectConnection);
|
---|
[6393] | 65 |
|
---|
[6434] | 66 | connect(BNC_CORE, SIGNAL(newSBASEph(t_ephSBAS)),
|
---|
| 67 | this, SLOT(slotNewSBASEph(t_ephSBAS)), Qt::DirectConnection);
|
---|
[3640] | 68 | }
|
---|
[2904] | 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 |
|
---|
[6432] | 81 | // New GPS Ephemeris
|
---|
[2904] | 82 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6432] | 83 | void bncEphUser::slotNewGPSEph(t_ephGPS eph) {
|
---|
| 84 | putNewEph(&eph);
|
---|
[6394] | 85 | }
|
---|
[6432] | 86 |
|
---|
| 87 | // New Glonass Ephemeris
|
---|
[6394] | 88 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6432] | 89 | void bncEphUser::slotNewGlonassEph(t_ephGlo eph) {
|
---|
| 90 | putNewEph(&eph);
|
---|
[6394] | 91 | }
|
---|
[5133] | 92 |
|
---|
[6432] | 93 | // New Galileo Ephemeris
|
---|
[6394] | 94 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6432] | 95 | void bncEphUser::slotNewGalileoEph(t_ephGal eph) {
|
---|
| 96 | putNewEph(&eph);
|
---|
[2904] | 97 | }
|
---|
| 98 |
|
---|
[6432] | 99 | // New SBAS Ephemeris
|
---|
[2904] | 100 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6432] | 101 | void bncEphUser::slotNewSBASEph(t_ephSBAS eph) {
|
---|
| 102 | putNewEph(&eph);
|
---|
[2904] | 103 | }
|
---|
| 104 |
|
---|
| 105 | //
|
---|
| 106 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6435] | 107 | t_irc bncEphUser::putNewEph(const t_eph* eph) {
|
---|
| 108 |
|
---|
[3670] | 109 | QMutexLocker locker(&_mutex);
|
---|
| 110 |
|
---|
[6435] | 111 | if (eph == 0) {
|
---|
| 112 | return failure;
|
---|
| 113 | }
|
---|
[6395] | 114 |
|
---|
[6435] | 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);
|
---|
[3670] | 125 | }
|
---|
[6435] | 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 | }
|
---|
[3670] | 141 |
|
---|
[5776] | 142 | QString prn(newEph->prn().toString().c_str());
|
---|
[6435] | 143 |
|
---|
[3670] | 144 | if (_eph.contains(prn)) {
|
---|
[6395] | 145 | if (newEph->isNewerThan(_eph.value(prn)->last)) {
|
---|
[3670] | 146 | delete _eph.value(prn)->prev;
|
---|
| 147 | _eph.value(prn)->prev = _eph.value(prn)->last;
|
---|
| 148 | _eph.value(prn)->last = newEph;
|
---|
[6395] | 149 | ephBufferChanged();
|
---|
[6435] | 150 | return success;
|
---|
[3670] | 151 | }
|
---|
| 152 | }
|
---|
| 153 | else {
|
---|
| 154 | _eph.insert(prn, new t_ephPair(newEph));
|
---|
[6395] | 155 | ephBufferChanged();
|
---|
[6435] | 156 | return success;
|
---|
[3670] | 157 | }
|
---|
[3671] | 158 |
|
---|
[6435] | 159 | return failure;
|
---|
[6395] | 160 | }
|
---|
[3671] | 161 |
|
---|