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 |
|
---|
12 | using namespace apache::thrift;
|
---|
13 | using namespace apache::thrift::protocol;
|
---|
14 | using namespace apache::thrift::transport;
|
---|
15 |
|
---|
16 | using namespace com::gpssolutions::rtnet;
|
---|
17 | using namespace std;
|
---|
18 | using namespace boost;
|
---|
19 |
|
---|
20 | class RtnetClientHandler : public RtnetDataIf {
|
---|
21 | public:
|
---|
22 | RtnetClientHandler() {}
|
---|
23 | ~RtnetClientHandler() {}
|
---|
24 | void startDataStream() {}
|
---|
25 | void registerRtnet(const RtnetInformation& info) {}
|
---|
26 | void handleZDAmb(const vector<ZDAmb>& ambList) {}
|
---|
27 | void handleDDAmbresBaselines(const vector<DDAmbresBaseline>& ambList) {}
|
---|
28 | void handleStationInfo(const vector<StationInfo>& stationList) {}
|
---|
29 | void handleStationAuxInfo(const vector<StationAuxInfo>& stationAuxList) {}
|
---|
30 | void handleDGPSCorr(const vector<DGPSCorr>& dgpsList) {}
|
---|
31 | void handleSatelliteClock(const vector<SatelliteClock>& svList) {}
|
---|
32 | void handleEpochResults(const RtnetEpoch& epoch) {}
|
---|
33 |
|
---|
34 | void handleSatelliteXYZ(const vector< SatelliteXYZ>& svXYZList);
|
---|
35 | };
|
---|
36 |
|
---|
37 | void RtnetClientHandler::
|
---|
38 | handleSatelliteXYZ(const vector<SatelliteXYZ>& svXYZList) {
|
---|
39 | cout.setf(ios::fixed);
|
---|
40 | for (unsigned ii = 0; ii < svXYZList.size(); ii++) {
|
---|
41 | const SatelliteXYZ& sat = svXYZList[ii];
|
---|
42 | cout << unsigned(sat.ID) << ' '
|
---|
43 | << setprecision(3) << sat.xyz.x << ' '
|
---|
44 | << setprecision(3) << sat.xyz.y << ' '
|
---|
45 | << setprecision(3) << sat.xyz.z << endl;
|
---|
46 | }
|
---|
47 | cout << endl;
|
---|
48 | }
|
---|
49 |
|
---|
50 | int main(int argc, char **argv) {
|
---|
51 |
|
---|
52 | shared_ptr<TSocket> socket(new TSocket("localhost", 6666));
|
---|
53 | shared_ptr<TTransport> transport(new TBufferedTransport(socket));
|
---|
54 | shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
|
---|
55 | shared_ptr<RtnetDataIf> dataHandler(new RtnetClientHandler());
|
---|
56 | shared_ptr<TProcessor> processor(new RtnetDataProcessor(dataHandler));
|
---|
57 |
|
---|
58 | try {
|
---|
59 | transport->open();
|
---|
60 |
|
---|
61 | while (processor->process(protocol,protocol,0)) {}
|
---|
62 |
|
---|
63 | transport->close();
|
---|
64 | }
|
---|
65 | catch (TException& e) {
|
---|
66 | cerr << "Caught an exception generated by Thrift: " << e.what() << endl;
|
---|
67 | return 1;
|
---|
68 | }
|
---|
69 | catch (...) {
|
---|
70 | cerr << "Unknown exception" << endl;
|
---|
71 | return 1;
|
---|
72 | }
|
---|
73 |
|
---|
74 | return 0;
|
---|
75 | }
|
---|