#include #include #include #include #include "thriftclient.h" #include "map_stations.h" using namespace apache::thrift; using namespace apache::thrift::protocol; using namespace apache::thrift::transport; using namespace com::gpssolutions::rtnet; using namespace std; using namespace boost; // Constructor ////////////////////////////////////////////////////////////////////////////// t_thriftClient::t_thriftClient(GnssCenter::t_map_stations* parent) { _stop = false; _parent = parent; } // Destructor ////////////////////////////////////////////////////////////////////////////// t_thriftClient::~t_thriftClient() { } // Run (virtual) ////////////////////////////////////////////////////////////////////////////// void t_thriftClient::run() { string host = "rtnet.rtcm-ntrip.org"; int port = 7777; shared_ptr socket(new TSocket(host, port)); shared_ptr transport(new TBufferedTransport(socket)); shared_ptr protocol(new TBinaryProtocol(transport)); shared_ptr dataHandler(new t_thriftHandler(_parent)); shared_ptr processor(new RtnetDataProcessor(dataHandler)); try { transport->open(); while (!_stop && processor->process(protocol,protocol,0)) {} transport->close(); } catch (TException& e) { cerr << "Caught an exception generated by Thrift: " << e.what() << endl; } catch (...) { cerr << "Unknown exception" << endl; } this->terminate(); this->deleteLater(); } // Constructor ////////////////////////////////////////////////////////////////////////////// t_thriftHandler::t_thriftHandler(GnssCenter::t_map_stations* parent) { _parent = parent; } // Destructor ////////////////////////////////////////////////////////////////////////////// t_thriftHandler::~t_thriftHandler() { } // Handle Satellite Positions ////////////////////////////////////////////////////////////////////////////// void t_thriftHandler:: handleSatelliteXYZ(const vector& svXYZList) { cout.setf(ios::fixed); for (unsigned ii = 0; ii < svXYZList.size(); ii++) { // const SatelliteXYZ& sat = svXYZList[ii]; // cout << unsigned(sat.ID) << ' ' // << setprecision(3) << sat.xyz.x << ' ' // << setprecision(3) << sat.xyz.y << ' ' // << setprecision(3) << sat.xyz.z << endl; } // cout << endl; } // Handle Station Info ////////////////////////////////////////////////////////////////////////////// void t_thriftHandler:: handleStationInfo(const vector& stationList) { for (unsigned ii = 0; ii < stationList.size(); ii++) { const StationInfo& staInfo = stationList[ii]; _stationCrd[staInfo.ID]._x = staInfo.xyz.x; _stationCrd[staInfo.ID]._y = staInfo.xyz.y; _stationCrd[staInfo.ID]._z = staInfo.xyz.z; } } // Handle Epoch Results ////////////////////////////////////////////////////////////////////////////// void t_thriftHandler:: handleEpochResults(const RtnetEpoch& epoch) { for (unsigned ii = 0; ii < epoch.stationResultList.size(); ii++) { const StationResults& staRes = epoch.stationResultList[ii]; t_thriftResult result; result._name = staRes.stationName; result._nGPS = staRes.nsv_gps_used; result._nGLO = staRes.nsv_glonass_used; if (_stationCrd.find(staRes.stationName) != _stationCrd.end()) { result._x = _stationCrd[staRes.stationName]._x; result._y = _stationCrd[staRes.stationName]._y; result._z = _stationCrd[staRes.stationName]._z; } _parent->slotNewThriftResult(&result); } }