Changeset 6083 in ntrip
- Timestamp:
- Sep 7, 2014, 6:35:49 PM (10 years ago)
- Location:
- trunk/BNC/src/PPP_free
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/PPP_free/bncpppclient.cpp
r6082 r6083 54 54 using namespace std; 55 55 56 // Global variable holding thread-specific pointers 57 ////////////////////////////////////////////////////////////////////////////// 58 bncPPPclient* PPP_CLIENT = 0; 59 60 // Static function returning thread-specific pointer 61 ////////////////////////////////////////////////////////////////////////////// 62 bncPPPclient* t_pppClient::instance() { 63 return PPP_CLIENT; 64 } 65 56 66 // Constructor 57 67 //////////////////////////////////////////////////////////////////////////// 58 bncPPPclient::bncPPPclient(QByteArray staID, const t_pppOptions* opt) : bncEphUser(false) { 59 60 _opt = opt; 61 _staID = staID; 62 _model = new bncModel(this); 63 _epoData = new t_epoData(); 68 bncPPPclient::bncPPPclient(const t_pppOptions* opt) : bncEphUser(false) { 69 70 _opt = new t_pppOptions(*opt); 71 _staID = QByteArray(_opt->_roverName.c_str()) 72 _model = new bncModel(this); 73 _epoData = new t_epoData(); 74 PPP_CLIENT = this; 64 75 } 65 76 … … 82 93 83 94 delete _model; 95 delete _epoData; 96 delete _opt; 84 97 } 85 98 … … 231 244 } 232 245 246 // 247 ////////////////////////////////////////////////////////////////////////////// 248 void t_pppClient::putEphemeris(const t_eph* eph) { 249 const t_ephGPS* ephGPS = dynamic_cast<const t_ephGPS*>(eph); 250 const t_ephGlo* ephGlo = dynamic_cast<const t_ephGlo*>(eph); 251 const t_ephGal* ephGal = dynamic_cast<const t_ephGal*>(eph); 252 if (ephGPS) { 253 putNewEph(new t_ephGPS(*ephGPS)); 254 } 255 else if (ephGlo) { 256 putNewEph(new t_ephGlo(*ephGlo)); 257 } 258 else if (ephGal) { 259 putNewEph(new t_ephGal(*ephGal)); 260 } 261 } 262 233 263 // Satellite Position 234 264 //////////////////////////////////////////////////////////////////////////// -
trunk/BNC/src/PPP_free/bncpppclient.h
r6082 r6083 28 28 #include <vector> 29 29 #include "bncephuser.h" 30 #include "GPSDecoder.h"31 32 30 33 31 namespace BNC_PPP { … … 41 39 class t_orbCorr; 42 40 class t_clkCorr; 41 class t_satBias; 43 42 44 43 class bncPPPclient : public bncEphUser { 45 44 public: 46 bncPPPclient( QByteArray staID,const t_pppOptions* opt);45 bncPPPclient(const t_pppOptions* opt); 47 46 ~bncPPPclient(); 48 void processEpoch(const std::vector<t_satObs*>& satObs, t_output* output); 49 void putOrbCorrections(const std::vector<t_orbCorr*>& corr); 50 void putClkCorrections(const std::vector<t_clkCorr*>& corr); 51 QByteArray staID() const {return _staID;} 52 const t_pppOptions* opt() const {return _opt;} 47 void processEpoch(const std::vector<t_satObs*>& satObs, t_output* output); 48 void putEphemeris(const t_eph* eph); 49 void putOrbCorrections(const std::vector<t_orbCorr*>& corr); 50 void putClkCorrections(const std::vector<t_clkCorr*>& corr); 51 void putBiases(const std::vector<t_satBias*>& satBias); 52 QByteArray staID() const {return _staID;} 53 const t_pppOptions* opt() const {return _opt;} 54 static bncPPPclient* instance(); 55 std::ostringstream& log() {return *_log;} 53 56 54 57 private: 55 class slipInfo {56 public:57 slipInfo() {58 slipCntL1 = -1;59 slipCntL2 = -1;60 slipCntL5 = -1;61 }62 ~slipInfo(){}63 int slipCntL1;64 int slipCntL2;65 int slipCntL5;66 };67 68 58 t_irc getSatPos(const bncTime& tt, const QString& prn, ColumnVector& xc, ColumnVector& vv); 69 59 void putNewObs(t_satData* satData); 70 60 t_irc cmpToT(t_satData* satData); 71 61 72 const t_pppOptions* _opt; 73 QByteArray _staID; 74 QMap<QString, t_corr*> _corr; 75 bncTime _corr_tt; 76 QMap<QString, t_bias*> _bias; 77 t_epoData* _epoData; 78 bncModel* _model; 62 t_pppOptions* _opt; 63 QByteArray _staID; 64 t_epoData* _epoData; 65 bncModel* _model; 66 std::ostringstream* _log; 79 67 }; 80 68 … … 162 150 } 163 151 152 #define LOG (BNC_PPP::t_pppClient::instance()->log()) 153 164 154 #endif -
trunk/BNC/src/PPP_free/pppClient.cpp
r6082 r6083 1 2 1 // Part of BNC, a utility for retrieving decoding and 3 2 // converting GNSS data streams from NTRIP broadcasters. … … 28 27 * ------------------------------------------------------------------------- 29 28 * 30 * Class: t_pppClient31 * 32 * Purpose: P PP Client processing starts here29 * Class: bncPPPclient 30 * 31 * Purpose: Precise Point Positioning 33 32 * 34 33 * Author: L. Mervart 35 34 * 36 * Created: 2 9-Jul-201435 * Created: 21-Nov-2009 37 36 * 38 37 * Changes: … … 40 39 * -----------------------------------------------------------------------*/ 41 40 42 #include <QThreadStorage> 43 44 #include <iostream> 41 #include <newmatio.h> 45 42 #include <iomanip> 46 #include <stdlib.h> 47 #include <string.h> 48 #include <stdexcept> 49 43 #include <sstream> 44 45 #include "bncpppclient.h" 46 #include "bnccore.h" 47 #include "bncutils.h" 48 #include "bncconst.h" 49 #include "bncmodel.h" 50 #include "pppOptions.h" 50 51 #include "pppClient.h" 51 #include "bncconst.h"52 #include "bncutils.h"53 #include "bncantex.h"54 52 55 53 using namespace BNC_PPP; … … 58 56 // Global variable holding thread-specific pointers 59 57 ////////////////////////////////////////////////////////////////////////////// 60 t_pppClient* PPP_CLIENT = 0;58 bncPPPclient* PPP_CLIENT = 0; 61 59 62 60 // Static function returning thread-specific pointer 63 61 ////////////////////////////////////////////////////////////////////////////// 64 t_pppClient* t_pppClient::instance() {62 bncPPPclient* t_pppClient::instance() { 65 63 return PPP_CLIENT; 66 64 } 67 65 68 66 // Constructor 69 ////////////////////////////////////////////////////////////////////////////// 70 t_pppClient::t_pppClient(const t_pppOptions* opt) { 67 //////////////////////////////////////////////////////////////////////////// 68 bncPPPclient::bncPPPclient(const t_pppOptions* opt) : bncEphUser(false) { 69 71 70 _opt = new t_pppOptions(*opt); 72 _log = new ostringstream(); 73 _client = new bncPPPclient(QByteArray(_opt->_roverName.c_str()), _opt); 71 _staID = QByteArray(_opt->_roverName.c_str()) 72 _model = new bncModel(this); 73 _epoData = new t_epoData(); 74 74 PPP_CLIENT = this; 75 75 } 76 76 77 77 // Destructor 78 ////////////////////////////////////////////////////////////////////////////// 79 t_pppClient::~t_pppClient() { 80 delete _log; 78 //////////////////////////////////////////////////////////////////////////// 79 bncPPPclient::~bncPPPclient() { 80 _epoData->clear(); 81 82 QMapIterator<QString, t_corr*> ic(_corr); 83 while (ic.hasNext()) { 84 ic.next(); 85 delete ic.value(); 86 } 87 88 QMapIterator<QString, t_bias*> ib(_bias); 89 while (ib.hasNext()) { 90 ib.next(); 91 delete ib.value(); 92 } 93 94 delete _model; 95 delete _epoData; 81 96 delete _opt; 82 delete _client; 97 } 98 99 // 100 //////////////////////////////////////////////////////////////////////////// 101 void bncPPPclient::processEpoch(const vector<t_satObs*>& satObs, t_output* output) { 102 QMutexLocker locker(&_mutex); 103 104 // Convert and store observations 105 // ------------------------------ 106 _epoData->clear(); 107 for (unsigned ii = 0; ii < satObs.size(); ii++) { 108 const t_satObs* obs = satObs[ii]; 109 t_satData* satData = new t_satData(); 110 111 if (_epoData->tt.undef()) { 112 _epoData->tt = obs->_time; 113 } 114 115 satData->tt = obs->_time; 116 satData->prn = QString(obs->_prn.toString().c_str()); 117 satData->slipFlag = false; 118 satData->P1 = 0.0; 119 satData->P2 = 0.0; 120 satData->P5 = 0.0; 121 satData->L1 = 0.0; 122 satData->L2 = 0.0; 123 satData->L5 = 0.0; 124 for (unsigned ifrq = 0; ifrq < obs->_obs.size(); ifrq++) { 125 t_frqObs* frqObs = obs->_obs[ifrq]; 126 if (frqObs->_rnxType2ch[0] == '1') { 127 if (frqObs->_codeValid) satData->P1 = frqObs->_code; 128 if (frqObs->_phaseValid) satData->L1 = frqObs->_phase; 129 if (frqObs->_slip) satData->slipFlag = true; 130 } 131 else if (frqObs->_rnxType2ch[0] == '2') { 132 if (frqObs->_codeValid) satData->P2 = frqObs->_code; 133 if (frqObs->_phaseValid) satData->L2 = frqObs->_phase; 134 if (frqObs->_slip) satData->slipFlag = true; 135 } 136 else if (frqObs->_rnxType2ch[0] == '5') { 137 if (frqObs->_codeValid) satData->P5 = frqObs->_code; 138 if (frqObs->_phaseValid) satData->L5 = frqObs->_phase; 139 if (frqObs->_slip) satData->slipFlag = true; 140 } 141 } 142 putNewObs(satData); 143 } 144 145 // Data Pre-Processing 146 // ------------------- 147 QMutableMapIterator<QString, t_satData*> it(_epoData->satData); 148 while (it.hasNext()) { 149 it.next(); 150 QString prn = it.key(); 151 t_satData* satData = it.value(); 152 153 if (cmpToT(satData) != success) { 154 delete satData; 155 it.remove(); 156 continue; 157 } 158 } 159 160 // Filter Solution 161 // --------------- 162 if (_model->update(_epoData) == success) { 163 output->_error = false; 164 output->_epoTime = _model->time(); 165 output->_xyzRover[0] = _model->x(); 166 output->_xyzRover[1] = _model->y(); 167 output->_xyzRover[2] = _model->z(); 168 output->_numSat = 0; 169 output->_pDop = 0.0; 170 } 171 else { 172 output->_error = true; 173 } 174 175 output->_log = LOG.str(); 176 } 177 178 // 179 //////////////////////////////////////////////////////////////////////////// 180 void bncPPPclient::putNewObs(t_satData* satData) { 181 182 // Set Observations GPS and Glonass 183 // -------------------------------- 184 if (satData->system() == 'G' || satData->system() == 'R') { 185 if (satData->P1 != 0.0 && satData->P2 != 0.0 && 186 satData->L1 != 0.0 && satData->L2 != 0.0 ) { 187 188 int channel = 0; 189 if (satData->system() == 'R') { 190 // cerr << "not yet implemented" << endl; 191 // exit(0); 192 } 193 194 t_frequency::type fType1 = t_lc::toFreq(satData->system(), t_lc::l1); 195 t_frequency::type fType2 = t_lc::toFreq(satData->system(), t_lc::l2); 196 double f1 = t_CST::freq(fType1, channel); 197 double f2 = t_CST::freq(fType2, channel); 198 double a1 = f1 * f1 / (f1 * f1 - f2 * f2); 199 double a2 = - f2 * f2 / (f1 * f1 - f2 * f2); 200 satData->L1 = satData->L1 * t_CST::c / f1; 201 satData->L2 = satData->L2 * t_CST::c / f2; 202 satData->P3 = a1 * satData->P1 + a2 * satData->P2; 203 satData->L3 = a1 * satData->L1 + a2 * satData->L2; 204 satData->lambda3 = a1 * t_CST::c / f1 + a2 * t_CST::c / f2; 205 _epoData->satData[satData->prn] = satData; 206 } 207 else { 208 delete satData; 209 } 210 } 211 212 // Set Observations Galileo 213 // ------------------------ 214 else if (satData->system() == 'E') { 215 if (satData->P1 != 0.0 && satData->P5 != 0.0 && 216 satData->L1 != 0.0 && satData->L5 != 0.0 ) { 217 double f1 = t_CST::freq(t_frequency::E1, 0); 218 double f5 = t_CST::freq(t_frequency::E5, 0); 219 double a1 = f1 * f1 / (f1 * f1 - f5 * f5); 220 double a5 = - f5 * f5 / (f1 * f1 - f5 * f5); 221 satData->L1 = satData->L1 * t_CST::c / f1; 222 satData->L5 = satData->L5 * t_CST::c / f5; 223 satData->P3 = a1 * satData->P1 + a5 * satData->P5; 224 satData->L3 = a1 * satData->L1 + a5 * satData->L5; 225 satData->lambda3 = a1 * t_CST::c / f1 + a5 * t_CST::c / f5; 226 _epoData->satData[satData->prn] = satData; 227 } 228 else { 229 delete satData; 230 } 231 } 232 } 233 234 // 235 //////////////////////////////////////////////////////////////////////////// 236 void bncPPPclient::putOrbCorrections(const std::vector<t_orbCorr*>& corr) { 237 QMutexLocker locker(&_mutex); 238 } 239 240 // 241 //////////////////////////////////////////////////////////////////////////// 242 void bncPPPclient::putClkCorrections(const std::vector<t_clkCorr*>& corr) { 243 QMutexLocker locker(&_mutex); 83 244 } 84 245 … … 90 251 const t_ephGal* ephGal = dynamic_cast<const t_ephGal*>(eph); 91 252 if (ephGPS) { 92 _client->putNewEph(new t_ephGPS(*ephGPS));253 putNewEph(new t_ephGPS(*ephGPS)); 93 254 } 94 255 else if (ephGlo) { 95 _client->putNewEph(new t_ephGlo(*ephGlo));256 putNewEph(new t_ephGlo(*ephGlo)); 96 257 } 97 258 else if (ephGal) { 98 _client->putNewEph(new t_ephGal(*ephGal)); 99 } 100 } 101 102 // 103 ////////////////////////////////////////////////////////////////////////////// 104 void t_pppClient::putOrbCorrections(const vector<t_orbCorr*>& corr) { 105 _client->putOrbCorrections(corr); 106 } 107 108 // 109 ////////////////////////////////////////////////////////////////////////////// 110 void t_pppClient::putClkCorrections(const vector<t_clkCorr*>& corr) { 111 _client->putClkCorrections(corr); 112 } 113 114 // 115 ////////////////////////////////////////////////////////////////////////////// 116 void t_pppClient::putBiases(const vector<t_satBias*>& biases) { 117 } 118 119 // 120 ////////////////////////////////////////////////////////////////////////////// 121 void t_pppClient::processEpoch(const vector<t_satObs*>& satObs, t_output* output) { 122 _client->processEpoch(satObs, output); 123 } 124 259 putNewEph(new t_ephGal(*ephGal)); 260 } 261 } 262 263 // Satellite Position 264 //////////////////////////////////////////////////////////////////////////// 265 t_irc bncPPPclient::getSatPos(const bncTime& tt, const QString& prn, 266 ColumnVector& xc, ColumnVector& vv) { 267 if (_eph.contains(prn)) { 268 t_eph* eLast = _eph.value(prn)->last; 269 t_eph* ePrev = _eph.value(prn)->prev; 270 if (eLast && eLast->getCrd(tt, xc, vv, _opt->useOrbClkCorr()) == success) { 271 return success; 272 } 273 else if (ePrev && ePrev->getCrd(tt, xc, vv, _opt->useOrbClkCorr()) == success) { 274 return success; 275 } 276 } 277 return failure; 278 } 279 280 // Correct Time of Transmission 281 //////////////////////////////////////////////////////////////////////////// 282 t_irc bncPPPclient::cmpToT(t_satData* satData) { 283 284 double prange = satData->P3; 285 if (prange == 0.0) { 286 return failure; 287 } 288 289 double clkSat = 0.0; 290 for (int ii = 1; ii <= 10; ii++) { 291 292 bncTime ToT = satData->tt - prange / t_CST::c - clkSat; 293 294 ColumnVector xc(4); 295 ColumnVector vv(3); 296 if (getSatPos(ToT, satData->prn, xc, vv) != success) { 297 return failure; 298 } 299 300 double clkSatOld = clkSat; 301 clkSat = xc(4); 302 303 if ( fabs(clkSat-clkSatOld) * t_CST::c < 1.e-4 ) { 304 satData->xx = xc.Rows(1,3); 305 satData->vv = vv; 306 satData->clk = clkSat * t_CST::c; 307 return success; 308 } 309 } 310 311 return failure; 312 } 313 -
trunk/BNC/src/PPP_free/pppClient.h
r6067 r6083 1 #ifndef PPPCLIENT_H 2 #define PPPCLIENT_H 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. 3 24 4 #include <sstream> 25 #ifndef BNCPPPCLIENT_H 26 #define BNCPPPCLIENT_H 27 5 28 #include <vector> 6 #include "pppInclude.h" 7 #include "ephemeris.h" 8 #include "pppOptions.h" 9 #include "bncpppclient.h" 29 #include "bncephuser.h" 10 30 11 31 namespace BNC_PPP { 32 33 class bncModel; 34 class t_pppOptions; 35 class t_satObs; 36 class t_satData; 37 class t_epoData; 38 class t_output; 39 class t_orbCorr; 40 class t_clkCorr; 41 class t_satBias; 12 42 13 class t_pppClient{43 class bncPPPclient : public bncEphUser { 14 44 public: 15 t_pppClient(const t_pppOptions* opt);16 ~ t_pppClient();17 18 void putEphemeris(const t_eph* eph);19 void putOrbCorrections(const std::vector<t_orbCorr*>& corr);20 void putClkCorrections(const std::vector<t_clkCorr*>& corr);21 void putBiases(const std::vector<t_satBias*>& satBias);22 void processEpoch(const std::vector<t_satObs*>& satObs, t_output* output);23 24 static t_pppClient* instance();25 std::ostringstream& log() {return *_log;}45 bncPPPclient(const t_pppOptions* opt); 46 ~bncPPPclient(); 47 void processEpoch(const std::vector<t_satObs*>& satObs, t_output* output); 48 void putEphemeris(const t_eph* eph); 49 void putOrbCorrections(const std::vector<t_orbCorr*>& corr); 50 void putClkCorrections(const std::vector<t_clkCorr*>& corr); 51 void putBiases(const std::vector<t_satBias*>& satBias); 52 QByteArray staID() const {return _staID;} 53 const t_pppOptions* opt() const {return _opt;} 54 static bncPPPclient* instance(); 55 std::ostringstream& log() {return *_log;} 26 56 27 57 private: 58 t_irc getSatPos(const bncTime& tt, const QString& prn, ColumnVector& xc, ColumnVector& vv); 59 void putNewObs(t_satData* satData); 60 t_irc cmpToT(t_satData* satData); 61 62 t_pppOptions* _opt; 63 QByteArray _staID; 64 t_epoData* _epoData; 65 bncModel* _model; 28 66 std::ostringstream* _log; 29 t_pppOptions* _opt;30 bncPPPclient* _client;31 67 }; 32 68 33 }; // namespace BNC_PPP 69 class t_satData { 70 public: 71 t_satData() { 72 obsIndex = 0; 73 P1 = 0.0; 74 P2 = 0.0; 75 P5 = 0.0; 76 P3 = 0.0; 77 L1 = 0.0; 78 L2 = 0.0; 79 L5 = 0.0; 80 L3 = 0.0; 81 } 82 ~t_satData() {} 83 bncTime tt; 84 QString prn; 85 double P1; 86 double P2; 87 double P5; 88 double P3; 89 double L1; 90 double L2; 91 double L5; 92 double L3; 93 ColumnVector xx; 94 ColumnVector vv; 95 double clk; 96 double eleSat; 97 double azSat; 98 double rho; 99 bool slipFlag; 100 double lambda3; 101 unsigned obsIndex; 102 char system() const {return prn.toAscii()[0];} 103 }; 104 105 class t_epoData { 106 public: 107 t_epoData() {} 108 109 ~t_epoData() { 110 clear(); 111 } 112 113 void clear() { 114 QMapIterator<QString, t_satData*> it(satData); 115 while (it.hasNext()) { 116 it.next(); 117 delete it.value(); 118 } 119 satData.clear(); 120 tt.reset(); 121 } 122 123 void deepCopy(const t_epoData* from) { 124 clear(); 125 tt = from->tt; 126 QMapIterator<QString, t_satData*> it(from->satData); 127 while (it.hasNext()) { 128 it.next(); 129 satData[it.key()] = new t_satData(*it.value()); 130 } 131 } 132 133 unsigned sizeSys(char system) const { 134 unsigned ans = 0; 135 QMapIterator<QString, t_satData*> it(satData); 136 while (it.hasNext()) { 137 it.next(); 138 if (it.value()->system() == system) { 139 ++ans; 140 } 141 } 142 return ans; 143 } 144 unsigned sizeAll() const {return satData.size();} 145 146 bncTime tt; 147 QMap<QString, t_satData*> satData; 148 }; 149 150 } 34 151 35 152 #define LOG (BNC_PPP::t_pppClient::instance()->log())
Note:
See TracChangeset
for help on using the changeset viewer.