| [4757] | 1 |
|
|---|
| [5719] | 2 | // Part of BNC, a utility for retrieving decoding and
|
|---|
| 3 | // converting GNSS data streams from NTRIP broadcasters.
|
|---|
| 4 | //
|
|---|
| 5 | // Copyright (C) 2007
|
|---|
| 6 | // German Federal Agency for Cartography and Geodesy (BKG)
|
|---|
| 7 | // http://www.bkg.bund.de
|
|---|
| 8 | // Czech Technical University Prague, Department of Geodesy
|
|---|
| 9 | // http://www.fsv.cvut.cz
|
|---|
| 10 | //
|
|---|
| 11 | // Email: euref-ip@bkg.bund.de
|
|---|
| 12 | //
|
|---|
| 13 | // This program is free software; you can redistribute it and/or
|
|---|
| 14 | // modify it under the terms of the GNU General Public License
|
|---|
| 15 | // as published by the Free Software Foundation, version 2.
|
|---|
| 16 | //
|
|---|
| 17 | // This program is distributed in the hope that it will be useful,
|
|---|
| 18 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 19 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 20 | // GNU General Public License for more details.
|
|---|
| 21 | //
|
|---|
| 22 | // You should have received a copy of the GNU General Public License
|
|---|
| 23 | // along with this program; if not, write to the Free Software
|
|---|
| 24 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|---|
| 25 |
|
|---|
| 26 | /* -------------------------------------------------------------------------
|
|---|
| 27 | * BKG NTRIP Client
|
|---|
| 28 | * -------------------------------------------------------------------------
|
|---|
| 29 | *
|
|---|
| [5813] | 30 | * Class: t_pppThread, t_pppRun
|
|---|
| [5719] | 31 | *
|
|---|
| 32 | * Purpose: Single PPP Client (running in its own thread)
|
|---|
| 33 | *
|
|---|
| 34 | * Author: L. Mervart
|
|---|
| 35 | *
|
|---|
| 36 | * Created: 29-Jul-2014
|
|---|
| 37 | *
|
|---|
| 38 | * Changes:
|
|---|
| 39 | *
|
|---|
| 40 | * -----------------------------------------------------------------------*/
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| [4757] | 43 | #include <iostream>
|
|---|
| [4775] | 44 | #include <iomanip>
|
|---|
| [4757] | 45 | #include <string.h>
|
|---|
| [5782] | 46 | #include <map>
|
|---|
| [4757] | 47 |
|
|---|
| [5813] | 48 | #include "pppThread.h"
|
|---|
| [5068] | 49 | #include "bnccore.h"
|
|---|
| [4757] | 50 |
|
|---|
| [5814] | 51 | using namespace BNC_PPP;
|
|---|
| [4757] | 52 | using namespace std;
|
|---|
| 53 |
|
|---|
| 54 | // Constructor
|
|---|
| 55 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| [5813] | 56 | t_pppThread::t_pppThread(const t_pppOptions* opt) : QThread(0) {
|
|---|
| [5774] | 57 | _opt = opt;
|
|---|
| 58 | _pppRun = 0;
|
|---|
| [5775] | 59 | connect(this, SIGNAL(finished()), this, SLOT(deleteLater()));
|
|---|
| 60 |
|
|---|
| [5767] | 61 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
|---|
| 62 | BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
|
|---|
| [4763] | 63 | }
|
|---|
| 64 |
|
|---|
| 65 | // Destructor
|
|---|
| 66 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| [5813] | 67 | t_pppThread::~t_pppThread() {
|
|---|
| [5731] | 68 | delete _pppRun;
|
|---|
| [4763] | 69 | }
|
|---|
| 70 |
|
|---|
| 71 | // Run (virtual)
|
|---|
| 72 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| [5813] | 73 | void t_pppThread::run() {
|
|---|
| [5742] | 74 | try {
|
|---|
| 75 | _pppRun = new t_pppRun(_opt);
|
|---|
| [5775] | 76 | QThread::exec();
|
|---|
| [5742] | 77 | }
|
|---|
| [5763] | 78 | catch (pppExcept exc) {
|
|---|
| [5768] | 79 | _pppRun = 0;
|
|---|
| [5766] | 80 | emit newMessage(QByteArray(exc.what().c_str()), true);
|
|---|
| [5742] | 81 | }
|
|---|
| [5731] | 82 | }
|
|---|
| 83 |
|
|---|
| 84 | // Constructor
|
|---|
| 85 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| [5810] | 86 | t_pppRun::t_pppRun(const t_pppOptions* opt) {
|
|---|
| [5731] | 87 | _opt = opt;
|
|---|
| [5767] | 88 | connect(this, SIGNAL(newMessage(QByteArray,bool)),
|
|---|
| 89 | BNC_CORE, SLOT(slotMessage(const QByteArray,bool)));
|
|---|
| [5742] | 90 | if (_opt->_realTime) {
|
|---|
| [5729] | 91 | connect(BNC_CORE->caster(), SIGNAL(newObs(QByteArray, QList<t_obs>)),
|
|---|
| 92 | this, SLOT(slotNewObs(QByteArray, QList<t_obs>)));
|
|---|
| [4757] | 93 |
|
|---|
| [5722] | 94 | connect(BNC_CORE, SIGNAL(newEphGPS(gpsephemeris)),
|
|---|
| 95 | this, SLOT(slotNewEphGPS(gpsephemeris)));
|
|---|
| 96 |
|
|---|
| 97 | connect(BNC_CORE, SIGNAL(newEphGlonass(glonassephemeris)),
|
|---|
| 98 | this, SLOT(slotNewEphGlonass(glonassephemeris)));
|
|---|
| 99 |
|
|---|
| 100 | connect(BNC_CORE, SIGNAL(newEphGalileo(galileoephemeris)),
|
|---|
| 101 | this, SLOT(slotNewEphGalileo(galileoephemeris)));
|
|---|
| [4757] | 102 |
|
|---|
| [5732] | 103 | connect(BNC_CORE, SIGNAL(newCorrections(QStringList)),
|
|---|
| 104 | this, SLOT(slotNewCorrections(QStringList)));
|
|---|
| [5742] | 105 |
|
|---|
| [5761] | 106 | _pppClient = new t_pppClient(_opt);
|
|---|
| [5722] | 107 | }
|
|---|
| [5742] | 108 | else {
|
|---|
| [5766] | 109 | throw pppExcept("t_pppRun: post-processing not yet implemented");
|
|---|
| [5742] | 110 | }
|
|---|
| [5731] | 111 | }
|
|---|
| [5729] | 112 |
|
|---|
| [5731] | 113 | // Destructor
|
|---|
| 114 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 115 | t_pppRun::~t_pppRun() {
|
|---|
| [4757] | 116 | }
|
|---|
| 117 |
|
|---|
| 118 | //
|
|---|
| 119 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| [5731] | 120 | void t_pppRun::slotNewEphGPS(gpsephemeris gpseph) {
|
|---|
| [4757] | 121 | QMutexLocker locker(&_mutex);
|
|---|
| [5742] | 122 | t_ephGPS eph;
|
|---|
| 123 | eph.set(&gpseph);
|
|---|
| [5772] | 124 | _pppClient->putEphemeris(&eph);
|
|---|
| [4757] | 125 | }
|
|---|
| 126 |
|
|---|
| 127 | //
|
|---|
| 128 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| [5731] | 129 | void t_pppRun::slotNewEphGlonass(glonassephemeris gloeph) {
|
|---|
| [4757] | 130 | QMutexLocker locker(&_mutex);
|
|---|
| [5769] | 131 | t_ephGlo eph;
|
|---|
| 132 | eph.set(&gloeph);
|
|---|
| [5772] | 133 | _pppClient->putEphemeris(&eph);
|
|---|
| [4757] | 134 | }
|
|---|
| 135 |
|
|---|
| 136 | //
|
|---|
| 137 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| [5769] | 138 | void t_pppRun::slotNewEphGalileo(galileoephemeris galeph) {
|
|---|
| [5681] | 139 | QMutexLocker locker(&_mutex);
|
|---|
| [5769] | 140 | t_ephGal eph;
|
|---|
| 141 | eph.set(&galeph);
|
|---|
| [5772] | 142 | _pppClient->putEphemeris(&eph);
|
|---|
| [4757] | 143 | }
|
|---|
| 144 |
|
|---|
| 145 | //
|
|---|
| 146 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| [5732] | 147 | void t_pppRun::slotNewCorrections(QStringList corrList) {
|
|---|
| [4757] | 148 | QMutexLocker locker(&_mutex);
|
|---|
| [5771] | 149 |
|
|---|
| 150 | QStringListIterator it(corrList);
|
|---|
| 151 | while (it.hasNext()) {
|
|---|
| [5775] | 152 | it.next();
|
|---|
| [5771] | 153 | }
|
|---|
| 154 |
|
|---|
| [5779] | 155 | // _pppClient->putOrbCorrections(const std::vector<t_orbCorr*>& corr);
|
|---|
| 156 | // _pppClient->putClkCorrections(const std::vector<t_clkCorr*>& corr);
|
|---|
| 157 | // _pppClient->putBiases(const std::vector<t_satBiases*>& biases);
|
|---|
| [4757] | 158 | }
|
|---|
| 159 | //
|
|---|
| 160 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| [5731] | 161 | void t_pppRun::slotNewObs(QByteArray staID, QList<t_obs> obsList) {
|
|---|
| [4757] | 162 | QMutexLocker locker(&_mutex);
|
|---|
| [5766] | 163 |
|
|---|
| [5777] | 164 | if (string(staID.data()) != _opt->_roverName) {
|
|---|
| 165 | return;
|
|---|
| 166 | }
|
|---|
| 167 |
|
|---|
| [5791] | 168 | // Loop over all obsevations (possible different epochs)
|
|---|
| 169 | // -----------------------------------------------------
|
|---|
| [5778] | 170 | QListIterator<t_obs> it(obsList);
|
|---|
| 171 | while (it.hasNext()) {
|
|---|
| [5780] | 172 | const t_obs& oldObs = it.next();
|
|---|
| 173 | t_pppSatObs* newObs = new t_pppSatObs;
|
|---|
| [5781] | 174 |
|
|---|
| 175 | newObs->_prn.set(oldObs.satSys, oldObs.satNum);
|
|---|
| 176 | newObs->_time.set(oldObs.GPSWeek, oldObs.GPSWeeks);
|
|---|
| [5780] | 177 |
|
|---|
| [5791] | 178 | // Find the corresponding data epoch or create a new one
|
|---|
| 179 | // -----------------------------------------------------
|
|---|
| 180 | t_pppEpoData* epoData = 0;
|
|---|
| 181 | deque<t_pppEpoData*>::const_iterator it;
|
|---|
| 182 | for (it = _pppEpochs.begin(); it != _pppEpochs.end(); it++) {
|
|---|
| 183 | if (newObs->_time == (*it)->_time) {
|
|---|
| 184 | epoData = *it;
|
|---|
| 185 | break;
|
|---|
| 186 | }
|
|---|
| 187 | }
|
|---|
| 188 | if (epoData == 0) {
|
|---|
| [5792] | 189 | if (_pppEpochs.empty() || newObs->_time > _pppEpochs.back()->_time) {
|
|---|
| [5791] | 190 | epoData = new t_pppEpoData;
|
|---|
| 191 | epoData->_time = newObs->_time;
|
|---|
| 192 | _pppEpochs.push_back(epoData);
|
|---|
| 193 | }
|
|---|
| 194 | }
|
|---|
| [5790] | 195 |
|
|---|
| [5791] | 196 | // Fill the new observation and add it to the corresponding epoch
|
|---|
| 197 | // --------------------------------------------------------------
|
|---|
| 198 | if (epoData != 0) {
|
|---|
| 199 | epoData->_pppSatObs.push_back(newObs);
|
|---|
| 200 | map<string, t_pppObs*> pppObsMap;
|
|---|
| 201 | for (unsigned iEntry = 0; iEntry < GNSSENTRY_NUMBER; iEntry++) {
|
|---|
| 202 | string hlp(oldObs.rnxStr(iEntry).toAscii().data());
|
|---|
| 203 | if (hlp.length() == 3) {
|
|---|
| 204 | char obsType = hlp[0];
|
|---|
| 205 | string rnxType2ch = hlp.substr(1);
|
|---|
| 206 | if (obsType == 'C' || obsType == 'L') {
|
|---|
| 207 | t_pppObs* pppObs = 0;
|
|---|
| 208 | if (pppObsMap.find(rnxType2ch) == pppObsMap.end()) {
|
|---|
| 209 | pppObs = new t_pppObs();
|
|---|
| 210 | pppObsMap[rnxType2ch] = pppObs;
|
|---|
| 211 | pppObs->_rnxType2ch = rnxType2ch;
|
|---|
| 212 | newObs->_obs.push_back(pppObs);
|
|---|
| 213 | }
|
|---|
| 214 | else {
|
|---|
| 215 | pppObs = pppObsMap[rnxType2ch];
|
|---|
| 216 | }
|
|---|
| 217 | if (obsType == 'C') {
|
|---|
| 218 | pppObs->_code = oldObs._measdata[iEntry];
|
|---|
| 219 | pppObs->_codeValid = true;
|
|---|
| 220 | }
|
|---|
| 221 | else if (obsType == 'L') {
|
|---|
| 222 | pppObs->_phase = oldObs._measdata[iEntry];
|
|---|
| 223 | pppObs->_phaseValid = true;
|
|---|
| 224 | }
|
|---|
| [5783] | 225 | }
|
|---|
| 226 | }
|
|---|
| [5782] | 227 | }
|
|---|
| 228 | }
|
|---|
| [5778] | 229 | }
|
|---|
| [5772] | 230 |
|
|---|
| [5791] | 231 | // Process the oldest epoch
|
|---|
| 232 | // ------------------------
|
|---|
| 233 | if (_pppEpochs.size() > 1) {
|
|---|
| [5772] | 234 |
|
|---|
| [5791] | 235 | const vector<t_pppSatObs*>& pppSatObs = _pppEpochs.front()->_pppSatObs;
|
|---|
| 236 |
|
|---|
| 237 | t_output output;
|
|---|
| 238 | _pppClient->processEpoch(pppSatObs, &output);
|
|---|
| 239 |
|
|---|
| 240 | delete _pppEpochs.front(); _pppEpochs.pop_front();
|
|---|
| 241 |
|
|---|
| 242 | emit newMessage(QByteArray(output._log.c_str()), true);
|
|---|
| [5779] | 243 | }
|
|---|
| [5589] | 244 | }
|
|---|
| [5525] | 245 |
|
|---|