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

Last change on this file since 10415 was 10275, checked in by stuerze, 11 months ago

minor changes to support windows operationg systems

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