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