// Part of BNC, a utility for retrieving decoding and // converting GNSS data streams from NTRIP broadcasters. // // Copyright (C) 2007 // German Federal Agency for Cartography and Geodesy (BKG) // http://www.bkg.bund.de // Czech Technical University Prague, Department of Geodesy // http://www.fsv.cvut.cz // // Email: euref-ip@bkg.bund.de // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation, version 2. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /* ------------------------------------------------------------------------- * BKG NTRIP Client * ------------------------------------------------------------------------- * * Class: t_pppEphPool * * Purpose: Buffer with satellite ephemerides * * Author: L. Mervart * * Created: 29-Jul-2014 * * Changes: * * -----------------------------------------------------------------------*/ #include #include "pppEphPool.h" #include "pppInclude.h" #include "pppClient.h" using namespace BNC_PPP; using namespace std; // ///////////////////////////////////////////////////////////////////////////// void t_pppEphPool::putEphemeris(t_eph* eph) { if (eph && eph->ok()) { _satEphPool[eph->prn().toInt()].putEphemeris(_maxQueueSize, eph); } else { delete eph; } } // ///////////////////////////////////////////////////////////////////////////// void t_pppEphPool::putOrbCorrection(t_orbCorr* corr) { if (corr) { _satEphPool[corr->prn().toInt()].putOrbCorrection(corr); } } // ///////////////////////////////////////////////////////////////////////////// void t_pppEphPool::putClkCorrection(t_clkCorr* corr) { if (corr) { _satEphPool[corr->prn().toInt()].putClkCorrection(corr); } } // ///////////////////////////////////////////////////////////////////////////// t_irc t_pppEphPool::getCrd(const t_prn& prn, const bncTime& tt, ColumnVector& xc, ColumnVector& vv) const { return _satEphPool[prn.toInt()].getCrd(tt, xc, vv); } // ///////////////////////////////////////////////////////////////////////////// int t_pppEphPool::getChannel(const t_prn& prn) const { return _satEphPool[prn.toInt()].getChannel(); } // ///////////////////////////////////////////////////////////////////////////// void t_pppEphPool::t_satEphPool::putEphemeris(unsigned maxQueueSize, t_eph* eph) { if (_ephs.empty() || eph->isNewerThan(_ephs.front())) { _ephs.push_front(eph); if (maxQueueSize > 0 && _ephs.size() > maxQueueSize) { delete _ephs.back(); _ephs.pop_back(); } } else { delete eph; } } // ///////////////////////////////////////////////////////////////////////////// void t_pppEphPool::t_satEphPool::putOrbCorrection(t_orbCorr* corr) { for (unsigned ii = 0; ii < _ephs.size(); ii++) { t_eph* eph = _ephs[ii]; if (eph->IOD() == corr->IOD()) { eph->setOrbCorr(corr); return; } } delete corr; } // ///////////////////////////////////////////////////////////////////////////// void t_pppEphPool::t_satEphPool::putClkCorrection(t_clkCorr* corr) { for (unsigned ii = 0; ii < _ephs.size(); ii++) { t_eph* eph = _ephs[ii]; if (eph->IOD() == corr->IOD()) { eph->setClkCorr(corr); } } delete corr; } // ///////////////////////////////////////////////////////////////////////////// t_irc t_pppEphPool::t_satEphPool::getCrd(const bncTime& tt, ColumnVector& xc, ColumnVector& vv) const { for (unsigned ii = 0; ii < _ephs.size(); ii++) { t_eph* eph = _ephs[ii]; t_irc irc = eph->getCrd(tt, xc, vv, OPT->useOrbClkCorr()); if (irc == success) { if (eph->prn().system() == 'R') { double age = tt - eph->TOC(); if (fabs(age) > 3600.0) { continue; } } return irc; } } return failure; } // ///////////////////////////////////////////////////////////////////////////// int t_pppEphPool::t_satEphPool::getChannel() const { if (_ephs.size() > 0) { return _ephs[0]->slotNum(); } return 0; }