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

Last change on this file since 4720 was 3756, checked in by mervart, 13 years ago
File size: 3.3 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 QList<QString> corrs;
74
75 if (!_lastLine.isEmpty()) {
76 corrs << _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 if (corrs.size()) {
88
89 QListIterator<QString> it(corrs);
90 while (it.hasNext()) {
91 const QString& cLine = it.next();
92 t_corr* corr = new t_corr();
93 corr->readLine(cLine);
94 if (corr->tRao.valid()) {
95 _corrIODs[corr->prn] = corr->iod;
96 }
97 }
98
99 emit newCorrections(corrs);
100 }
101 return;
102 }
103 else {
104 corrs << _lastLine;
105 }
106 }
107}
108
109// Read till a given time
110////////////////////////////////////////////////////////////////////////////
111bool t_corrFile::stopRead(const bncTime& tt) {
112
113 if (_lastLine.isEmpty()) {
114 return false;
115 }
116
117 QTextStream in(_lastLine.toAscii(), QIODevice::ReadOnly);
118 int messageType, updateInterval, GPSweek;
119 double GPSweeks;
120 in >> messageType >> updateInterval >> GPSweek >> GPSweeks;
121
122 bncTime tNew(GPSweek, GPSweeks);
123
124 if (tNew > tt) {
125 return true;
126 }
127 else {
128 return false;
129 }
130}
Note: See TracBrowser for help on using the repository browser.