| 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->ok()) {
|
|---|
| 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 | cout << "ORB: " << corr->_prn.toString() << ' ' << corr->IOD() << endl;
|
|---|
| 84 | for (unsigned ii = 0; ii < _ephs.size(); ii++) {
|
|---|
| 85 | t_eph* eph = _ephs[ii];
|
|---|
| 86 | if (eph->IOD() == corr->IOD()) {
|
|---|
| 87 | eph->setOrbCorr(corr);
|
|---|
| 88 | return;
|
|---|
| 89 | }
|
|---|
| 90 | }
|
|---|
| 91 | cout << "wrong" << endl;
|
|---|
| 92 | delete corr;
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | //
|
|---|
| 96 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 97 | void t_pppEphPool::t_satEphPool::putClkCorrection(t_clkCorr* corr) {
|
|---|
| 98 | cout << "CLK: " << corr->_prn.toString() << ' ' << corr->IOD() << ' ' << corr->_dClk << endl;
|
|---|
| 99 | bool set = false;
|
|---|
| 100 | for (unsigned ii = 0; ii < _ephs.size(); ii++) {
|
|---|
| 101 | t_eph* eph = _ephs[ii];
|
|---|
| 102 | if (eph->IOD() == corr->IOD()) {
|
|---|
| 103 | eph->setClkCorr(corr);
|
|---|
| 104 | set = true;
|
|---|
| 105 | }
|
|---|
| 106 | }
|
|---|
| 107 | if (!set) {
|
|---|
| 108 | cout << "wrong" << endl;
|
|---|
| 109 | }
|
|---|
| 110 | delete corr;
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | //
|
|---|
| 114 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 115 | t_irc t_pppEphPool::t_satEphPool::getCrd(const bncTime& tt, ColumnVector& xc,
|
|---|
| 116 | ColumnVector& vv) const {
|
|---|
| 117 | cout << "getCrd " << endl;
|
|---|
| 118 | for (unsigned ii = 0; ii < _ephs.size(); ii++) {
|
|---|
| 119 | t_eph* eph = _ephs[ii];
|
|---|
| 120 | t_irc irc = eph->getCrd(tt, xc, vv, OPT->useOrbClkCorr());
|
|---|
| 121 | cout << "getCrd " << eph->prn().toString() << ' ' << irc << endl;
|
|---|
| 122 | if (irc == success) {
|
|---|
| 123 | if (eph->prn().system() == 'R') {
|
|---|
| 124 | double age = tt - eph->TOC();
|
|---|
| 125 | if (fabs(age) > 3600.0) {
|
|---|
| 126 | continue;
|
|---|
| 127 | }
|
|---|
| 128 | }
|
|---|
| 129 | return irc;
|
|---|
| 130 | }
|
|---|
| 131 | }
|
|---|
| 132 | return failure;
|
|---|
| 133 | }
|
|---|
| 134 |
|
|---|
| 135 | //
|
|---|
| 136 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 137 | int t_pppEphPool::t_satEphPool::getChannel() const {
|
|---|
| 138 | if (_ephs.size() > 0) {
|
|---|
| 139 | return _ephs[0]->slotNum();
|
|---|
| 140 | }
|
|---|
| 141 | return 0;
|
|---|
| 142 | }
|
|---|