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 "bncapp.h"
|
---|
21 |
|
---|
22 | QMutex bncSettings::_mutex; // static mutex
|
---|
23 |
|
---|
24 | // Constructor
|
---|
25 | ////////////////////////////////////////////////////////////////////////////
|
---|
26 | bncSettings::bncSettings() {
|
---|
27 | QMutexLocker locker(&_mutex);
|
---|
28 |
|
---|
29 | _bncApp = static_cast<bncApp*>(qApp);
|
---|
30 |
|
---|
31 | // First fill the options
|
---|
32 | // ----------------------
|
---|
33 | if (_bncApp->_settings.size() == 0) {
|
---|
34 | QSettings settings(_bncApp->confFileName(), QSettings::IniFormat);
|
---|
35 |
|
---|
36 | // Read from File
|
---|
37 | // --------------
|
---|
38 | if (settings.allKeys().size() > 0) {
|
---|
39 | QStringListIterator it(settings.allKeys());
|
---|
40 | while (it.hasNext()) {
|
---|
41 | QString key = it.next();
|
---|
42 | _bncApp->_settings[key] = settings.value(key);
|
---|
43 | }
|
---|
44 | }
|
---|
45 |
|
---|
46 | // Set Defaults
|
---|
47 | // ------------
|
---|
48 | else {
|
---|
49 | setValue("startTab", "0");
|
---|
50 | setValue("statusTab", "0");
|
---|
51 | setValue("casterUrlList", (QStringList()
|
---|
52 | << "http://user:pass@www.euref-ip.net:2101"
|
---|
53 | << "http://user:pass@www.igs-ip.net:2101"
|
---|
54 | << "http://user:pass@products.igs-ip.net:2101"
|
---|
55 | << "http://user:pass@mgex.igs-ip.net:2101"));
|
---|
56 | setValue("mountPoints", "");
|
---|
57 | setValue("ntripVersion", "1");
|
---|
58 | // Network
|
---|
59 | setValue("proxyHost", "");
|
---|
60 | setValue("proxyPort", "");
|
---|
61 | setValue("sslCaCertPath", "");
|
---|
62 | setValue("ignoreSslErrors", "0");
|
---|
63 | // General
|
---|
64 | setValue("logFile", "");
|
---|
65 | setValue("rnxAppend", "0");
|
---|
66 | setValue("onTheFlyInterval", "1 day");
|
---|
67 | setValue("autoStart", "0");
|
---|
68 | setValue("rawOutFile", "");
|
---|
69 | // RINEX Observations
|
---|
70 | setValue("rnxPath", "");
|
---|
71 | setValue("rnxIntr", "1 day");
|
---|
72 | setValue("rnxSampl", "0");
|
---|
73 | setValue("rnxSkel", "SKL");
|
---|
74 | setValue("rnxScript", "");
|
---|
75 | setValue("rnxV3", "0");
|
---|
76 | // RINEX Ephemeris
|
---|
77 | setValue("ephPath", "");
|
---|
78 | setValue("ephIntr", "1 day");
|
---|
79 | setValue("outEphPort", "");
|
---|
80 | setValue("ephV3", "0");
|
---|
81 | // Braodcast Corrections
|
---|
82 | setValue("corrPath", "");
|
---|
83 | setValue("corrIntr", "1 day");
|
---|
84 | setValue("corrPort", "");
|
---|
85 | setValue("corrTime", "5");
|
---|
86 | // Feed Engine
|
---|
87 | setValue("outPort", "");
|
---|
88 | setValue("waitTime", "5");
|
---|
89 | setValue("binSampl", "0");
|
---|
90 | setValue("outFile", "");
|
---|
91 | setValue("outUPort", "");
|
---|
92 | // Serial Output
|
---|
93 | setValue("serialMountPoint", "");
|
---|
94 | setValue("serialPortName", "");
|
---|
95 | setValue("serialBaudRate", "9600");
|
---|
96 | setValue("serialFlowControl", "OFF");
|
---|
97 | setValue("serialDataBits", "8");
|
---|
98 | setValue("serialParity", "NONE");
|
---|
99 | setValue("serialStopBits", "1");
|
---|
100 | setValue("serialAutoNMEA", "Auto");
|
---|
101 | setValue("serialFileNMEA", "");
|
---|
102 | setValue("serialHeightNMEA", "");
|
---|
103 | // Outages
|
---|
104 | setValue("obsRate", "");
|
---|
105 | setValue("adviseFail", "15");
|
---|
106 | setValue("adviseReco", "5");
|
---|
107 | setValue("adviseScript", "");
|
---|
108 | // Miscellaneous
|
---|
109 | setValue("miscMount", "");
|
---|
110 | setValue("perfIntr", "");
|
---|
111 | setValue("scanRTCM", "0");
|
---|
112 | // PPP
|
---|
113 | setValue("pppSPP", "");
|
---|
114 | setValue("pppMount", "");
|
---|
115 | setValue("pppCorrMount", "");
|
---|
116 | setValue("pppRefCrdX", "");
|
---|
117 | setValue("pppRefCrdY", "");
|
---|
118 | setValue("pppRefCrdZ", "");
|
---|
119 | setValue("pppRefdN", "");
|
---|
120 | setValue("pppRefdE", "");
|
---|
121 | setValue("pppRefdU", "");
|
---|
122 | setValue("nmeaFile", "");
|
---|
123 | setValue("nmeaPort", "");
|
---|
124 | setValue("pppPlotCoordinates", "");
|
---|
125 | setValue("postObsFile", "");
|
---|
126 | setValue("postNavFile", "");
|
---|
127 | setValue("postCorrFile", "");
|
---|
128 | setValue("postOutFile", "");
|
---|
129 | setValue("pppAntenna", "");
|
---|
130 | setValue("pppAntex", "");
|
---|
131 | setValue("pppApplySatAnt", "0");
|
---|
132 | setValue("pppUsePhase", "");
|
---|
133 | setValue("pppEstTropo", "");
|
---|
134 | setValue("pppGLONASS", "");
|
---|
135 | setValue("pppGalileo", "");
|
---|
136 | setValue("pppSync", "");
|
---|
137 | setValue("pppAverage", "");
|
---|
138 | setValue("pppQuickStart", "");
|
---|
139 | setValue("pppMaxSolGap", "");
|
---|
140 | setValue("pppSigmaCode", "10.0");
|
---|
141 | setValue("pppSigmaPhase", "0.02");
|
---|
142 | setValue("pppSigCrd0", "100.0");
|
---|
143 | setValue("pppSigCrdP", "100.0");
|
---|
144 | setValue("pppSigTrp0", "0.1");
|
---|
145 | setValue("pppSigTrpP", "3e-6");
|
---|
146 | // Reqc
|
---|
147 | setValue("reqcAction", "");
|
---|
148 | setValue("reqcObsFile", "");
|
---|
149 | setValue("reqcNavFile", "");
|
---|
150 | setValue("reqcOutObsFile", "");
|
---|
151 | setValue("reqcOutNavFile", "");
|
---|
152 | setValue("reqcOutLogFile", "");
|
---|
153 | setValue("reqcRnxVersion", "");
|
---|
154 | setValue("reqcSampling", "");
|
---|
155 | setValue("reqcStartDateTime", "");
|
---|
156 | setValue("reqcEndDateTime", "");
|
---|
157 | setValue("reqcOldMarkerName", "");
|
---|
158 | setValue("reqcNewMarkerName", "");
|
---|
159 | setValue("reqcOldAntennaName", "");
|
---|
160 | setValue("reqcNewAntennaName", "");
|
---|
161 | setValue("reqcOldReceiverName", "");
|
---|
162 | setValue("reqcNewReceiverName", "");
|
---|
163 | // Combination
|
---|
164 | setValue("combineStreams", "");
|
---|
165 | setValue("cmbMethod", "");
|
---|
166 | setValue("cmbMaxres", "");
|
---|
167 | // Upload (clk)
|
---|
168 | setValue("uploadMountpointsOut","");
|
---|
169 | setValue("uploadIntr", "1 day");
|
---|
170 | setValue("uploadSampl", "5");
|
---|
171 | setValue("uploadSamplOrb", "0");
|
---|
172 | setValue("trafo_dx", "");
|
---|
173 | setValue("trafo_dy", "");
|
---|
174 | setValue("trafo_dz", "");
|
---|
175 | setValue("trafo_dxr", "");
|
---|
176 | setValue("trafo_dyr", "");
|
---|
177 | setValue("trafo_dzr", "");
|
---|
178 | setValue("trafo_ox", "");
|
---|
179 | setValue("trafo_oy", "");
|
---|
180 | setValue("trafo_oz", "");
|
---|
181 | setValue("trafo_oxr", "");
|
---|
182 | setValue("trafo_oyr", "");
|
---|
183 | setValue("trafo_ozr", "");
|
---|
184 | setValue("trafo_sc", "");
|
---|
185 | setValue("trafo_scr", "");
|
---|
186 | setValue("trafo_t0", "");
|
---|
187 | // Upload (eph)
|
---|
188 | setValue("uploadEphHost", "");
|
---|
189 | setValue("uploadEphPort", "");
|
---|
190 | setValue("uploadEphMountpoint", "");
|
---|
191 | setValue("uploadEphPassword", "");
|
---|
192 | setValue("uploadEphSample", "5");
|
---|
193 | }
|
---|
194 | }
|
---|
195 | }
|
---|
196 |
|
---|
197 | // Destructor
|
---|
198 | ////////////////////////////////////////////////////////////////////////////
|
---|
199 | bncSettings::~bncSettings() {
|
---|
200 | QMutexLocker locker(&_mutex);
|
---|
201 |
|
---|
202 | }
|
---|
203 |
|
---|
204 | //
|
---|
205 | ////////////////////////////////////////////////////////////////////////////
|
---|
206 | QVariant bncSettings::value(const QString& key,
|
---|
207 | const QVariant& defaultValue) const {
|
---|
208 | QMutexLocker locker(&_mutex);
|
---|
209 |
|
---|
210 | if (_bncApp->_settings.contains(key)) {
|
---|
211 | return _bncApp->_settings[key];
|
---|
212 | }
|
---|
213 | else {
|
---|
214 | return defaultValue;
|
---|
215 | }
|
---|
216 | }
|
---|
217 |
|
---|
218 | //
|
---|
219 | ////////////////////////////////////////////////////////////////////////////
|
---|
220 | void bncSettings::setValue(const QString &key, const QVariant& value) {
|
---|
221 | _bncApp->_settings[key] = value;
|
---|
222 | }
|
---|
223 |
|
---|
224 | //
|
---|
225 | ////////////////////////////////////////////////////////////////////////////
|
---|
226 | void bncSettings::remove(const QString& key ) {
|
---|
227 | QMutexLocker locker(&_mutex);
|
---|
228 | _bncApp->_settings.remove(key);
|
---|
229 | }
|
---|
230 |
|
---|
231 | //
|
---|
232 | ////////////////////////////////////////////////////////////////////////////
|
---|
233 | void bncSettings::sync() {
|
---|
234 | QMutexLocker locker(&_mutex);
|
---|
235 | QSettings settings(_bncApp->confFileName(), QSettings::IniFormat);
|
---|
236 | settings.clear();
|
---|
237 | QMapIterator<QString, QVariant> it(_bncApp->_settings);
|
---|
238 | while (it.hasNext()) {
|
---|
239 | it.next();
|
---|
240 | settings.setValue(it.key(), it.value());
|
---|
241 | }
|
---|
242 | settings.sync();
|
---|
243 | }
|
---|