source: ntrip/trunk/BNC/test_bnc_qt.cpp@ 733

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

* empty log message *

File size: 4.4 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: test_bnc_qt
30 *
31 * Purpose: Example program to read BNC output from IP port.
32 *
33 * Author: L. Mervart
34 *
35 * Created: 24-Jan-2007
36 *
37 * Changes:
38 *
39 * -----------------------------------------------------------------------*/
40
41#include <iostream>
42#include <iomanip>
43
44#include "RTCM/GPSDecoder.h"
45
46#include <QFile>
47#include <QTextStream>
48#include <QTcpSocket>
49
50using namespace std;
51
52const char begEpoch = 'A';
53const char begObs = 'B';
54const char endEpoch = 'C';
55
56int main(int /* argc */, char** /* argv */) {
57
58 QTcpSocket socketObs;
59 //// QTcpSocket socketEph;
60
61 QFile obsFile("obs.txt");
62 //// QFile ephFile("eph.txt");
63
64 socketObs.connectToHost("127.0.0.1", 1968);
65 if (!socketObs.waitForConnected(10000)) {
66 cout << "socketObs: not connected" << endl;
67 exit(1);
68 }
69
70 //// socketEph.connectToHost("127.0.0.1", 1969);
71 //// if (!socketEph.waitForConnected(10000)) {
72 //// cout << "socketEph: not connected" << endl;
73 //// exit(1);
74 //// }
75
76 obsFile.open(QIODevice::WriteOnly | QIODevice::Unbuffered);
77 //// ephFile.open(QIODevice::WriteOnly | QIODevice::Unbuffered);
78
79 QTextStream outObs(&obsFile);
80 outObs.setRealNumberNotation(QTextStream::FixedNotation);
81
82 //// QTextStream outEph(&ephFile);
83 //// outEph.setRealNumberNotation(QTextStream::FixedNotation);
84
85 // Receive Data
86 // ------------
87 t_obsInternal obs;
88 char flag = ' ';
89 cout.setf(ios::showpoint | ios::fixed);
90
91 while (true) {
92 if (socketObs.state() != QAbstractSocket::ConnectedState) {
93 cout << "socketObs: disconnected" << endl;
94 exit(0);
95 }
96 //// if (socketEph.state() != QAbstractSocket::ConnectedState) {
97 //// cout << "socketEph: disconnected" << endl;
98 //// exit(0);
99 //// }
100
101 if ( socketObs.bytesAvailable() ) {
102 int bytesRecv = socketObs.read(&flag, 1);
103 if (flag == begObs) {
104 if ( socketObs.bytesAvailable() >= sizeof(obs) ) {
105 bytesRecv = socketObs.read((char*) &obs, sizeof(obs));
106 outObs << obs.StatID << " "
107 << obs.satSys << obs.satNum << " "
108 << obs.GPSWeek << " "
109 << qSetRealNumberPrecision(2) << obs.GPSWeeks << " "
110 << qSetRealNumberPrecision(4) << obs.C1 << " "
111 << qSetRealNumberPrecision(4) << obs.C2 << " "
112 << qSetRealNumberPrecision(4) << obs.P1 << " "
113 << qSetRealNumberPrecision(4) << obs.P2 << " "
114 << qSetRealNumberPrecision(4) << obs.L1 << " "
115 << qSetRealNumberPrecision(4) << obs.L2 << " "
116 << qSetRealNumberPrecision(4) << obs.S1 << " "
117 << qSetRealNumberPrecision(4) << obs.S2 << " "
118 << obs.SNR1 << " "
119 << obs.SNR2 << endl;
120 }
121 }
122 }
123 else {
124 socketObs.waitForReadyRead(1);
125 }
126
127 //// if ( socketEph.bytesAvailable() ) {
128 //// QByteArray eph = socketEph.readAll();
129 //// outEph << eph.data() << endl;
130 //// }
131 //// else {
132 //// socketEph.waitForReadyRead(1);
133 //// }
134 }
135
136 return 0;
137}
Note: See TracBrowser for help on using the repository browser.