source: ntrip/trunk/BNC/corrfile.cpp@ 3691

Last change on this file since 3691 was 3691, checked in by mervart, 13 years ago
File size: 3.2 KB
RevLine 
[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"
44
45using namespace std;
46
47// Constructor
48////////////////////////////////////////////////////////////////////////////
49t_corrFile::t_corrFile(QString fileName) {
50 expandEnvVar(fileName);
51 _file = new QFile(fileName);
52 _file->open(QIODevice::ReadOnly | QIODevice::Text);
53 _stream = new QTextStream();
54 _stream->setDevice(_file);
55}
56
57// Destructor
58////////////////////////////////////////////////////////////////////////////
59t_corrFile::~t_corrFile() {
60 delete _stream;
61 delete _file;
62}
63
[3689]64// Read till a given time
65////////////////////////////////////////////////////////////////////////////
66void t_corrFile::syncRead(const bncTime& tt) {
67
[3691]68 cout << "tt = " << tt.gpssec() << endl;
69
70 if (stopRead(tt)) {
71 return;
72 }
73
[3690]74 QList<QString> corrs;
[3689]75
[3690]76 if (!_lastLine.isEmpty() && !stopRead(tt)) {
77 corrs << _lastLine;
[3691]78 cout << _lastLine.toAscii().data() << endl;
[3690]79 }
80
81 while (_stream->status() == QTextStream::Ok && !_stream->atEnd()) {
82 QString line = _stream->readLine();
83 if (line.isEmpty() || line[0] == '!') {
84 continue;
85 }
86 _lastLine = line;
87
88 if (stopRead(tt)) {
[3691]89 cout << "stop " << endl;
[3690]90 if (corrs.size()) {
91 emit newCorrections(corrs);
92 }
[3691]93 return;
[3690]94 }
95 else {
96 corrs << _lastLine;
[3691]97 cout << _lastLine.toAscii().data() << endl;
[3690]98 }
99 }
[3689]100}
[3690]101
102// Read till a given time
103////////////////////////////////////////////////////////////////////////////
104bool t_corrFile::stopRead(const bncTime& tt) {
105
106 if (_lastLine.isEmpty()) {
107 return false;
108 }
109
110 QTextStream in(_lastLine.toAscii(), QIODevice::ReadOnly);
111 int messageType, updateInterval, GPSweek;
112 double GPSweeks;
113 in >> messageType >> updateInterval >> GPSweek >> GPSweeks;
114
115 bncTime tNew(GPSweek, GPSweeks);
116
117 if (tNew >= tt) {
118 return true;
119 }
120 else {
121 return false;
122 }
123}
Note: See TracBrowser for help on using the repository browser.