1 | /* -------------------------------------------------------------------------
|
---|
2 | * BKG NTRIP Client
|
---|
3 | * -------------------------------------------------------------------------
|
---|
4 | *
|
---|
5 | * Class: bncSettings
|
---|
6 | *
|
---|
7 | * Purpose: Subclasses the QSettings
|
---|
8 | *
|
---|
9 | * Author: L. Mervart
|
---|
10 | *
|
---|
11 | * Created: 25-Jan-2009
|
---|
12 | *
|
---|
13 | * Changes:
|
---|
14 | *
|
---|
15 | * -----------------------------------------------------------------------*/
|
---|
16 |
|
---|
17 | #include <QSettings>
|
---|
18 |
|
---|
19 | #include "bncsettings.h"
|
---|
20 | #include "bnccore.h"
|
---|
21 |
|
---|
22 | QMutex bncSettings::_mutex; // static mutex
|
---|
23 |
|
---|
24 | // Constructor
|
---|
25 | ////////////////////////////////////////////////////////////////////////////
|
---|
26 | bncSettings::bncSettings() {
|
---|
27 | QMutexLocker locker(&_mutex);
|
---|
28 |
|
---|
29 | // First fill the options
|
---|
30 | // ----------------------
|
---|
31 | if (BNC_CORE->_settings.size() == 0) {
|
---|
32 | reRead();
|
---|
33 | }
|
---|
34 | }
|
---|
35 |
|
---|
36 | // Destructor
|
---|
37 | ////////////////////////////////////////////////////////////////////////////
|
---|
38 | bncSettings::~bncSettings() {
|
---|
39 | }
|
---|
40 |
|
---|
41 | // (Re-)read the Options from File or Set the Defaults
|
---|
42 | ////////////////////////////////////////////////////////////////////////////
|
---|
43 | void bncSettings::reRead() {
|
---|
44 |
|
---|
45 | QSettings settings(BNC_CORE->confFileName(), QSettings::IniFormat);
|
---|
46 |
|
---|
47 | // Read from File
|
---|
48 | // --------------
|
---|
49 | if (settings.allKeys().size() > 0) {
|
---|
50 | QStringListIterator it(settings.allKeys());
|
---|
51 | while (it.hasNext()) {
|
---|
52 | QString key = it.next();
|
---|
53 | BNC_CORE->_settings[key] = settings.value(key);
|
---|
54 | }
|
---|
55 | }
|
---|
56 |
|
---|
57 | // Set Defaults
|
---|
58 | // ------------
|
---|
59 | else {
|
---|
60 | setValue_p("startTab", "0");
|
---|
61 | setValue_p("statusTab", "0");
|
---|
62 | setValue_p("font", "");
|
---|
63 | setValue_p("casterUrlList", (QStringList()
|
---|
64 | << "http://user:pass@euref-ip.net:2101"
|
---|
65 | << "http://user:pass@igs-ip.net:2101"
|
---|
66 | << "http://user:pass@products.igs-ip.net:2101"
|
---|
67 | << "http://user:pass@mgex.igs-ip.net:2101"));
|
---|
68 | setValue_p("mountPoints", "");
|
---|
69 | setValue_p("ntripVersion", "2");
|
---|
70 | // Network
|
---|
71 | setValue_p("proxyHost", "");
|
---|
72 | setValue_p("proxyPort", "");
|
---|
73 | setValue_p("sslCaCertPath", "");
|
---|
74 | setValue_p("sslClientCertPath", "");
|
---|
75 | setValue_p("sslIgnoreErrors", "0");
|
---|
76 | // General
|
---|
77 | setValue_p("logFile", "");
|
---|
78 | setValue_p("rnxAppend", "0");
|
---|
79 | setValue_p("onTheFlyInterval", "no");
|
---|
80 | setValue_p("autoStart", "0");
|
---|
81 | setValue_p("rawOutFile", "");
|
---|
82 | // RINEX Observations
|
---|
83 | setValue_p("rnxPath", "");
|
---|
84 | setValue_p("rnxIntr", "1 day");
|
---|
85 | setValue_p("rnxOnlyWithSKL", "");
|
---|
86 | setValue_p("rnxSampl", "1 sec");
|
---|
87 | setValue_p("rnxSkel", "skl");
|
---|
88 | setValue_p("rnxSkelPath", "");
|
---|
89 | setValue_p("rnxV2Priority", "");
|
---|
90 | setValue_p("rnxScript", "");
|
---|
91 | setValue_p("rnxVersion", "3");
|
---|
92 | // RINEX Ephemeris
|
---|
93 | setValue_p("ephPath", "");
|
---|
94 | setValue_p("ephIntr", "1 day");
|
---|
95 | setValue_p("ephOutPort", "");
|
---|
96 | setValue_p("ephVersion", "3");
|
---|
97 | // Reqc
|
---|
98 | setValue_p("reqcAction", "");
|
---|
99 | setValue_p("reqcObsFile", "");
|
---|
100 | setValue_p("reqcNavFile", "");
|
---|
101 | setValue_p("reqcOutObsFile", "");
|
---|
102 | setValue_p("reqcOutNavFile", "");
|
---|
103 | setValue_p("reqcOutLogFile", "");
|
---|
104 | setValue_p("reqcSkyPlotSignals", "G:1&2&5 R:1&2&3 E:1&7 C:2&6 J:1&2 I:5&9 S:1&5");
|
---|
105 | setValue_p("reqcPlotDir", "");
|
---|
106 | setValue_p("reqcRnxVersion", "");
|
---|
107 | setValue_p("reqcSampling", "1 sec");
|
---|
108 | setValue_p("reqcStartDateTime", "1967-11-02T00:00:00");
|
---|
109 | setValue_p("reqcEndDateTime", "2099-01-01T00:00:00");
|
---|
110 | setValue_p("reqcLogSummaryOnly", "");
|
---|
111 | setValue_p("reqcRunBy", "");
|
---|
112 | setValue_p("reqcComment", "");
|
---|
113 | setValue_p("reqcOldMarkerName", "");
|
---|
114 | setValue_p("reqcNewMarkerName", "");
|
---|
115 | setValue_p("reqcOldAntennaName", "");
|
---|
116 | setValue_p("reqcNewAntennaName", "");
|
---|
117 | setValue_p("reqcOldReceiverName", "");
|
---|
118 | setValue_p("reqcNewReceiverName", "");
|
---|
119 | setValue_p("reqcOldAntennaNumber", "");
|
---|
120 | setValue_p("reqcNewAntennaNumber","");
|
---|
121 | setValue_p("reqcOldAntennadE", "");
|
---|
122 | setValue_p("reqcNewAntennadE", "");
|
---|
123 | setValue_p("reqcOldAntennadN", "");
|
---|
124 | setValue_p("reqcNewAntennadN", "");
|
---|
125 | setValue_p("reqcOldAntennadU", "");
|
---|
126 | setValue_p("reqcNewAntennadU", "");
|
---|
127 | setValue_p("reqcOldReceiverNumber", "");
|
---|
128 | setValue_p("reqcNewReceiverNumber", "");
|
---|
129 | setValue_p("reqcUseObsTypes", "");
|
---|
130 | setValue_p("reqcV2Priority", "G:12&PWCSLX G:5&IQX R:12&PC R:3&IQX R:46&ABX E:16&BCXZ E:578&IQX J:1&SLXCZ J:26&SLX J:5&IQX C:267&IQX C:18&DPX I:ABCX S:1&C S:5&IQX");
|
---|
131 | // SP3
|
---|
132 | setValue_p("sp3CompFile", "");
|
---|
133 | setValue_p("sp3CompExclude", "");
|
---|
134 | setValue_p("sp3CompOutLogFile", "");
|
---|
135 | // Braodcast Corrections
|
---|
136 | setValue_p("corrPath", "");
|
---|
137 | setValue_p("corrIntr", "1 day");
|
---|
138 | setValue_p("corrPort", "");
|
---|
139 | // Feed Engine
|
---|
140 | setValue_p("outPort", "");
|
---|
141 | setValue_p("outWait", "5");
|
---|
142 | setValue_p("outSampl", "1 sec");
|
---|
143 | setValue_p("outFile", "");
|
---|
144 | setValue_p("outUPort", "");
|
---|
145 | setValue_p("outLockTime", "0");
|
---|
146 | // Serial Output
|
---|
147 | setValue_p("serialMountPoint", "");
|
---|
148 | setValue_p("serialPortName", "");
|
---|
149 | setValue_p("serialBaudRate", "9600");
|
---|
150 | setValue_p("serialFlowControl", "OFF");
|
---|
151 | setValue_p("serialDataBits", "8");
|
---|
152 | setValue_p("serialParity", "NONE");
|
---|
153 | setValue_p("serialStopBits", "1");
|
---|
154 | setValue_p("serialAutoNMEA", "Auto");
|
---|
155 | setValue_p("serialFileNMEA", "");
|
---|
156 | setValue_p("serialHeightNMEA", "");
|
---|
157 | setValue_p("serialManualNMEASampling", "10");
|
---|
158 | // Outages
|
---|
159 | setValue_p("adviseObsRate", "");
|
---|
160 | setValue_p("adviseFail", "15");
|
---|
161 | setValue_p("adviseReco", "5");
|
---|
162 | setValue_p("adviseScript", "");
|
---|
163 | // Miscellaneous
|
---|
164 | setValue_p("miscMount", "");
|
---|
165 | setValue_p("miscIntr", "");
|
---|
166 | setValue_p("miscScanRTCM", "0");
|
---|
167 | setValue_p("miscPort", "");
|
---|
168 | // Combination
|
---|
169 | setValue_p("cmbStreams", "");
|
---|
170 | setValue_p("cmbMethod", "");
|
---|
171 | setValue_p("cmbMaxres", "");
|
---|
172 | setValue_p("cmbSampl", "10");
|
---|
173 | setValue_p("cmbGps", "2");
|
---|
174 | setValue_p("cmbGlo", "2");
|
---|
175 | setValue_p("cmbGal", "2");
|
---|
176 | setValue_p("cmbBds", "2");
|
---|
177 | setValue_p("cmbQzss", "0");
|
---|
178 | setValue_p("cmbSbas", "0");
|
---|
179 | setValue_p("cmbIrnss", "0");
|
---|
180 |
|
---|
181 | // Upload (clk)
|
---|
182 | setValue_p("uploadMountpointsOut","");
|
---|
183 | setValue_p("uploadIntr", "1 day");
|
---|
184 | setValue_p("uploadSamplRtcmEphCorr", "0");
|
---|
185 | setValue_p("uploadSamplSp3", "1");
|
---|
186 | setValue_p("uploadSamplClkRnx", "10");
|
---|
187 | setValue_p("uploadSamplBiaSnx", "60");
|
---|
188 | setValue_p("trafo_dx", "");
|
---|
189 | setValue_p("trafo_dy", "");
|
---|
190 | setValue_p("trafo_dz", "");
|
---|
191 | setValue_p("trafo_dxr", "");
|
---|
192 | setValue_p("trafo_dyr", "");
|
---|
193 | setValue_p("trafo_dzr", "");
|
---|
194 | setValue_p("trafo_ox", "");
|
---|
195 | setValue_p("trafo_oy", "");
|
---|
196 | setValue_p("trafo_oz", "");
|
---|
197 | setValue_p("trafo_oxr", "");
|
---|
198 | setValue_p("trafo_oyr", "");
|
---|
199 | setValue_p("trafo_ozr", "");
|
---|
200 | setValue_p("trafo_sc", "");
|
---|
201 | setValue_p("trafo_scr", "");
|
---|
202 | setValue_p("trafo_t0", "");
|
---|
203 | // Upload (eph)
|
---|
204 | setValue_p("uploadEphMountpointsOut","");
|
---|
205 | setValue_p("uploadSamplRtcmEph", "5");
|
---|
206 | }
|
---|
207 | }
|
---|
208 |
|
---|
209 | //
|
---|
210 | ////////////////////////////////////////////////////////////////////////////
|
---|
211 | QVariant bncSettings::value(const QString& key,
|
---|
212 | const QVariant& defaultValue) const {
|
---|
213 | QMutexLocker locker(&_mutex);
|
---|
214 |
|
---|
215 | if (BNC_CORE->_settings.contains(key)) {
|
---|
216 | return BNC_CORE->_settings[key];
|
---|
217 | }
|
---|
218 | else {
|
---|
219 | return defaultValue;
|
---|
220 | }
|
---|
221 | }
|
---|
222 |
|
---|
223 | //
|
---|
224 | ////////////////////////////////////////////////////////////////////////////
|
---|
225 | void bncSettings::setValue(const QString &key, const QVariant& value) {
|
---|
226 | QMutexLocker locker(&_mutex);
|
---|
227 | setValue_p(key, value);
|
---|
228 | }
|
---|
229 |
|
---|
230 | //
|
---|
231 | ////////////////////////////////////////////////////////////////////////////
|
---|
232 | void bncSettings::setValue_p(const QString &key, const QVariant& value) {
|
---|
233 | BNC_CORE->_settings[key] = value;
|
---|
234 | }
|
---|
235 |
|
---|
236 | //
|
---|
237 | ////////////////////////////////////////////////////////////////////////////
|
---|
238 | void bncSettings::remove(const QString& key ) {
|
---|
239 | QMutexLocker locker(&_mutex);
|
---|
240 | BNC_CORE->_settings.remove(key);
|
---|
241 | }
|
---|
242 |
|
---|
243 | //
|
---|
244 | ////////////////////////////////////////////////////////////////////////////
|
---|
245 | bool bncSettings::contains(const QString& key) const {
|
---|
246 | QMutexLocker locker(&_mutex);
|
---|
247 | return BNC_CORE->_settings.contains(key);
|
---|
248 | }
|
---|
249 |
|
---|
250 | //
|
---|
251 | ////////////////////////////////////////////////////////////////////////////
|
---|
252 | void bncSettings::sync() {
|
---|
253 | QMutexLocker locker(&_mutex);
|
---|
254 | QSettings settings(BNC_CORE->confFileName(), QSettings::IniFormat);
|
---|
255 | settings.clear();
|
---|
256 | QMapIterator<QString, QVariant> it(BNC_CORE->_settings);
|
---|
257 |
|
---|
258 | while (it.hasNext()) {
|
---|
259 | it.next();
|
---|
260 | settings.setValue(it.key(), it.value());
|
---|
261 | }
|
---|
262 |
|
---|
263 | settings.sync();
|
---|
264 | }
|
---|