source: ntrip/trunk/BNC/src/rinex/corrfile.cpp@ 6156

Last change on this file since 6156 was 6146, checked in by mervart, 10 years ago
File size: 3.6 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: 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"
44#include "bncephuser.h"
45
46using namespace std;
47
48// Constructor
49////////////////////////////////////////////////////////////////////////////
50t_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////////////////////////////////////////////////////////////////////////////
60t_corrFile::~t_corrFile() {
61 delete _stream;
62 delete _file;
63}
64
65// Read till a given time
66////////////////////////////////////////////////////////////////////////////
67void t_corrFile::syncRead(const bncTime& tt) {
68
69 if (stopRead(tt)) {
70 return;
71 }
72
73 QStringList lines;
74
75 if (!_lastLine.isEmpty()) {
76 lines << _lastLine;
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)) {
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;
95 _corrIODs[QString(corr._prn.toString().c_str())] = corr.IOD();
96 clkCorr.push_back(corr);
97 }
98 else if (str[0] == 'O') {
99 t_orbCorr corr(str.toAscii().data());
100 _lastTime = corr._time;
101 _corrIODs[QString(corr._prn.toString().c_str())] = corr.IOD();
102 orbCorr.push_back(corr);
103 }
104 }
105 if (orbCorr.size() > 0) {
106 emit newOrbCorrections(orbCorr);
107 }
108 if (clkCorr.size() > 0) {
109 emit newClkCorrections(clkCorr);
110 }
111 return;
112 }
113 else {
114 lines << _lastLine;
115 }
116 }
117}
118
119// Read till a given time
120////////////////////////////////////////////////////////////////////////////
121bool t_corrFile::stopRead(const bncTime& tt) {
122
123 if (_lastTime.undef()) {
124 return false;
125 }
126
127 if (_lastTime > tt) {
128 return true;
129 }
130 else {
131 return false;
132 }
133}
Note: See TracBrowser for help on using the repository browser.