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

Last change on this file since 10235 was 10235, checked in by stuerze, 7 months ago

minor changes

File size: 8.8 KB
Line 
1
2#ifndef BNCCOMB_H
3#define BNCCOMB_H
4
5#include <fstream>
6#include <iostream>
7#include <unistd.h>
8#include <map>
9#include <newmat.h>
10#include <deque>
11#include "bncephuser.h"
12#include "satObs.h"
13#include "bncconst.h"
14#include "../RTCM3/clock_and_orbit/clock_orbit_rtcm.h"
15#include "../RTCM3/clock_and_orbit/clock_orbit_igs.h"
16
17class bncRtnetDecoder;
18class bncAntex;
19class bncBiasSnx;
20
21class bncComb : public QObject {
22 Q_OBJECT
23 public:
24 static bncComb* getInstance() {
25 if (instance == 0) {
26 instance = new bncComb;
27 }
28 return instance;
29 }
30 bncComb(const bncComb&) = delete;
31 bncComb& operator=(const bncComb&) = delete;
32 static void destruct() {
33 delete instance;
34 instance = nullptr;
35 }
36 int nStreams() const {return _ACs.size();}
37
38 public slots:
39 void slotProviderIDChanged(QString mountPoint);
40 void slotNewOrbCorrections(QList<t_orbCorr> orbCorrections);
41 void slotNewClkCorrections(QList<t_clkCorr> clkCorrections);
42 void slotNewCodeBiases(QList<t_satCodeBias> satCodeBiases);
43
44 private slots:
45 void slotReadBiasSnxFile();
46
47 signals:
48 void newMessage(QByteArray msg, bool showOnScreen);
49 void newOrbCorrections(QList<t_orbCorr>);
50 void newClkCorrections(QList<t_clkCorr>);
51 void newCodeBiases(QList<t_satCodeBias>);
52
53 private:
54 bncComb(); // no public constructor
55 ~bncComb(); // no public destructor
56 static bncComb* instance; // declaration class variable
57 enum e_method{singleEpoch, filter};
58
59 class cmbParam {
60 public:
61 enum parType {offACgnss, offACSat, clkSat};
62 cmbParam(parType type_, int index_, const QString& ac_, const QString& prn_);
63 ~cmbParam();
64 double partial(char sys, const QString& AC_, const QString& prn_);
65 QString toString(char sys) const;
66 parType type;
67 int index;
68 QString AC;
69 QString prn;
70 double xx;
71 double sig0;
72 double sigP;
73 bool epoSpec;
74 const t_eph* eph;
75 };
76
77 class cmbAC {
78 public:
79 cmbAC() {
80 weightFactor = 1.0;
81 numObs['G'] = 0;
82 numObs['R'] = 0;
83 numObs['E'] = 0;
84 numObs['C'] = 0;
85 numObs['J'] = 0;
86 numObs['S'] = 0;
87 numObs['I'] = 0;
88 isAPC = false;
89 }
90 ~cmbAC() {
91 numObs.clear();
92 }
93 QString mountPoint;
94 QString name;
95 double weightFactor;
96 bool isAPC;
97 QMap<char, unsigned> numObs;
98 };
99
100 class cmbCorr {
101 public:
102 cmbCorr() {
103 _eph = 0;
104 _iod = 0;
105 _dClkResult = 0.0;
106 _satCodeBiasIF = 0.0;
107 _weightFactor = 1.0;
108 }
109 ~cmbCorr() {
110 }
111 QString _prn;
112 bncTime _time;
113 unsigned long _iod;
114 t_eph* _eph;
115 t_orbCorr _orbCorr;
116 t_clkCorr _clkCorr;
117 t_satCodeBias _satCodeBias;
118 QString _acName;
119 double _satCodeBiasIF;
120 double _dClkResult;
121 ColumnVector _diffRao;
122 double _weightFactor;
123 QString ID() {return _acName + "_" + _prn;}
124 };
125
126 class cmbEpoch {
127 public:
128 cmbEpoch() {}
129 ~cmbEpoch() {
130 clear();
131 }
132 void clear() {
133 QVectorIterator<cmbCorr*> it(corrs);
134 while (it.hasNext()) {
135 delete it.next();
136 }
137 corrs.clear();
138 }
139 QVector<cmbCorr*> corrs;
140 };
141
142 class epoClkData {
143 public:
144 epoClkData() {}
145 ~epoClkData() {
146 _clkCorr.erase(_clkCorr.begin(), _clkCorr.end());
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, 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 cmbCorr* _newCorr;
251 bncRtnetDecoder* _rtnetDecoder;
252 QByteArray _log;
253 bncAntex* _antex;
254 bncBiasSnx* _bsx;
255 double _MAXRES;
256 e_method _method;
257 int _cmbSampl;
258 int _ms;
259 QMap<char, cmbEpoch> _buffer;
260 QMap<char, SymmetricMatrix> _QQ;
261 QMap<char, QString> _masterOrbitAC;
262 QMap<char, unsigned> _masterMissingEpochs;
263 QMap<char, bool> _masterIsAPC;
264 QMap<char, QVector<cmbParam*>> _params;
265 QMap<QString, QMap<t_prn, t_orbCorr> > _orbCorrections;
266 QMap<QString, QMap<t_prn, t_satCodeBias> > _satCodeBiases;
267 QMap<char, unsigned> _cmbSysPrn;
268 bncEphUser _ephUser;
269 SsrCorr* _ssrCorr;
270 QString _cmbRefAttributes;
271 bool _useGps;
272 bool _useGlo;
273 bool _useGal;
274 bool _useBds;
275 bool _useQzss;
276 bool _useSbas;
277 bool _useIrnss;
278 bool _running;
279};
280
281#define BNC_CMB (bncComb::getInstance())
282
283#endif
Note: See TracBrowser for help on using the repository browser.