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

Last change on this file since 10770 was 10754, checked in by stuerze, 3 months ago

initial preparation for adding the new RTCM-SSR format

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