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

Last change on this file since 2492 was 2492, checked in by stoecker, 14 years ago

removed double storage of RTCM3 stuff

File size: 23.4 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// Changed declaration of data types, consistent with Rinex3 Perlt
416 _out << "G 10 C1C C1P L1C S1C C2X C2P L2X S2X L2P S2P SYS / # / OBS TYPES" << endl;
417 _out << "R 10 C1C C1P L1C S1C C2C C2P L2C S2C L2P S2P 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// Added header line for Rinex3 regarding mandatory MARKER TYPE field Perlt
434 else if (line.indexOf("MARKER NAME") != -1) {
435 if (_rinexVers == 3) {
436 _out << line.toAscii().data() << endl;
437 _out << setw(71) << "GEODETIC MARKER TYPE" << endl;
438 }
439 else {
440 _out << line.toAscii().data() << endl;
441 }
442// End
443 }
444 else {
445 _out << line.toAscii().data() << endl;
446 }
447 }
448 }
449
450 // Write Dummy Header
451 // ------------------
452 else {
453 double antennaNEU[3]; antennaNEU[0] = antennaNEU[1] = antennaNEU[2] = 0.0;
454
455 if (_rinexVers == 3) {
456 _out << " 3.00 OBSERVATION DATA M (MIXED) RINEX VERSION / TYPE" << endl;
457 QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
458 _out << _pgmName.toAscii().data() << _userName.toAscii().data()
459 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
460 }
461 else {
462 _out << " 2.11 OBSERVATION DATA M (MIXED) RINEX VERSION / TYPE" << endl;
463 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
464 _out << _pgmName.toAscii().data() << _userName.toAscii().data()
465 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
466 }
467 _out.setf(ios::left);
468 _out << setw(60) << _statID.data() << "MARKER NAME" << endl;
469// Added header line for Rinex3 regarding mandatory MARKER TYPE field Perlt
470 if (_rinexVers == 3) {
471 _out << setw(60) << "unknown" << "MARKER TYPE " << endl;
472 }
473// End
474 _out << setw(60) << "unknown unknown" << "OBSERVER / AGENCY" << endl;
475 _out << setw(20) << "unknown"
476 << setw(20) << "unknown"
477 << setw(20) << "unknown" << "REC # / TYPE / VERS" << endl;
478 _out << setw(20) << "unknown"
479 << setw(20) << "unknown"
480 << setw(20) << " " << "ANT # / TYPE" << endl;
481 _out.unsetf(ios::left);
482 _out << setw(14) << setprecision(4) << _approxPos[0]
483 << setw(14) << setprecision(4) << _approxPos[1]
484 << setw(14) << setprecision(4) << _approxPos[2]
485 << " " << "APPROX POSITION XYZ" << endl;
486 _out << setw(14) << setprecision(4) << antennaNEU[0]
487 << setw(14) << setprecision(4) << antennaNEU[1]
488 << setw(14) << setprecision(4) << antennaNEU[2]
489 << " " << "ANTENNA: DELTA H/E/N" << endl;
490 if (_rinexVers == 3) {
491// Changed declaration of data types, consistent with Rinex3 Perlt
492 _out << "G 10 C1C C1P L1C S1C C2X C2P L2X S2X L2P S2P SYS / # / OBS TYPES" << endl;
493 _out << "R 10 C1C C1P L1C S1C C2C C2P L2C S2C L2P S2P SYS / # / OBS TYPES" << endl;
494 _out << "S 3 C1C L1C S1C SYS / # / OBS TYPES" << endl;
495
496 }
497 else {
498 _out << " 1 1 WAVELENGTH FACT L1/2" << endl;
499 _out << " 8 C1 C2 P1 P2 L1 L2 S1 S2 # / TYPES OF OBSERV" << endl;
500 }
501 _out << datTim.toString(" yyyy MM dd"
502 " hh mm ss.zzz0000").toAscii().data();
503 _out << " GPS TIME OF FIRST OBS" << endl;
504 QString hlp = (_format + QString(" %1").arg(_mountPoint.host() +
505 _mountPoint.path())).leftJustified(60, ' ', true);
506 _out << hlp.toAscii().data() << "COMMENT" << endl;
507
508 if (_nmea == "yes") {
509 hlp = ("NMEA LAT=" + _latitude + " " + "LONG=" + _longitude).leftJustified(60, ' ',true);
510 _out << hlp.toAscii().data() << "COMMENT" << endl; }
511
512 _out << " END OF HEADER" << endl;
513 }
514
515 _headerWritten = true;
516}
517
518// Stores Observation into Internal Array
519////////////////////////////////////////////////////////////////////////////
520void bncRinex::deepCopy(const p_obs obs) {
521 p_obs newObs = new t_obs();
522 memcpy(&newObs->_o, &obs->_o, sizeof(t_obsInternal));
523 _obs.push_back(newObs);
524}
525
526// Write One Epoch into the RINEX File
527////////////////////////////////////////////////////////////////////////////
528void bncRinex::dumpEpoch(long maxTime) {
529
530 // Select observations older than maxTime
531 // --------------------------------------
532 QList<p_obs> dumpList;
533 QMutableListIterator<p_obs> mIt(_obs);
534 while (mIt.hasNext()) {
535 p_obs obs = mIt.next();
536 if (obs->_o.GPSWeek * 7*24*3600 + obs->_o.GPSWeeks < maxTime - 0.05) {
537 dumpList.push_back(obs);
538 mIt.remove();
539 }
540 }
541
542 // Easy Return
543 // -----------
544 if (dumpList.isEmpty()) {
545 return;
546 }
547
548 // Time of Epoch
549 // -------------
550 p_obs fObs = *dumpList.begin();
551 QDateTime datTim = dateAndTimeFromGPSweek(fObs->_o.GPSWeek, fObs->_o.GPSWeeks);
552 QDateTime datTimNom = dateAndTimeFromGPSweek(fObs->_o.GPSWeek,
553 floor(fObs->_o.GPSWeeks+0.5));
554
555 // Close the file
556 // --------------
557 if (_nextCloseEpoch.isValid() && datTimNom >= _nextCloseEpoch) {
558 closeFile();
559 _headerWritten = false;
560 }
561
562 // Write RINEX Header
563 // ------------------
564 if (!_headerWritten) {
565 writeHeader(datTim, datTimNom);
566 }
567
568 double sec = double(datTim.time().second()) + fmod(fObs->_o.GPSWeeks,1.0);
569
570 // Epoch header line: RINEX Version 3
571 // ----------------------------------
572 if (_rinexVers == 3) {
573 _out << datTim.toString("> yyyy MM dd hh mm ").toAscii().data()
574 << setw(10) << setprecision(7) << sec
575 << " " << 0 << setw(3) << dumpList.size() << endl;
576 }
577 // Epoch header line: RINEX Version 2
578 // ----------------------------------
579 else {
580 _out << datTim.toString(" yy MM dd hh mm ").toAscii().data()
581 << setw(10) << setprecision(7) << sec
582 << " " << 0 << setw(3) << dumpList.size();
583
584 QListIterator<p_obs> it(dumpList); int iSat = 0;
585 while (it.hasNext()) {
586 iSat++;
587 p_obs obs = it.next();
588 _out << obs->_o.satSys << setw(2) << obs->_o.satNum;
589 if (iSat == 12 && it.hasNext()) {
590 _out << endl << " ";
591 iSat = 0;
592 }
593 }
594 _out << endl;
595 }
596
597 QListIterator<p_obs> it(dumpList);
598 while (it.hasNext()) {
599 p_obs obs = it.next();
600
601 // Cycle slips detection
602 // ---------------------
603 int prn = 0;
604 switch (obs->_o.satSys) {
605 case 'G': prn = obs->_o.satNum; break;
606 case 'R': prn = obs->_o.satNum + 200; break;
607 default: prn = obs->_o.satNum;
608 }
609
610 char lli1 = ' ';
611 char lli2 = ' ';
612 if ( obs->_o.slip_cnt_L1 >= 0 ) {
613 if ( _slip_cnt_L1.find(prn) != _slip_cnt_L1.end() &&
614 _slip_cnt_L1.find(prn).value() != obs->_o.slip_cnt_L1 ) {
615 lli1 = '1';
616 }
617 }
618 else if ( obs->_o.lock_timei_L1 >= 0 ) {
619 if ( _lock_timei_L1.find(prn) != _lock_timei_L1.end() &&
620 _lock_timei_L1.find(prn).value() != obs->_o.lock_timei_L1 ) {
621 lli1 = '1';
622 }
623 }
624
625 if ( obs->_o.slip_cnt_L2 >= 0 ) {
626 if ( _slip_cnt_L2.find(prn) != _slip_cnt_L2.end() &&
627 _slip_cnt_L2.find(prn).value() != obs->_o.slip_cnt_L2 ) {
628 lli2 = '1';
629 }
630 }
631 else if ( obs->_o.lock_timei_L2 >= 0 ) {
632 if ( _lock_timei_L2.find(prn) != _lock_timei_L2.end() &&
633 _lock_timei_L2.find(prn).value() != obs->_o.lock_timei_L2 ) {
634 lli2 = '1';
635 }
636 }
637
638 _slip_cnt_L1[prn] = obs->_o.slip_cnt_L1;
639 _slip_cnt_L2[prn] = obs->_o.slip_cnt_L2;
640
641 _lock_timei_L1[prn] = obs->_o.lock_timei_L1;
642 _lock_timei_L2[prn] = obs->_o.lock_timei_L2;
643
644 // RINEX Version 3
645 // ---------------
646 if (_rinexVers == 3) {
647 char sbasflag = 'S';
648 // Changed data output, C1P, C2C|X, L2C|X, S2C|X added. Changed Output for SBAS Perlt
649 if (sbasflag != obs->_o.satSys) {
650 _out << obs->_o.satSys
651 << setw(2) << setfill('0') << obs->_o.satNum << setfill(' ')
652 << setw(14) << setprecision(3) << obs->_o.C1 << " "
653 << setw(14) << setprecision(3) << obs->_o.P1 << " "
654 << setw(14) << setprecision(3) << obs->_o.L1 << lli1
655 << setw(1) << obs->_o.SNR1
656 << setw(14) << setprecision(3) << obs->_o.S1 << " "
657 << setw(14) << setprecision(3) << obs->_o.C2 << " "
658 << setw(14) << setprecision(3) << obs->_o.P2 << " " ;
659 if ((obs->_o.C2 != 0.0) && (obs->_o.P2 == 0.0)) {
660 _out << setw(14) << setprecision(3) << obs->_o.L2 << lli2
661 << setw(1) << obs->_o.SNR2
662 << setw(14) << setprecision(3) << obs->_o.S2 << " "
663 << " 0.000 0.000 ";
664 }
665 else {
666 _out << " 0.000 0.000 "
667 << setw(14) << setprecision(3) << obs->_o.L2 << " "
668 << setw(1) << obs->_o.SNR2
669 << setw(14) << setprecision(3) << obs->_o.S2;
670 }
671 _out << endl;
672 }
673 else {
674 _out << obs->_o.satSys
675 << setw(2) << setfill('0') << obs->_o.satNum << setfill(' ')
676 << setw(14) << setprecision(3) << obs->_o.C1 << " "
677 << setw(14) << setprecision(3) << obs->_o.P1 << " "
678 << setw(14) << setprecision(3) << obs->_o.L1 << lli1
679 << setw(1) << obs->_o.SNR1
680 << setw(14) << setprecision(3) << obs->_o.S1 << endl;
681 }
682 }
683
684 // RINEX Version 2
685 // ---------------
686 else {
687 char lli = ' ';
688 char snr = ' ';
689 _out << setw(14) << setprecision(3) << obs->_o.C1 << lli << snr;
690 _out << setw(14) << setprecision(3) << obs->_o.C2 << lli << snr;
691 _out << setw(14) << setprecision(3) << obs->_o.P1 << lli << snr;
692 _out << setw(14) << setprecision(3) << obs->_o.P2 << lli << snr;
693 _out << setw(14) << setprecision(3) << obs->_o.L1 << lli1
694 << setw(1) << obs->_o.SNR1 << endl;
695 _out << setw(14) << setprecision(3) << obs->_o.L2 << lli2
696 << setw(1) << obs->_o.SNR2;
697 _out << setw(14) << setprecision(3) << obs->_o.S1 ;
698 _out << setw(16) << setprecision(3) << obs->_o.S2 ;
699 _out << endl;
700 }
701
702 delete obs;
703 }
704
705 _out.flush();
706}
707
708// Close the Old RINEX File
709////////////////////////////////////////////////////////////////////////////
710void bncRinex::closeFile() {
711 if (_rinexVers == 3) {
712 _out << "> 4 1" << endl;
713 _out << "END OF FILE" << endl;
714 }
715 _out.close();
716 if (!_rnxScriptName.isEmpty()) {
717 qApp->thread()->wait(100);
718#ifdef WIN32
719 QProcess::startDetached(_rnxScriptName, QStringList() << _fName) ;
720#else
721 QProcess::startDetached("nohup", QStringList() << _rnxScriptName << _fName) ;
722#endif
723
724 }
725}
Note: See TracBrowser for help on using the repository browser.