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

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