source: ntrip/trunk/GnssCenter/thrift/test_rtnet/rtnetThriftClient.cpp@ 5392

Last change on this file since 5392 was 5392, checked in by mervart, 11 years ago
File size: 2.5 KB
Line 
1
2#include <iomanip>
3#include <vector>
4#include <string>
5
6#include <transport/TSocket.h>
7#include <transport/TBufferTransports.h>
8#include <protocol/TBinaryProtocol.h>
9
10#include "gen-cpp/RtnetData.h"
11
12using namespace apache::thrift;
13using namespace apache::thrift::protocol;
14using namespace apache::thrift::transport;
15
16using namespace com::gpssolutions::rtnet;
17using namespace std;
18using namespace boost;
19
20// Handler Class Definition
21//////////////////////////////////////////////////////////////////////////////
22class RtnetClientHandler : public RtnetDataIf {
23 public:
24 RtnetClientHandler() {}
25 ~RtnetClientHandler() {}
26
27 void startDataStream() {}
28 void registerRtnet(const RtnetInformation& info) {}
29 void handleZDAmb(const vector<ZDAmb>& ambList) {}
30 void handleDDAmbresBaselines(const vector<DDAmbresBaseline>& ambList) {}
31 void handleSatelliteXYZ(const vector< SatelliteXYZ>& svXYZList);
32 void handleStationInfo(const vector<StationInfo>& stationList) {}
33 void handleStationAuxInfo(const vector<StationAuxInfo>& stationAuxList) {}
34 void handleDGPSCorr(const vector<DGPSCorr>& dgpsList) {}
35 void handleSatelliteClock(const vector<SatelliteClock>& svList) {}
36 void handleEpochResults(const RtnetEpoch& epoch) {}
37};
38
39// Program
40//////////////////////////////////////////////////////////////////////////////
41int main(int argc, char **argv) {
42
43 shared_ptr<TSocket> socket(new TSocket("localhost", 6666));
44 shared_ptr<TTransport> transport(new TBufferedTransport(socket));
45 shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
46 shared_ptr<RtnetDataIf> dataHandler(new RtnetClientHandler());
47 shared_ptr<TProcessor> processor(new RtnetDataProcessor(dataHandler));
48
49 try {
50 transport->open();
51
52 while (processor->process(protocol,protocol,0)) {}
53
54 transport->close();
55 }
56 catch (TException& e) {
57 cerr << "Caught an exception generated by Thrift: " << e.what() << endl;
58 return 1;
59 }
60 catch (...) {
61 cerr << "Unknown exception" << endl;
62 return 1;
63 }
64
65 return 0;
66}
67
68// Handle Satellite Positions
69//////////////////////////////////////////////////////////////////////////////
70void RtnetClientHandler::
71handleSatelliteXYZ(const vector<SatelliteXYZ>& svXYZList) {
72 cout.setf(ios::fixed);
73 for (unsigned ii = 0; ii < svXYZList.size(); ii++) {
74 const SatelliteXYZ& sat = svXYZList[ii];
75 cout << unsigned(sat.ID) << ' '
76 << setprecision(3) << sat.xyz.x << ' '
77 << setprecision(3) << sat.xyz.y << ' '
78 << setprecision(3) << sat.xyz.z << endl;
79 }
80 cout << endl;
81}
82
Note: See TracBrowser for help on using the repository browser.