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

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