source: ntrip/trunk/BNC/combination/bnccomb.cpp@ 2921

Last change on this file since 2921 was 2921, checked in by mervart, 13 years ago
File size: 4.7 KB
Line 
1/* -------------------------------------------------------------------------
2 * BKG NTRIP Client
3 * -------------------------------------------------------------------------
4 *
5 * Class: bncComb
6 *
7 * Purpose: Combinations of Orbit/Clock Corrections
8 *
9 * Author: L. Mervart
10 *
11 * Created: 22-Jan-2011
12 *
13 * Changes:
14 *
15 * -----------------------------------------------------------------------*/
16
17#include <iomanip>
18
19#include "bnccomb.h"
20#include "bncapp.h"
21#include "bncsettings.h"
22
23using namespace std;
24
25// Constructor
26////////////////////////////////////////////////////////////////////////////
27bncComb::bncComb() {
28
29 bncSettings settings;
30
31 QStringList combineStreams = settings.value("combineStreams").toStringList();
32
33 if (combineStreams.size() >= 2) {
34 QListIterator<QString> it(combineStreams);
35 while (it.hasNext()) {
36 QStringList hlp = it.next().split(" ");
37 cmbAC* newAC = new cmbAC();
38 newAC->mountPoint = hlp[0];
39 newAC->name = hlp[1];
40 newAC->weight = hlp[2].toDouble();
41
42 _ACs[newAC->mountPoint] = newAC;
43 }
44 }
45}
46
47// Destructor
48////////////////////////////////////////////////////////////////////////////
49bncComb::~bncComb() {
50 QMapIterator<QString, cmbAC*> it(_ACs);
51 while (it.hasNext()) {
52 it.next();
53 delete it.value();
54 }
55}
56
57//
58////////////////////////////////////////////////////////////////////////////
59void bncComb::processCorrLine(const QString& staID, const QString& line) {
60 QMutexLocker locker(&_mutex);
61
62 // Find the relevant instance of cmbAC class
63 // -----------------------------------------
64 if (_ACs.find(staID) == _ACs.end()) {
65 return;
66 }
67 cmbAC* AC = _ACs[staID];
68
69 // Read the Correction
70 // -------------------
71 t_corr* newCorr = new t_corr();
72 if (!newCorr->readLine(line) == success) {
73 delete newCorr;
74 return;
75 }
76
77 // Check Modulo Time
78 // -----------------
79 const int moduloTime = 10;
80 if (int(newCorr->tt.gpssec()) % moduloTime != 0.0) {
81 delete newCorr;
82 return;
83 }
84
85 // Find/Create the instance of cmbEpoch class
86 // ------------------------------------------
87 cmbEpoch* newEpoch = 0;
88 QListIterator<cmbEpoch*> it(AC->epochs);
89 while (it.hasNext()) {
90 cmbEpoch* hlpEpoch = it.next();
91 if (hlpEpoch->time == newCorr->tt) {
92 newEpoch = hlpEpoch;
93 break;
94 }
95 }
96 if (newEpoch == 0) {
97 newEpoch = new cmbEpoch();
98 newEpoch->time = newCorr->tt;
99 AC->epochs.append(newEpoch);
100 }
101
102 if (newEpoch->corr.find(newCorr->prn) != newEpoch->corr.end()) {
103 newEpoch->corr[newCorr->prn]->readLine(line); // merge (multiple messages)
104 }
105 else {
106 newEpoch->corr[newCorr->prn] = newCorr;
107 }
108
109 processEpochsBefore(newCorr->tt);
110}
111
112//
113////////////////////////////////////////////////////////////////////////////
114void bncComb::processEpochsBefore(const bncTime& time) {
115
116 const double waitTime = 10.0; // wait 10 seconds
117
118 bool corrProcessed = false;
119
120 QMapIterator<QString, cmbAC*> itAC(_ACs);
121 while (itAC.hasNext()) {
122 itAC.next();
123 cmbAC* AC = itAC.value();
124
125
126 QMutableListIterator<cmbEpoch*> itEpo(AC->epochs);
127 while (itEpo.hasNext()) {
128 cmbEpoch* epoch = itEpo.next();
129 double dt = time - epoch->time;
130
131 if (dt == waitTime) {
132 QMapIterator<QString, t_corr*> itCorr(epoch->corr);
133 while (itCorr.hasNext()) {
134 itCorr.next();
135 t_corr* corr = itCorr.value();
136 processSingleCorr(AC, corr);
137 corrProcessed = true;
138 }
139 }
140
141 if (dt >= waitTime) {
142 if (dt > waitTime) {
143 cout << "delete " << AC->name.toAscii().data() << " "
144 << epoch->time.timestr() << " " << endl;
145 }
146 delete epoch;
147 itEpo.remove();
148 }
149 }
150 }
151
152 if (corrProcessed) {
153 printResults();
154 }
155}
156
157//
158////////////////////////////////////////////////////////////////////////////
159void bncComb::processSingleCorr(const cmbAC* AC, const t_corr* corr) {
160 cout.setf(ios::fixed);
161 cout << AC->name.toAscii().data() << " "
162 << AC->mountPoint.toAscii().data() << " "
163 << corr->prn.toAscii().data() << " "
164 << corr->tt.timestr() << " "
165 << setw(4) << corr->iod << " "
166 << setw(8) << setprecision(4) << corr->dClk * t_CST::c << " "
167 << setw(8) << setprecision(4) << corr->rao[0] << " "
168 << setw(8) << setprecision(4) << corr->rao[1] << " "
169 << setw(8) << setprecision(4) << corr->rao[2] << endl;
170}
171
172//
173////////////////////////////////////////////////////////////////////////////
174void bncComb::printResults() const {
175
176 cout << "Corrections processed" << endl << endl;
177
178}
Note: See TracBrowser for help on using the repository browser.