| 1 | /* -------------------------------------------------------------------------
|
|---|
| 2 | * BKG NTRIP Client
|
|---|
| 3 | * -------------------------------------------------------------------------
|
|---|
| 4 | *
|
|---|
| 5 | * Class: t_pppEphPool
|
|---|
| 6 | *
|
|---|
| 7 | * Purpose: Buffer with satellite ephemerides
|
|---|
| 8 | *
|
|---|
| 9 | * Author: L. Mervart
|
|---|
| 10 | *
|
|---|
| 11 | * Created: 29-Jul-2014
|
|---|
| 12 | *
|
|---|
| 13 | * Changes:
|
|---|
| 14 | *
|
|---|
| 15 | * -----------------------------------------------------------------------*/
|
|---|
| 16 |
|
|---|
| 17 | #include <iostream>
|
|---|
| 18 | #include "pppEphPool.h"
|
|---|
| 19 | #include "pppInclude.h"
|
|---|
| 20 | #include "pppClient.h"
|
|---|
| 21 |
|
|---|
| 22 | using namespace BNC_PPP;
|
|---|
| 23 | using namespace std;
|
|---|
| 24 |
|
|---|
| 25 | //
|
|---|
| 26 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 27 | void t_pppEphPool::putEphemeris(t_eph* eph) {
|
|---|
| 28 | if (eph && eph->checkState() != t_eph::bad) {
|
|---|
| 29 | _satEphPool[eph->prn().toInt()].putEphemeris(_maxQueueSize, eph);
|
|---|
| 30 | }
|
|---|
| 31 | else {
|
|---|
| 32 | delete eph;
|
|---|
| 33 | }
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | //
|
|---|
| 37 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 38 | void t_pppEphPool::putOrbCorrection(t_orbCorr* corr) {
|
|---|
| 39 | if (corr) {
|
|---|
| 40 | _satEphPool[corr->_prn.toInt()].putOrbCorrection(corr);
|
|---|
| 41 | }
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | //
|
|---|
| 45 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 46 | void t_pppEphPool::putClkCorrection(t_clkCorr* corr) {
|
|---|
| 47 | if (corr) {
|
|---|
| 48 | _satEphPool[corr->_prn.toInt()].putClkCorrection(corr);
|
|---|
| 49 | }
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | //
|
|---|
| 53 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 54 | t_irc t_pppEphPool::getCrd(const t_prn& prn, const bncTime& tt,
|
|---|
| 55 | ColumnVector& xc, ColumnVector& vv) const {
|
|---|
| 56 | return _satEphPool[prn.toInt()].getCrd(tt, xc, vv);
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | //
|
|---|
| 60 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 61 | int t_pppEphPool::getChannel(const t_prn& prn) const {
|
|---|
| 62 | return _satEphPool[prn.toInt()].getChannel();
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | //
|
|---|
| 66 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 67 | void t_pppEphPool::t_satEphPool::putEphemeris(unsigned maxQueueSize, t_eph* eph) {
|
|---|
| 68 | if (_ephs.empty() || eph->isNewerThan(_ephs.front())) {
|
|---|
| 69 | _ephs.push_front(eph);
|
|---|
| 70 | if (maxQueueSize > 0 && _ephs.size() > maxQueueSize) {
|
|---|
| 71 | delete _ephs.back();
|
|---|
| 72 | _ephs.pop_back();
|
|---|
| 73 | }
|
|---|
| 74 | }
|
|---|
| 75 | else {
|
|---|
| 76 | delete eph;
|
|---|
| 77 | }
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | //
|
|---|
| 81 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 82 | void t_pppEphPool::t_satEphPool::putOrbCorrection(t_orbCorr* corr) {
|
|---|
| 83 | for (unsigned ii = 0; ii < _ephs.size(); ii++) {
|
|---|
| 84 | t_eph* eph = _ephs[ii];
|
|---|
| 85 | if (eph->IOD() == corr->_iod) {
|
|---|
| 86 | eph->setOrbCorr(corr);
|
|---|
| 87 | }
|
|---|
| 88 | }
|
|---|
| 89 | delete corr;
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | //
|
|---|
| 93 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 94 | void t_pppEphPool::t_satEphPool::putClkCorrection(t_clkCorr* corr) {
|
|---|
| 95 | for (unsigned ii = 0; ii < _ephs.size(); ii++) {
|
|---|
| 96 | t_eph* eph = _ephs[ii];
|
|---|
| 97 | if (eph->IOD() == corr->_iod) {
|
|---|
| 98 | eph->setClkCorr(corr);
|
|---|
| 99 | }
|
|---|
| 100 | }
|
|---|
| 101 | delete corr;
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | //
|
|---|
| 105 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 106 | t_irc t_pppEphPool::t_satEphPool::getCrd(const bncTime& tt, ColumnVector& xc,
|
|---|
| 107 | ColumnVector& vv) const {
|
|---|
| 108 | for (unsigned ii = 0; ii < _ephs.size(); ii++) {
|
|---|
| 109 | t_eph* eph = _ephs[ii];
|
|---|
| 110 | t_irc irc = eph->getCrd(tt, xc, vv, OPT->useOrbClkCorr());
|
|---|
| 111 | if (irc == success) {
|
|---|
| 112 | if (eph->prn().system() == 'R') {
|
|---|
| 113 | double age = tt - eph->TOC();
|
|---|
| 114 | if (fabs(age) > 3600.0) {
|
|---|
| 115 | continue;
|
|---|
| 116 | }
|
|---|
| 117 | }
|
|---|
| 118 | return irc;
|
|---|
| 119 | }
|
|---|
| 120 | }
|
|---|
| 121 | return failure;
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | //
|
|---|
| 125 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 126 | int t_pppEphPool::t_satEphPool::getChannel() const {
|
|---|
| 127 | if (_ephs.size() > 0) {
|
|---|
| 128 | return _ephs[0]->slotNum();
|
|---|
| 129 | }
|
|---|
| 130 | return 0;
|
|---|
| 131 | }
|
|---|