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