1 | // Part of BNC, a utility for retrieving decoding and
|
---|
2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
3 | //
|
---|
4 | // Copyright (C) 2007
|
---|
5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
6 | // http://www.bkg.bund.de
|
---|
7 | // Czech Technical University Prague, Department of Geodesy
|
---|
8 | // http://www.fsv.cvut.cz
|
---|
9 | //
|
---|
10 | // Email: euref-ip@bkg.bund.de
|
---|
11 | //
|
---|
12 | // This program is free software; you can redistribute it and/or
|
---|
13 | // modify it under the terms of the GNU General Public License
|
---|
14 | // as published by the Free Software Foundation, version 2.
|
---|
15 | //
|
---|
16 | // This program is distributed in the hope that it will be useful,
|
---|
17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | // GNU General Public License for more details.
|
---|
20 | //
|
---|
21 | // You should have received a copy of the GNU General Public License
|
---|
22 | // along with this program; if not, write to the Free Software
|
---|
23 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
24 |
|
---|
25 | /* -------------------------------------------------------------------------
|
---|
26 | * BKG NTRIP Client
|
---|
27 | * -------------------------------------------------------------------------
|
---|
28 | *
|
---|
29 | * Class: bncApp
|
---|
30 | *
|
---|
31 | * Purpose: This class implements the main application
|
---|
32 | *
|
---|
33 | * Author: L. Mervart
|
---|
34 | *
|
---|
35 | * Created: 29-Aug-2006
|
---|
36 | *
|
---|
37 | * Changes:
|
---|
38 | *
|
---|
39 | * -----------------------------------------------------------------------*/
|
---|
40 |
|
---|
41 | #include <iostream>
|
---|
42 | #include <QSettings>
|
---|
43 | #include <QMessageBox>
|
---|
44 | #include <cmath>
|
---|
45 |
|
---|
46 | #include "bncapp.h"
|
---|
47 | #include "bncutils.h"
|
---|
48 |
|
---|
49 | using namespace std;
|
---|
50 |
|
---|
51 | struct converttimeinfo {
|
---|
52 | int second; /* seconds of GPS time [0..59] */
|
---|
53 | int minute; /* minutes of GPS time [0..59] */
|
---|
54 | int hour; /* hour of GPS time [0..24] */
|
---|
55 | int day; /* day of GPS time [1..28..30(31)*/
|
---|
56 | int month; /* month of GPS time [1..12]*/
|
---|
57 | int year; /* year of GPS time [1980..] */
|
---|
58 | };
|
---|
59 |
|
---|
60 | extern "C" {
|
---|
61 | void converttime(struct converttimeinfo *c, int week, int tow);
|
---|
62 | void updatetime(int *week, int *tow, int tk, int fixnumleap);
|
---|
63 | }
|
---|
64 |
|
---|
65 | // Constructor
|
---|
66 | ////////////////////////////////////////////////////////////////////////////
|
---|
67 | bncApp::bncApp(int argc, char* argv[], bool GUIenabled) :
|
---|
68 | QApplication(argc, argv, GUIenabled) {
|
---|
69 |
|
---|
70 | _bncVersion = "BNC 1.5";
|
---|
71 |
|
---|
72 | _logFileFlag = 0;
|
---|
73 | _logFile = 0;
|
---|
74 | _logStream = 0;
|
---|
75 |
|
---|
76 | // Lists of Ephemeris
|
---|
77 | // ------------------
|
---|
78 | for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) {
|
---|
79 | _gpsEph[ii-PRN_GPS_START] = 0;
|
---|
80 | }
|
---|
81 | for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) {
|
---|
82 | _glonassEph[ii-PRN_GLONASS_START] = 0;
|
---|
83 | }
|
---|
84 |
|
---|
85 | // Eph file(s)
|
---|
86 | // -----------
|
---|
87 | _rinexVers = 0;
|
---|
88 | _ephFileGPS = 0;
|
---|
89 | _ephStreamGPS = 0;
|
---|
90 | _ephFileGlonass = 0;
|
---|
91 | _ephStreamGlonass = 0;
|
---|
92 |
|
---|
93 | _pgmName = _bncVersion.leftJustified(20, ' ', true);
|
---|
94 | #ifdef WIN32
|
---|
95 | _userName = QString("${USERNAME}");
|
---|
96 | #else
|
---|
97 | _userName = QString("${USER}");
|
---|
98 | #endif
|
---|
99 | expandEnvVar(_userName);
|
---|
100 | _userName = _userName.leftJustified(20, ' ', true);
|
---|
101 | }
|
---|
102 |
|
---|
103 | // Destructor
|
---|
104 | ////////////////////////////////////////////////////////////////////////////
|
---|
105 | bncApp::~bncApp() {
|
---|
106 | delete _logStream;
|
---|
107 | delete _logFile;
|
---|
108 | delete _ephStreamGPS;
|
---|
109 | delete _ephFileGPS;
|
---|
110 | if (_rinexVers == 2) {
|
---|
111 | delete _ephStreamGlonass;
|
---|
112 | delete _ephFileGlonass;
|
---|
113 | }
|
---|
114 | for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) {
|
---|
115 | delete _gpsEph[ii-PRN_GPS_START];
|
---|
116 | }
|
---|
117 | for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) {
|
---|
118 | delete _glonassEph[ii-PRN_GLONASS_START];
|
---|
119 | }
|
---|
120 | }
|
---|
121 |
|
---|
122 | // Write a Program Message
|
---|
123 | ////////////////////////////////////////////////////////////////////////////
|
---|
124 | void bncApp::slotMessage(const QByteArray msg) {
|
---|
125 |
|
---|
126 | QMutexLocker locker(&_mutex);
|
---|
127 |
|
---|
128 | // First time resolve the log file name
|
---|
129 | // ------------------------------------
|
---|
130 | if (_logFileFlag == 0) {
|
---|
131 | _logFileFlag = 1;
|
---|
132 | QSettings settings;
|
---|
133 | QString logFileName = settings.value("logFile").toString();
|
---|
134 | if ( !logFileName.isEmpty() ) {
|
---|
135 | expandEnvVar(logFileName);
|
---|
136 | _logFile = new QFile(logFileName);
|
---|
137 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
|
---|
138 | _logFile->open(QIODevice::WriteOnly | QIODevice::Append);
|
---|
139 | }
|
---|
140 | else {
|
---|
141 | _logFile->open(QIODevice::WriteOnly);
|
---|
142 | }
|
---|
143 | _logStream = new QTextStream();
|
---|
144 | _logStream->setDevice(_logFile);
|
---|
145 | }
|
---|
146 | }
|
---|
147 |
|
---|
148 | if (_logStream) {
|
---|
149 | *_logStream << QDateTime::currentDateTime().toUTC().toString("yy-MM-dd hh:mm:ss ").toAscii().data();
|
---|
150 | *_logStream << msg.data() << endl;
|
---|
151 | _logStream->flush();
|
---|
152 | }
|
---|
153 | }
|
---|
154 |
|
---|
155 | // New GPS Ephemeris
|
---|
156 | ////////////////////////////////////////////////////////////////////////////
|
---|
157 | void bncApp::slotNewGPSEph(gpsephemeris* gpseph) {
|
---|
158 |
|
---|
159 | QMutexLocker locker(&_mutex);
|
---|
160 |
|
---|
161 | printEphHeader();
|
---|
162 |
|
---|
163 | if (!_ephStreamGPS) {
|
---|
164 | delete gpseph;
|
---|
165 | return;
|
---|
166 | }
|
---|
167 |
|
---|
168 | gpsephemeris** ee = &_gpsEph[gpseph->satellite-1];
|
---|
169 | if ( *ee == 0 ||
|
---|
170 | gpseph->GPSweek > (*ee)->GPSweek ||
|
---|
171 | (gpseph->GPSweek == (*ee)->GPSweek && gpseph->TOW > (*ee)->TOW) ) {
|
---|
172 | delete *ee;
|
---|
173 | *ee = gpseph;
|
---|
174 | printGPSEph(gpseph);
|
---|
175 | }
|
---|
176 | else {
|
---|
177 | delete gpseph;
|
---|
178 | }
|
---|
179 | }
|
---|
180 |
|
---|
181 | // New Glonass Ephemeris
|
---|
182 | ////////////////////////////////////////////////////////////////////////////
|
---|
183 | void bncApp::slotNewGlonassEph(glonassephemeris* glonasseph) {
|
---|
184 |
|
---|
185 | QMutexLocker locker(&_mutex);
|
---|
186 |
|
---|
187 | printEphHeader();
|
---|
188 |
|
---|
189 | if (!_ephStreamGlonass) {
|
---|
190 | delete glonasseph;
|
---|
191 | return;
|
---|
192 | }
|
---|
193 |
|
---|
194 | glonassephemeris** ee = &_glonassEph[glonasseph->almanac_number-1];
|
---|
195 |
|
---|
196 | int wwOld, towOld, wwNew, towNew;
|
---|
197 | if (*ee != 0) {
|
---|
198 | wwOld = (*ee)->GPSWeek;
|
---|
199 | towOld = (*ee)->GPSTOW;
|
---|
200 | updatetime(&wwOld, &towOld, (*ee)->tb*1000, 1);
|
---|
201 |
|
---|
202 | wwNew = glonasseph->GPSWeek;
|
---|
203 | towNew = glonasseph->GPSTOW;
|
---|
204 | updatetime(&wwNew, &towNew, glonasseph->tb*1000, 1);
|
---|
205 | }
|
---|
206 |
|
---|
207 | if ( *ee == 0 ||
|
---|
208 | wwNew > wwOld ||
|
---|
209 | (wwNew == wwOld && towNew > towOld) ) {
|
---|
210 | delete *ee;
|
---|
211 | *ee = glonasseph;
|
---|
212 | printGlonassEph(glonasseph);
|
---|
213 | }
|
---|
214 | else {
|
---|
215 | delete glonasseph;
|
---|
216 | }
|
---|
217 | }
|
---|
218 |
|
---|
219 | // Print Header of the output File(s)
|
---|
220 | ////////////////////////////////////////////////////////////////////////////
|
---|
221 | void bncApp::printEphHeader() {
|
---|
222 |
|
---|
223 | QSettings settings;
|
---|
224 |
|
---|
225 | // Initialization
|
---|
226 | // --------------
|
---|
227 | if (_rinexVers == 0) {
|
---|
228 |
|
---|
229 | if ( Qt::CheckState(settings.value("ephV3").toInt()) == Qt::Checked) {
|
---|
230 | _rinexVers = 3;
|
---|
231 | }
|
---|
232 | else {
|
---|
233 | _rinexVers = 2;
|
---|
234 | }
|
---|
235 |
|
---|
236 | _ephPath = settings.value("ephPath").toString();
|
---|
237 |
|
---|
238 | if ( !_ephPath.isEmpty() ) {
|
---|
239 | if ( _ephPath[_ephPath.length()-1] != QDir::separator() ) {
|
---|
240 | _ephPath += QDir::separator();
|
---|
241 | }
|
---|
242 | expandEnvVar(_ephPath);
|
---|
243 | }
|
---|
244 | }
|
---|
245 |
|
---|
246 | // (Re-)Open output File(s)
|
---|
247 | // ------------------------
|
---|
248 | if (!_ephPath.isEmpty()) {
|
---|
249 |
|
---|
250 | QDateTime datTim = QDateTime::currentDateTime().toUTC();
|
---|
251 |
|
---|
252 | QString ephFileNameGPS = _ephPath + "BNC_" +
|
---|
253 | QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0'));
|
---|
254 |
|
---|
255 | QString hlpStr;
|
---|
256 | QString intStr = settings.value("ephIntr").toString();
|
---|
257 | if (intStr == "1 day") {
|
---|
258 | hlpStr = "0";
|
---|
259 | }
|
---|
260 | else if (intStr == "1 hour") {
|
---|
261 | char ch = 'A' + datTim.time().hour();
|
---|
262 | hlpStr = ch;
|
---|
263 | }
|
---|
264 | else {
|
---|
265 | char ch = 'A' + datTim.time().hour();
|
---|
266 | hlpStr = ch;
|
---|
267 | if (datTim.time().minute() < 15) {
|
---|
268 | hlpStr += "00";
|
---|
269 | }
|
---|
270 | else if (datTim.time().minute() < 30) {
|
---|
271 | hlpStr += "15";
|
---|
272 | }
|
---|
273 | else if (datTim.time().minute() < 45) {
|
---|
274 | hlpStr += "30";
|
---|
275 | }
|
---|
276 | else {
|
---|
277 | hlpStr += "45";
|
---|
278 | }
|
---|
279 | }
|
---|
280 | if (_rinexVers == 3) {
|
---|
281 | ephFileNameGPS += hlpStr + datTim.toString(".yyP");
|
---|
282 | }
|
---|
283 | else {
|
---|
284 | ephFileNameGPS += hlpStr + datTim.toString(".yyN");
|
---|
285 | }
|
---|
286 |
|
---|
287 | if (_ephFileNameGPS == ephFileNameGPS) {
|
---|
288 | return;
|
---|
289 | }
|
---|
290 | else {
|
---|
291 | _ephFileNameGPS = ephFileNameGPS;
|
---|
292 | }
|
---|
293 |
|
---|
294 | for (int ii = PRN_GPS_START; ii <= PRN_GPS_END; ii++) {
|
---|
295 | delete _gpsEph[ii-PRN_GPS_START];
|
---|
296 | _gpsEph[ii-PRN_GPS_START] = 0;
|
---|
297 | }
|
---|
298 | for (int ii = PRN_GLONASS_START; ii <= PRN_GLONASS_END; ii++) {
|
---|
299 | delete _glonassEph[ii-PRN_GLONASS_START];
|
---|
300 | _glonassEph[ii-PRN_GLONASS_START] = 0;
|
---|
301 | }
|
---|
302 |
|
---|
303 | delete _ephStreamGPS;
|
---|
304 | delete _ephFileGPS;
|
---|
305 |
|
---|
306 | QFlags<QIODevice::OpenModeFlag> appendFlagGPS;
|
---|
307 | QFlags<QIODevice::OpenModeFlag> appendFlagGlonass;
|
---|
308 |
|
---|
309 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
|
---|
310 | QFile::exists(ephFileNameGPS) ) {
|
---|
311 | appendFlagGPS = QIODevice::Append;
|
---|
312 | }
|
---|
313 |
|
---|
314 | _ephFileGPS = new QFile(ephFileNameGPS);
|
---|
315 | _ephFileGPS->open(QIODevice::WriteOnly | appendFlagGPS);
|
---|
316 | _ephStreamGPS = new QTextStream();
|
---|
317 | _ephStreamGPS->setDevice(_ephFileGPS);
|
---|
318 |
|
---|
319 | if (_rinexVers == 3) {
|
---|
320 | _ephFileGlonass = _ephFileGPS;
|
---|
321 | _ephStreamGlonass = _ephStreamGPS;
|
---|
322 | }
|
---|
323 | else if (_rinexVers == 2) {
|
---|
324 | QString ephFileNameGlonass = _ephPath + "BNC_" +
|
---|
325 | QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +
|
---|
326 | hlpStr + datTim.toString(".yyG");
|
---|
327 |
|
---|
328 | delete _ephStreamGlonass;
|
---|
329 | delete _ephFileGlonass;
|
---|
330 |
|
---|
331 | if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked &&
|
---|
332 | QFile::exists(ephFileNameGlonass) ) {
|
---|
333 | appendFlagGlonass = QIODevice::Append;
|
---|
334 | }
|
---|
335 |
|
---|
336 | _ephFileGlonass = new QFile(ephFileNameGlonass);
|
---|
337 | _ephFileGlonass->open(QIODevice::WriteOnly | appendFlagGlonass);
|
---|
338 | _ephStreamGlonass = new QTextStream();
|
---|
339 | _ephStreamGlonass->setDevice(_ephFileGlonass);
|
---|
340 | }
|
---|
341 |
|
---|
342 | // Header - RINEX Version 3
|
---|
343 | // ------------------------
|
---|
344 | if (_rinexVers == 3) {
|
---|
345 | if ( ! (appendFlagGPS & QIODevice::Append)) {
|
---|
346 | QString line;
|
---|
347 | line.sprintf(
|
---|
348 | "%9.2f%11sN: GNSS NAV DATA M: Mixed%12sRINEX VERSION / TYPE\n",
|
---|
349 | 3.0, "", "");
|
---|
350 | *_ephStreamGPS << line;
|
---|
351 |
|
---|
352 | QString hlp = QDateTime::currentDateTime().toUTC().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
|
---|
353 | *_ephStreamGPS << _pgmName.toAscii().data()
|
---|
354 | << _userName.toAscii().data()
|
---|
355 | << hlp.toAscii().data()
|
---|
356 | << "PGM / RUN BY / DATE" << endl;
|
---|
357 |
|
---|
358 | line.sprintf("%60sEND OF HEADER\n", "");
|
---|
359 | *_ephStreamGPS << line;
|
---|
360 |
|
---|
361 | _ephStreamGPS->flush();
|
---|
362 | }
|
---|
363 | }
|
---|
364 |
|
---|
365 | // Headers - RINEX Version 2
|
---|
366 | // -------------------------
|
---|
367 | else if (_rinexVers == 2) {
|
---|
368 | if (! (appendFlagGPS & QIODevice::Append)) {
|
---|
369 | QString line;
|
---|
370 | line.sprintf(
|
---|
371 | "%9.2f%11sN: GPS NAV DATA%25sRINEX VERSION / TYPE\n", 2.11, "", "");
|
---|
372 | *_ephStreamGPS << line;
|
---|
373 |
|
---|
374 | QString hlp = QDateTime::currentDateTime().toUTC().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
|
---|
375 | *_ephStreamGPS << _pgmName.toAscii().data()
|
---|
376 | << _userName.toAscii().data()
|
---|
377 | << hlp.toAscii().data()
|
---|
378 | << "PGM / RUN BY / DATE" << endl;
|
---|
379 |
|
---|
380 | line.sprintf("%60sEND OF HEADER\n", "");
|
---|
381 | *_ephStreamGPS << line;
|
---|
382 |
|
---|
383 | _ephStreamGPS->flush();
|
---|
384 | }
|
---|
385 | if (! (appendFlagGlonass & QIODevice::Append)) {
|
---|
386 | QString line;
|
---|
387 | line.sprintf(
|
---|
388 | "%9.2f%11sG: GLONASS NAV DATA%21sRINEX VERSION / TYPE\n",2.11,"","");
|
---|
389 | *_ephStreamGlonass << line;
|
---|
390 |
|
---|
391 | QString hlp = QDateTime::currentDateTime().toUTC().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
|
---|
392 | *_ephStreamGlonass << _pgmName.toAscii().data()
|
---|
393 | << _userName.toAscii().data()
|
---|
394 | << hlp.toAscii().data()
|
---|
395 | << "PGM / RUN BY / DATE" << endl;
|
---|
396 |
|
---|
397 | line.sprintf("%60sEND OF HEADER\n", "");
|
---|
398 | *_ephStreamGlonass << line;
|
---|
399 |
|
---|
400 | _ephStreamGlonass->flush();
|
---|
401 | }
|
---|
402 | }
|
---|
403 | }
|
---|
404 | }
|
---|
405 |
|
---|
406 | // Print One GPS Ephemeris
|
---|
407 | ////////////////////////////////////////////////////////////////////////////
|
---|
408 | void bncApp::printGPSEph(gpsephemeris* ep) {
|
---|
409 |
|
---|
410 | if (_ephStreamGPS) {
|
---|
411 |
|
---|
412 | QString line;
|
---|
413 |
|
---|
414 | struct converttimeinfo cti;
|
---|
415 | converttime(&cti, ep->GPSweek, ep->TOC);
|
---|
416 |
|
---|
417 | if (_rinexVers == 3) {
|
---|
418 | line.sprintf("G%02d %04d %02d %02d %02d %02d %02d%19.12e%19.12e%19.12e",
|
---|
419 | ep->satellite, cti.year, cti.month, cti.day, cti.hour,
|
---|
420 | cti.minute, cti.second, ep->clock_bias, ep->clock_drift,
|
---|
421 | ep->clock_driftrate);
|
---|
422 | }
|
---|
423 | else if (_rinexVers == 2) {
|
---|
424 | line.sprintf("%02d %02d %02d %02d %02d %02d%5.1f%19.12e%19.12e%19.12e",
|
---|
425 | ep->satellite, cti.year%100, cti.month, cti.day, cti.hour,
|
---|
426 | cti.minute, (double) cti.second, ep->clock_bias,
|
---|
427 | ep->clock_drift, ep->clock_driftrate);
|
---|
428 | }
|
---|
429 | *_ephStreamGPS << line << endl;
|
---|
430 |
|
---|
431 | line.sprintf(" %19.12e%19.12e%19.12e%19.12e", (double)ep->IODE,
|
---|
432 | ep->Crs, ep->Delta_n, ep->M0);
|
---|
433 | *_ephStreamGPS << line << endl;
|
---|
434 |
|
---|
435 | line.sprintf(" %19.12e%19.12e%19.12e%19.12e", ep->Cuc,
|
---|
436 | ep->e, ep->Cus, ep->sqrt_A);
|
---|
437 | *_ephStreamGPS << line << endl;
|
---|
438 |
|
---|
439 | line.sprintf(" %19.12e%19.12e%19.12e%19.12e",
|
---|
440 | (double) ep->TOE, ep->Cic, ep->OMEGA0, ep->Cis);
|
---|
441 | *_ephStreamGPS << line << endl;
|
---|
442 |
|
---|
443 | line.sprintf(" %19.12e%19.12e%19.12e%19.12e", ep->i0,
|
---|
444 | ep->Crc, ep->omega, ep->OMEGADOT);
|
---|
445 | *_ephStreamGPS << line << endl;
|
---|
446 |
|
---|
447 | double dd = 0;
|
---|
448 | unsigned long ii = ep->flags;
|
---|
449 | if(ii & GPSEPHF_L2CACODE)
|
---|
450 | dd += 2.0;
|
---|
451 | if(ii & GPSEPHF_L2PCODE)
|
---|
452 | dd += 1.0;
|
---|
453 | line.sprintf(" %19.12e%19.12e%19.12e%19.12e", ep->IDOT, dd,
|
---|
454 | (double) ep->GPSweek, ii & GPSEPHF_L2PCODEDATA ? 1.0 : 0.0);
|
---|
455 | *_ephStreamGPS << line << endl;
|
---|
456 |
|
---|
457 | if(ep->URAindex <= 6) /* URA index */
|
---|
458 | dd = ceil(10.0*pow(2.0, 1.0+((double)ep->URAindex)/2.0))/10.0;
|
---|
459 | else
|
---|
460 | dd = ceil(10.0*pow(2.0, ((double)ep->URAindex)/2.0))/10.0;
|
---|
461 | line.sprintf(" %19.12e%19.12e%19.12e%19.12e", dd,
|
---|
462 | ((double) ep->SVhealth), ep->TGD, ((double) ep->IODC));
|
---|
463 | *_ephStreamGPS << line << endl;
|
---|
464 |
|
---|
465 | line.sprintf(" %19.12e%19.12e", ((double)ep->TOW), 0.0);
|
---|
466 | *_ephStreamGPS << line << endl;
|
---|
467 |
|
---|
468 | _ephStreamGPS->flush();
|
---|
469 | }
|
---|
470 | }
|
---|
471 |
|
---|
472 | // Print One Glonass Ephemeris
|
---|
473 | ////////////////////////////////////////////////////////////////////////////
|
---|
474 | void bncApp::printGlonassEph(glonassephemeris* ep) {
|
---|
475 |
|
---|
476 | if (_ephStreamGlonass) {
|
---|
477 | int ww = ep->GPSWeek;
|
---|
478 | int tow = ep->GPSTOW;
|
---|
479 | struct converttimeinfo cti;
|
---|
480 |
|
---|
481 | updatetime(&ww, &tow, ep->tb*1000, 1);
|
---|
482 | converttime(&cti, ww, tow);
|
---|
483 |
|
---|
484 | int ii = ep->tk-3*60*60;
|
---|
485 | if (ii < 0) {
|
---|
486 | ii += 86400;
|
---|
487 | }
|
---|
488 |
|
---|
489 | QString line;
|
---|
490 |
|
---|
491 | if (_rinexVers == 3) {
|
---|
492 | line.sprintf("R%02d %04d %02d %02d %02d %02d %02d%19.12e%19.12e%19.12e",
|
---|
493 | ep->almanac_number, cti.year, cti.month, cti.day, cti.hour,
|
---|
494 | cti.minute, cti.second, -ep->tau, ep->gamma, (double) ii);
|
---|
495 | }
|
---|
496 | else if (_rinexVers == 2) {
|
---|
497 | line.sprintf("%02d %02d %02d %02d %02d %02d%5.1f%19.12e%19.12e%19.12e",
|
---|
498 | ep->almanac_number, cti.year%100, cti.month, cti.day,
|
---|
499 | cti.hour, cti.minute, (double) cti.second, -ep->tau,
|
---|
500 | ep->gamma, (double) ii);
|
---|
501 | }
|
---|
502 | *_ephStreamGlonass << line << endl;
|
---|
503 |
|
---|
504 | line.sprintf(" %19.12e%19.12e%19.12e%19.12e", ep->x_pos,
|
---|
505 | ep->x_velocity, ep->x_acceleration,
|
---|
506 | (ep->flags & GLOEPHF_UNHEALTHY) ? 1.0 : 0.0);
|
---|
507 | *_ephStreamGlonass << line << endl;
|
---|
508 |
|
---|
509 | line.sprintf(" %19.12e%19.12e%19.12e%19.12e", ep->y_pos,
|
---|
510 | ep->y_velocity, ep->y_acceleration,
|
---|
511 | (double) ep->frequency_number);
|
---|
512 | *_ephStreamGlonass << line << endl;
|
---|
513 |
|
---|
514 | line.sprintf(" %19.12e%19.12e%19.12e%19.12e", ep->z_pos,
|
---|
515 | ep->z_velocity, ep->z_acceleration, (double) ep->E);
|
---|
516 | *_ephStreamGlonass << line << endl;
|
---|
517 |
|
---|
518 | _ephStreamGlonass->flush();
|
---|
519 | }
|
---|
520 | }
|
---|