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

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