1 |
|
---|
2 | #include <iostream>
|
---|
3 | #include <string.h>
|
---|
4 |
|
---|
5 | #include "bncrtrover.h"
|
---|
6 | #include "bncapp.h"
|
---|
7 | #include "bncsettings.h"
|
---|
8 | #include "bnctime.h"
|
---|
9 |
|
---|
10 | #include "rtrover_interface.h"
|
---|
11 |
|
---|
12 | using namespace std;
|
---|
13 |
|
---|
14 | // Constructor
|
---|
15 | ////////////////////////////////////////////////////////////////////////////
|
---|
16 | t_bncRtrover::t_bncRtrover() {
|
---|
17 |
|
---|
18 | bncSettings settings;
|
---|
19 |
|
---|
20 | // Processed Station, Corrections Source
|
---|
21 | // -------------------------------------
|
---|
22 | _pppCorrMount = settings.value("pppCorrMount").toString();
|
---|
23 |
|
---|
24 | // Define Input Options
|
---|
25 | // --------------------
|
---|
26 |
|
---|
27 | // Connect to BNC Signals
|
---|
28 | // ----------------------
|
---|
29 | connect(((bncApp*)qApp), SIGNAL(newCorrections(QList<QString>)),
|
---|
30 | this, SLOT(slotNewCorrections(QList<QString>)));
|
---|
31 |
|
---|
32 | connect(((bncApp*)qApp), SIGNAL(newEphGPS(gpsephemeris)),
|
---|
33 | this, SLOT(slotNewEphGPS(gpsephemeris)));
|
---|
34 |
|
---|
35 | connect(((bncApp*)qApp), SIGNAL(newEphGlonass(glonassephemeris)),
|
---|
36 | this, SLOT(slotNewEphGlonass(glonassephemeris)));
|
---|
37 |
|
---|
38 | connect(((bncApp*)qApp), SIGNAL(newEphGalileo(galileoephemeris)),
|
---|
39 | this, SLOT(slotNewEphGalileo(galileoephemeris)));
|
---|
40 | }
|
---|
41 |
|
---|
42 | // Destructor
|
---|
43 | ////////////////////////////////////////////////////////////////////////////
|
---|
44 | t_bncRtrover::~t_bncRtrover() {
|
---|
45 | QMapIterator<QString, t_corr*> ic(_corr);
|
---|
46 | while (ic.hasNext()) {
|
---|
47 | ic.next();
|
---|
48 | delete ic.value();
|
---|
49 | }
|
---|
50 | rtrover_destroy();
|
---|
51 | }
|
---|
52 |
|
---|
53 | //
|
---|
54 | ////////////////////////////////////////////////////////////////////////////
|
---|
55 | void t_bncRtrover::slotNewEphGPS(gpsephemeris gpseph) {
|
---|
56 | QMutexLocker locker(&_mutex);
|
---|
57 | }
|
---|
58 |
|
---|
59 | //
|
---|
60 | ////////////////////////////////////////////////////////////////////////////
|
---|
61 | void t_bncRtrover::slotNewEphGlonass(glonassephemeris gloeph) {
|
---|
62 | QMutexLocker locker(&_mutex);
|
---|
63 |
|
---|
64 | int wwUTC = gloeph.GPSWeek;
|
---|
65 | int towUTC = gloeph.GPSTOW;
|
---|
66 | updatetime(&wwUTC, &towUTC, gloeph.tb*1000, 1); // Moscow -> UTC
|
---|
67 | bncTime tUTC(wwUTC,towUTC);
|
---|
68 |
|
---|
69 | int wwGPS = gloeph.GPSWeek;
|
---|
70 | int towGPS = gloeph.GPSTOW;
|
---|
71 | updatetime(&wwGPS, &towGPS, gloeph.tb*1000, 0); // Moscow -> GPS
|
---|
72 | bncTime tGPS(wwGPS,towGPS);
|
---|
73 | }
|
---|
74 |
|
---|
75 | //
|
---|
76 | ////////////////////////////////////////////////////////////////////////////
|
---|
77 | void t_bncRtrover::slotNewEphGalileo(galileoephemeris /* galeph */) {
|
---|
78 | // not yet implemented
|
---|
79 | }
|
---|
80 |
|
---|
81 | //
|
---|
82 | ////////////////////////////////////////////////////////////////////////////
|
---|
83 | void t_bncRtrover::slotNewCorrections(QList<QString> corrList) {
|
---|
84 | QMutexLocker locker(&_mutex);
|
---|
85 |
|
---|
86 | // Check the Mountpoint (source of corrections)
|
---|
87 | // --------------------------------------------
|
---|
88 | if (!_pppCorrMount.isEmpty()) {
|
---|
89 | QMutableListIterator<QString> itm(corrList);
|
---|
90 | while (itm.hasNext()) {
|
---|
91 | QStringList hlp = itm.next().split(" ");
|
---|
92 | if (hlp.size() > 0) {
|
---|
93 | QString mountpoint = hlp[hlp.size()-1];
|
---|
94 | if (mountpoint != _pppCorrMount) {
|
---|
95 | itm.remove();
|
---|
96 | }
|
---|
97 | }
|
---|
98 | }
|
---|
99 | }
|
---|
100 |
|
---|
101 | if (corrList.size() == 0) {
|
---|
102 | return;
|
---|
103 | }
|
---|
104 |
|
---|
105 | QListIterator<QString> it(corrList);
|
---|
106 | while (it.hasNext()) {
|
---|
107 | QString line = it.next();
|
---|
108 |
|
---|
109 | QTextStream in(&line);
|
---|
110 | int messageType;
|
---|
111 | int updateInterval;
|
---|
112 | int GPSweek;
|
---|
113 | double GPSweeks;
|
---|
114 | QString prn;
|
---|
115 | in >> messageType >> updateInterval >> GPSweek >> GPSweeks >> prn;
|
---|
116 |
|
---|
117 | if ( t_corr::relevantMessageType(messageType) ) {
|
---|
118 | t_corr* cc = 0;
|
---|
119 | if (_corr.contains(prn)) {
|
---|
120 | cc = _corr.value(prn);
|
---|
121 | }
|
---|
122 | else {
|
---|
123 | cc = new t_corr();
|
---|
124 | _corr[prn] = cc;
|
---|
125 | }
|
---|
126 |
|
---|
127 | cc->readLine(line);
|
---|
128 | }
|
---|
129 | }
|
---|
130 |
|
---|
131 | QMapIterator<QString, t_corr*> ic(_corr);
|
---|
132 | while (ic.hasNext()) {
|
---|
133 | ic.next();
|
---|
134 | t_corr* cc = ic.value();
|
---|
135 | if (cc->ready()) {
|
---|
136 |
|
---|
137 | }
|
---|
138 | }
|
---|
139 | }
|
---|
140 |
|
---|
141 | //
|
---|
142 | ////////////////////////////////////////////////////////////////////////////
|
---|
143 | void t_bncRtrover::putNewObs(const t_obs& obsIn) {
|
---|
144 | QMutexLocker locker(&_mutex);
|
---|
145 |
|
---|
146 | bncTime obsTime(obsIn.GPSWeek, obsIn.GPSWeeks);
|
---|
147 |
|
---|
148 | if (_epoch.size() != 0) {
|
---|
149 | bncTime epoTime(_epoch[0].GPSWeek, _epoch[0].GPSWeeks);
|
---|
150 | if (epoTime != obsTime) {
|
---|
151 | //// const GPSS::gpcObs* allObs[_epoch.size()];
|
---|
152 | for (unsigned iObs = 0; iObs < _epoch.size(); iObs++) {
|
---|
153 | t_obs& obs = _epoch[iObs];
|
---|
154 |
|
---|
155 | }
|
---|
156 |
|
---|
157 | // for (unsigned iObs = 0; iObs < _epoch.size(); iObs++) {
|
---|
158 | // delete allObs[iObs];
|
---|
159 | // }
|
---|
160 |
|
---|
161 | _epoch.clear();
|
---|
162 | }
|
---|
163 | }
|
---|
164 |
|
---|
165 | t_obs newObs(obsIn);
|
---|
166 | _epoch.push_back(newObs);
|
---|
167 | }
|
---|