source: ntrip/trunk/BNC/src/combination/bnccomb.h@ 10460

Last change on this file since 10460 was 10451, checked in by stuerze, 9 months ago

two more options added to the combination procedure

File size: 9.0 KB
RevLine 
[2898]1
2#ifndef BNCCOMB_H
3#define BNCCOMB_H
4
[3035]5#include <fstream>
[10038]6#include <iostream>
[10275]7#ifndef WIN32
[10227]8#include <unistd.h>
[10275]9#else
10#include <windows.h>
11#endif
[9635]12#include <map>
[2933]13#include <newmat.h>
[10038]14#include <deque>
[2906]15#include "bncephuser.h"
[6141]16#include "satObs.h"
[9635]17#include "bncconst.h"
[9025]18#include "../RTCM3/clock_and_orbit/clock_orbit_rtcm.h"
19#include "../RTCM3/clock_and_orbit/clock_orbit_igs.h"
[2898]20
[3201]21class bncRtnetDecoder;
[3052]22class bncAntex;
[9676]23class bncBiasSnx;
[2927]24
[6443]25class bncComb : public QObject {
[2898]26 Q_OBJECT
27 public:
[10040]28 static bncComb* getInstance() {
29 if (instance == 0) {
30 instance = new bncComb;
31 }
32 return instance;
33 }
34 bncComb(const bncComb&) = delete;
35 bncComb& operator=(const bncComb&) = delete;
36 static void destruct() {
37 delete instance;
38 instance = nullptr;
39 }
[2918]40 int nStreams() const {return _ACs.size();}
[2898]41
[5583]42 public slots:
43 void slotProviderIDChanged(QString mountPoint);
[6155]44 void slotNewOrbCorrections(QList<t_orbCorr> orbCorrections);
45 void slotNewClkCorrections(QList<t_clkCorr> clkCorrections);
[9530]46 void slotNewCodeBiases(QList<t_satCodeBias> satCodeBiases);
[5583]47
[9676]48 private slots:
49 void slotReadBiasSnxFile();
50
[2898]51 signals:
52 void newMessage(QByteArray msg, bool showOnScreen);
[7085]53 void newOrbCorrections(QList<t_orbCorr>);
54 void newClkCorrections(QList<t_clkCorr>);
[9529]55 void newCodeBiases(QList<t_satCodeBias>);
[2898]56
57 private:
[10040]58 bncComb(); // no public constructor
59 ~bncComb(); // no public destructor
60 static bncComb* instance; // declaration class variable
[3470]61 enum e_method{singleEpoch, filter};
62
[6154]63 class cmbParam {
64 public:
[9258]65 enum parType {offACgnss, offACSat, clkSat};
[6154]66 cmbParam(parType type_, int index_, const QString& ac_, const QString& prn_);
67 ~cmbParam();
[9258]68 double partial(char sys, const QString& AC_, const QString& prn_);
69 QString toString(char sys) const;
[6154]70 parType type;
71 int index;
72 QString AC;
73 QString prn;
74 double xx;
75 double sig0;
76 double sigP;
77 bool epoSpec;
78 const t_eph* eph;
79 };
80
[2918]81 class cmbAC {
82 public:
[3433]83 cmbAC() {
[9821]84 weightFactor = 1.0;
85 numObs['G'] = 0;
86 numObs['R'] = 0;
87 numObs['E'] = 0;
88 numObs['C'] = 0;
89 numObs['J'] = 0;
90 numObs['S'] = 0;
91 numObs['I'] = 0;
[10116]92 isAPC = false;
[3433]93 }
[10229]94 ~cmbAC() {
95 numObs.clear();
96 }
[10235]97 QString mountPoint;
98 QString name;
99 double weightFactor;
[10451]100 QStringList excludeSats;
[10235]101 bool isAPC;
[9258]102 QMap<char, unsigned> numObs;
[2918]103 };
104
[6155]105 class cmbCorr {
[3423]106 public:
[6155]107 cmbCorr() {
[9819]108 _eph = 0;
109 _iod = 0;
110 _dClkResult = 0.0;
111 _satCodeBiasIF = 0.0;
[10038]112 _weightFactor = 1.0;
[6155]113 }
[10224]114 ~cmbCorr() {
115 }
[9676]116 QString _prn;
117 bncTime _time;
118 unsigned long _iod;
119 t_eph* _eph;
[10216]120 t_orbCorr _orbCorr;
[10225]121 t_clkCorr _clkCorr;
[10216]122 t_satCodeBias _satCodeBias;
[9676]123 QString _acName;
[9819]124 double _satCodeBiasIF;
[9676]125 double _dClkResult;
126 ColumnVector _diffRao;
[9821]127 double _weightFactor;
[6157]128 QString ID() {return _acName + "_" + _prn;}
[3423]129 };
130
[3434]131 class cmbEpoch {
132 public:
133 cmbEpoch() {}
134 ~cmbEpoch() {
[10038]135 clear();
136 }
137 void clear() {
[3434]138 QVectorIterator<cmbCorr*> it(corrs);
139 while (it.hasNext()) {
140 delete it.next();
141 }
[10235]142 corrs.clear();
[3434]143 }
[10235]144 QVector<cmbCorr*> corrs;
[3434]145 };
146
[10038]147 class epoClkData {
148 public:
149 epoClkData() {}
150 ~epoClkData() {
[10225]151 _clkCorr.erase(_clkCorr.begin(), _clkCorr.end());
[10038]152 }
153 bncTime _time;
[10235]154 std::vector<t_clkCorr> _clkCorr;
[10038]155 };
156
[9676]157 class cmbRefSig {
[9635]158 public:
159 enum type {dummy = 0, c1, c2, cIF};
160
161 static t_frequency::type toFreq(char sys, type tt) {
162 switch (tt) {
163 case c1:
164 if (sys == 'G') return t_frequency::G1;
165 else if (sys == 'R') return t_frequency::R1;
166 else if (sys == 'E') return t_frequency::E1;
167 else if (sys == 'C') return t_frequency::C2;
168 else if (sys == 'J') return t_frequency::J1;
169 else if (sys == 'S') return t_frequency::S1;
170 else return t_frequency::dummy;
171 case c2:
172 if (sys == 'G') return t_frequency::G2;
173 else if (sys == 'R') return t_frequency::R2;
174 else if (sys == 'E') return t_frequency::E5;
175 else if (sys == 'C') return t_frequency::C6;
176 else if (sys == 'J') return t_frequency::J2;
177 else if (sys == 'S') return t_frequency::S5;
178 else return t_frequency::dummy;
179 case dummy:
180 case cIF:
181 return t_frequency::dummy;
182 }
183 return t_frequency::dummy;
184 }
185
186 static char toAttrib(char sys, type LC) {
187 switch (LC) {
188 case c1:
189 if (sys == 'G') return 'W';
190 else if (sys == 'R') return 'P';
191 else if (sys == 'E') return 'C';
192 else if (sys == 'C') return 'I';
193 else if (sys == 'J') return 'C';
194 else if (sys == 'S') return 'C';
195 break;
196 case c2:
197 if (sys == 'G') return 'W';
198 else if (sys == 'R') return 'P';
199 else if (sys == 'E') return 'Q';
200 else if (sys == 'C') return 'I';
201 else if (sys == 'J') return 'L';
202 else if (sys == 'S') return 'Q';
203 break;
204 case dummy:
205 case cIF:
206 return '_';
207 break;
208 }
209 return '_';
210 }
211
212 static void coeff(char sys, type tLC, double channel, std::map<t_frequency::type, double>& codeCoeff) {
213 codeCoeff.clear();
214 t_frequency::type fType1 = toFreq(sys, c1);
215 t_frequency::type fType2 = toFreq(sys, c2);
216 double f1 = t_CST::freq(fType1, channel);
217 double f2 = t_CST::freq(fType2, channel);
218 switch (tLC) {
219 case c1:
220 codeCoeff[fType1] = 1.0;
221 return;
222 case c2:
223 codeCoeff[fType2] = 1.0;
224 return;
225 case cIF:
226 codeCoeff[fType1] = f1 * f1 / (f1 * f1 - f2 * f2);
227 codeCoeff[fType2] = -f2 * f2 / (f1 * f1 - f2 * f2);
228 return;
[9676]229 case cmbRefSig::dummy:
[9635]230 return;
231 }
232 return;
233 }
234 };
235
[10225]236 void processEpoch(bncTime epoTime, const std::vector<t_clkCorr>& clkCorrVec);
[10038]237 void processSystem(bncTime epoTime, char sys, QTextStream& out);
238 t_irc processEpoch_filter(bncTime epoTime, char sys, QTextStream& out, QMap<QString, cmbCorr*>& resCorr, ColumnVector& dx);
239 t_irc processEpoch_singleEpoch(bncTime epoTime, char sys, QTextStream& out, QMap<QString, cmbCorr*>& resCorr, ColumnVector& dx);
[9258]240 t_irc createAmat(char sys, Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP,
[6155]241 const ColumnVector& x0, QMap<QString, cmbCorr*>& resCorr);
[10229]242 void dumpResults(bncTime epoTime, QMap<QString, cmbCorr*>& resCorr);
[10038]243 void printResults(bncTime epoTime, QTextStream& out, const QMap<QString, cmbCorr*>& resCorr);
[7011]244 void switchToLastEph(t_eph* lastEph, cmbCorr* corr);
[10038]245 t_irc checkOrbits(bncTime epoTime, char sys, QTextStream& out);
[10451]246 bool excludeSat(const t_prn& prn, const QStringList excludeSats) const;
[10038]247 QVector<cmbCorr*>& corrs(char sys) {return _buffer[sys].corrs;}
[2918]248
[9529]249 QMutex _mutex;
250 QList<cmbAC*> _ACs;
[10038]251 std::deque<epoClkData*> _epoClkData;
252 bncTime _lastClkCorrTime;
[10042]253 bncTime _resTime;
[10227]254 cmbCorr* _newCorr;
[9529]255 bncRtnetDecoder* _rtnetDecoder;
256 QByteArray _log;
257 bncAntex* _antex;
[9676]258 bncBiasSnx* _bsx;
[10451]259 double _MAX_RES;
260 double _MAX_DISPLACEMENT;
[10216]261 e_method _method;
262 int _cmbSampl;
263 int _ms;
[10229]264 QMap<char, cmbEpoch> _buffer;
265 QMap<char, SymmetricMatrix> _QQ;
[9529]266 QMap<char, QString> _masterOrbitAC;
267 QMap<char, unsigned> _masterMissingEpochs;
[10116]268 QMap<char, bool> _masterIsAPC;
[10216]269 QMap<char, QVector<cmbParam*>> _params;
270 QMap<QString, QMap<t_prn, t_orbCorr> > _orbCorrections;
271 QMap<QString, QMap<t_prn, t_satCodeBias> > _satCodeBiases;
272 QMap<char, unsigned> _cmbSysPrn;
[9529]273 bncEphUser _ephUser;
274 SsrCorr* _ssrCorr;
[10229]275 QString _cmbRefAttributes;
[9529]276 bool _useGps;
277 bool _useGlo;
278 bool _useGal;
279 bool _useBds;
280 bool _useQzss;
281 bool _useSbas;
282 bool _useIrnss;
[10227]283 bool _running;
[2898]284};
285
[10040]286#define BNC_CMB (bncComb::getInstance())
[7299]287
[2898]288#endif
Note: See TracBrowser for help on using the repository browser.