[464] | 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.
|
---|
[379] | 24 |
|
---|
[464] | 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 |
|
---|
[379] | 41 | #include <iostream>
|
---|
| 42 | #include <iomanip>
|
---|
| 43 |
|
---|
| 44 | #include "RTCM/GPSDecoder.h"
|
---|
| 45 |
|
---|
[599] | 46 | #include <QFile>
|
---|
| 47 | #include <QTextStream>
|
---|
[379] | 48 | #include <QTcpSocket>
|
---|
| 49 |
|
---|
| 50 | using namespace std;
|
---|
| 51 |
|
---|
| 52 | const char begEpoch = 'A';
|
---|
| 53 | const char begObs = 'B';
|
---|
| 54 | const char endEpoch = 'C';
|
---|
| 55 |
|
---|
| 56 | int main(int /* argc */, char** /* argv */) {
|
---|
| 57 |
|
---|
[599] | 58 | QTcpSocket socketObs;
|
---|
| 59 |
|
---|
| 60 | QFile obsFile("obs.txt");
|
---|
[379] | 61 |
|
---|
[599] | 62 | socketObs.connectToHost("127.0.0.1", 1968);
|
---|
| 63 | if (!socketObs.waitForConnected(10000)) {
|
---|
| 64 | cout << "socketObs: not connected" << endl;
|
---|
[388] | 65 | exit(1);
|
---|
[379] | 66 | }
|
---|
| 67 |
|
---|
[599] | 68 | obsFile.open(QIODevice::WriteOnly | QIODevice::Unbuffered);
|
---|
| 69 |
|
---|
| 70 | QTextStream outObs(&obsFile);
|
---|
| 71 | outObs.setRealNumberNotation(QTextStream::FixedNotation);
|
---|
| 72 |
|
---|
[379] | 73 | // Receive Data
|
---|
| 74 | // ------------
|
---|
[627] | 75 | t_obsInternal obs;
|
---|
[379] | 76 | char flag = ' ';
|
---|
| 77 | cout.setf(ios::showpoint | ios::fixed);
|
---|
| 78 |
|
---|
| 79 | while (true) {
|
---|
[599] | 80 | if (socketObs.state() != QAbstractSocket::ConnectedState) {
|
---|
| 81 | cout << "socketObs: disconnected" << endl;
|
---|
| 82 | exit(0);
|
---|
| 83 | }
|
---|
| 84 |
|
---|
[734] | 85 | if ( socketObs.bytesAvailable() > sizeof(obs) ) {
|
---|
| 86 | socketObs.read(&flag, 1);
|
---|
[379] | 87 | if (flag == begObs) {
|
---|
[734] | 88 | socketObs.read((char*) &obs, sizeof(obs));
|
---|
| 89 | outObs << obs.StatID << " "
|
---|
| 90 | << obs.satSys << obs.satNum << " "
|
---|
| 91 | << obs.GPSWeek << " "
|
---|
| 92 | << qSetRealNumberPrecision(2) << obs.GPSWeeks << " "
|
---|
| 93 | << qSetRealNumberPrecision(4) << obs.C1 << " "
|
---|
| 94 | << qSetRealNumberPrecision(4) << obs.C2 << " "
|
---|
| 95 | << qSetRealNumberPrecision(4) << obs.P1 << " "
|
---|
| 96 | << qSetRealNumberPrecision(4) << obs.P2 << " "
|
---|
| 97 | << qSetRealNumberPrecision(4) << obs.L1 << " "
|
---|
| 98 | << qSetRealNumberPrecision(4) << obs.L2 << " "
|
---|
| 99 | << qSetRealNumberPrecision(4) << obs.S1 << " "
|
---|
| 100 | << qSetRealNumberPrecision(4) << obs.S2 << " "
|
---|
| 101 | << obs.SNR1 << " "
|
---|
| 102 | << obs.SNR2 << endl;
|
---|
[379] | 103 | }
|
---|
| 104 | }
|
---|
[601] | 105 | else {
|
---|
[633] | 106 | socketObs.waitForReadyRead(1);
|
---|
[601] | 107 | }
|
---|
[379] | 108 | }
|
---|
| 109 |
|
---|
| 110 | return 0;
|
---|
| 111 | }
|
---|