[3687] | 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: t_corrFile
|
---|
| 30 | *
|
---|
| 31 | * Purpose: Reads DGPS Correction File
|
---|
| 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 12-Feb-2012
|
---|
| 36 | *
|
---|
| 37 | * Changes:
|
---|
| 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
| 41 | #include <iostream>
|
---|
| 42 | #include "corrfile.h"
|
---|
| 43 | #include "bncutils.h"
|
---|
[3756] | 44 | #include "bncephuser.h"
|
---|
[3687] | 45 |
|
---|
| 46 | using namespace std;
|
---|
| 47 |
|
---|
| 48 | // Constructor
|
---|
| 49 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 50 | t_corrFile::t_corrFile(QString fileName) {
|
---|
| 51 | expandEnvVar(fileName);
|
---|
| 52 | _file = new QFile(fileName);
|
---|
| 53 | _file->open(QIODevice::ReadOnly | QIODevice::Text);
|
---|
| 54 | _stream = new QTextStream();
|
---|
| 55 | _stream->setDevice(_file);
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | // Destructor
|
---|
| 59 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 60 | t_corrFile::~t_corrFile() {
|
---|
| 61 | delete _stream;
|
---|
| 62 | delete _file;
|
---|
| 63 | }
|
---|
| 64 |
|
---|
[3689] | 65 | // Read till a given time
|
---|
| 66 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 67 | void t_corrFile::syncRead(const bncTime& tt) {
|
---|
| 68 |
|
---|
[3691] | 69 | if (stopRead(tt)) {
|
---|
| 70 | return;
|
---|
| 71 | }
|
---|
| 72 |
|
---|
[6141] | 73 | QStringList lines;
|
---|
[3689] | 74 |
|
---|
[3692] | 75 | if (!_lastLine.isEmpty()) {
|
---|
[6141] | 76 | lines << _lastLine;
|
---|
[3690] | 77 | }
|
---|
| 78 |
|
---|
| 79 | while (_stream->status() == QTextStream::Ok && !_stream->atEnd()) {
|
---|
| 80 | QString line = _stream->readLine();
|
---|
| 81 | if (line.isEmpty() || line[0] == '!') {
|
---|
| 82 | continue;
|
---|
| 83 | }
|
---|
| 84 | _lastLine = line;
|
---|
| 85 |
|
---|
| 86 | if (stopRead(tt)) {
|
---|
[6141] | 87 | QList<t_orbCorr> orbCorr;
|
---|
| 88 | QList<t_clkCorr> clkCorr;
|
---|
| 89 | QListIterator<QString> it(lines);
|
---|
| 90 | while (it.hasNext()) {
|
---|
| 91 | const QString& str = it.next();
|
---|
| 92 | if (str[0] == 'C') {
|
---|
| 93 | t_clkCorr corr(str.toAscii().data());
|
---|
| 94 | _lastTime = corr._time;
|
---|
[6146] | 95 | _corrIODs[QString(corr._prn.toString().c_str())] = corr.IOD();
|
---|
[6141] | 96 | clkCorr.push_back(corr);
|
---|
[3756] | 97 | }
|
---|
[6141] | 98 | else if (str[0] == 'O') {
|
---|
| 99 | t_orbCorr corr(str.toAscii().data());
|
---|
| 100 | _lastTime = corr._time;
|
---|
[6146] | 101 | _corrIODs[QString(corr._prn.toString().c_str())] = corr.IOD();
|
---|
[6141] | 102 | orbCorr.push_back(corr);
|
---|
| 103 | }
|
---|
| 104 | }
|
---|
| 105 | if (orbCorr.size() > 0) {
|
---|
| 106 | emit newOrbCorrections(orbCorr);
|
---|
[3690] | 107 | }
|
---|
[6141] | 108 | if (clkCorr.size() > 0) {
|
---|
| 109 | emit newClkCorrections(clkCorr);
|
---|
| 110 | }
|
---|
[3691] | 111 | return;
|
---|
[3690] | 112 | }
|
---|
| 113 | else {
|
---|
[6141] | 114 | lines << _lastLine;
|
---|
[3690] | 115 | }
|
---|
| 116 | }
|
---|
[3689] | 117 | }
|
---|
[3690] | 118 |
|
---|
| 119 | // Read till a given time
|
---|
| 120 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 121 | bool t_corrFile::stopRead(const bncTime& tt) {
|
---|
| 122 |
|
---|
[6141] | 123 | if (_lastTime.undef()) {
|
---|
[3690] | 124 | return false;
|
---|
| 125 | }
|
---|
| 126 |
|
---|
[6141] | 127 | if (_lastTime > tt) {
|
---|
[3690] | 128 | return true;
|
---|
| 129 | }
|
---|
| 130 | else {
|
---|
| 131 | return false;
|
---|
| 132 | }
|
---|
| 133 | }
|
---|