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

Last change on this file since 1581 was 1535, checked in by mervart, 16 years ago

* empty log message *

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