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

Last change on this file since 1377 was 1376, checked in by mervart, 16 years ago

* empty log message *

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