[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 |
|
---|
| 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;
|
---|
[4935] | 18 | using namespace boost;
|
---|
[4925] | 19 |
|
---|
[4935] | 20 | class RtnetClientHandler : public RtnetDataIf {
|
---|
[4927] | 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) {}
|
---|
[4926] | 33 |
|
---|
[4927] | 34 | void handleSatelliteXYZ(const vector< SatelliteXYZ>& svXYZList);
|
---|
[4925] | 35 | };
|
---|
| 36 |
|
---|
[4927] | 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;
|
---|
[4925] | 48 | }
|
---|
| 49 |
|
---|
| 50 | int main(int argc, char **argv) {
|
---|
| 51 |
|
---|
[4935] | 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));
|
---|
[4928] | 57 |
|
---|
[4935] | 58 | try {
|
---|
| 59 | transport->open();
|
---|
[4925] | 60 |
|
---|
[4935] | 61 | while (processor->process(protocol,protocol,0)) {}
|
---|
| 62 |
|
---|
| 63 | transport->close();
|
---|
[4925] | 64 | }
|
---|
| 65 | catch (TException& e) {
|
---|
[4927] | 66 | cerr << "Caught an exception generated by Thrift: " << e.what() << endl;
|
---|
| 67 | return 1;
|
---|
[4925] | 68 | }
|
---|
| 69 | catch (...) {
|
---|
[4927] | 70 | cerr << "Unknown exception" << endl;
|
---|
| 71 | return 1;
|
---|
[4925] | 72 | }
|
---|
| 73 |
|
---|
| 74 | return 0;
|
---|
| 75 | }
|
---|