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

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

* empty log message *

File size: 23.4 KB
RevLine 
[280]1// Part of BNC, a utility for retrieving decoding and
[464]2// converting GNSS data streams from NTRIP broadcasters.
[280]3//
[464]4// Copyright (C) 2007
[280]5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
[464]7// Czech Technical University Prague, Department of Geodesy
[280]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.
[73]24
25/* -------------------------------------------------------------------------
[93]26 * BKG NTRIP Client
[73]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
[292]41#include <stdlib.h>
[300]42#include <iostream>
[75]43#include <iomanip>
[221]44#include <math.h>
[75]45
[300]46#include <QtCore>
47#include <QUrl>
48#include <QString>
49
[73]50#include "bncrinex.h"
[157]51#include "bncapp.h"
[82]52#include "bncutils.h"
[126]53#include "bncconst.h"
[298]54#include "bnctabledlg.h"
[301]55#include "bncgetthread.h"
[1858]56#include "bncnetqueryv2.h"
[1535]57#include "bncsettings.h"
[2012]58#include "bncversion.h"
[223]59#include "RTCM3/rtcm3torinex.h"
[75]60
61using namespace std;
62
[73]63// Constructor
64////////////////////////////////////////////////////////////////////////////
[408]65bncRinex::bncRinex(const QByteArray& statID, const QUrl& mountPoint,
[366]66 const QByteArray& format, const QByteArray& latitude,
[1639]67 const QByteArray& longitude, const QByteArray& nmea,
68 const QByteArray& ntripVersion) {
[1387]69
[408]70 _statID = statID;
[336]71 _mountPoint = mountPoint;
[337]72 _format = format.left(6);
[366]73 _latitude = latitude;
74 _longitude = longitude;
75 _nmea = nmea;
[1639]76 _ntripVersion = ntripVersion;
[77]77 _headerWritten = false;
[369]78 _reconnectFlag = false;
[656]79 _reloadTable = false;
80 _reloadDone = false;
[132]81
[1535]82 bncSettings settings;
[132]83 _rnxScriptName = settings.value("rnxScript").toString();
84 expandEnvVar(_rnxScriptName);
[153]85
[2012]86 _pgmName = QString(BNCPGMNAME).leftJustified(20, ' ', true);
[319]87#ifdef WIN32
88 _userName = QString("${USERNAME}");
89#else
[158]90 _userName = QString("${USER}");
[319]91#endif
[157]92 expandEnvVar(_userName);
[158]93 _userName = _userName.leftJustified(20, ' ', true);
[539]94
95 if ( Qt::CheckState(settings.value("rnxV3").toInt()) == Qt::Checked) {
96 _rinexVers = 3;
97 }
98 else {
99 _rinexVers = 2;
100 }
[1044]101
102 _approxPos[0] = _approxPos[1] = _approxPos[2] = 0.0;
[73]103}
104
105// Destructor
106////////////////////////////////////////////////////////////////////////////
107bncRinex::~bncRinex() {
[622]108 QListIterator<p_obs> it(_obs);
[607]109 while (it.hasNext()) {
110 delete it.next();
111 }
[1535]112 bncSettings settings;
[698]113 if ((_rinexVers == 3) && ( Qt::CheckState(settings.value("rnxAppend").toInt()) != Qt::Checked) ) {
[843]114 _out << "> 4 1" << endl;
[698]115 _out << "END OF FILE" << endl;
116 }
[77]117 _out.close();
[73]118}
119
[420]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(),
[1376]128 table, _reloadTable);
[420]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(";");
[1495]135 if (tags.size() > 7) {
136 if (tags.at(1) == _mountPoint.path().mid(1).toAscii()) {
137 net = tags.at(7);
138 break;
139 }
[420]140 }
141 }
142 }
143 QString sklDir;
[1495]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 }
[420]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
[1858]165 bncNetQueryV2 query;
[1386]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() ) {
[1348]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");
[556]182 }
[1348]183 else {
184 _headerLines.append(" 2.11 OBSERVATION DATA"
185 " M (MIXED)"
186 " RINEX VERSION / TYPE");
[421]187 }
[1348]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");
[421]198 }
[1348]199 _headerLines.append("TIME OF FIRST OBS");
200 _headerLines.append( line );
201 break;
[421]202 }
[420]203 else {
[1348]204 _headerLines.append( line );
[420]205 }
206 }
[1386]207 line = in.readLine();
[420]208 }
[1386]209 }
210 else {
211 return failure;
[420]212 }
[1386]213
[420]214 }
215 return irc;
216}
217
[82]218// Read Skeleton Header File
219////////////////////////////////////////////////////////////////////////////
220void bncRinex::readSkeleton() {
221
[420]222 // Read the local file
223 // -------------------
[276]224 QFile skl(_sklName);
[82]225 if ( skl.exists() && skl.open(QIODevice::ReadOnly) ) {
[422]226 _headerLines.clear();
[82]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 }
[298]235
[420]236 // Read downloaded file
237 // --------------------
[1778]238 else if ( _ntripVersion != "N" && _ntripVersion != "UN" ) {
[1154]239 QDate currDate = currentDateAndTimeGPS().date();
[420]240 if ( !_skeletonDate.isValid() || _skeletonDate != currDate ) {
241 if ( downloadSkeleton() == success) {
242 _skeletonDate = currDate;
[656]243 _reloadDone = false;
[298]244 }
[656]245 else {
246 if(!_reloadDone) {
247 _reloadTable = true;
248 if ( downloadSkeleton() == success) {
249 _skeletonDate = currDate;
250 }
251 _reloadTable = false;
252 _reloadDone = true;
253 }
254 }
[298]255 }
256 }
[82]257}
258
[647]259// Next File Epoch (static)
[82]260////////////////////////////////////////////////////////////////////////////
[647]261QString bncRinex::nextEpochStr(const QDateTime& datTim,
262 const QString& intStr, QDateTime* nextEpoch) {
[82]263
[647]264 QString epoStr;
[82]265
[129]266 QTime nextTime;
267 QDate nextDate;
268
[204]269 int indHlp = intStr.indexOf("min");
270
271 if ( indHlp != -1) {
272 int step = intStr.left(indHlp-1).toInt();
[127]273 char ch = 'A' + datTim.time().hour();
[647]274 epoStr = ch;
[204]275 if (datTim.time().minute() >= 60-step) {
[647]276 epoStr += QString("%1").arg(60-step, 2, 10, QChar('0'));
[199]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 {
[204]287 for (int limit = step; limit <= 60-step; limit += step) {
288 if (datTim.time().minute() < limit) {
[647]289 epoStr += QString("%1").arg(limit-step, 2, 10, QChar('0'));
[204]290 nextTime.setHMS(datTim.time().hour(), limit, 0);
291 nextDate = datTim.date();
292 break;
293 }
[199]294 }
295 }
296 }
[127]297 else if (intStr == "1 hour") {
298 char ch = 'A' + datTim.time().hour();
[647]299 epoStr = ch;
[129]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 }
[127]308 }
309 else {
[647]310 epoStr = "0";
[129]311 nextTime.setHMS(0, 0, 0);
312 nextDate = datTim.date().addDays(1);
[127]313 }
[82]314
[647]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
[1535]326 bncSettings settings;
[647]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
[183]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
[276]354 QString sklExt = settings.value("rnxSkel").toString();
355 if (!sklExt.isEmpty()) {
356 _sklName = path + ID4 + distStr + "." + sklExt;
357 }
358
[183]359 path += ID4 +
[127]360 QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +
[276]361 hlpStr + distStr + datTim.toString(".yyO");
[82]362
363 _fName = path.toAscii();
364}
365
[77]366// Write RINEX Header
367////////////////////////////////////////////////////////////////////////////
[267]368void bncRinex::writeHeader(const QDateTime& datTim,
369 const QDateTime& datTimNom) {
[77]370
[1535]371 bncSettings settings;
[356]372
[77]373 // Open the Output File
374 // --------------------
[267]375 resolveFileName(datTimNom);
[260]376
377 // Append to existing file and return
378 // ----------------------------------
379 if ( QFile::exists(_fName) ) {
[369]380 if (_reconnectFlag ||
381 Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
[260]382 _out.open(_fName.data(), ios::app);
383 _out.setf(ios::showpoint | ios::fixed);
384 _headerWritten = true;
[369]385 _reconnectFlag = false;
[260]386 return;
387 }
388 }
389
[82]390 _out.open(_fName.data());
[85]391 _out.setf(ios::showpoint | ios::fixed);
[77]392
[82]393 // Copy Skeleton Header
394 // --------------------
[276]395 readSkeleton();
[82]396 if (_headerLines.size() > 0) {
397 QStringListIterator it(_headerLines);
398 while (it.hasNext()) {
399 QString line = it.next();
[157]400 if (line.indexOf("PGM / RUN BY / DATE") != -1) {
[552]401 if (_rinexVers == 3) {
[1154]402 QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
[552]403 _out << _pgmName.toAscii().data() << _userName.toAscii().data()
404 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
405 }
406 else {
[1154]407 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
[552]408 _out << _pgmName.toAscii().data() << _userName.toAscii().data()
409 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
410 }
[157]411 }
412 else if (line.indexOf("# / TYPES OF OBSERV") != -1) {
[545]413 if (_rinexVers == 3) {
[689]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;
[545]418 }
419 else {
420 _out << " 8 C1 C2 P1 P2 L1 L2 S1 S2"
421 " # / TYPES OF OBSERV" << endl;
422 }
[82]423 }
424 else if (line.indexOf("TIME OF FIRST OBS") != -1) {
[125]425 _out << datTim.toString(" yyyy MM dd"
426 " hh mm ss.zzz0000").toAscii().data();
[553]427 _out << " GPS TIME OF FIRST OBS" << endl;
[337]428 QString hlp = (_format + QString(" %1").arg(_mountPoint.host() +
429 _mountPoint.path())).leftJustified(60, ' ', true);
[156]430 _out << hlp.toAscii().data() << "COMMENT" << endl;
[82]431 }
[689]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 }
[82]443 else {
444 _out << line.toAscii().data() << endl;
445 }
446 }
447 }
[78]448
[82]449 // Write Dummy Header
450 // ------------------
451 else {
452 double antennaNEU[3]; antennaNEU[0] = antennaNEU[1] = antennaNEU[2] = 0.0;
453
[545]454 if (_rinexVers == 3) {
455 _out << " 3.00 OBSERVATION DATA M (MIXED) RINEX VERSION / TYPE" << endl;
[1154]456 QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
[552]457 _out << _pgmName.toAscii().data() << _userName.toAscii().data()
458 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
[545]459 }
460 else {
461 _out << " 2.11 OBSERVATION DATA M (MIXED) RINEX VERSION / TYPE" << endl;
[1154]462 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
[552]463 _out << _pgmName.toAscii().data() << _userName.toAscii().data()
464 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
[545]465 }
[86]466 _out.setf(ios::left);
[82]467 _out << setw(60) << _statID.data() << "MARKER NAME" << endl;
[689]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
[354]473 _out << setw(60) << "unknown unknown" << "OBSERVER / AGENCY" << endl;
[82]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;
[86]480 _out.unsetf(ios::left);
[1044]481 _out << setw(14) << setprecision(4) << _approxPos[0]
482 << setw(14) << setprecision(4) << _approxPos[1]
483 << setw(14) << setprecision(4) << _approxPos[2]
[82]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;
[544]489 if (_rinexVers == 3) {
[689]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;
[544]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"
[125]501 " hh mm ss.zzz0000").toAscii().data();
[553]502 _out << " GPS TIME OF FIRST OBS" << endl;
[552]503 QString hlp = (_format + QString(" %1").arg(_mountPoint.host() +
[337]504 _mountPoint.path())).leftJustified(60, ' ', true);
[156]505 _out << hlp.toAscii().data() << "COMMENT" << endl;
[366]506
[410]507 if (_nmea == "yes") {
508 hlp = ("NMEA LAT=" + _latitude + " " + "LONG=" + _longitude).leftJustified(60, ' ',true);
[366]509 _out << hlp.toAscii().data() << "COMMENT" << endl; }
510
[82]511 _out << " END OF HEADER" << endl;
512 }
[78]513
[77]514 _headerWritten = true;
515}
516
[73]517// Stores Observation into Internal Array
518////////////////////////////////////////////////////////////////////////////
[622]519void bncRinex::deepCopy(const p_obs obs) {
520 p_obs newObs = new t_obs();
[626]521 memcpy(&newObs->_o, &obs->_o, sizeof(t_obsInternal));
[74]522 _obs.push_back(newObs);
[73]523}
524
525// Write One Epoch into the RINEX File
526////////////////////////////////////////////////////////////////////////////
[160]527void bncRinex::dumpEpoch(long maxTime) {
[73]528
[160]529 // Select observations older than maxTime
530 // --------------------------------------
[622]531 QList<p_obs> dumpList;
532 QMutableListIterator<p_obs> mIt(_obs);
[160]533 while (mIt.hasNext()) {
[622]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);
[160]537 mIt.remove();
538 }
539 }
540
[75]541 // Easy Return
542 // -----------
[160]543 if (dumpList.isEmpty()) {
[75]544 return;
545 }
546
547 // Time of Epoch
548 // -------------
[622]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));
[75]553
[130]554 // Close the file
555 // --------------
[267]556 if (_nextCloseEpoch.isValid() && datTimNom >= _nextCloseEpoch) {
[130]557 closeFile();
558 _headerWritten = false;
559 }
560
[78]561 // Write RINEX Header
562 // ------------------
563 if (!_headerWritten) {
[267]564 writeHeader(datTim, datTimNom);
[78]565 }
566
[622]567 double sec = double(datTim.time().second()) + fmod(fObs->_o.GPSWeeks,1.0);
[75]568
[1044]569 // Epoch header line: RINEX Version 3
570 // ----------------------------------
[540]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;
[74]575 }
[1044]576 // Epoch header line: RINEX Version 2
577 // ----------------------------------
[540]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();
[1044]582
[622]583 QListIterator<p_obs> it(dumpList); int iSat = 0;
[540]584 while (it.hasNext()) {
585 iSat++;
[622]586 p_obs obs = it.next();
587 _out << obs->_o.satSys << setw(2) << obs->_o.satNum;
[540]588 if (iSat == 12 && it.hasNext()) {
589 _out << endl << " ";
590 iSat = 0;
591 }
592 }
[77]593 _out << endl;
[1044]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 {
[540]686 char lli = ' ';
687 char snr = ' ';
[622]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;
[1044]692 _out << setw(14) << setprecision(3) << obs->_o.L1 << lli1
[622]693 << setw(1) << obs->_o.SNR1 << endl;
[1044]694 _out << setw(14) << setprecision(3) << obs->_o.L2 << lli2
[622]695 << setw(1) << obs->_o.SNR2;
696 _out << setw(14) << setprecision(3) << obs->_o.S1 ;
697 _out << setw(16) << setprecision(3) << obs->_o.S2 ;
[540]698 _out << endl;
699 }
[1044]700
701 delete obs;
[75]702 }
703
[77]704 _out.flush();
[73]705}
706
[130]707// Close the Old RINEX File
708////////////////////////////////////////////////////////////////////////////
709void bncRinex::closeFile() {
[698]710 if (_rinexVers == 3) {
[843]711 _out << "> 4 1" << endl;
[698]712 _out << "END OF FILE" << endl;
713 }
[130]714 _out.close();
[132]715 if (!_rnxScriptName.isEmpty()) {
[1523]716 qApp->thread()->wait(100);
[435]717#ifdef WIN32
718 QProcess::startDetached(_rnxScriptName, QStringList() << _fName) ;
719#else
[475]720 QProcess::startDetached("nohup", QStringList() << _rnxScriptName << _fName) ;
[435]721#endif
[436]722
[132]723 }
[130]724}
Note: See TracBrowser for help on using the repository browser.