source: ntrip/trunk/BNC/src/bncsettings.cpp@ 8100

Last change on this file since 8100 was 8090, checked in by stuerze, 8 years ago

settings are not cleared anymore in order to have never an empty option because that has caused randomly crashes

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