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

Last change on this file since 10116 was 10116, checked in by stuerze, 17 months ago

minor changes

File size: 8.7 KB
Line 
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
16class bncRtnetDecoder;
17class bncAntex;
18class bncBiasSnx;
19
20class 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 _orbCorr = 0;
102 _clkCorr = 0;
103 _satCodeBias = 0;
104 _iod = 0;
105 _dClkResult = 0.0;
106 _satCodeBiasIF = 0.0;
107 _weightFactor = 1.0;
108 }
109 ~cmbCorr() {}
110 QString _prn;
111 bncTime _time;
112 unsigned long _iod;
113 t_eph* _eph;
114 t_orbCorr* _orbCorr;
115 t_clkCorr* _clkCorr;
116 t_satCodeBias* _satCodeBias;
117 QString _acName;
118 double _satCodeBiasIF;
119 double _dClkResult;
120 ColumnVector _diffRao;
121 double _weightFactor;
122 QString ID() {return _acName + "_" + _prn;}
123 };
124
125 class cmbEpoch {
126 public:
127 cmbEpoch() {}
128 ~cmbEpoch() {
129 clear();
130 }
131 void clear() {
132 QVectorIterator<cmbCorr*> it(corrs);
133 while (it.hasNext()) {
134 delete it.next();
135 }
136 }
137 QVector<cmbCorr*> corrs;
138 };
139
140 class epoClkData {
141 public:
142 epoClkData() {}
143 ~epoClkData() {
144 for (unsigned ii = 0; ii < _clkCorr.size(); ii++) {
145 delete _clkCorr[ii];
146 }
147 }
148 bncTime _time;
149 std::vector<t_clkCorr*> _clkCorr;
150 };
151
152
153
154 class cmbRefSig {
155 public:
156 enum type {dummy = 0, c1, c2, cIF};
157
158 static t_frequency::type toFreq(char sys, type tt) {
159 switch (tt) {
160 case c1:
161 if (sys == 'G') return t_frequency::G1;
162 else if (sys == 'R') return t_frequency::R1;
163 else if (sys == 'E') return t_frequency::E1;
164 else if (sys == 'C') return t_frequency::C2;
165 else if (sys == 'J') return t_frequency::J1;
166 else if (sys == 'S') return t_frequency::S1;
167 else return t_frequency::dummy;
168 case c2:
169 if (sys == 'G') return t_frequency::G2;
170 else if (sys == 'R') return t_frequency::R2;
171 else if (sys == 'E') return t_frequency::E5;
172 else if (sys == 'C') return t_frequency::C6;
173 else if (sys == 'J') return t_frequency::J2;
174 else if (sys == 'S') return t_frequency::S5;
175 else return t_frequency::dummy;
176 case dummy:
177 case cIF:
178 return t_frequency::dummy;
179 }
180 return t_frequency::dummy;
181 }
182
183 static char toAttrib(char sys, type LC) {
184 switch (LC) {
185 case c1:
186 if (sys == 'G') return 'W';
187 else if (sys == 'R') return 'P';
188 else if (sys == 'E') return 'C';
189 else if (sys == 'C') return 'I';
190 else if (sys == 'J') return 'C';
191 else if (sys == 'S') return 'C';
192 break;
193 case c2:
194 if (sys == 'G') return 'W';
195 else if (sys == 'R') return 'P';
196 else if (sys == 'E') return 'Q';
197 else if (sys == 'C') return 'I';
198 else if (sys == 'J') return 'L';
199 else if (sys == 'S') return 'Q';
200 break;
201 case dummy:
202 case cIF:
203 return '_';
204 break;
205 }
206 return '_';
207 }
208
209 static void coeff(char sys, type tLC, double channel, std::map<t_frequency::type, double>& codeCoeff) {
210 codeCoeff.clear();
211 t_frequency::type fType1 = toFreq(sys, c1);
212 t_frequency::type fType2 = toFreq(sys, c2);
213 double f1 = t_CST::freq(fType1, channel);
214 double f2 = t_CST::freq(fType2, channel);
215 switch (tLC) {
216 case c1:
217 codeCoeff[fType1] = 1.0;
218 return;
219 case c2:
220 codeCoeff[fType2] = 1.0;
221 return;
222 case cIF:
223 codeCoeff[fType1] = f1 * f1 / (f1 * f1 - f2 * f2);
224 codeCoeff[fType2] = -f2 * f2 / (f1 * f1 - f2 * f2);
225 return;
226 case cmbRefSig::dummy:
227 return;
228 }
229 return;
230 }
231 };
232
233 void processEpoch(bncTime epoTime, const std::vector<t_clkCorr*>& clkCorrVec);
234 void processSystem(bncTime epoTime, char sys, QTextStream& out);
235 t_irc processEpoch_filter(bncTime epoTime, char sys, QTextStream& out, QMap<QString, cmbCorr*>& resCorr, ColumnVector& dx);
236 t_irc processEpoch_singleEpoch(bncTime epoTime, char sys, QTextStream& out, QMap<QString, cmbCorr*>& resCorr, ColumnVector& dx);
237 t_irc createAmat(char sys, Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP,
238 const ColumnVector& x0, QMap<QString, cmbCorr*>& resCorr);
239 void dumpResults(bncTime epoTime, const QMap<QString, cmbCorr*>& resCorr);
240 void printResults(bncTime epoTime, QTextStream& out, const QMap<QString, cmbCorr*>& resCorr);
241 void switchToLastEph(t_eph* lastEph, cmbCorr* corr);
242 t_irc checkOrbits(bncTime epoTime, char sys, QTextStream& out);
243 QVector<cmbCorr*>& corrs(char sys) {return _buffer[sys].corrs;}
244
245 QMutex _mutex;
246 QList<cmbAC*> _ACs;
247 std::deque<epoClkData*> _epoClkData;
248 bncTime _lastClkCorrTime;
249 bncTime _resTime;
250 QMap<char, QVector<cmbParam*>> _params;
251 QMap<char, cmbEpoch> _buffer;
252 bncRtnetDecoder* _rtnetDecoder;
253 QMap<char, SymmetricMatrix> _QQ;
254 QByteArray _log;
255 bncAntex* _antex;
256 bncBiasSnx* _bsx;
257 double _MAXRES;
258 QMap<char, QString> _masterOrbitAC;
259 QMap<char, unsigned> _masterMissingEpochs;
260 QMap<char, bool> _masterIsAPC;
261 e_method _method;
262 int _cmbSampl;
263 int _ms;
264 QString _cmbRefAttributes;
265 QMap<QString, QMap<t_prn, t_orbCorr*> > _orbCorrections;
266 QMap<QString, QMap<t_prn, t_satCodeBias*> > _satCodeBiases;
267 bncEphUser _ephUser;
268 SsrCorr* _ssrCorr;
269 QMap<char, unsigned> _cmbSysPrn;
270 bool _useGps;
271 bool _useGlo;
272 bool _useGal;
273 bool _useBds;
274 bool _useQzss;
275 bool _useSbas;
276 bool _useIrnss;
277};
278
279#define BNC_CMB (bncComb::getInstance())
280
281#endif
Note: See TracBrowser for help on using the repository browser.