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

Last change on this file since 10911 was 10911, checked in by stuerze, 8 days ago

minor changes to solve an issue under windows operation system

File size: 9.7 KB
Line 
1
2#ifndef BNCCOMB_H
3#define BNCCOMB_H
4
5#ifndef WIN32
6#include <unistd.h>
7#else
8#define _HAS_STD_BYTE 0
9#include <windows.h>
10#endif
11#include <fstream>
12#include <iostream>
13#include <map>
14#include <newmat.h>
15#include <newmatio.h>
16#include <deque>
17#include "bncephuser.h"
18#include "satObs.h"
19#include "bncconst.h"
20#include "bncoutf.h"
21#include "../RTCM3/clock_and_orbit/clock_orbit_rtcm.h"
22#include "../RTCM3/clock_and_orbit/clock_orbit_rtcm_new.h"
23#include "../RTCM3/clock_and_orbit/clock_orbit_igs.h"
24
25class bncRtnetDecoder;
26class bncAntex;
27class bncBiasSnx;
28
29class bncComb : public QObject {
30 Q_OBJECT
31 public:
32 static bncComb* getInstance() {
33 if (instance == 0) {
34 instance = new bncComb;
35 }
36 return instance;
37 }
38 bncComb(const bncComb&) = delete;
39 bncComb& operator=(const bncComb&) = delete;
40 static void destruct() {
41 delete instance;
42 instance = nullptr;
43 }
44 int nStreams() const {return _ACs.size();}
45
46 public slots:
47 void slotProviderIDChanged(QString mountPoint);
48 void slotNewOrbCorrections(QList<t_orbCorr> orbCorrections);
49 void slotNewClkCorrections(QList<t_clkCorr> clkCorrections);
50 void slotNewCodeBiases(QList<t_satCodeBias> satCodeBiases);
51 void slotNewPhaseBiases(QList<t_satPhaseBias> satPhaseBiases);
52
53 private slots:
54 void slotReadBiasSnxFile();
55
56 signals:
57 void newMessage(QByteArray msg, bool showOnScreen);
58 void newOrbCorrections(QList<t_orbCorr>);
59 void newClkCorrections(QList<t_clkCorr>);
60 void newCodeBiases(QList<t_satCodeBias>);
61 void newPhaseBiases(QList<t_satPhaseBias>);
62
63 private:
64 bncComb(); // no public constructor
65 ~bncComb(); // no public destructor
66 static bncComb* instance; // declaration class variable
67 enum e_method{singleEpoch, filter};
68
69 class cmbParam {
70 public:
71 enum parType {offACgnss, offACSat, clkSat};
72 cmbParam(parType type_, int index_, const QString& ac_, const QString& prn_);
73 ~cmbParam();
74 double partial(char sys, const QString& AC_, const QString& prn_);
75 QString toString(char sys) const;
76 parType type;
77 int index;
78 QString AC;
79 QString prn;
80 double xx;
81 double sig0;
82 double sigP;
83 bool epoSpec;
84 const t_eph* eph;
85 };
86
87 class cmbAC {
88 public:
89 cmbAC() {
90 weightFactor = 1.0;
91 numObs['G'] = 0;
92 numObs['R'] = 0;
93 numObs['E'] = 0;
94 numObs['C'] = 0;
95 numObs['J'] = 0;
96 numObs['S'] = 0;
97 numObs['I'] = 0;
98 isAPC = false;
99 }
100 ~cmbAC() {
101 numObs.clear();
102 }
103 QString mountPoint;
104 QString name;
105 double weightFactor;
106 QStringList excludeSats;
107 bool isAPC;
108 QMap<char, unsigned> numObs;
109 };
110
111 class cmbCorr {
112 public:
113 cmbCorr() {
114 _eph = 0;
115 _iod = 0;
116 _dClkResult = 0.0;
117 _satCodeBiasIF = 0.0;
118 _lambdaIF = 0.0;
119 _satYawAngle = 0.0;
120 _weightFactor = 1.0;
121 _satPos.ReSize(3); _satPos = 0.0;
122 _diffRao2Mean = 0.0;
123 }
124 ~cmbCorr() {
125 }
126 QString _prn;
127 bncTime _time;
128 unsigned long _iod;
129 t_eph* _eph;
130 t_orbCorr _orbCorr;
131 t_clkCorr _clkCorr;
132 t_satCodeBias _satCodeBias;
133 //t_satPhaseBias _satPhaseBias;
134 QString _acName;
135 double _satCodeBiasIF;
136 double _lambdaIF;
137 double _satYawAngle;
138 double _dClkResult;
139 ColumnVector _satPos;
140 ColumnVector _diffRao2Mean;
141 double _weightFactor;
142 QString ID() {return _acName + "_" + _prn;}
143 };
144
145 class cmbEpoch {
146 public:
147 cmbEpoch() {}
148 ~cmbEpoch() {
149 clear();
150 }
151 void clear() {
152 QVectorIterator<cmbCorr*> it(corrs);
153 while (it.hasNext()) {
154 delete it.next();
155 }
156 corrs.clear();
157 }
158 QVector<cmbCorr*> corrs;
159 };
160
161 class epoClkData {
162 public:
163 epoClkData() {}
164 ~epoClkData() {
165 _clkCorr.erase(_clkCorr.begin(), _clkCorr.end());
166 }
167 bncTime _time;
168 std::vector<t_clkCorr> _clkCorr;
169 };
170
171 class cmbRefSig {
172 public:
173 enum type {dummy = 0, c1, c2, cIF};
174
175 static t_frequency::type toFreq(char sys, type tt) {
176 switch (tt) {
177 case c1:
178 if (sys == 'G') return t_frequency::G1;
179 else if (sys == 'R') return t_frequency::R1;
180 else if (sys == 'E') return t_frequency::E1;
181 else if (sys == 'C') return t_frequency::C2;
182 else if (sys == 'J') return t_frequency::J1;
183 else if (sys == 'S') return t_frequency::S1;
184 else return t_frequency::dummy;
185 case c2:
186 if (sys == 'G') return t_frequency::G2;
187 else if (sys == 'R') return t_frequency::R2;
188 else if (sys == 'E') return t_frequency::E5;
189 else if (sys == 'C') return t_frequency::C6;
190 else if (sys == 'J') return t_frequency::J2;
191 else if (sys == 'S') return t_frequency::S5;
192 else return t_frequency::dummy;
193 case dummy:
194 case cIF:
195 return t_frequency::dummy;
196 }
197 return t_frequency::dummy;
198 }
199
200 static char toAttrib(char sys, type LC) {
201 switch (LC) {
202 case c1:
203 if (sys == 'G') return 'W';
204 else if (sys == 'R') return 'P';
205 else if (sys == 'E') return 'C';
206 else if (sys == 'C') return 'I';
207 else if (sys == 'J') return 'C';
208 else if (sys == 'S') return 'C';
209 break;
210 case c2:
211 if (sys == 'G') return 'W';
212 else if (sys == 'R') return 'P';
213 else if (sys == 'E') return 'Q';
214 else if (sys == 'C') return 'I';
215 else if (sys == 'J') return 'L';
216 else if (sys == 'S') return 'Q';
217 break;
218 case dummy:
219 case cIF:
220 return '_';
221 break;
222 }
223 return '_';
224 }
225
226 static void coeff(char sys, type tLC, double channel, std::map<t_frequency::type, double>& codeCoeff) {
227 codeCoeff.clear();
228 t_frequency::type fType1 = toFreq(sys, c1);
229 t_frequency::type fType2 = toFreq(sys, c2);
230 double f1 = t_CST::freq(fType1, channel);
231 double f2 = t_CST::freq(fType2, channel);
232 switch (tLC) {
233 case c1:
234 codeCoeff[fType1] = 1.0;
235 return;
236 case c2:
237 codeCoeff[fType2] = 1.0;
238 return;
239 case cIF:
240 codeCoeff[fType1] = f1 * f1 / (f1 * f1 - f2 * f2);
241 codeCoeff[fType2] = -f2 * f2 / (f1 * f1 - f2 * f2);
242 return;
243 case cmbRefSig::dummy:
244 return;
245 }
246 return;
247 }
248 };
249
250 void processEpoch(bncTime epoTime, const std::vector<t_clkCorr>& clkCorrVec);
251 void processSystem(bncTime epoTime, char sys, QTextStream& out);
252 t_irc processEpoch_filter(bncTime epoTime, char sys, QTextStream& out, QMap<QString, cmbCorr*>& masterCorr, ColumnVector& dx);
253 t_irc processEpoch_singleEpoch(bncTime epoTime, char sys, QTextStream& out, QMap<QString, cmbCorr*>& masterCorr, ColumnVector& dx);
254 t_irc createAmat(char sys, Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP, const ColumnVector& x0, const QMap<QString, cmbCorr*>& masterCorr);
255 void dumpResults(bncTime epoTime, QMap<QString, cmbCorr*>& masterCorr);
256 void printResults(bncTime epoTime, QTextStream& out, const QMap<QString, cmbCorr*>& masterCorr);
257 void switchToLastEph(t_eph* lastEph, cmbCorr* corr);
258 t_irc checkOrbits(bncTime epoTime, char sys, QTextStream& out, QMap<QString, cmbCorr*>& masterCorr);
259 bool excludeSat(const t_prn& prn, const QStringList excludeSats) const;
260 QVector<cmbCorr*>& corrs(char sys) {return _buffer[sys].corrs;}
261
262 QMutex _mutex;
263 QList<cmbAC*> _ACs;
264 std::deque<epoClkData*> _epoClkData;
265 bncTime _lastClkCorrTime;
266 bncTime _resTime;
267 cmbCorr* _newCorr;
268 bncRtnetDecoder* _rtnetDecoder;
269 QByteArray _log;
270 bncAntex* _antex;
271 bncBiasSnx* _bsx;
272 bncoutf* _logFile;
273 double _MAX_RES;
274 double _MAX_DISPLACEMENT;
275 e_method _method;
276 int _cmbSampl;
277 int _ms;
278 QMap<char, cmbEpoch> _buffer;
279 QMap<char, SymmetricMatrix> _QQ;
280 QMap<char, QString> _masterOrbitAC;
281 QMap<char, unsigned> _masterMissingEpochs;
282 QMap<char, bool> _masterIsAPC;
283 QMap<char, QVector<cmbParam*>> _params;
284 QMap<QString, QMap<t_prn, t_orbCorr> > _orbCorrections;
285 QMap<QString, QMap<t_prn, t_satCodeBias>> _satCodeBiases;
286 QMap<QString, QMap<t_prn, t_satPhaseBias>> _satPhaseBiases;
287 QMap<char, unsigned> _cmbSysPrn;
288 bncEphUser _ephUser;
289 SsrCorr* _ssrCorr;
290 QString _cmbRefAttributes;
291 bool _useGps;
292 bool _useGlo;
293 bool _useGal;
294 bool _useBds;
295 bool _useQzss;
296 bool _useSbas;
297 bool _useNavic;
298 bool _running;
299};
300
301#define BNC_CMB (bncComb::getInstance())
302
303#endif
Note: See TracBrowser for help on using the repository browser.