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

Last change on this file since 1386 was 1386, checked in by mervart, 15 years ago

* empty log message *

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