[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 |
|
---|
[1223] | 41 | #include <stdlib.h>
|
---|
[379] | 42 | #include <iostream>
|
---|
| 43 | #include <iomanip>
|
---|
| 44 |
|
---|
| 45 | #include "RTCM/GPSDecoder.h"
|
---|
[2253] | 46 | #include "bnctime.h"
|
---|
| 47 | extern "C" {
|
---|
| 48 | #include "RTCM3/rtcm3torinex.h"
|
---|
| 49 | }
|
---|
[379] | 50 |
|
---|
| 51 | #include <QTcpSocket>
|
---|
| 52 |
|
---|
| 53 | using namespace std;
|
---|
| 54 |
|
---|
[2253] | 55 | void RTCM3Error(const char*, ...) {}
|
---|
[379] | 56 |
|
---|
[2253] | 57 | int main(int /* argc */, char** /* argv */) {
|
---|
[1223] | 58 |
|
---|
[2259] | 59 | int year = 2010;
|
---|
| 60 | int month = 1;
|
---|
| 61 | int day = 10;
|
---|
| 62 | int hour = 12;
|
---|
| 63 | int min = 30;
|
---|
| 64 | double sec = 0.0;
|
---|
| 65 |
|
---|
[2253] | 66 | bncTime tt;
|
---|
[2259] | 67 | tt.set(year, month, day, hour, min, sec);
|
---|
[2254] | 68 | cout << tt.timestr() << " Moscow time (UTC + 3h)" << endl;
|
---|
[2259] | 69 | cout << "GPS-UTC: " << gnumleap(year, month, day) << endl;
|
---|
[1223] | 70 |
|
---|
[2259] | 71 |
|
---|
[2254] | 72 | int week = tt.gpsw();
|
---|
| 73 | int tow = int(tt.gpssec());
|
---|
| 74 | updatetime(&week, &tow, tow*1000, 1);
|
---|
| 75 | bncTime t2(week, tow);
|
---|
| 76 | cout << t2.timestr() << " UTC " << endl;
|
---|
[599] | 77 |
|
---|
[2254] | 78 | week = tt.gpsw();
|
---|
| 79 | tow = int(tt.gpssec());
|
---|
| 80 | updatetime(&week, &tow, tow*1000, 0);
|
---|
| 81 | bncTime t3(week, tow);
|
---|
| 82 | cout << t3.timestr() << " GPS " << endl;
|
---|
| 83 |
|
---|
| 84 |
|
---|
[2253] | 85 | // if (argc != 2) {
|
---|
| 86 | // cerr << "Usage: test_bnc_qt port\n";
|
---|
| 87 | // exit(1);
|
---|
| 88 | // }
|
---|
| 89 | //
|
---|
| 90 | // int port = atoi(argv[1]);
|
---|
| 91 | //
|
---|
| 92 | // QTcpSocket socketObs;
|
---|
| 93 | //
|
---|
| 94 | // socketObs.connectToHost("127.0.0.1", port);
|
---|
| 95 | // if (!socketObs.waitForConnected(10000)) {
|
---|
| 96 | // cerr << "socketObs: not connected on port " << port << endl;
|
---|
| 97 | // exit(1);
|
---|
| 98 | // }
|
---|
| 99 | //
|
---|
| 100 | // cout.setf(ios::fixed);
|
---|
| 101 | //
|
---|
| 102 | // // Receive Data
|
---|
| 103 | // // ------------
|
---|
| 104 | // const char begObs[] = "BEGOBS";
|
---|
| 105 | // const char begEpoch[] = "BEGEPOCH";
|
---|
| 106 | // const char endEpoch[] = "ENDEPOCH";
|
---|
| 107 | // const unsigned begObsNBytes = sizeof(begObs) - 1;
|
---|
| 108 | // const unsigned begEpochNBytes = sizeof(begEpoch) - 1;
|
---|
| 109 | // const unsigned endEpochNBytes = sizeof(endEpoch) - 1;
|
---|
| 110 | //
|
---|
| 111 | // QByteArray buffer;
|
---|
| 112 | //
|
---|
| 113 | // while (true) {
|
---|
| 114 | // if (socketObs.state() != QAbstractSocket::ConnectedState) {
|
---|
| 115 | // cerr << "socketObs: disconnected" << endl;
|
---|
| 116 | // exit(1);
|
---|
| 117 | // }
|
---|
| 118 | //
|
---|
| 119 | // if ( socketObs.bytesAvailable() ) {
|
---|
| 120 | // buffer += socketObs.readAll();
|
---|
| 121 | //
|
---|
| 122 | // // Skip begEpoch and endEpoch Marks
|
---|
| 123 | // // --------------------------------
|
---|
| 124 | // for (;;) {
|
---|
| 125 | // int i1 = buffer.indexOf(begEpoch);
|
---|
| 126 | // if (i1 == -1) {
|
---|
| 127 | // break;
|
---|
| 128 | // }
|
---|
| 129 | // else {
|
---|
| 130 | // buffer.remove(i1, begEpochNBytes);
|
---|
| 131 | // cout << endl;
|
---|
| 132 | // }
|
---|
| 133 | // }
|
---|
| 134 | // for (;;) {
|
---|
| 135 | // int i2 = buffer.indexOf(endEpoch);
|
---|
| 136 | // if (i2 == -1) {
|
---|
| 137 | // break;
|
---|
| 138 | // }
|
---|
| 139 | // else {
|
---|
| 140 | // buffer.remove(i2, endEpochNBytes);
|
---|
| 141 | // }
|
---|
| 142 | // }
|
---|
| 143 | // for (;;) {
|
---|
| 144 | // int i3 = buffer.indexOf(begObs);
|
---|
| 145 | // if (i3 == -1) {
|
---|
| 146 | // break;
|
---|
| 147 | // }
|
---|
| 148 | // else {
|
---|
| 149 | // buffer.remove(i3, begObsNBytes);
|
---|
| 150 | // }
|
---|
| 151 | // }
|
---|
| 152 | //
|
---|
| 153 | // // Interpret a portion of buffer as observation
|
---|
| 154 | // // --------------------------------------------
|
---|
| 155 | // t_obsInternal* obs;
|
---|
| 156 | // const int obsSize = sizeof(t_obsInternal);
|
---|
| 157 | //
|
---|
| 158 | //
|
---|
| 159 | // while (buffer.size() >= obsSize) {
|
---|
| 160 | //
|
---|
| 161 | // obs = (t_obsInternal*) (buffer.left(obsSize).data());
|
---|
| 162 | //
|
---|
| 163 | // cout << obs->StatID << " "
|
---|
| 164 | // << obs->satSys << obs->satNum << " "
|
---|
| 165 | // << obs->GPSWeek << " "
|
---|
| 166 | // << setprecision(2) << obs->GPSWeeks << " "
|
---|
| 167 | // << setprecision(4) << obs->C1 << " "
|
---|
| 168 | // << setprecision(4) << obs->C2 << " "
|
---|
| 169 | // << setprecision(4) << obs->P1 << " "
|
---|
| 170 | // << setprecision(4) << obs->P2 << " "
|
---|
| 171 | // << setprecision(4) << obs->L1 << " "
|
---|
| 172 | // << setprecision(4) << obs->L2 << " "
|
---|
| 173 | // << obs->slip_cnt_L1 << " "
|
---|
| 174 | // << obs->slip_cnt_L2 << " "
|
---|
| 175 | // << setprecision(4) << obs->S1 << " "
|
---|
| 176 | // << setprecision(4) << obs->S2 << " "
|
---|
| 177 | // << obs->SNR1 << " "
|
---|
| 178 | // << obs->SNR2 << endl;
|
---|
| 179 | //
|
---|
| 180 | // buffer.remove(0,obsSize);
|
---|
| 181 | // }
|
---|
| 182 | // }
|
---|
| 183 | // else {
|
---|
| 184 | // socketObs.waitForReadyRead(1);
|
---|
| 185 | // }
|
---|
| 186 | // }
|
---|
[379] | 187 |
|
---|
| 188 | return 0;
|
---|
| 189 | }
|
---|