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

Last change on this file since 10227 was 10227, checked in by stuerze, 4 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 QString mountPoint;
92 QString name;
93 double weightFactor;
94 bool isAPC;
95 QMap<char, unsigned> numObs;
96 };
97
98 class cmbCorr {
99 public:
100 cmbCorr() {
101 _eph = 0;
102 _iod = 0;
103 _dClkResult = 0.0;
104 _satCodeBiasIF = 0.0;
105 _weightFactor = 1.0;
106 }
107 ~cmbCorr() {
108 }
109 QString _prn;
110 bncTime _time;
111 unsigned long _iod;
112 t_eph* _eph;
113 t_orbCorr _orbCorr;
114 t_clkCorr _clkCorr;
115 t_satCodeBias _satCodeBias;
116 QString _acName;
117 double _satCodeBiasIF;
118 double _dClkResult;
119 ColumnVector _diffRao;
120 double _weightFactor;
121 QString ID() {return _acName + "_" + _prn;}
122 };
123
124 class cmbEpoch {
125 public:
126 cmbEpoch() {}
127 ~cmbEpoch() {
128 clear();
129 }
130 void clear() {
131 QVectorIterator<cmbCorr*> it(corrs);
132 while (it.hasNext()) {
133 delete it.next();
134 }
135 }
136 QVector<cmbCorr*> corrs;
137 };
138
139 class epoClkData {
140 public:
141 epoClkData() {}
142 ~epoClkData() {
143 _clkCorr.erase(_clkCorr.begin(), _clkCorr.end());
144 }
145 bncTime _time;
146 std::vector<t_clkCorr> _clkCorr;
147 };
148
149
150
151 class cmbRefSig {
152 public:
153 enum type {dummy = 0, c1, c2, cIF};
154
155 static t_frequency::type toFreq(char sys, type tt) {
156 switch (tt) {
157 case c1:
158 if (sys == 'G') return t_frequency::G1;
159 else if (sys == 'R') return t_frequency::R1;
160 else if (sys == 'E') return t_frequency::E1;
161 else if (sys == 'C') return t_frequency::C2;
162 else if (sys == 'J') return t_frequency::J1;
163 else if (sys == 'S') return t_frequency::S1;
164 else return t_frequency::dummy;
165 case c2:
166 if (sys == 'G') return t_frequency::G2;
167 else if (sys == 'R') return t_frequency::R2;
168 else if (sys == 'E') return t_frequency::E5;
169 else if (sys == 'C') return t_frequency::C6;
170 else if (sys == 'J') return t_frequency::J2;
171 else if (sys == 'S') return t_frequency::S5;
172 else return t_frequency::dummy;
173 case dummy:
174 case cIF:
175 return t_frequency::dummy;
176 }
177 return t_frequency::dummy;
178 }
179
180 static char toAttrib(char sys, type LC) {
181 switch (LC) {
182 case c1:
183 if (sys == 'G') return 'W';
184 else if (sys == 'R') return 'P';
185 else if (sys == 'E') return 'C';
186 else if (sys == 'C') return 'I';
187 else if (sys == 'J') return 'C';
188 else if (sys == 'S') return 'C';
189 break;
190 case c2:
191 if (sys == 'G') return 'W';
192 else if (sys == 'R') return 'P';
193 else if (sys == 'E') return 'Q';
194 else if (sys == 'C') return 'I';
195 else if (sys == 'J') return 'L';
196 else if (sys == 'S') return 'Q';
197 break;
198 case dummy:
199 case cIF:
200 return '_';
201 break;
202 }
203 return '_';
204 }
205
206 static void coeff(char sys, type tLC, double channel, std::map<t_frequency::type, double>& codeCoeff) {
207 codeCoeff.clear();
208 t_frequency::type fType1 = toFreq(sys, c1);
209 t_frequency::type fType2 = toFreq(sys, c2);
210 double f1 = t_CST::freq(fType1, channel);
211 double f2 = t_CST::freq(fType2, channel);
212 switch (tLC) {
213 case c1:
214 codeCoeff[fType1] = 1.0;
215 return;
216 case c2:
217 codeCoeff[fType2] = 1.0;
218 return;
219 case cIF:
220 codeCoeff[fType1] = f1 * f1 / (f1 * f1 - f2 * f2);
221 codeCoeff[fType2] = -f2 * f2 / (f1 * f1 - f2 * f2);
222 return;
223 case cmbRefSig::dummy:
224 return;
225 }
226 return;
227 }
228 };
229
230 void processEpoch(bncTime epoTime, const std::vector<t_clkCorr>& clkCorrVec);
231 void processSystem(bncTime epoTime, char sys, QTextStream& out);
232 t_irc processEpoch_filter(bncTime epoTime, char sys, QTextStream& out, QMap<QString, cmbCorr*>& resCorr, ColumnVector& dx);
233 t_irc processEpoch_singleEpoch(bncTime epoTime, char sys, QTextStream& out, QMap<QString, cmbCorr*>& resCorr, ColumnVector& dx);
234 t_irc createAmat(char sys, Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP,
235 const ColumnVector& x0, QMap<QString, cmbCorr*>& resCorr);
236 void dumpResults(bncTime epoTime, const QMap<QString, cmbCorr*>& resCorr);
237 void printResults(bncTime epoTime, QTextStream& out, const QMap<QString, cmbCorr*>& resCorr);
238 void switchToLastEph(t_eph* lastEph, cmbCorr* corr);
239 t_irc checkOrbits(bncTime epoTime, char sys, QTextStream& out);
240 QVector<cmbCorr*>& corrs(char sys) {return _buffer[sys].corrs;}
241
242 QMutex _mutex;
243 QList<cmbAC*> _ACs;
244 std::deque<epoClkData*> _epoClkData;
245 bncTime _lastClkCorrTime;
246 bncTime _resTime;
247 cmbCorr* _newCorr;
248 QMap<char, cmbEpoch> _buffer;
249 bncRtnetDecoder* _rtnetDecoder;
250 QMap<char, SymmetricMatrix> _QQ;
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, QString> _masterOrbitAC;
259 QMap<char, unsigned> _masterMissingEpochs;
260 QMap<char, bool> _masterIsAPC;
261 QString _cmbRefAttributes;
262 QMap<char, QVector<cmbParam*>> _params;
263 QMap<QString, QMap<t_prn, t_orbCorr> > _orbCorrections;
264 QMap<QString, QMap<t_prn, t_satCodeBias> > _satCodeBiases;
265 QMap<char, unsigned> _cmbSysPrn;
266 bncEphUser _ephUser;
267 SsrCorr* _ssrCorr;
268 bool _useGps;
269 bool _useGlo;
270 bool _useGal;
271 bool _useBds;
272 bool _useQzss;
273 bool _useSbas;
274 bool _useIrnss;
275 bool _running;
276};
277
278#define BNC_CMB (bncComb::getInstance())
279
280#endif
Note: See TracBrowser for help on using the repository browser.