source: ntrip/trunk/BNC/src/RTRover/bncrtrover.cpp@ 4764

Last change on this file since 4764 was 4764, checked in by mervart, 12 years ago
File size: 6.8 KB
Line 
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
12using namespace std;
13
14// Constructor
15////////////////////////////////////////////////////////////////////////////
16t_bncRtrover::t_bncRtrover() : QThread(0) {
17
18}
19
20// Destructor
21////////////////////////////////////////////////////////////////////////////
22t_bncRtrover::~t_bncRtrover() {
23 QMapIterator<QString, t_corr*> ic(_corr);
24 while (ic.hasNext()) {
25 ic.next();
26 delete ic.value();
27 }
28 rtrover_destroy();
29}
30
31// Run (virtual)
32////////////////////////////////////////////////////////////////////////////
33void t_bncRtrover::run() {
34 bncSettings settings;
35
36 // Processed Station, Corrections Source
37 // -------------------------------------
38 _pppCorrMount = settings.value("pppCorrMount").toString();
39
40 // Define Input Options
41 // --------------------
42 rtrover_opt opt;
43 rtrover_setOptions(&opt);
44
45 // Connect to BNC Signals
46 // ----------------------
47 connect(((bncApp*)qApp), SIGNAL(newCorrections(QList<QString>)),
48 this, SLOT(slotNewCorrections(QList<QString>)));
49
50 connect(((bncApp*)qApp), SIGNAL(newEphGPS(gpsephemeris)),
51 this, SLOT(slotNewEphGPS(gpsephemeris)));
52
53 connect(((bncApp*)qApp), SIGNAL(newEphGlonass(glonassephemeris)),
54 this, SLOT(slotNewEphGlonass(glonassephemeris)));
55
56 connect(((bncApp*)qApp), SIGNAL(newEphGalileo(galileoephemeris)),
57 this, SLOT(slotNewEphGalileo(galileoephemeris)));
58
59 // Start processing loop
60 // ---------------------
61 QThread::exec();
62}
63
64//
65////////////////////////////////////////////////////////////////////////////
66void t_bncRtrover::slotNewEphGPS(gpsephemeris gpseph) {
67 QMutexLocker locker(&_mutex);
68
69 bncTime toc(gpseph.GPSweek, gpseph.TOC);
70 bncTime toe(gpseph.GPSweek, gpseph.TOE);
71
72 rtrover_ephGPS eph;
73 eph._satellite._system = 'G';
74 eph._satellite._number = gpseph.satellite;
75 eph._TOC._mjd = toc.mjd();
76 eph._TOC._sec = toc.daysec();
77 eph._TOE._mjd = toe.mjd();
78 eph._TOE._sec = toe.daysec();
79 eph._IODE = gpseph.IODE;
80 eph._IODC = gpseph.IODC;
81 eph._clock_bias = gpseph.clock_bias;
82 eph._clock_drift = gpseph.clock_drift;
83 eph._clock_driftrate = gpseph.clock_driftrate;
84 eph._Crs = gpseph.Crs;
85 eph._Delta_n = gpseph.Delta_n;
86 eph._M0 = gpseph.M0;
87 eph._Cuc = gpseph.Cuc;
88 eph._e = gpseph.e;
89 eph._Cus = gpseph.Cus;
90 eph._sqrt_A = gpseph.sqrt_A;
91 eph._Cic = gpseph.Cic;
92 eph._OMEGA0 = gpseph.OMEGA0;
93 eph._Cis = gpseph.Cis;
94 eph._i0 = gpseph.i0;
95 eph._Crc = gpseph.Crc;
96 eph._omega = gpseph.omega;
97 eph._OMEGADOT = gpseph.OMEGADOT;
98 eph._IDOT = gpseph.IDOT;
99 eph._TGD = gpseph.TGD;
100 eph._health = gpseph.SVhealth;
101
102 rtrover_putGPSEphemeris(&eph);
103}
104
105//
106////////////////////////////////////////////////////////////////////////////
107void t_bncRtrover::slotNewEphGlonass(glonassephemeris gloeph) {
108 QMutexLocker locker(&_mutex);
109
110 int wwUTC = gloeph.GPSWeek;
111 int towUTC = gloeph.GPSTOW;
112 updatetime(&wwUTC, &towUTC, gloeph.tb*1000, 1); // Moscow -> UTC
113 bncTime tUTC(wwUTC,towUTC);
114
115 int wwGPS = gloeph.GPSWeek;
116 int towGPS = gloeph.GPSTOW;
117 updatetime(&wwGPS, &towGPS, gloeph.tb*1000, 0); // Moscow -> GPS
118 bncTime tGPS(wwGPS,towGPS);
119
120 rtrover_ephGlo eph;
121 eph._satellite._system = 'R';
122 eph._satellite._number = gloeph.almanac_number;
123 eph._timeUTC._mjd = tUTC.mjd();
124 eph._timeUTC._sec = tUTC.daysec();
125 eph._gps_utc = int(tGPS-tUTC);
126 eph._E = gloeph.E;
127 eph._tau = gloeph.tau;
128 eph._gamma = gloeph.gamma;
129 eph._x_pos = gloeph.x_pos;
130 eph._x_velocity = gloeph.x_velocity;
131 eph._x_acceleration = gloeph.x_acceleration;
132 eph._y_pos = gloeph.y_pos;
133 eph._y_velocity = gloeph.y_velocity;
134 eph._y_acceleration = gloeph.y_acceleration;
135 eph._z_pos = gloeph.z_pos;
136 eph._z_velocity = gloeph.z_velocity;
137 eph._z_acceleration = gloeph.z_acceleration;
138 eph._health = 0; // TODO ?
139 eph._frequency_number = gloeph.frequency_number;
140
141 rtrover_putGloEphemeris(&eph);
142}
143
144//
145////////////////////////////////////////////////////////////////////////////
146void t_bncRtrover::slotNewEphGalileo(galileoephemeris /* galeph */) {
147 // not yet implemented
148}
149
150//
151////////////////////////////////////////////////////////////////////////////
152void t_bncRtrover::slotNewCorrections(QList<QString> corrList) {
153 QMutexLocker locker(&_mutex);
154
155 // Check the Mountpoint (source of corrections)
156 // --------------------------------------------
157 if (!_pppCorrMount.isEmpty()) {
158 QMutableListIterator<QString> itm(corrList);
159 while (itm.hasNext()) {
160 QStringList hlp = itm.next().split(" ");
161 if (hlp.size() > 0) {
162 QString mountpoint = hlp[hlp.size()-1];
163 if (mountpoint != _pppCorrMount) {
164 itm.remove();
165 }
166 }
167 }
168 }
169
170 if (corrList.size() == 0) {
171 return;
172 }
173
174 QListIterator<QString> it(corrList);
175 while (it.hasNext()) {
176 QString line = it.next();
177
178 QTextStream in(&line);
179 int messageType;
180 int updateInterval;
181 int GPSweek;
182 double GPSweeks;
183 QString prn;
184 in >> messageType >> updateInterval >> GPSweek >> GPSweeks >> prn;
185
186 if ( t_corr::relevantMessageType(messageType) ) {
187 t_corr* cc = 0;
188 if (_corr.contains(prn)) {
189 cc = _corr.value(prn);
190 }
191 else {
192 cc = new t_corr();
193 _corr[prn] = cc;
194 }
195
196 cc->readLine(line);
197 }
198 }
199
200 QMapIterator<QString, t_corr*> ic(_corr);
201 while (ic.hasNext()) {
202 ic.next();
203 t_corr* cc = ic.value();
204 if (cc->ready()) {
205
206 }
207 }
208}
209
210//
211////////////////////////////////////////////////////////////////////////////
212void t_bncRtrover::slotNewObs(QByteArray staID, bool firstObs, t_obs obsIn) {
213 QMutexLocker locker(&_mutex);
214
215 bncTime obsTime(obsIn.GPSWeek, obsIn.GPSWeeks);
216
217 if (_epoch.size() != 0) {
218 bncTime epoTime(_epoch[0].GPSWeek, _epoch[0].GPSWeeks);
219 if (epoTime != obsTime) {
220 //// const GPSS::gpcObs* allObs[_epoch.size()];
221 for (unsigned iObs = 0; iObs < _epoch.size(); iObs++) {
222 t_obs& obs = _epoch[iObs];
223
224 }
225
226// for (unsigned iObs = 0; iObs < _epoch.size(); iObs++) {
227// delete allObs[iObs];
228// }
229
230 _epoch.clear();
231 }
232 }
233
234 t_obs newObs(obsIn);
235 _epoch.push_back(newObs);
236
237 int numSatRover = 1;
238 rtrover_satObs satObsRover[numSatRover];
239 for (int ii = 0; ii < numSatRover; ii++) {
240
241 }
242 rtrover_output output;
243 rtrover_processEpoch(numSatRover, satObsRover, 0, 0, &output);
244}
Note: See TracBrowser for help on using the repository browser.