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

Last change on this file since 2254 was 2254, checked in by mervart, 14 years ago

* empty log message *

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