[5407] | 1 |
|
---|
| 2 | #include <iomanip>
|
---|
| 3 | #include <sstream>
|
---|
| 4 | #include <vector>
|
---|
| 5 |
|
---|
| 6 | #include "thriftclient.h"
|
---|
| 7 |
|
---|
| 8 | using namespace apache::thrift;
|
---|
| 9 | using namespace apache::thrift::protocol;
|
---|
| 10 | using namespace apache::thrift::transport;
|
---|
| 11 |
|
---|
| 12 | using namespace com::gpssolutions::rtnet;
|
---|
| 13 | using namespace std;
|
---|
| 14 | using namespace boost;
|
---|
| 15 |
|
---|
[5409] | 16 | // Constructor
|
---|
| 17 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 18 | t_thriftClient::t_thriftClient() {
|
---|
[5407] | 19 |
|
---|
[5409] | 20 | }
|
---|
| 21 |
|
---|
| 22 | // Destructor
|
---|
| 23 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 24 | t_thriftClient::~t_thriftClient() {
|
---|
| 25 |
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | // Run (virtual)
|
---|
| 29 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 30 | void t_thriftClient::run() {
|
---|
| 31 |
|
---|
| 32 | string host = "rtnet.rtcm-ntrip.org";
|
---|
| 33 | int port = 7777;
|
---|
| 34 |
|
---|
| 35 | shared_ptr<TSocket> socket(new TSocket(host, port));
|
---|
| 36 | shared_ptr<TTransport> transport(new TBufferedTransport(socket));
|
---|
| 37 | shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
|
---|
| 38 | shared_ptr<RtnetDataIf> dataHandler(new t_thriftClient());
|
---|
| 39 | shared_ptr<TProcessor> processor(new RtnetDataProcessor(dataHandler));
|
---|
| 40 |
|
---|
| 41 | try {
|
---|
| 42 | transport->open();
|
---|
| 43 | while (processor->process(protocol,protocol,0)) {}
|
---|
| 44 | transport->close();
|
---|
| 45 | }
|
---|
| 46 | catch (TException& e) {
|
---|
| 47 | cerr << "Caught an exception generated by Thrift: " << e.what() << endl;
|
---|
| 48 | }
|
---|
| 49 | catch (...) {
|
---|
| 50 | cerr << "Unknown exception" << endl;
|
---|
| 51 | }
|
---|
| 52 | }
|
---|
| 53 |
|
---|
[5407] | 54 | // Handle Satellite Positions
|
---|
| 55 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 56 | void t_thriftClient::
|
---|
| 57 | handleSatelliteXYZ(const vector<SatelliteXYZ>& svXYZList) {
|
---|
| 58 | cout.setf(ios::fixed);
|
---|
| 59 | for (unsigned ii = 0; ii < svXYZList.size(); ii++) {
|
---|
| 60 | // const SatelliteXYZ& sat = svXYZList[ii];
|
---|
| 61 | // cout << unsigned(sat.ID) << ' '
|
---|
| 62 | // << setprecision(3) << sat.xyz.x << ' '
|
---|
| 63 | // << setprecision(3) << sat.xyz.y << ' '
|
---|
| 64 | // << setprecision(3) << sat.xyz.z << endl;
|
---|
| 65 | }
|
---|
| 66 | // cout << endl;
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | // Handle Station Info
|
---|
| 70 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 71 | void t_thriftClient::
|
---|
| 72 | handleStationInfo(const vector<StationInfo>& stationList) {
|
---|
| 73 | for (unsigned ii = 0; ii < stationList.size(); ii++) {
|
---|
| 74 | const StationInfo& staInfo = stationList[ii];
|
---|
| 75 | _stationCrd[staInfo.ID]._x = staInfo.xyz.x;
|
---|
| 76 | _stationCrd[staInfo.ID]._y = staInfo.xyz.y;
|
---|
| 77 | _stationCrd[staInfo.ID]._z = staInfo.xyz.z;
|
---|
| 78 | }
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | // Handle Eoch Results
|
---|
| 82 | //////////////////////////////////////////////////////////////////////////////
|
---|
| 83 | void t_thriftClient::
|
---|
| 84 | handleEpochResults(const RtnetEpoch& epoch) {
|
---|
| 85 | for (unsigned ii = 0; ii < epoch.stationResultList.size(); ii++) {
|
---|
| 86 | const StationResults& staRes = epoch.stationResultList[ii];
|
---|
| 87 | cout << staRes.stationName << ' '
|
---|
| 88 | << (int) staRes.nsv_gps_used << ' ' << (int) staRes.nsv_glonass_used << ' ';
|
---|
| 89 | if (_stationCrd.find(staRes.stationName) != _stationCrd.end()) {
|
---|
| 90 | cout << _stationCrd[staRes.stationName]._x << ' '
|
---|
| 91 | << _stationCrd[staRes.stationName]._y << ' '
|
---|
| 92 | << _stationCrd[staRes.stationName]._z;
|
---|
| 93 | }
|
---|
| 94 | cout << endl;
|
---|
| 95 | }
|
---|
| 96 | }
|
---|