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

Last change on this file since 4761 was 4761, checked in by mervart, 12 years ago
File size: 6.4 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() {
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////////////////////////////////////////////////////////////////////////////
46t_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////////////////////////////////////////////////////////////////////////////
57void 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////////////////////////////////////////////////////////////////////////////
98void 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 eph._satellite._system = 'R';
113 eph._satellite._number = gloeph.almanac_number;
114 eph._timeUTC._mjd = tUTC.mjd();
115 eph._timeUTC._sec = tUTC.daysec();
116 eph._gps_utc = int(tGPS-tUTC);
117 eph._E = gloeph.E;
118 eph._tau = gloeph.tau;
119 eph._gamma = gloeph.gamma;
120 eph._x_pos = gloeph.x_pos;
121 eph._x_velocity = gloeph.x_velocity;
122 eph._x_acceleration = gloeph.x_acceleration;
123 eph._y_pos = gloeph.y_pos;
124 eph._y_velocity = gloeph.y_velocity;
125 eph._y_acceleration = gloeph.y_acceleration;
126 eph._z_pos = gloeph.z_pos;
127 eph._z_velocity = gloeph.z_velocity;
128 eph._z_acceleration = gloeph.z_acceleration;
129 eph._health = 0; // TODO ?
130 eph._frequency_number = gloeph.frequency_number;
131
132 rtrover_putGloEphemeris(&eph);
133}
134
135//
136////////////////////////////////////////////////////////////////////////////
137void t_bncRtrover::slotNewEphGalileo(galileoephemeris /* galeph */) {
138 // not yet implemented
139}
140
141//
142////////////////////////////////////////////////////////////////////////////
143void t_bncRtrover::slotNewCorrections(QList<QString> corrList) {
144 QMutexLocker locker(&_mutex);
145
146 // Check the Mountpoint (source of corrections)
147 // --------------------------------------------
148 if (!_pppCorrMount.isEmpty()) {
149 QMutableListIterator<QString> itm(corrList);
150 while (itm.hasNext()) {
151 QStringList hlp = itm.next().split(" ");
152 if (hlp.size() > 0) {
153 QString mountpoint = hlp[hlp.size()-1];
154 if (mountpoint != _pppCorrMount) {
155 itm.remove();
156 }
157 }
158 }
159 }
160
161 if (corrList.size() == 0) {
162 return;
163 }
164
165 QListIterator<QString> it(corrList);
166 while (it.hasNext()) {
167 QString line = it.next();
168
169 QTextStream in(&line);
170 int messageType;
171 int updateInterval;
172 int GPSweek;
173 double GPSweeks;
174 QString prn;
175 in >> messageType >> updateInterval >> GPSweek >> GPSweeks >> prn;
176
177 if ( t_corr::relevantMessageType(messageType) ) {
178 t_corr* cc = 0;
179 if (_corr.contains(prn)) {
180 cc = _corr.value(prn);
181 }
182 else {
183 cc = new t_corr();
184 _corr[prn] = cc;
185 }
186
187 cc->readLine(line);
188 }
189 }
190
191 QMapIterator<QString, t_corr*> ic(_corr);
192 while (ic.hasNext()) {
193 ic.next();
194 t_corr* cc = ic.value();
195 if (cc->ready()) {
196
197 }
198 }
199}
200
201//
202////////////////////////////////////////////////////////////////////////////
203void t_bncRtrover::putNewObs(const t_obs& obsIn) {
204 QMutexLocker locker(&_mutex);
205
206 bncTime obsTime(obsIn.GPSWeek, obsIn.GPSWeeks);
207
208 if (_epoch.size() != 0) {
209 bncTime epoTime(_epoch[0].GPSWeek, _epoch[0].GPSWeeks);
210 if (epoTime != obsTime) {
211 //// const GPSS::gpcObs* allObs[_epoch.size()];
212 for (unsigned iObs = 0; iObs < _epoch.size(); iObs++) {
213 t_obs& obs = _epoch[iObs];
214
215 }
216
217// for (unsigned iObs = 0; iObs < _epoch.size(); iObs++) {
218// delete allObs[iObs];
219// }
220
221 _epoch.clear();
222 }
223 }
224
225 t_obs newObs(obsIn);
226 _epoch.push_back(newObs);
227}
Note: See TracBrowser for help on using the repository browser.