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

Last change on this file since 4763 was 4763, checked in by mervart, 12 years ago
File size: 6.5 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
60//
61////////////////////////////////////////////////////////////////////////////
62void t_bncRtrover::slotNewEphGPS(gpsephemeris gpseph) {
63 QMutexLocker locker(&_mutex);
64
65 bncTime toc(gpseph.GPSweek, gpseph.TOC);
66 bncTime toe(gpseph.GPSweek, gpseph.TOE);
67
68 rtrover_ephGPS eph;
69 eph._satellite._system = 'G';
70 eph._satellite._number = gpseph.satellite;
71 eph._TOC._mjd = toc.mjd();
72 eph._TOC._sec = toc.daysec();
73 eph._TOE._mjd = toe.mjd();
74 eph._TOE._sec = toe.daysec();
75 eph._IODE = gpseph.IODE;
76 eph._IODC = gpseph.IODC;
77 eph._clock_bias = gpseph.clock_bias;
78 eph._clock_drift = gpseph.clock_drift;
79 eph._clock_driftrate = gpseph.clock_driftrate;
80 eph._Crs = gpseph.Crs;
81 eph._Delta_n = gpseph.Delta_n;
82 eph._M0 = gpseph.M0;
83 eph._Cuc = gpseph.Cuc;
84 eph._e = gpseph.e;
85 eph._Cus = gpseph.Cus;
86 eph._sqrt_A = gpseph.sqrt_A;
87 eph._Cic = gpseph.Cic;
88 eph._OMEGA0 = gpseph.OMEGA0;
89 eph._Cis = gpseph.Cis;
90 eph._i0 = gpseph.i0;
91 eph._Crc = gpseph.Crc;
92 eph._omega = gpseph.omega;
93 eph._OMEGADOT = gpseph.OMEGADOT;
94 eph._IDOT = gpseph.IDOT;
95 eph._TGD = gpseph.TGD;
96 eph._health = gpseph.SVhealth;
97
98 rtrover_putGPSEphemeris(&eph);
99}
100
101//
102////////////////////////////////////////////////////////////////////////////
103void t_bncRtrover::slotNewEphGlonass(glonassephemeris gloeph) {
104 QMutexLocker locker(&_mutex);
105
106 int wwUTC = gloeph.GPSWeek;
107 int towUTC = gloeph.GPSTOW;
108 updatetime(&wwUTC, &towUTC, gloeph.tb*1000, 1); // Moscow -> UTC
109 bncTime tUTC(wwUTC,towUTC);
110
111 int wwGPS = gloeph.GPSWeek;
112 int towGPS = gloeph.GPSTOW;
113 updatetime(&wwGPS, &towGPS, gloeph.tb*1000, 0); // Moscow -> GPS
114 bncTime tGPS(wwGPS,towGPS);
115
116 rtrover_ephGlo eph;
117 eph._satellite._system = 'R';
118 eph._satellite._number = gloeph.almanac_number;
119 eph._timeUTC._mjd = tUTC.mjd();
120 eph._timeUTC._sec = tUTC.daysec();
121 eph._gps_utc = int(tGPS-tUTC);
122 eph._E = gloeph.E;
123 eph._tau = gloeph.tau;
124 eph._gamma = gloeph.gamma;
125 eph._x_pos = gloeph.x_pos;
126 eph._x_velocity = gloeph.x_velocity;
127 eph._x_acceleration = gloeph.x_acceleration;
128 eph._y_pos = gloeph.y_pos;
129 eph._y_velocity = gloeph.y_velocity;
130 eph._y_acceleration = gloeph.y_acceleration;
131 eph._z_pos = gloeph.z_pos;
132 eph._z_velocity = gloeph.z_velocity;
133 eph._z_acceleration = gloeph.z_acceleration;
134 eph._health = 0; // TODO ?
135 eph._frequency_number = gloeph.frequency_number;
136
137 rtrover_putGloEphemeris(&eph);
138}
139
140//
141////////////////////////////////////////////////////////////////////////////
142void t_bncRtrover::slotNewEphGalileo(galileoephemeris /* galeph */) {
143 // not yet implemented
144}
145
146//
147////////////////////////////////////////////////////////////////////////////
148void t_bncRtrover::slotNewCorrections(QList<QString> corrList) {
149 QMutexLocker locker(&_mutex);
150
151 // Check the Mountpoint (source of corrections)
152 // --------------------------------------------
153 if (!_pppCorrMount.isEmpty()) {
154 QMutableListIterator<QString> itm(corrList);
155 while (itm.hasNext()) {
156 QStringList hlp = itm.next().split(" ");
157 if (hlp.size() > 0) {
158 QString mountpoint = hlp[hlp.size()-1];
159 if (mountpoint != _pppCorrMount) {
160 itm.remove();
161 }
162 }
163 }
164 }
165
166 if (corrList.size() == 0) {
167 return;
168 }
169
170 QListIterator<QString> it(corrList);
171 while (it.hasNext()) {
172 QString line = it.next();
173
174 QTextStream in(&line);
175 int messageType;
176 int updateInterval;
177 int GPSweek;
178 double GPSweeks;
179 QString prn;
180 in >> messageType >> updateInterval >> GPSweek >> GPSweeks >> prn;
181
182 if ( t_corr::relevantMessageType(messageType) ) {
183 t_corr* cc = 0;
184 if (_corr.contains(prn)) {
185 cc = _corr.value(prn);
186 }
187 else {
188 cc = new t_corr();
189 _corr[prn] = cc;
190 }
191
192 cc->readLine(line);
193 }
194 }
195
196 QMapIterator<QString, t_corr*> ic(_corr);
197 while (ic.hasNext()) {
198 ic.next();
199 t_corr* cc = ic.value();
200 if (cc->ready()) {
201
202 }
203 }
204}
205
206//
207////////////////////////////////////////////////////////////////////////////
208void t_bncRtrover::slotNewObs(QByteArray staID, bool firstObs, t_obs obsIn) {
209 QMutexLocker locker(&_mutex);
210
211 bncTime obsTime(obsIn.GPSWeek, obsIn.GPSWeeks);
212
213 if (_epoch.size() != 0) {
214 bncTime epoTime(_epoch[0].GPSWeek, _epoch[0].GPSWeeks);
215 if (epoTime != obsTime) {
216 //// const GPSS::gpcObs* allObs[_epoch.size()];
217 for (unsigned iObs = 0; iObs < _epoch.size(); iObs++) {
218 t_obs& obs = _epoch[iObs];
219
220 }
221
222// for (unsigned iObs = 0; iObs < _epoch.size(); iObs++) {
223// delete allObs[iObs];
224// }
225
226 _epoch.clear();
227 }
228 }
229
230 t_obs newObs(obsIn);
231 _epoch.push_back(newObs);
232}
Note: See TracBrowser for help on using the repository browser.