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

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