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

Last change on this file since 10694 was 10694, checked in by stuerze, 3 weeks ago

some corrections are added for consistency before clock combination

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