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

Last change on this file since 10818 was 10813, checked in by stuerze, 6 months ago

minor changes

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