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

Last change on this file since 1482 was 1387, checked in by mervart, 16 years ago

* empty log message *

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