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
RevLine 
[4925]1
[4927]2#include <iomanip>
[4925]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;
[4935]18using namespace boost;
[4925]19
[5392]20// Handler Class Definition
21//////////////////////////////////////////////////////////////////////////////
[4935]22class RtnetClientHandler : public RtnetDataIf {
[4927]23 public:
24 RtnetClientHandler() {}
25 ~RtnetClientHandler() {}
[5392]26
[4927]27 void startDataStream() {}
28 void registerRtnet(const RtnetInformation& info) {}
29 void handleZDAmb(const vector<ZDAmb>& ambList) {}
30 void handleDDAmbresBaselines(const vector<DDAmbresBaseline>& ambList) {}
[5392]31 void handleSatelliteXYZ(const vector< SatelliteXYZ>& svXYZList);
[4927]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) {}
[4925]37};
38
[5392]39// Program
40//////////////////////////////////////////////////////////////////////////////
[4925]41int main(int argc, char **argv) {
42
[4935]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));
[4928]48
[4935]49 try {
50 transport->open();
[4925]51
[4935]52 while (processor->process(protocol,protocol,0)) {}
53
54 transport->close();
[4925]55 }
56 catch (TException& e) {
[4927]57 cerr << "Caught an exception generated by Thrift: " << e.what() << endl;
58 return 1;
[4925]59 }
60 catch (...) {
[4927]61 cerr << "Unknown exception" << endl;
62 return 1;
[4925]63 }
64
65 return 0;
66}
[5392]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.