1 |
|
---|
2 | #include <iostream>
|
---|
3 | #include <string.h>
|
---|
4 |
|
---|
5 | #include "bncrtrover.h"
|
---|
6 | #include "bncapp.h"
|
---|
7 | #include "bncsettings.h"
|
---|
8 | #include "bnctime.h"
|
---|
9 |
|
---|
10 | #include "rtrover_interface.h"
|
---|
11 |
|
---|
12 | using namespace std;
|
---|
13 |
|
---|
14 | // Constructor
|
---|
15 | ////////////////////////////////////////////////////////////////////////////
|
---|
16 | t_bncRtrover::t_bncRtrover() {
|
---|
17 |
|
---|
18 | bncSettings settings;
|
---|
19 |
|
---|
20 | // Processed Station, Corrections Source
|
---|
21 | // -------------------------------------
|
---|
22 | _pppCorrMount = settings.value("pppCorrMount").toString();
|
---|
23 |
|
---|
24 | // Define Input Options
|
---|
25 | // --------------------
|
---|
26 | rtrover_opt opt;
|
---|
27 | rtrover_setOptions(&opt);
|
---|
28 |
|
---|
29 | // Connect to BNC Signals
|
---|
30 | // ----------------------
|
---|
31 | connect(((bncApp*)qApp), SIGNAL(newCorrections(QList<QString>)),
|
---|
32 | this, SLOT(slotNewCorrections(QList<QString>)));
|
---|
33 |
|
---|
34 | connect(((bncApp*)qApp), SIGNAL(newEphGPS(gpsephemeris)),
|
---|
35 | this, SLOT(slotNewEphGPS(gpsephemeris)));
|
---|
36 |
|
---|
37 | connect(((bncApp*)qApp), SIGNAL(newEphGlonass(glonassephemeris)),
|
---|
38 | this, SLOT(slotNewEphGlonass(glonassephemeris)));
|
---|
39 |
|
---|
40 | connect(((bncApp*)qApp), SIGNAL(newEphGalileo(galileoephemeris)),
|
---|
41 | this, SLOT(slotNewEphGalileo(galileoephemeris)));
|
---|
42 | }
|
---|
43 |
|
---|
44 | // Destructor
|
---|
45 | ////////////////////////////////////////////////////////////////////////////
|
---|
46 | t_bncRtrover::~t_bncRtrover() {
|
---|
47 | QMapIterator<QString, t_corr*> ic(_corr);
|
---|
48 | while (ic.hasNext()) {
|
---|
49 | ic.next();
|
---|
50 | delete ic.value();
|
---|
51 | }
|
---|
52 | rtrover_destroy();
|
---|
53 | }
|
---|
54 |
|
---|
55 | //
|
---|
56 | ////////////////////////////////////////////////////////////////////////////
|
---|
57 | void t_bncRtrover::slotNewEphGPS(gpsephemeris gpseph) {
|
---|
58 | QMutexLocker locker(&_mutex);
|
---|
59 |
|
---|
60 | bncTime toc(gpseph.GPSweek, gpseph.TOC);
|
---|
61 | bncTime toe(gpseph.GPSweek, gpseph.TOE);
|
---|
62 |
|
---|
63 | rtrover_ephGPS eph;
|
---|
64 | eph._satellite._system = 'G';
|
---|
65 | eph._satellite._number = gpseph.satellite;
|
---|
66 | eph._TOC._mjd = toc.mjd();
|
---|
67 | eph._TOC._sec = toc.daysec();
|
---|
68 | eph._TOE._mjd = toe.mjd();
|
---|
69 | eph._TOE._sec = toe.daysec();
|
---|
70 | eph._IODE = gpseph.IODE;
|
---|
71 | eph._IODC = gpseph.IODC;
|
---|
72 | eph._clock_bias = gpseph.clock_bias;
|
---|
73 | eph._clock_drift = gpseph.clock_drift;
|
---|
74 | eph._clock_driftrate = gpseph.clock_driftrate;
|
---|
75 | eph._Crs = gpseph.Crs;
|
---|
76 | eph._Delta_n = gpseph.Delta_n;
|
---|
77 | eph._M0 = gpseph.M0;
|
---|
78 | eph._Cuc = gpseph.Cuc;
|
---|
79 | eph._e = gpseph.e;
|
---|
80 | eph._Cus = gpseph.Cus;
|
---|
81 | eph._sqrt_A = gpseph.sqrt_A;
|
---|
82 | eph._Cic = gpseph.Cic;
|
---|
83 | eph._OMEGA0 = gpseph.OMEGA0;
|
---|
84 | eph._Cis = gpseph.Cis;
|
---|
85 | eph._i0 = gpseph.i0;
|
---|
86 | eph._Crc = gpseph.Crc;
|
---|
87 | eph._omega = gpseph.omega;
|
---|
88 | eph._OMEGADOT = gpseph.OMEGADOT;
|
---|
89 | eph._IDOT = gpseph.IDOT;
|
---|
90 | eph._TGD = gpseph.TGD;
|
---|
91 | eph._health = gpseph.SVhealth;
|
---|
92 |
|
---|
93 | rtrover_putGPSEphemeris(&eph);
|
---|
94 | }
|
---|
95 |
|
---|
96 | //
|
---|
97 | ////////////////////////////////////////////////////////////////////////////
|
---|
98 | void t_bncRtrover::slotNewEphGlonass(glonassephemeris gloeph) {
|
---|
99 | QMutexLocker locker(&_mutex);
|
---|
100 |
|
---|
101 | int wwUTC = gloeph.GPSWeek;
|
---|
102 | int towUTC = gloeph.GPSTOW;
|
---|
103 | updatetime(&wwUTC, &towUTC, gloeph.tb*1000, 1); // Moscow -> UTC
|
---|
104 | bncTime tUTC(wwUTC,towUTC);
|
---|
105 |
|
---|
106 | int wwGPS = gloeph.GPSWeek;
|
---|
107 | int towGPS = gloeph.GPSTOW;
|
---|
108 | updatetime(&wwGPS, &towGPS, gloeph.tb*1000, 0); // Moscow -> GPS
|
---|
109 | bncTime tGPS(wwGPS,towGPS);
|
---|
110 |
|
---|
111 | rtrover_ephGlo eph;
|
---|
112 |
|
---|
113 | rtrover_putGloEphemeris(&eph);
|
---|
114 | }
|
---|
115 |
|
---|
116 | //
|
---|
117 | ////////////////////////////////////////////////////////////////////////////
|
---|
118 | void t_bncRtrover::slotNewEphGalileo(galileoephemeris /* galeph */) {
|
---|
119 | // not yet implemented
|
---|
120 | }
|
---|
121 |
|
---|
122 | //
|
---|
123 | ////////////////////////////////////////////////////////////////////////////
|
---|
124 | void t_bncRtrover::slotNewCorrections(QList<QString> corrList) {
|
---|
125 | QMutexLocker locker(&_mutex);
|
---|
126 |
|
---|
127 | // Check the Mountpoint (source of corrections)
|
---|
128 | // --------------------------------------------
|
---|
129 | if (!_pppCorrMount.isEmpty()) {
|
---|
130 | QMutableListIterator<QString> itm(corrList);
|
---|
131 | while (itm.hasNext()) {
|
---|
132 | QStringList hlp = itm.next().split(" ");
|
---|
133 | if (hlp.size() > 0) {
|
---|
134 | QString mountpoint = hlp[hlp.size()-1];
|
---|
135 | if (mountpoint != _pppCorrMount) {
|
---|
136 | itm.remove();
|
---|
137 | }
|
---|
138 | }
|
---|
139 | }
|
---|
140 | }
|
---|
141 |
|
---|
142 | if (corrList.size() == 0) {
|
---|
143 | return;
|
---|
144 | }
|
---|
145 |
|
---|
146 | QListIterator<QString> it(corrList);
|
---|
147 | while (it.hasNext()) {
|
---|
148 | QString line = it.next();
|
---|
149 |
|
---|
150 | QTextStream in(&line);
|
---|
151 | int messageType;
|
---|
152 | int updateInterval;
|
---|
153 | int GPSweek;
|
---|
154 | double GPSweeks;
|
---|
155 | QString prn;
|
---|
156 | in >> messageType >> updateInterval >> GPSweek >> GPSweeks >> prn;
|
---|
157 |
|
---|
158 | if ( t_corr::relevantMessageType(messageType) ) {
|
---|
159 | t_corr* cc = 0;
|
---|
160 | if (_corr.contains(prn)) {
|
---|
161 | cc = _corr.value(prn);
|
---|
162 | }
|
---|
163 | else {
|
---|
164 | cc = new t_corr();
|
---|
165 | _corr[prn] = cc;
|
---|
166 | }
|
---|
167 |
|
---|
168 | cc->readLine(line);
|
---|
169 | }
|
---|
170 | }
|
---|
171 |
|
---|
172 | QMapIterator<QString, t_corr*> ic(_corr);
|
---|
173 | while (ic.hasNext()) {
|
---|
174 | ic.next();
|
---|
175 | t_corr* cc = ic.value();
|
---|
176 | if (cc->ready()) {
|
---|
177 |
|
---|
178 | }
|
---|
179 | }
|
---|
180 | }
|
---|
181 |
|
---|
182 | //
|
---|
183 | ////////////////////////////////////////////////////////////////////////////
|
---|
184 | void t_bncRtrover::putNewObs(const t_obs& obsIn) {
|
---|
185 | QMutexLocker locker(&_mutex);
|
---|
186 |
|
---|
187 | bncTime obsTime(obsIn.GPSWeek, obsIn.GPSWeeks);
|
---|
188 |
|
---|
189 | if (_epoch.size() != 0) {
|
---|
190 | bncTime epoTime(_epoch[0].GPSWeek, _epoch[0].GPSWeeks);
|
---|
191 | if (epoTime != obsTime) {
|
---|
192 | //// const GPSS::gpcObs* allObs[_epoch.size()];
|
---|
193 | for (unsigned iObs = 0; iObs < _epoch.size(); iObs++) {
|
---|
194 | t_obs& obs = _epoch[iObs];
|
---|
195 |
|
---|
196 | }
|
---|
197 |
|
---|
198 | // for (unsigned iObs = 0; iObs < _epoch.size(); iObs++) {
|
---|
199 | // delete allObs[iObs];
|
---|
200 | // }
|
---|
201 |
|
---|
202 | _epoch.clear();
|
---|
203 | }
|
---|
204 | }
|
---|
205 |
|
---|
206 | t_obs newObs(obsIn);
|
---|
207 | _epoch.push_back(newObs);
|
---|
208 | }
|
---|