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

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

* empty log message *

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 "RTCM3/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 QDate currDate = currentDateAndTimeGPS().date();
240 if ( !_skeletonDate.isValid() || _skeletonDate != currDate ) {
241 if ( downloadSkeleton() == success) {
242 _skeletonDate = currDate;
243 _reloadDone = false;
244 }
245 else {
246 if(!_reloadDone) {
247 _reloadTable = true;
248 if ( downloadSkeleton() == success) {
249 _skeletonDate = currDate;
250 }
251 _reloadTable = false;
252 _reloadDone = true;
253 }
254 }
255 }
256 }
257}
258
259// Next File Epoch (static)
260////////////////////////////////////////////////////////////////////////////
261QString bncRinex::nextEpochStr(const QDateTime& datTim,
262 const QString& intStr, QDateTime* nextEpoch) {
263
264 QString epoStr;
265
266 QTime nextTime;
267 QDate nextDate;
268
269 int indHlp = intStr.indexOf("min");
270
271 if ( indHlp != -1) {
272 int step = intStr.left(indHlp-1).toInt();
273 char ch = 'A' + datTim.time().hour();
274 epoStr = ch;
275 if (datTim.time().minute() >= 60-step) {
276 epoStr += QString("%1").arg(60-step, 2, 10, QChar('0'));
277 if (datTim.time().hour() < 23) {
278 nextTime.setHMS(datTim.time().hour() + 1 , 0, 0);
279 nextDate = datTim.date();
280 }
281 else {
282 nextTime.setHMS(0, 0, 0);
283 nextDate = datTim.date().addDays(1);
284 }
285 }
286 else {
287 for (int limit = step; limit <= 60-step; limit += step) {
288 if (datTim.time().minute() < limit) {
289 epoStr += QString("%1").arg(limit-step, 2, 10, QChar('0'));
290 nextTime.setHMS(datTim.time().hour(), limit, 0);
291 nextDate = datTim.date();
292 break;
293 }
294 }
295 }
296 }
297 else if (intStr == "1 hour") {
298 char ch = 'A' + datTim.time().hour();
299 epoStr = ch;
300 if (datTim.time().hour() < 23) {
301 nextTime.setHMS(datTim.time().hour() + 1 , 0, 0);
302 nextDate = datTim.date();
303 }
304 else {
305 nextTime.setHMS(0, 0, 0);
306 nextDate = datTim.date().addDays(1);
307 }
308 }
309 else {
310 epoStr = "0";
311 nextTime.setHMS(0, 0, 0);
312 nextDate = datTim.date().addDays(1);
313 }
314
315 if (nextEpoch) {
316 *nextEpoch = QDateTime(nextDate, nextTime);
317 }
318
319 return epoStr;
320}
321
322// File Name according to RINEX Standards
323////////////////////////////////////////////////////////////////////////////
324void bncRinex::resolveFileName(const QDateTime& datTim) {
325
326 bncSettings settings;
327 QString path = settings.value("rnxPath").toString();
328 expandEnvVar(path);
329
330 if ( path.length() > 0 && path[path.length()-1] != QDir::separator() ) {
331 path += QDir::separator();
332 }
333
334 QString hlpStr = nextEpochStr(datTim, settings.value("rnxIntr").toString(),
335 &_nextCloseEpoch);
336
337 QString ID4 = _statID.left(4);
338
339 // Check name conflict
340 // -------------------
341 QString distStr;
342 int num = 0;
343 QListIterator<QString> it(settings.value("mountPoints").toStringList());
344 while (it.hasNext()) {
345 QString mp = it.next();
346 if (mp.indexOf(ID4) != -1) {
347 ++num;
348 }
349 }
350 if (num > 1) {
351 distStr = "_" + _statID.mid(4);
352 }
353
354 QString sklExt = settings.value("rnxSkel").toString();
355 if (!sklExt.isEmpty()) {
356 _sklName = path + ID4 + distStr + "." + sklExt;
357 }
358
359 path += ID4 +
360 QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +
361 hlpStr + distStr + datTim.toString(".yyO");
362
363 _fName = path.toAscii();
364}
365
366// Write RINEX Header
367////////////////////////////////////////////////////////////////////////////
368void bncRinex::writeHeader(const QDateTime& datTim,
369 const QDateTime& datTimNom) {
370
371 bncSettings settings;
372
373 // Open the Output File
374 // --------------------
375 resolveFileName(datTimNom);
376
377 // Append to existing file and return
378 // ----------------------------------
379 if ( QFile::exists(_fName) ) {
380 if (_reconnectFlag ||
381 Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
382 _out.open(_fName.data(), ios::app);
383 _out.setf(ios::showpoint | ios::fixed);
384 _headerWritten = true;
385 _reconnectFlag = false;
386 return;
387 }
388 }
389
390 _out.open(_fName.data());
391 _out.setf(ios::showpoint | ios::fixed);
392
393 // Copy Skeleton Header
394 // --------------------
395 readSkeleton();
396 if (_headerLines.size() > 0) {
397 QStringListIterator it(_headerLines);
398 while (it.hasNext()) {
399 QString line = it.next();
400 if (line.indexOf("PGM / RUN BY / DATE") != -1) {
401 if (_rinexVers == 3) {
402 QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
403 _out << _pgmName.toAscii().data() << _userName.toAscii().data()
404 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
405 }
406 else {
407 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
408 _out << _pgmName.toAscii().data() << _userName.toAscii().data()
409 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
410 }
411 }
412 else if (line.indexOf("# / TYPES OF OBSERV") != -1) {
413 if (_rinexVers == 3) {
414// Changed declaration of data types, consistent with Rinex3 Perlt
415 _out << "G 10 C1C C1P L1C S1C C2X C2P L2X S2X 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 << "S 3 C1C L1C S1C SYS / # / OBS TYPES" << endl;
418 }
419 else {
420 _out << " 8 C1 C2 P1 P2 L1 L2 S1 S2"
421 " # / TYPES OF OBSERV" << endl;
422 }
423 }
424 else if (line.indexOf("TIME OF FIRST OBS") != -1) {
425 _out << datTim.toString(" yyyy MM dd"
426 " hh mm ss.zzz0000").toAscii().data();
427 _out << " GPS TIME OF FIRST OBS" << endl;
428 QString hlp = (_format + QString(" %1").arg(_mountPoint.host() +
429 _mountPoint.path())).leftJustified(60, ' ', true);
430 _out << hlp.toAscii().data() << "COMMENT" << endl;
431 }
432// Added header line for Rinex3 regarding mandatory MARKER TYPE field Perlt
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// End
442 }
443 else {
444 _out << line.toAscii().data() << endl;
445 }
446 }
447 }
448
449 // Write Dummy Header
450 // ------------------
451 else {
452 double antennaNEU[3]; antennaNEU[0] = antennaNEU[1] = antennaNEU[2] = 0.0;
453
454 if (_rinexVers == 3) {
455 _out << " 3.00 OBSERVATION DATA M (MIXED) RINEX VERSION / TYPE" << endl;
456 QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
457 _out << _pgmName.toAscii().data() << _userName.toAscii().data()
458 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
459 }
460 else {
461 _out << " 2.11 OBSERVATION DATA M (MIXED) RINEX VERSION / TYPE" << endl;
462 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
463 _out << _pgmName.toAscii().data() << _userName.toAscii().data()
464 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
465 }
466 _out.setf(ios::left);
467 _out << setw(60) << _statID.data() << "MARKER NAME" << endl;
468// Added header line for Rinex3 regarding mandatory MARKER TYPE field Perlt
469 if (_rinexVers == 3) {
470 _out << setw(60) << "unknown" << "MARKER TYPE " << endl;
471 }
472// End
473 _out << setw(60) << "unknown unknown" << "OBSERVER / AGENCY" << endl;
474 _out << setw(20) << "unknown"
475 << setw(20) << "unknown"
476 << setw(20) << "unknown" << "REC # / TYPE / VERS" << endl;
477 _out << setw(20) << "unknown"
478 << setw(20) << "unknown"
479 << setw(20) << " " << "ANT # / TYPE" << endl;
480 _out.unsetf(ios::left);
481 _out << setw(14) << setprecision(4) << _approxPos[0]
482 << setw(14) << setprecision(4) << _approxPos[1]
483 << setw(14) << setprecision(4) << _approxPos[2]
484 << " " << "APPROX POSITION XYZ" << endl;
485 _out << setw(14) << setprecision(4) << antennaNEU[0]
486 << setw(14) << setprecision(4) << antennaNEU[1]
487 << setw(14) << setprecision(4) << antennaNEU[2]
488 << " " << "ANTENNA: DELTA H/E/N" << endl;
489 if (_rinexVers == 3) {
490// Changed declaration of data types, consistent with Rinex3 Perlt
491 _out << "G 10 C1C C1P L1C S1C C2X C2P L2X S2X L2P S2P SYS / # / OBS TYPES" << endl;
492 _out << "R 10 C1C C1P L1C S1C C2C C2P L2C S2C L2P S2P SYS / # / OBS TYPES" << endl;
493 _out << "S 3 C1C L1C S1C SYS / # / OBS TYPES" << endl;
494
495 }
496 else {
497 _out << " 1 1 WAVELENGTH FACT L1/2" << endl;
498 _out << " 8 C1 C2 P1 P2 L1 L2 S1 S2 # / TYPES OF OBSERV" << endl;
499 }
500 _out << datTim.toString(" yyyy MM dd"
501 " hh mm ss.zzz0000").toAscii().data();
502 _out << " GPS TIME OF FIRST OBS" << endl;
503 QString hlp = (_format + QString(" %1").arg(_mountPoint.host() +
504 _mountPoint.path())).leftJustified(60, ' ', true);
505 _out << hlp.toAscii().data() << "COMMENT" << endl;
506
507 if (_nmea == "yes") {
508 hlp = ("NMEA LAT=" + _latitude + " " + "LONG=" + _longitude).leftJustified(60, ' ',true);
509 _out << hlp.toAscii().data() << "COMMENT" << endl; }
510
511 _out << " END OF HEADER" << endl;
512 }
513
514 _headerWritten = true;
515}
516
517// Stores Observation into Internal Array
518////////////////////////////////////////////////////////////////////////////
519void bncRinex::deepCopy(const p_obs obs) {
520 p_obs newObs = new t_obs();
521 memcpy(&newObs->_o, &obs->_o, sizeof(t_obsInternal));
522 _obs.push_back(newObs);
523}
524
525// Write One Epoch into the RINEX File
526////////////////////////////////////////////////////////////////////////////
527void bncRinex::dumpEpoch(long maxTime) {
528
529 // Select observations older than maxTime
530 // --------------------------------------
531 QList<p_obs> dumpList;
532 QMutableListIterator<p_obs> mIt(_obs);
533 while (mIt.hasNext()) {
534 p_obs obs = mIt.next();
535 if (obs->_o.GPSWeek * 7*24*3600 + obs->_o.GPSWeeks < maxTime - 0.05) {
536 dumpList.push_back(obs);
537 mIt.remove();
538 }
539 }
540
541 // Easy Return
542 // -----------
543 if (dumpList.isEmpty()) {
544 return;
545 }
546
547 // Time of Epoch
548 // -------------
549 p_obs fObs = *dumpList.begin();
550 QDateTime datTim = dateAndTimeFromGPSweek(fObs->_o.GPSWeek, fObs->_o.GPSWeeks);
551 QDateTime datTimNom = dateAndTimeFromGPSweek(fObs->_o.GPSWeek,
552 floor(fObs->_o.GPSWeeks+0.5));
553
554 // Close the file
555 // --------------
556 if (_nextCloseEpoch.isValid() && datTimNom >= _nextCloseEpoch) {
557 closeFile();
558 _headerWritten = false;
559 }
560
561 // Write RINEX Header
562 // ------------------
563 if (!_headerWritten) {
564 writeHeader(datTim, datTimNom);
565 }
566
567 double sec = double(datTim.time().second()) + fmod(fObs->_o.GPSWeeks,1.0);
568
569 // Epoch header line: RINEX Version 3
570 // ----------------------------------
571 if (_rinexVers == 3) {
572 _out << datTim.toString("> yyyy MM dd hh mm ").toAscii().data()
573 << setw(10) << setprecision(7) << sec
574 << " " << 0 << setw(3) << dumpList.size() << endl;
575 }
576 // Epoch header line: RINEX Version 2
577 // ----------------------------------
578 else {
579 _out << datTim.toString(" yy MM dd hh mm ").toAscii().data()
580 << setw(10) << setprecision(7) << sec
581 << " " << 0 << setw(3) << dumpList.size();
582
583 QListIterator<p_obs> it(dumpList); int iSat = 0;
584 while (it.hasNext()) {
585 iSat++;
586 p_obs obs = it.next();
587 _out << obs->_o.satSys << setw(2) << obs->_o.satNum;
588 if (iSat == 12 && it.hasNext()) {
589 _out << endl << " ";
590 iSat = 0;
591 }
592 }
593 _out << endl;
594 }
595
596 QListIterator<p_obs> it(dumpList);
597 while (it.hasNext()) {
598 p_obs obs = it.next();
599
600 // Cycle slips detection
601 // ---------------------
602 int prn = 0;
603 switch (obs->_o.satSys) {
604 case 'G': prn = obs->_o.satNum; break;
605 case 'R': prn = obs->_o.satNum + 200; break;
606 default: prn = obs->_o.satNum;
607 }
608
609 char lli1 = ' ';
610 char lli2 = ' ';
611 if ( obs->_o.slip_cnt_L1 >= 0 ) {
612 if ( _slip_cnt_L1.find(prn) != _slip_cnt_L1.end() &&
613 _slip_cnt_L1.find(prn).value() != obs->_o.slip_cnt_L1 ) {
614 lli1 = '1';
615 }
616 }
617 else if ( obs->_o.lock_timei_L1 >= 0 ) {
618 if ( _lock_timei_L1.find(prn) != _lock_timei_L1.end() &&
619 _lock_timei_L1.find(prn).value() != obs->_o.lock_timei_L1 ) {
620 lli1 = '1';
621 }
622 }
623
624 if ( obs->_o.slip_cnt_L2 >= 0 ) {
625 if ( _slip_cnt_L2.find(prn) != _slip_cnt_L2.end() &&
626 _slip_cnt_L2.find(prn).value() != obs->_o.slip_cnt_L2 ) {
627 lli2 = '1';
628 }
629 }
630 else if ( obs->_o.lock_timei_L2 >= 0 ) {
631 if ( _lock_timei_L2.find(prn) != _lock_timei_L2.end() &&
632 _lock_timei_L2.find(prn).value() != obs->_o.lock_timei_L2 ) {
633 lli2 = '1';
634 }
635 }
636
637 _slip_cnt_L1[prn] = obs->_o.slip_cnt_L1;
638 _slip_cnt_L2[prn] = obs->_o.slip_cnt_L2;
639
640 _lock_timei_L1[prn] = obs->_o.lock_timei_L1;
641 _lock_timei_L2[prn] = obs->_o.lock_timei_L2;
642
643 // RINEX Version 3
644 // ---------------
645 if (_rinexVers == 3) {
646 char sbasflag = 'S';
647 // Changed data output, C1P, C2C|X, L2C|X, S2C|X added. Changed Output for SBAS Perlt
648 if (sbasflag != obs->_o.satSys) {
649 _out << obs->_o.satSys
650 << setw(2) << setfill('0') << obs->_o.satNum << setfill(' ')
651 << setw(14) << setprecision(3) << obs->_o.C1 << " "
652 << setw(14) << setprecision(3) << obs->_o.P1 << " "
653 << setw(14) << setprecision(3) << obs->_o.L1 << lli1
654 << setw(1) << obs->_o.SNR1
655 << setw(14) << setprecision(3) << obs->_o.S1 << " "
656 << setw(14) << setprecision(3) << obs->_o.C2 << " "
657 << setw(14) << setprecision(3) << obs->_o.P2 << " " ;
658 if ((obs->_o.C2 != 0.0) && (obs->_o.P2 == 0.0)) {
659 _out << setw(14) << setprecision(3) << obs->_o.L2 << lli2
660 << setw(1) << obs->_o.SNR2
661 << setw(14) << setprecision(3) << obs->_o.S2 << " "
662 << " 0.000 0.000 ";
663 }
664 else {
665 _out << " 0.000 0.000 "
666 << setw(14) << setprecision(3) << obs->_o.L2 << " "
667 << setw(1) << obs->_o.SNR2
668 << setw(14) << setprecision(3) << obs->_o.S2;
669 }
670 _out << endl;
671 }
672 else {
673 _out << obs->_o.satSys
674 << setw(2) << setfill('0') << obs->_o.satNum << setfill(' ')
675 << setw(14) << setprecision(3) << obs->_o.C1 << " "
676 << setw(14) << setprecision(3) << obs->_o.P1 << " "
677 << setw(14) << setprecision(3) << obs->_o.L1 << lli1
678 << setw(1) << obs->_o.SNR1
679 << setw(14) << setprecision(3) << obs->_o.S1 << endl;
680 }
681 }
682
683 // RINEX Version 2
684 // ---------------
685 else {
686 char lli = ' ';
687 char snr = ' ';
688 _out << setw(14) << setprecision(3) << obs->_o.C1 << lli << snr;
689 _out << setw(14) << setprecision(3) << obs->_o.C2 << lli << snr;
690 _out << setw(14) << setprecision(3) << obs->_o.P1 << lli << snr;
691 _out << setw(14) << setprecision(3) << obs->_o.P2 << lli << snr;
692 _out << setw(14) << setprecision(3) << obs->_o.L1 << lli1
693 << setw(1) << obs->_o.SNR1 << endl;
694 _out << setw(14) << setprecision(3) << obs->_o.L2 << lli2
695 << setw(1) << obs->_o.SNR2;
696 _out << setw(14) << setprecision(3) << obs->_o.S1 ;
697 _out << setw(16) << setprecision(3) << obs->_o.S2 ;
698 _out << endl;
699 }
700
701 delete obs;
702 }
703
704 _out.flush();
705}
706
707// Close the Old RINEX File
708////////////////////////////////////////////////////////////////////////////
709void bncRinex::closeFile() {
710 if (_rinexVers == 3) {
711 _out << "> 4 1" << endl;
712 _out << "END OF FILE" << endl;
713 }
714 _out.close();
715 if (!_rnxScriptName.isEmpty()) {
716 qApp->thread()->wait(100);
717#ifdef WIN32
718 QProcess::startDetached(_rnxScriptName, QStringList() << _fName) ;
719#else
720 QProcess::startDetached("nohup", QStringList() << _rnxScriptName << _fName) ;
721#endif
722
723 }
724}
Note: See TracBrowser for help on using the repository browser.