[1535] | 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 |
|
---|
[4072] | 17 | #include <QSettings>
|
---|
| 18 |
|
---|
[1535] | 19 | #include "bncsettings.h"
|
---|
[5070] | 20 | #include "bnccore.h"
|
---|
[1535] | 21 |
|
---|
[4073] | 22 | QMutex bncSettings::_mutex; // static mutex
|
---|
| 23 |
|
---|
[1535] | 24 | // Constructor
|
---|
| 25 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4077] | 26 | bncSettings::bncSettings() {
|
---|
[4073] | 27 | QMutexLocker locker(&_mutex);
|
---|
[1536] | 28 |
|
---|
[4070] | 29 | // First fill the options
|
---|
| 30 | // ----------------------
|
---|
[5068] | 31 | if (BNC_CORE->_settings.size() == 0) {
|
---|
[4251] | 32 | reRead();
|
---|
[1536] | 33 | }
|
---|
[1535] | 34 | }
|
---|
| 35 |
|
---|
[4070] | 36 | // Destructor
|
---|
| 37 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 38 | bncSettings::~bncSettings() {
|
---|
| 39 | }
|
---|
| 40 |
|
---|
[4251] | 41 | // (Re-)read the Options from File or Set the Defaults
|
---|
| 42 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 43 | void bncSettings::reRead() {
|
---|
| 44 |
|
---|
[5068] | 45 | BNC_CORE->_settings.clear();
|
---|
[4251] | 46 |
|
---|
[5068] | 47 | QSettings settings(BNC_CORE->confFileName(), QSettings::IniFormat);
|
---|
[4251] | 48 |
|
---|
[5080] | 49 | #ifdef GNSSCENTER_PLUGIN
|
---|
| 50 | settings.beginGroup("BNC");
|
---|
| 51 | #endif
|
---|
| 52 |
|
---|
[4251] | 53 | // Read from File
|
---|
| 54 | // --------------
|
---|
| 55 | if (settings.allKeys().size() > 0) {
|
---|
| 56 | QStringListIterator it(settings.allKeys());
|
---|
| 57 | while (it.hasNext()) {
|
---|
| 58 | QString key = it.next();
|
---|
[5068] | 59 | BNC_CORE->_settings[key] = settings.value(key);
|
---|
[4251] | 60 | }
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | // Set Defaults
|
---|
| 64 | // ------------
|
---|
| 65 | else {
|
---|
| 66 | setValue_p("startTab", "0");
|
---|
| 67 | setValue_p("statusTab", "0");
|
---|
[6828] | 68 | setValue_p("font", "");
|
---|
[4251] | 69 | setValue_p("casterUrlList", (QStringList()
|
---|
| 70 | << "http://user:pass@www.euref-ip.net:2101"
|
---|
| 71 | << "http://user:pass@www.igs-ip.net:2101"
|
---|
| 72 | << "http://user:pass@products.igs-ip.net:2101"
|
---|
| 73 | << "http://user:pass@mgex.igs-ip.net:2101"));
|
---|
| 74 | setValue_p("mountPoints", "");
|
---|
| 75 | setValue_p("ntripVersion", "1");
|
---|
| 76 | // Network
|
---|
| 77 | setValue_p("proxyHost", "");
|
---|
| 78 | setValue_p("proxyPort", "");
|
---|
| 79 | setValue_p("sslCaCertPath", "");
|
---|
| 80 | setValue_p("ignoreSslErrors", "0");
|
---|
| 81 | // General
|
---|
| 82 | setValue_p("logFile", "");
|
---|
| 83 | setValue_p("rnxAppend", "0");
|
---|
| 84 | setValue_p("onTheFlyInterval", "1 day");
|
---|
| 85 | setValue_p("autoStart", "0");
|
---|
| 86 | setValue_p("rawOutFile", "");
|
---|
| 87 | // RINEX Observations
|
---|
| 88 | setValue_p("rnxPath", "");
|
---|
| 89 | setValue_p("rnxIntr", "1 day");
|
---|
[6827] | 90 | setValue_p("rnxOnlyWithSKL", "");
|
---|
[4251] | 91 | setValue_p("rnxSampl", "0");
|
---|
| 92 | setValue_p("rnxSkel", "SKL");
|
---|
[6827] | 93 | setValue_p("rnxV2Priority", "");
|
---|
[4251] | 94 | setValue_p("rnxScript", "");
|
---|
| 95 | setValue_p("rnxV3", "0");
|
---|
| 96 | // RINEX Ephemeris
|
---|
| 97 | setValue_p("ephPath", "");
|
---|
| 98 | setValue_p("ephIntr", "1 day");
|
---|
| 99 | setValue_p("outEphPort", "");
|
---|
| 100 | setValue_p("ephV3", "0");
|
---|
[6827] | 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("reqcNewAntennaNumber","");
|
---|
| 124 | setValue_p("reqcNewAntennadE", "");
|
---|
| 125 | setValue_p("reqcNewAntennadN", "");
|
---|
| 126 | setValue_p("reqcNewAntennadU", "");
|
---|
| 127 | setValue_p("reqcNewReceiverNumber", "");
|
---|
| 128 | setValue_p("reqcOldAntennaNumber", "");
|
---|
| 129 | setValue_p("reqcOldAntennadE", "");
|
---|
| 130 | setValue_p("reqcOldAntennadN", "");
|
---|
| 131 | setValue_p("reqcOldAntennadU", "");
|
---|
| 132 | setValue_p("reqcOldReceiverNumber", "");
|
---|
| 133 | setValue_p("reqcUseObsTypes", "");
|
---|
| 134 | setValue_p("reqcV2Priority", "");
|
---|
| 135 | // SP3
|
---|
| 136 | setValue_p("sp3CompFile", "");
|
---|
| 137 | setValue_p("sp3CompExclude", "");
|
---|
| 138 | setValue_p("sp3CompOutLogFile", "");
|
---|
[4251] | 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("waitTime", "5");
|
---|
| 146 | setValue_p("binSampl", "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", "");
|
---|
[6827] | 160 | setValue_p("serialManualNMEASampling", "");
|
---|
[4251] | 161 | // Outages
|
---|
| 162 | setValue_p("obsRate", "");
|
---|
| 163 | setValue_p("adviseFail", "15");
|
---|
| 164 | setValue_p("adviseReco", "5");
|
---|
| 165 | setValue_p("adviseScript", "");
|
---|
| 166 | // Miscellaneous
|
---|
| 167 | setValue_p("miscMount", "");
|
---|
| 168 | setValue_p("perfIntr", "");
|
---|
| 169 | setValue_p("scanRTCM", "0");
|
---|
[5642] | 170 | setValue_p("miscPort", "");
|
---|
[4251] | 171 | // Combination
|
---|
| 172 | setValue_p("combineStreams", "");
|
---|
| 173 | setValue_p("cmbMethod", "");
|
---|
| 174 | setValue_p("cmbMaxres", "");
|
---|
[6827] | 175 | setValue_p("cmbSampl", "10");
|
---|
| 176 | setValue_p("cmbUseGlonass", "");
|
---|
[4251] | 177 | // Upload (clk)
|
---|
| 178 | setValue_p("uploadMountpointsOut","");
|
---|
| 179 | setValue_p("uploadIntr", "1 day");
|
---|
| 180 | setValue_p("uploadSamplRtcmEphCorr", "0");
|
---|
[6827] | 181 | setValue_p("uploadSamplSp3", "1");
|
---|
| 182 | setValue_p("uploadSamplClkRnx", "10");
|
---|
[4251] | 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("uploadEphHost", "");
|
---|
| 200 | setValue_p("uploadEphPort", "");
|
---|
[6827] | 201 | setValue_p("uploadAntexFile", "");
|
---|
[4251] | 202 | setValue_p("uploadEphMountpoint", "");
|
---|
| 203 | setValue_p("uploadEphPassword", "");
|
---|
| 204 | setValue_p("uploadEphSample", "5");
|
---|
| 205 | }
|
---|
[5080] | 206 | #ifdef GNSSCENTER_PLUGIN
|
---|
| 207 | settings.endGroup();
|
---|
| 208 | #endif
|
---|
[4251] | 209 | }
|
---|
| 210 |
|
---|
[4070] | 211 | //
|
---|
| 212 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 213 | QVariant bncSettings::value(const QString& key,
|
---|
| 214 | const QVariant& defaultValue) const {
|
---|
[4073] | 215 | QMutexLocker locker(&_mutex);
|
---|
| 216 |
|
---|
[5068] | 217 | if (BNC_CORE->_settings.contains(key)) {
|
---|
| 218 | return BNC_CORE->_settings[key];
|
---|
[4070] | 219 | }
|
---|
| 220 | else {
|
---|
| 221 | return defaultValue;
|
---|
| 222 | }
|
---|
| 223 | }
|
---|
| 224 |
|
---|
| 225 | //
|
---|
| 226 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 227 | void bncSettings::setValue(const QString &key, const QVariant& value) {
|
---|
[4078] | 228 | QMutexLocker locker(&_mutex);
|
---|
| 229 | setValue_p(key, value);
|
---|
| 230 | }
|
---|
| 231 |
|
---|
| 232 | //
|
---|
| 233 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 234 | void bncSettings::setValue_p(const QString &key, const QVariant& value) {
|
---|
[5068] | 235 | BNC_CORE->_settings[key] = value;
|
---|
[4070] | 236 | }
|
---|
| 237 |
|
---|
| 238 | //
|
---|
| 239 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 240 | void bncSettings::remove(const QString& key ) {
|
---|
[4073] | 241 | QMutexLocker locker(&_mutex);
|
---|
[5068] | 242 | BNC_CORE->_settings.remove(key);
|
---|
[4070] | 243 | }
|
---|
| 244 |
|
---|
| 245 | //
|
---|
| 246 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6411] | 247 | bool bncSettings::contains(const QString& key) const {
|
---|
| 248 | QMutexLocker locker(&_mutex);
|
---|
| 249 | return BNC_CORE->_settings.contains(key);
|
---|
| 250 | }
|
---|
| 251 |
|
---|
| 252 | //
|
---|
| 253 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4070] | 254 | void bncSettings::sync() {
|
---|
[4073] | 255 | QMutexLocker locker(&_mutex);
|
---|
[5068] | 256 | QSettings settings(BNC_CORE->confFileName(), QSettings::IniFormat);
|
---|
[4075] | 257 | settings.clear();
|
---|
[5068] | 258 | QMapIterator<QString, QVariant> it(BNC_CORE->_settings);
|
---|
[5080] | 259 | #ifdef GNSSCENTER_PLUGIN
|
---|
| 260 | settings.beginGroup("BNC");
|
---|
| 261 | #endif
|
---|
[4075] | 262 | while (it.hasNext()) {
|
---|
| 263 | it.next();
|
---|
| 264 | settings.setValue(it.key(), it.value());
|
---|
| 265 | }
|
---|
[5080] | 266 | #ifdef GNSSCENTER_PLUGIN
|
---|
| 267 | settings.endGroup();
|
---|
| 268 | #endif
|
---|
[4075] | 269 | settings.sync();
|
---|
[4070] | 270 | }
|
---|