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