[2035] | 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: bncPPPclient
|
---|
| 30 | *
|
---|
| 31 | * Purpose: Precise Point Positioning
|
---|
| 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 21-Nov-2009
|
---|
| 36 | *
|
---|
| 37 | * Changes:
|
---|
| 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
| 41 | #include <iomanip>
|
---|
| 42 | #include <newmatio.h>
|
---|
| 43 |
|
---|
| 44 | #include "bncpppclient.h"
|
---|
| 45 |
|
---|
| 46 | extern "C" {
|
---|
| 47 | #include "clock_orbit_rtcm.h"
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | using namespace std;
|
---|
| 51 |
|
---|
| 52 | // Constructor
|
---|
| 53 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 54 | bncPPPclient::bncPPPclient(QByteArray staID) {
|
---|
[2039] | 55 | _staID = staID;
|
---|
| 56 | _epoData = 0;
|
---|
[2035] | 57 | }
|
---|
| 58 |
|
---|
| 59 | // Destructor
|
---|
| 60 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 61 | bncPPPclient::~bncPPPclient() {
|
---|
[2039] | 62 | delete _epoData;
|
---|
[2035] | 63 | QMapIterator<QString, t_eph*> it(_eph);
|
---|
| 64 | while (it.hasNext()) {
|
---|
| 65 | it.next();
|
---|
| 66 | delete it.value();
|
---|
| 67 | }
|
---|
| 68 | QMapIterator<QString, t_corr*> ic(_corr);
|
---|
| 69 | while (ic.hasNext()) {
|
---|
| 70 | ic.next();
|
---|
| 71 | delete ic.value();
|
---|
| 72 | }
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | //
|
---|
| 76 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 77 | void bncPPPclient::putNewObs(p_obs pp) {
|
---|
[2037] | 78 | QMutexLocker locker(&_mutex);
|
---|
| 79 |
|
---|
| 80 | t_obsInternal* obs = &(pp->_o);
|
---|
| 81 |
|
---|
| 82 | t_time tt(obs->GPSWeek, obs->GPSWeeks);
|
---|
| 83 |
|
---|
[2039] | 84 | if (!_epoData) {
|
---|
| 85 | _epoData = new t_epoData();
|
---|
| 86 | _epoData->tt = tt;
|
---|
[2037] | 87 | }
|
---|
[2039] | 88 | else if (tt != _epoData->tt) {
|
---|
[2037] | 89 | processEpoch();
|
---|
[2039] | 90 | delete _epoData;
|
---|
| 91 | _epoData = new t_epoData();
|
---|
| 92 | _epoData->tt = tt;
|
---|
[2037] | 93 | }
|
---|
| 94 |
|
---|
[2039] | 95 | t_satData* satData = new t_satData();
|
---|
| 96 |
|
---|
| 97 | satData->C1 = obs->C1;
|
---|
| 98 | satData->C2 = obs->C2;
|
---|
| 99 | satData->P1 = obs->P1;
|
---|
| 100 | satData->P2 = obs->P2;
|
---|
| 101 | satData->L1 = obs->L1;
|
---|
| 102 | satData->L2 = obs->L2;
|
---|
| 103 |
|
---|
| 104 | QString prn =
|
---|
[2037] | 105 | QString("%1%2").arg(obs->satSys).arg(obs->satNum, 2, 10, QChar('0'));
|
---|
[2039] | 106 |
|
---|
| 107 | _epoData->satData[prn] = satData;
|
---|
[2035] | 108 | }
|
---|
| 109 |
|
---|
| 110 | //
|
---|
| 111 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 112 | void bncPPPclient::slotNewEphGPS(gpsephemeris gpseph) {
|
---|
| 113 | QMutexLocker locker(&_mutex);
|
---|
| 114 |
|
---|
| 115 | QString prn = QString("G%1").arg(gpseph.satellite, 2, 10, QChar('0'));
|
---|
| 116 |
|
---|
[2040] | 117 | cout << "EPH " << prn.toAscii().data() << " " << gpseph.IODE << " "
|
---|
| 118 | << gpseph.IODC << endl;
|
---|
| 119 |
|
---|
[2035] | 120 | if (_eph.contains(prn)) {
|
---|
[2040] | 121 | t_ephGPS* ee = static_cast<t_ephGPS*>(_eph.value(prn));
|
---|
| 122 | if ( (ee->GPSweek() < gpseph.GPSweek) ||
|
---|
| 123 | (ee->GPSweek() == gpseph.GPSweek &&
|
---|
| 124 | ee->TOC() < gpseph.TOC) ) {
|
---|
| 125 | ee->set(&gpseph);
|
---|
| 126 | }
|
---|
[2035] | 127 | }
|
---|
| 128 | else {
|
---|
| 129 | t_ephGPS* ee = new t_ephGPS();
|
---|
| 130 | ee->set(&gpseph);
|
---|
| 131 | _eph[prn] = ee;
|
---|
| 132 | }
|
---|
| 133 | }
|
---|
| 134 |
|
---|
| 135 | //
|
---|
| 136 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 137 | void bncPPPclient::slotNewCorrections(QList<QString> corrList) {
|
---|
| 138 | QMutexLocker locker(&_mutex);
|
---|
| 139 | QListIterator<QString> it(corrList);
|
---|
| 140 | while (it.hasNext()) {
|
---|
| 141 | QTextStream in(it.next().toAscii());
|
---|
| 142 | int messageType;
|
---|
| 143 | int updateInterval;
|
---|
| 144 | int GPSweek;
|
---|
| 145 | double GPSweeks;
|
---|
| 146 | QString prn;
|
---|
| 147 | in >> messageType >> updateInterval >> GPSweek >> GPSweeks >> prn;
|
---|
| 148 | if ( messageType == COTYPE_GPSCOMBINED ||
|
---|
| 149 | messageType == COTYPE_GLONASSCOMBINED ) {
|
---|
| 150 | t_corr* cc = 0;
|
---|
| 151 | if (_corr.contains(prn)) {
|
---|
| 152 | cc = _corr.value(prn);
|
---|
| 153 | }
|
---|
| 154 | else {
|
---|
| 155 | cc = new t_corr();
|
---|
| 156 | _corr[prn] = cc;
|
---|
| 157 | }
|
---|
| 158 | cc->tt.set(GPSweek, GPSweeks);
|
---|
| 159 | in >> cc->iod >> cc->dClk >> cc->rao[0] >> cc->rao[1] >> cc->rao[2];
|
---|
| 160 | }
|
---|
| 161 | }
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | // Satellite Position
|
---|
| 165 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 166 | t_irc bncPPPclient::getSatPos(const t_time& tt, const QString& prn,
|
---|
| 167 | ColumnVector& xc, ColumnVector& vv) {
|
---|
| 168 |
|
---|
| 169 | if (_eph.contains(prn)) {
|
---|
[2040] | 170 | t_eph* ee = _eph.value(prn);
|
---|
| 171 | ee->position(tt.gpsw(), tt.gpssec(), xc.data(), vv.data());
|
---|
| 172 |
|
---|
| 173 | if (_corr.contains(prn)) {
|
---|
| 174 | t_corr* cc = _corr.value(prn);
|
---|
| 175 | cout << "found: " << prn.toAscii().data()
|
---|
| 176 | << " age: " << (tt - cc->tt) << " "
|
---|
| 177 | << ee->IOD() << " " << cc->iod << endl;
|
---|
| 178 | }
|
---|
| 179 | else {
|
---|
| 180 | cout << "not found: " << prn.toAscii().data() << endl;
|
---|
| 181 | }
|
---|
| 182 |
|
---|
[2035] | 183 | return success;
|
---|
| 184 | }
|
---|
| 185 |
|
---|
| 186 | return failure;
|
---|
| 187 | }
|
---|
| 188 |
|
---|
| 189 | //
|
---|
| 190 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 191 | void bncPPPclient::processEpoch() {
|
---|
| 192 |
|
---|
[2039] | 193 | QMapIterator<QString, t_satData*> it(_epoData->satData);
|
---|
| 194 | while (it.hasNext()) {
|
---|
| 195 | it.next();
|
---|
| 196 | QString prn = it.key();
|
---|
| 197 | t_satData* satData = it.value();
|
---|
[2035] | 198 |
|
---|
| 199 | ColumnVector xc(4);
|
---|
| 200 | ColumnVector vv(3);
|
---|
| 201 |
|
---|
| 202 | cout.setf(ios::fixed);
|
---|
| 203 |
|
---|
[2039] | 204 | if (getSatPos(_epoData->tt, prn, xc, vv) == success) {
|
---|
| 205 | cout << _epoData->tt.timestr(1) << " " << prn.toAscii().data() << " "
|
---|
[2035] | 206 | << setw(14) << setprecision(3) << xc(1) << " "
|
---|
| 207 | << setw(14) << setprecision(3) << xc(2) << " "
|
---|
| 208 | << setw(14) << setprecision(3) << xc(3) << " "
|
---|
| 209 | << setw(14) << setprecision(6) << xc(4)*1.e6 << endl;
|
---|
| 210 | }
|
---|
| 211 | }
|
---|
| 212 |
|
---|
| 213 | cout << endl;
|
---|
| 214 | cout.flush();
|
---|
| 215 | }
|
---|