source: ntrip/trunk/BNC/bncrinex.cpp@ 2688

Last change on this file since 2688 was 2688, checked in by mervart, 13 years ago
File size: 24.6 KB
Line 
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: bncRinex
30 *
31 * Purpose: writes RINEX files
32 *
33 * Author: L. Mervart
34 *
35 * Created: 27-Aug-2006
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <stdlib.h>
42#include <iostream>
43#include <iomanip>
44#include <math.h>
45
46#include <QtCore>
47#include <QUrl>
48#include <QString>
49
50#include "bncrinex.h"
51#include "bncapp.h"
52#include "bncutils.h"
53#include "bncconst.h"
54#include "bnctabledlg.h"
55#include "bncgetthread.h"
56#include "bncnetqueryv2.h"
57#include "bncsettings.h"
58#include "bncversion.h"
59#include "rtcm3torinex.h"
60
61using namespace std;
62
63// Constructor
64////////////////////////////////////////////////////////////////////////////
65bncRinex::bncRinex(const QByteArray& statID, const QUrl& mountPoint,
66 const QByteArray& format, const QByteArray& latitude,
67 const QByteArray& longitude, const QByteArray& nmea,
68 const QByteArray& ntripVersion) {
69
70 _statID = statID;
71 _mountPoint = mountPoint;
72 _format = format.left(6);
73 _latitude = latitude;
74 _longitude = longitude;
75 _nmea = nmea;
76 _ntripVersion = ntripVersion;
77 _headerWritten = false;
78 _reconnectFlag = false;
79 _reloadTable = false;
80 _reloadDone = false;
81
82 bncSettings settings;
83 _rnxScriptName = settings.value("rnxScript").toString();
84 expandEnvVar(_rnxScriptName);
85
86 _pgmName = QString(BNCPGMNAME).leftJustified(20, ' ', true);
87#ifdef WIN32
88 _userName = QString("${USERNAME}");
89#else
90 _userName = QString("${USER}");
91#endif
92 expandEnvVar(_userName);
93 _userName = _userName.leftJustified(20, ' ', true);
94
95 if ( Qt::CheckState(settings.value("rnxV3").toInt()) == Qt::Checked) {
96 _rinexVers = 3;
97 }
98 else {
99 _rinexVers = 2;
100 }
101
102 _approxPos[0] = _approxPos[1] = _approxPos[2] = 0.0;
103}
104
105// Destructor
106////////////////////////////////////////////////////////////////////////////
107bncRinex::~bncRinex() {
108 QListIterator<p_obs> it(_obs);
109 while (it.hasNext()) {
110 delete it.next();
111 }
112 bncSettings settings;
113 if ((_rinexVers == 3) && ( Qt::CheckState(settings.value("rnxAppend").toInt()) != Qt::Checked) ) {
114 _out << "> 4 1" << endl;
115 _out << "END OF FILE" << endl;
116 }
117 _out.close();
118}
119
120// Download Skeleton Header File
121////////////////////////////////////////////////////////////////////////////
122t_irc bncRinex::downloadSkeleton() {
123
124 t_irc irc = failure;
125
126 QStringList table;
127 bncTableDlg::getFullTable(_mountPoint.host(), _mountPoint.port(),
128 table, _reloadTable);
129 QString net;
130 QStringListIterator it(table);
131 while (it.hasNext()) {
132 QString line = it.next();
133 if (line.indexOf("STR") == 0) {
134 QStringList tags = line.split(";");
135 if (tags.size() > 7) {
136 if (tags.at(1) == _mountPoint.path().mid(1).toAscii()) {
137 net = tags.at(7);
138 break;
139 }
140 }
141 }
142 }
143 QString sklDir;
144 if (!net.isEmpty()) {
145 it.toFront();
146 while (it.hasNext()) {
147 QString line = it.next();
148 if (line.indexOf("NET") == 0) {
149 QStringList tags = line.split(";");
150 if (tags.size() > 6) {
151 if (tags.at(1) == net) {
152 sklDir = tags.at(6).trimmed();
153 break;
154 }
155 }
156 }
157 }
158 }
159 if (!sklDir.isEmpty() && sklDir != "none") {
160 QUrl url(sklDir + "/" + _mountPoint.path().mid(1,4).toLower() + ".skl");
161 if (url.port() == -1) {
162 url.setPort(80);
163 }
164
165 bncNetQueryV2 query;
166 QByteArray outData;
167 query.waitForRequestResult(url, outData);
168 if (query.status() == bncNetQuery::finished) {
169 _headerLines.clear();
170 bool firstLineRead = false;
171 QTextStream in(outData);
172 QString line = in.readLine();
173 while ( !line.isNull() ) {
174 if (line.indexOf("MARKER NAME") != -1) {
175 irc = success;
176 }
177 if (line.indexOf("RINEX VERSION") != -1) {
178 if (_rinexVers == 3) {
179 _headerLines.append(" 3.00 OBSERVATION DATA"
180 " M (MIXED)"
181 " RINEX VERSION / TYPE");
182 }
183 else {
184 _headerLines.append(" 2.11 OBSERVATION DATA"
185 " M (MIXED)"
186 " RINEX VERSION / TYPE");
187 }
188 _headerLines.append("PGM / RUN BY / DATE");
189 firstLineRead = true;
190 }
191 else if (firstLineRead) {
192 if (line.indexOf("END OF HEADER") != -1) {
193 _headerLines.append("# / TYPES OF OBSERV");
194 if (_rinexVers == 2) {
195 _headerLines.append(
196 QString(" 1 1").leftJustified(60, ' ', true) +
197 "WAVELENGTH FACT L1/2");
198 }
199 _headerLines.append("TIME OF FIRST OBS");
200 _headerLines.append( line );
201 break;
202 }
203 else {
204 _headerLines.append( line );
205 }
206 }
207 line = in.readLine();
208 }
209 }
210 else {
211 return failure;
212 }
213
214 }
215 return irc;
216}
217
218// Read Skeleton Header File
219////////////////////////////////////////////////////////////////////////////
220void bncRinex::readSkeleton() {
221
222 // Read the local file
223 // -------------------
224 QFile skl(_sklName);
225 if ( skl.exists() && skl.open(QIODevice::ReadOnly) ) {
226 _headerLines.clear();
227 QTextStream in(&skl);
228 while ( !in.atEnd() ) {
229 _headerLines.append( in.readLine() );
230 if (_headerLines.last().indexOf("END OF HEADER") != -1) {
231 break;
232 }
233 }
234 }
235
236 // Read downloaded file
237 // --------------------
238 else if ( _ntripVersion != "N" && _ntripVersion != "UN" &&
239 _ntripVersion != "S" ) {
240 QDate currDate = currentDateAndTimeGPS().date();
241 if ( !_skeletonDate.isValid() || _skeletonDate != currDate ) {
242 if ( downloadSkeleton() == success) {
243 _skeletonDate = currDate;
244 _reloadDone = false;
245 }
246 else {
247 if(!_reloadDone) {
248 _reloadTable = true;
249 if ( downloadSkeleton() == success) {
250 _skeletonDate = currDate;
251 }
252 _reloadTable = false;
253 _reloadDone = true;
254 }
255 }
256 }
257 }
258}
259
260// Next File Epoch (static)
261////////////////////////////////////////////////////////////////////////////
262QString bncRinex::nextEpochStr(const QDateTime& datTim,
263 const QString& intStr, QDateTime* nextEpoch) {
264
265 QString epoStr;
266
267 QTime nextTime;
268 QDate nextDate;
269
270 int indHlp = intStr.indexOf("min");
271
272 if ( indHlp != -1) {
273 int step = intStr.left(indHlp-1).toInt();
274 char ch = 'A' + datTim.time().hour();
275 epoStr = ch;
276 if (datTim.time().minute() >= 60-step) {
277 epoStr += QString("%1").arg(60-step, 2, 10, QChar('0'));
278 if (datTim.time().hour() < 23) {
279 nextTime.setHMS(datTim.time().hour() + 1 , 0, 0);
280 nextDate = datTim.date();
281 }
282 else {
283 nextTime.setHMS(0, 0, 0);
284 nextDate = datTim.date().addDays(1);
285 }
286 }
287 else {
288 for (int limit = step; limit <= 60-step; limit += step) {
289 if (datTim.time().minute() < limit) {
290 epoStr += QString("%1").arg(limit-step, 2, 10, QChar('0'));
291 nextTime.setHMS(datTim.time().hour(), limit, 0);
292 nextDate = datTim.date();
293 break;
294 }
295 }
296 }
297 }
298 else if (intStr == "1 hour") {
299 char ch = 'A' + datTim.time().hour();
300 epoStr = ch;
301 if (datTim.time().hour() < 23) {
302 nextTime.setHMS(datTim.time().hour() + 1 , 0, 0);
303 nextDate = datTim.date();
304 }
305 else {
306 nextTime.setHMS(0, 0, 0);
307 nextDate = datTim.date().addDays(1);
308 }
309 }
310 else {
311 epoStr = "0";
312 nextTime.setHMS(0, 0, 0);
313 nextDate = datTim.date().addDays(1);
314 }
315
316 if (nextEpoch) {
317 *nextEpoch = QDateTime(nextDate, nextTime);
318 }
319
320 return epoStr;
321}
322
323// File Name according to RINEX Standards
324////////////////////////////////////////////////////////////////////////////
325void bncRinex::resolveFileName(const QDateTime& datTim) {
326
327 bncSettings settings;
328 QString path = settings.value("rnxPath").toString();
329 expandEnvVar(path);
330
331 if ( path.length() > 0 && path[path.length()-1] != QDir::separator() ) {
332 path += QDir::separator();
333 }
334
335 QString hlpStr = nextEpochStr(datTim, settings.value("rnxIntr").toString(),
336 &_nextCloseEpoch);
337
338 QString ID4 = _statID.left(4);
339
340 // Check name conflict
341 // -------------------
342 QString distStr;
343 int num = 0;
344 QListIterator<QString> it(settings.value("mountPoints").toStringList());
345 while (it.hasNext()) {
346 QString mp = it.next();
347 if (mp.indexOf(ID4) != -1) {
348 ++num;
349 }
350 }
351 if (num > 1) {
352 distStr = "_" + _statID.mid(4);
353 }
354
355 QString sklExt = settings.value("rnxSkel").toString();
356 if (!sklExt.isEmpty()) {
357 _sklName = path + ID4 + distStr + "." + sklExt;
358 }
359
360 path += ID4 +
361 QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +
362 hlpStr + distStr + datTim.toString(".yyO");
363
364 _fName = path.toAscii();
365}
366
367// Write RINEX Header
368////////////////////////////////////////////////////////////////////////////
369void bncRinex::writeHeader(const QDateTime& datTim,
370 const QDateTime& datTimNom) {
371
372 bncSettings settings;
373
374 // Open the Output File
375 // --------------------
376 resolveFileName(datTimNom);
377
378 // Append to existing file and return
379 // ----------------------------------
380 if ( QFile::exists(_fName) ) {
381 if (_reconnectFlag ||
382 Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
383 _out.open(_fName.data(), ios::app);
384 _out.setf(ios::showpoint | ios::fixed);
385 _headerWritten = true;
386 _reconnectFlag = false;
387 return;
388 }
389 }
390
391 _out.open(_fName.data());
392 _out.setf(ios::showpoint | ios::fixed);
393
394 // Copy Skeleton Header
395 // --------------------
396 readSkeleton();
397 if (_headerLines.size() > 0) {
398 QStringListIterator it(_headerLines);
399 while (it.hasNext()) {
400 QString line = it.next();
401 if (line.indexOf("PGM / RUN BY / DATE") != -1) {
402 if (_rinexVers == 3) {
403 QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
404 _out << _pgmName.toAscii().data() << _userName.toAscii().data()
405 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
406 }
407 else {
408 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
409 _out << _pgmName.toAscii().data() << _userName.toAscii().data()
410 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
411 }
412 }
413 else if (line.indexOf("# / TYPES OF OBSERV") != -1) {
414 if (_rinexVers == 3) {
415 _out << "G 10 C1C C1P L1C S1C C2W C2P L2W S2W L2P S2P SYS / # / OBS TYPES" << endl;
416 _out << "R 10 C1C C1P L1C S1C C2C C2P L2C S2C L2P S2P SYS / # / OBS TYPES" << endl;
417 _out << "E 6 C1X L1X S1X C5X L5X S5X SYS / # / OBS TYPES" << endl;
418 _out << "S 3 C1C L1C S1C SYS / # / OBS TYPES" << endl;
419 }
420 else {
421 _out << " 8 C1 C2 P1 P2 L1 L2 S1 S2"
422 " # / TYPES OF OBSERV" << endl;
423 }
424 }
425 else if (line.indexOf("TIME OF FIRST OBS") != -1) {
426 _out << datTim.toString(" yyyy MM dd"
427 " hh mm ss.zzz0000").toAscii().data();
428 _out << " GPS TIME OF FIRST OBS" << endl;
429 QString hlp = (_format + QString(" %1").arg(_mountPoint.host() +
430 _mountPoint.path())).leftJustified(60, ' ', true);
431 _out << hlp.toAscii().data() << "COMMENT" << endl;
432 }
433 else if (line.indexOf("MARKER NAME") != -1) {
434 if (_rinexVers == 3) {
435 _out << line.toAscii().data() << endl;
436 _out << setw(71) << "GEODETIC MARKER TYPE" << endl;
437 }
438 else {
439 _out << line.toAscii().data() << endl;
440 }
441 }
442 else {
443 _out << line.toAscii().data() << endl;
444 }
445 }
446 }
447
448 // Write Dummy Header
449 // ------------------
450 else {
451 double antennaNEU[3]; antennaNEU[0] = antennaNEU[1] = antennaNEU[2] = 0.0;
452
453 if (_rinexVers == 3) {
454 _out << " 3.00 OBSERVATION DATA M (MIXED) RINEX VERSION / TYPE" << endl;
455 QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
456 _out << _pgmName.toAscii().data() << _userName.toAscii().data()
457 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
458 }
459 else {
460 _out << " 2.11 OBSERVATION DATA M (MIXED) RINEX VERSION / TYPE" << endl;
461 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
462 _out << _pgmName.toAscii().data() << _userName.toAscii().data()
463 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
464 }
465 _out.setf(ios::left);
466 _out << setw(60) << _statID.data() << "MARKER NAME" << endl;
467 if (_rinexVers == 3) {
468 _out << setw(60) << "unknown" << "MARKER TYPE " << endl;
469 }
470 _out << setw(60) << "unknown unknown" << "OBSERVER / AGENCY" << endl;
471 _out << setw(20) << "unknown"
472 << setw(20) << "unknown"
473 << setw(20) << "unknown" << "REC # / TYPE / VERS" << endl;
474 _out << setw(20) << "unknown"
475 << setw(20) << "unknown"
476 << setw(20) << " " << "ANT # / TYPE" << endl;
477 _out.unsetf(ios::left);
478 _out << setw(14) << setprecision(4) << _approxPos[0]
479 << setw(14) << setprecision(4) << _approxPos[1]
480 << setw(14) << setprecision(4) << _approxPos[2]
481 << " " << "APPROX POSITION XYZ" << endl;
482 _out << setw(14) << setprecision(4) << antennaNEU[0]
483 << setw(14) << setprecision(4) << antennaNEU[1]
484 << setw(14) << setprecision(4) << antennaNEU[2]
485 << " " << "ANTENNA: DELTA H/E/N" << endl;
486 if (_rinexVers == 3) {
487 _out << "G 10 C1C C1P L1C S1C C2W C2P L2W S2W L2P S2P SYS / # / OBS TYPES" << endl;
488 _out << "R 10 C1C C1P L1C S1C C2C C2P L2C S2C L2P S2P SYS / # / OBS TYPES" << endl;
489 _out << "E 6 C1X L1X S1X C5X L5X S5X SYS / # / OBS TYPES" << endl;
490 _out << "S 3 C1C L1C S1C SYS / # / OBS TYPES" << endl;
491 }
492 else {
493 _out << " 1 1 WAVELENGTH FACT L1/2" << endl;
494 _out << " 8 C1 C2 P1 P2 L1 L2 S1 S2 # / TYPES OF OBSERV" << endl;
495 }
496 _out << datTim.toString(" yyyy MM dd"
497 " hh mm ss.zzz0000").toAscii().data();
498 _out << " GPS TIME OF FIRST OBS" << endl;
499 QString hlp = (_format + QString(" %1").arg(_mountPoint.host() +
500 _mountPoint.path())).leftJustified(60, ' ', true);
501 _out << hlp.toAscii().data() << "COMMENT" << endl;
502
503 if (_nmea == "yes") {
504 hlp = ("NMEA LAT=" + _latitude + " " + "LONG=" + _longitude).leftJustified(60, ' ',true);
505 _out << hlp.toAscii().data() << "COMMENT" << endl; }
506
507 _out << " END OF HEADER" << endl;
508 }
509
510 _headerWritten = true;
511}
512
513// Stores Observation into Internal Array
514////////////////////////////////////////////////////////////////////////////
515void bncRinex::deepCopy(const p_obs obs) {
516 p_obs newObs = new t_obs();
517 memcpy(&newObs->_o, &obs->_o, sizeof(t_obsInternal));
518 _obs.push_back(newObs);
519}
520
521// Write One Epoch into the RINEX File
522////////////////////////////////////////////////////////////////////////////
523void bncRinex::dumpEpoch(long maxTime) {
524
525 // Select observations older than maxTime
526 // --------------------------------------
527 QList<p_obs> dumpList;
528 QMutableListIterator<p_obs> mIt(_obs);
529 while (mIt.hasNext()) {
530 p_obs obs = mIt.next();
531 if (obs->_o.GPSWeek * 7*24*3600 + obs->_o.GPSWeeks < maxTime - 0.05) {
532 dumpList.push_back(obs);
533 mIt.remove();
534 }
535 }
536
537 // Easy Return
538 // -----------
539 if (dumpList.isEmpty()) {
540 return;
541 }
542
543 // Time of Epoch
544 // -------------
545 p_obs fObs = *dumpList.begin();
546 QDateTime datTim = dateAndTimeFromGPSweek(fObs->_o.GPSWeek, fObs->_o.GPSWeeks);
547 QDateTime datTimNom = dateAndTimeFromGPSweek(fObs->_o.GPSWeek,
548 floor(fObs->_o.GPSWeeks+0.5));
549
550 // Close the file
551 // --------------
552 if (_nextCloseEpoch.isValid() && datTimNom >= _nextCloseEpoch) {
553 closeFile();
554 _headerWritten = false;
555 }
556
557 // Write RINEX Header
558 // ------------------
559 if (!_headerWritten) {
560 writeHeader(datTim, datTimNom);
561 }
562
563 double sec = double(datTim.time().second()) + fmod(fObs->_o.GPSWeeks,1.0);
564
565 // Epoch header line: RINEX Version 3
566 // ----------------------------------
567 if (_rinexVers == 3) {
568 _out << datTim.toString("> yyyy MM dd hh mm ").toAscii().data()
569 << setw(10) << setprecision(7) << sec
570 << " " << 0 << setw(3) << dumpList.size() << endl;
571 }
572 // Epoch header line: RINEX Version 2
573 // ----------------------------------
574 else {
575 _out << datTim.toString(" yy MM dd hh mm ").toAscii().data()
576 << setw(10) << setprecision(7) << sec
577 << " " << 0 << setw(3) << dumpList.size();
578
579 QListIterator<p_obs> it(dumpList); int iSat = 0;
580 while (it.hasNext()) {
581 iSat++;
582 p_obs obs = it.next();
583 _out << obs->_o.satSys << setw(2) << obs->_o.satNum;
584 if (iSat == 12 && it.hasNext()) {
585 _out << endl << " ";
586 iSat = 0;
587 }
588 }
589 _out << endl;
590 }
591
592 QListIterator<p_obs> it(dumpList);
593 while (it.hasNext()) {
594 p_obs obs = it.next();
595
596 // Cycle slips detection
597 // ---------------------
598 int prn = 0;
599 switch (obs->_o.satSys) {
600 case 'G': prn = obs->_o.satNum; break;
601 case 'R': prn = obs->_o.satNum + 200; break;
602 default: prn = obs->_o.satNum;
603 }
604
605 char lli1 = ' ';
606 char lli2 = ' ';
607 char lli5 = ' ';
608 if ( obs->_o.slip_cnt_L1 >= 0 ) {
609 if ( _slip_cnt_L1.find(prn) != _slip_cnt_L1.end() &&
610 _slip_cnt_L1.find(prn).value() != obs->_o.slip_cnt_L1 ) {
611 lli1 = '1';
612 }
613 }
614 else if ( obs->_o.lock_timei_L1 >= 0 ) {
615 if ( _lock_timei_L1.find(prn) != _lock_timei_L1.end() &&
616 _lock_timei_L1.find(prn).value() != obs->_o.lock_timei_L1 ) {
617 lli1 = '1';
618 }
619 }
620
621 if ( obs->_o.slip_cnt_L2 >= 0 ) {
622 if ( _slip_cnt_L2.find(prn) != _slip_cnt_L2.end() &&
623 _slip_cnt_L2.find(prn).value() != obs->_o.slip_cnt_L2 ) {
624 lli2 = '1';
625 }
626 }
627 else if ( obs->_o.lock_timei_L2 >= 0 ) {
628 if ( _lock_timei_L2.find(prn) != _lock_timei_L2.end() &&
629 _lock_timei_L2.find(prn).value() != obs->_o.lock_timei_L2 ) {
630 lli2 = '1';
631 }
632 }
633
634 if ( obs->_o.slip_cnt_L5 >= 0 ) {
635 if ( _slip_cnt_L5.find(prn) != _slip_cnt_L5.end() &&
636 _slip_cnt_L5.find(prn).value() != obs->_o.slip_cnt_L5 ) {
637 lli5 = '1';
638 }
639 }
640 else if ( obs->_o.lock_timei_L5 >= 0 ) {
641 if ( _lock_timei_L5.find(prn) != _lock_timei_L5.end() &&
642 _lock_timei_L5.find(prn).value() != obs->_o.lock_timei_L5 ) {
643 lli5 = '1';
644 }
645 }
646
647 _slip_cnt_L1[prn] = obs->_o.slip_cnt_L1;
648 _slip_cnt_L2[prn] = obs->_o.slip_cnt_L2;
649 _slip_cnt_L5[prn] = obs->_o.slip_cnt_L5;
650
651 _lock_timei_L1[prn] = obs->_o.lock_timei_L1;
652 _lock_timei_L2[prn] = obs->_o.lock_timei_L2;
653 _lock_timei_L5[prn] = obs->_o.lock_timei_L5;
654
655 // RINEX Version 3
656 // ---------------
657 if (_rinexVers == 3) {
658 if (obs->_o.satSys == 'G' || obs->_o.satSys == 'R') { // GPS and Glonass
659 _out << obs->_o.satSys
660 << setw(2) << setfill('0') << obs->_o.satNum << setfill(' ')
661 << setw(14) << setprecision(3) << obs->_o.C1 << " "
662 << setw(14) << setprecision(3) << obs->_o.P1 << " "
663 << setw(14) << setprecision(3) << obs->_o.L1 << lli1
664 << setw(1) << obs->_o.SNR1
665 << setw(14) << setprecision(3) << obs->_o.S1 << " "
666 << setw(14) << setprecision(3) << obs->_o.C2 << " "
667 << setw(14) << setprecision(3) << obs->_o.P2 << " " ;
668 if ((obs->_o.C2 != 0.0) && (obs->_o.P2 == 0.0)) {
669 _out << setw(14) << setprecision(3) << obs->_o.L2 << lli2
670 << setw(1) << obs->_o.SNR2
671 << setw(14) << setprecision(3) << obs->_o.S2 << " "
672 << " 0.000 0.000 ";
673 }
674 else {
675 _out << " 0.000 0.000 "
676 << setw(14) << setprecision(3) << obs->_o.L2 << " "
677 << setw(1) << obs->_o.SNR2
678 << setw(14) << setprecision(3) << obs->_o.S2;
679 }
680 _out << endl;
681 }
682 else if (obs->_o.satSys == 'S') { // SBAS
683 _out << obs->_o.satSys
684 << setw(2) << setfill('0') << obs->_o.satNum << setfill(' ')
685 << setw(14) << setprecision(3) << obs->_o.C1 << " "
686 << setw(14) << setprecision(3) << obs->_o.P1 << " "
687 << setw(14) << setprecision(3) << obs->_o.L1 << lli1
688 << setw(1) << obs->_o.SNR1
689 << setw(14) << setprecision(3) << obs->_o.S1 << endl;
690 }
691 else if (obs->_o.satSys == 'E') { // Galileo
692 _out << obs->_o.satSys
693 << setw(2) << setfill('0') << obs->_o.satNum << setfill(' ')
694 << setw(14) << setprecision(3) << obs->_o.C1 << " "
695 << setw(14) << setprecision(3) << obs->_o.L1 << lli1 << " "
696 << setw(14) << setprecision(3) << obs->_o.S1 << " "
697 << setw(14) << setprecision(3) << obs->_o.C5 << " "
698 << setw(14) << setprecision(3) << obs->_o.L5 << lli5 << " "
699 << setw(14) << setprecision(3) << obs->_o.S5 << endl;
700 }
701 }
702
703 // RINEX Version 2
704 // ---------------
705 else {
706 char lli = ' ';
707 char snr = ' ';
708 _out << setw(14) << setprecision(3) << obs->_o.C1 << lli << snr;
709 _out << setw(14) << setprecision(3) << obs->_o.C2 << lli << snr;
710 _out << setw(14) << setprecision(3) << obs->_o.P1 << lli << snr;
711 _out << setw(14) << setprecision(3) << obs->_o.P2 << lli << snr;
712 _out << setw(14) << setprecision(3) << obs->_o.L1 << lli1
713 << setw(1) << obs->_o.SNR1 << endl;
714 _out << setw(14) << setprecision(3) << obs->_o.L2 << lli2
715 << setw(1) << obs->_o.SNR2;
716 _out << setw(14) << setprecision(3) << obs->_o.S1 ;
717 _out << setw(16) << setprecision(3) << obs->_o.S2 ;
718 _out << endl;
719 }
720
721 delete obs;
722 }
723
724 _out.flush();
725}
726
727// Close the Old RINEX File
728////////////////////////////////////////////////////////////////////////////
729void bncRinex::closeFile() {
730 if (_rinexVers == 3) {
731 _out << "> 4 1" << endl;
732 _out << "END OF FILE" << endl;
733 }
734 _out.close();
735 if (!_rnxScriptName.isEmpty()) {
736 qApp->thread()->wait(100);
737#ifdef WIN32
738 QProcess::startDetached(_rnxScriptName, QStringList() << _fName) ;
739#else
740 QProcess::startDetached("nohup", QStringList() << _rnxScriptName << _fName) ;
741#endif
742
743 }
744}
Note: See TracBrowser for help on using the repository browser.