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

Last change on this file since 1637 was 1535, checked in by mervart, 16 years ago

* empty log message *

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