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

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