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

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

bug fixed

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