source: ntrip/trunk/GnssCenter/map_stations/thriftclient.cpp@ 5409

Last change on this file since 5409 was 5409, checked in by mervart, 9 years ago
File size: 3.0 KB
Line 
1
2#include <iomanip>
3#include <sstream>
4#include <vector>
5
6#include "thriftclient.h"
7
8using namespace apache::thrift;
9using namespace apache::thrift::protocol;
10using namespace apache::thrift::transport;
11
12using namespace com::gpssolutions::rtnet;
13using namespace std;
14using namespace boost;
15
16// Constructor
17//////////////////////////////////////////////////////////////////////////////
18t_thriftClient::t_thriftClient() {
19
20}
21
22// Destructor
23//////////////////////////////////////////////////////////////////////////////
24t_thriftClient::~t_thriftClient() {
25
26}
27
28// Run (virtual)
29//////////////////////////////////////////////////////////////////////////////
30void t_thriftClient::run() {
31
32 string host = "rtnet.rtcm-ntrip.org";
33 int port = 7777;
34
35 shared_ptr<TSocket> socket(new TSocket(host, port));
36 shared_ptr<TTransport> transport(new TBufferedTransport(socket));
37 shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
38 shared_ptr<RtnetDataIf> dataHandler(new t_thriftClient());
39 shared_ptr<TProcessor> processor(new RtnetDataProcessor(dataHandler));
40
41 try {
42 transport->open();
43 while (processor->process(protocol,protocol,0)) {}
44 transport->close();
45 }
46 catch (TException& e) {
47 cerr << "Caught an exception generated by Thrift: " << e.what() << endl;
48 }
49 catch (...) {
50 cerr << "Unknown exception" << endl;
51 }
52}
53
54// Handle Satellite Positions
55//////////////////////////////////////////////////////////////////////////////
56void t_thriftClient::
57handleSatelliteXYZ(const vector<SatelliteXYZ>& svXYZList) {
58 cout.setf(ios::fixed);
59 for (unsigned ii = 0; ii < svXYZList.size(); ii++) {
60// const SatelliteXYZ& sat = svXYZList[ii];
61// cout << unsigned(sat.ID) << ' '
62// << setprecision(3) << sat.xyz.x << ' '
63// << setprecision(3) << sat.xyz.y << ' '
64// << setprecision(3) << sat.xyz.z << endl;
65 }
66// cout << endl;
67}
68
69// Handle Station Info
70//////////////////////////////////////////////////////////////////////////////
71void t_thriftClient::
72handleStationInfo(const vector<StationInfo>& stationList) {
73 for (unsigned ii = 0; ii < stationList.size(); ii++) {
74 const StationInfo& staInfo = stationList[ii];
75 _stationCrd[staInfo.ID]._x = staInfo.xyz.x;
76 _stationCrd[staInfo.ID]._y = staInfo.xyz.y;
77 _stationCrd[staInfo.ID]._z = staInfo.xyz.z;
78 }
79}
80
81// Handle Eoch Results
82//////////////////////////////////////////////////////////////////////////////
83void t_thriftClient::
84handleEpochResults(const RtnetEpoch& epoch) {
85 for (unsigned ii = 0; ii < epoch.stationResultList.size(); ii++) {
86 const StationResults& staRes = epoch.stationResultList[ii];
87 cout << staRes.stationName << ' '
88 << (int) staRes.nsv_gps_used << ' ' << (int) staRes.nsv_glonass_used << ' ';
89 if (_stationCrd.find(staRes.stationName) != _stationCrd.end()) {
90 cout << _stationCrd[staRes.stationName]._x << ' '
91 << _stationCrd[staRes.stationName]._y << ' '
92 << _stationCrd[staRes.stationName]._z;
93 }
94 cout << endl;
95 }
96}
Note: See TracBrowser for help on using the repository browser.