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

Last change on this file was 10955, checked in by stuerze, 7 weeks ago

Possibility to select how satellite attitude is modelled when converting Antenna Phase Center (APC) corrections to
Center-of-Mass (CoM) positions required for SP3 output

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