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