[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 | *
|
---|
[7297] | 13 | * Changes:
|
---|
[1535] | 14 | *
|
---|
| 15 | * -----------------------------------------------------------------------*/
|
---|
| 16 |
|
---|
[4072] | 17 | #include <QSettings>
|
---|
| 18 |
|
---|
[1535] | 19 | #include "bncsettings.h"
|
---|
[5070] | 20 | #include "bnccore.h"
|
---|
[1535] | 21 |
|
---|
[7297] | 22 | QMutex bncSettings::_mutex; // static mutex
|
---|
[4073] | 23 |
|
---|
[1535] | 24 | // Constructor
|
---|
| 25 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4077] | 26 | bncSettings::bncSettings() {
|
---|
[4073] | 27 | QMutexLocker locker(&_mutex);
|
---|
[1536] | 28 |
|
---|
[4070] | 29 | // First fill the options
|
---|
[7297] | 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 | QSettings settings(BNC_CORE->confFileName(), QSettings::IniFormat);
|
---|
[4251] | 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();
|
---|
[5068] | 53 | BNC_CORE->_settings[key] = settings.value(key);
|
---|
[4251] | 54 | }
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | // Set Defaults
|
---|
| 58 | // ------------
|
---|
| 59 | else {
|
---|
| 60 | setValue_p("startTab", "0");
|
---|
| 61 | setValue_p("statusTab", "0");
|
---|
[6828] | 62 | setValue_p("font", "");
|
---|
[7297] | 63 | setValue_p("casterUrlList", (QStringList()
|
---|
[9404] | 64 | << "http://user:pass@euref-ip.net:2101"
|
---|
| 65 | << "http://user:pass@igs-ip.net:2101"
|
---|
[4251] | 66 | << "http://user:pass@products.igs-ip.net:2101"
|
---|
| 67 | << "http://user:pass@mgex.igs-ip.net:2101"));
|
---|
| 68 | setValue_p("mountPoints", "");
|
---|
[9292] | 69 | setValue_p("ntripVersion", "2");
|
---|
[4251] | 70 | // Network
|
---|
| 71 | setValue_p("proxyHost", "");
|
---|
| 72 | setValue_p("proxyPort", "");
|
---|
| 73 | setValue_p("sslCaCertPath", "");
|
---|
[9795] | 74 | setValue_p("sslClientCertPath", "");
|
---|
[9292] | 75 | setValue_p("sslIgnoreErrors", "0");
|
---|
[4251] | 76 | // General
|
---|
| 77 | setValue_p("logFile", "");
|
---|
[9292] | 78 | setValue_p("rnxAppend", "0");
|
---|
| 79 | setValue_p("onTheFlyInterval", "no");
|
---|
| 80 | setValue_p("autoStart", "0");
|
---|
[4251] | 81 | setValue_p("rawOutFile", "");
|
---|
| 82 | // RINEX Observations
|
---|
| 83 | setValue_p("rnxPath", "");
|
---|
[9292] | 84 | setValue_p("rnxIntr", "1 day");
|
---|
[6827] | 85 | setValue_p("rnxOnlyWithSKL", "");
|
---|
[9292] | 86 | setValue_p("rnxSampl", "1 sec");
|
---|
| 87 | setValue_p("rnxSkel", "skl");
|
---|
[9184] | 88 | setValue_p("rnxSkelPath", "");
|
---|
[6827] | 89 | setValue_p("rnxV2Priority", "");
|
---|
[4251] | 90 | setValue_p("rnxScript", "");
|
---|
[9760] | 91 | setValue_p("rnxVersion", "3");
|
---|
[4251] | 92 | // RINEX Ephemeris
|
---|
| 93 | setValue_p("ephPath", "");
|
---|
[9292] | 94 | setValue_p("ephIntr", "1 day");
|
---|
[7326] | 95 | setValue_p("ephOutPort", "");
|
---|
[9760] | 96 | setValue_p("ephVersion", "3");
|
---|
[6827] | 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", "");
|
---|
[9424] | 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");
|
---|
[6827] | 105 | setValue_p("reqcPlotDir", "");
|
---|
| 106 | setValue_p("reqcRnxVersion", "");
|
---|
[8397] | 107 | setValue_p("reqcSampling", "1 sec");
|
---|
[8354] | 108 | setValue_p("reqcStartDateTime", "1967-11-02T00:00:00");
|
---|
| 109 | setValue_p("reqcEndDateTime", "2099-01-01T00:00:00");
|
---|
[6827] | 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", "");
|
---|
[8010] | 119 | setValue_p("reqcOldAntennaNumber", "");
|
---|
[6827] | 120 | setValue_p("reqcNewAntennaNumber","");
|
---|
[8010] | 121 | setValue_p("reqcOldAntennadE", "");
|
---|
[6827] | 122 | setValue_p("reqcNewAntennadE", "");
|
---|
[8010] | 123 | setValue_p("reqcOldAntennadN", "");
|
---|
[6827] | 124 | setValue_p("reqcNewAntennadN", "");
|
---|
[8010] | 125 | setValue_p("reqcOldAntennadU", "");
|
---|
[6827] | 126 | setValue_p("reqcNewAntennadU", "");
|
---|
[8010] | 127 | setValue_p("reqcOldReceiverNumber", "");
|
---|
[6827] | 128 | setValue_p("reqcNewReceiverNumber", "");
|
---|
| 129 | setValue_p("reqcUseObsTypes", "");
|
---|
[9850] | 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");
|
---|
[7297] | 131 | // SP3
|
---|
[6827] | 132 | setValue_p("sp3CompFile", "");
|
---|
| 133 | setValue_p("sp3CompExclude", "");
|
---|
| 134 | setValue_p("sp3CompOutLogFile", "");
|
---|
[10105] | 135 | setValue_p("sp3CompSummaryOnly", "");
|
---|
[4251] | 136 | // Braodcast Corrections
|
---|
| 137 | setValue_p("corrPath", "");
|
---|
[9292] | 138 | setValue_p("corrIntr", "1 day");
|
---|
[4251] | 139 | setValue_p("corrPort", "");
|
---|
| 140 | // Feed Engine
|
---|
| 141 | setValue_p("outPort", "");
|
---|
[9292] | 142 | setValue_p("outWait", "5");
|
---|
| 143 | setValue_p("outSampl", "1 sec");
|
---|
[4251] | 144 | setValue_p("outFile", "");
|
---|
| 145 | setValue_p("outUPort", "");
|
---|
[9292] | 146 | setValue_p("outLockTime", "0");
|
---|
[4251] | 147 | // Serial Output
|
---|
| 148 | setValue_p("serialMountPoint", "");
|
---|
| 149 | setValue_p("serialPortName", "");
|
---|
[9854] | 150 | setValue_p("serialBaudRate", "9600");
|
---|
[4251] | 151 | setValue_p("serialFlowControl", "OFF");
|
---|
[9854] | 152 | setValue_p("serialDataBits", "8");
|
---|
| 153 | setValue_p("serialParity", "NONE");
|
---|
| 154 | setValue_p("serialStopBits", "1");
|
---|
| 155 | setValue_p("serialAutoNMEA", "Auto");
|
---|
[4251] | 156 | setValue_p("serialFileNMEA", "");
|
---|
| 157 | setValue_p("serialHeightNMEA", "");
|
---|
[10420] | 158 | setValue_p("serialNMEASampling", "10");
|
---|
[4251] | 159 | // Outages
|
---|
[7330] | 160 | setValue_p("adviseObsRate", "");
|
---|
[9854] | 161 | setValue_p("adviseFail", "15");
|
---|
| 162 | setValue_p("adviseReco", "5");
|
---|
[4251] | 163 | setValue_p("adviseScript", "");
|
---|
| 164 | // Miscellaneous
|
---|
[7297] | 165 | setValue_p("miscMount", "");
|
---|
[7418] | 166 | setValue_p("miscIntr", "");
|
---|
[9854] | 167 | setValue_p("miscScanRTCM", "0");
|
---|
[7297] | 168 | setValue_p("miscPort", "");
|
---|
[4251] | 169 | // Combination
|
---|
[7297] | 170 | setValue_p("cmbStreams", "");
|
---|
[4251] | 171 | setValue_p("cmbMethod", "");
|
---|
| 172 | setValue_p("cmbMaxres", "");
|
---|
[10451] | 173 | setValue_p("cmbMaxdisplacement", "");
|
---|
[9292] | 174 | setValue_p("cmbSampl", "10");
|
---|
| 175 | setValue_p("cmbGps", "2");
|
---|
| 176 | setValue_p("cmbGlo", "2");
|
---|
| 177 | setValue_p("cmbGal", "2");
|
---|
| 178 | setValue_p("cmbBds", "2");
|
---|
| 179 | setValue_p("cmbQzss", "0");
|
---|
| 180 | setValue_p("cmbSbas", "0");
|
---|
| 181 | setValue_p("cmbIrnss", "0");
|
---|
| 182 |
|
---|
[4251] | 183 | // Upload (clk)
|
---|
| 184 | setValue_p("uploadMountpointsOut","");
|
---|
[9292] | 185 | setValue_p("uploadIntr", "1 day");
|
---|
[4251] | 186 | setValue_p("uploadSamplRtcmEphCorr", "0");
|
---|
[10157] | 187 | setValue_p("uploadSamplSp3", "0 sec");
|
---|
| 188 | setValue_p("uploadSamplClkRnx", "0");
|
---|
| 189 | setValue_p("uploadSamplBiaSnx", "0");
|
---|
[4251] | 190 | setValue_p("trafo_dx", "");
|
---|
| 191 | setValue_p("trafo_dy", "");
|
---|
| 192 | setValue_p("trafo_dz", "");
|
---|
| 193 | setValue_p("trafo_dxr", "");
|
---|
| 194 | setValue_p("trafo_dyr", "");
|
---|
| 195 | setValue_p("trafo_dzr", "");
|
---|
| 196 | setValue_p("trafo_ox", "");
|
---|
| 197 | setValue_p("trafo_oy", "");
|
---|
| 198 | setValue_p("trafo_oz", "");
|
---|
| 199 | setValue_p("trafo_oxr", "");
|
---|
| 200 | setValue_p("trafo_oyr", "");
|
---|
| 201 | setValue_p("trafo_ozr", "");
|
---|
| 202 | setValue_p("trafo_sc", "");
|
---|
| 203 | setValue_p("trafo_scr", "");
|
---|
| 204 | setValue_p("trafo_t0", "");
|
---|
| 205 | // Upload (eph)
|
---|
[7889] | 206 | setValue_p("uploadEphMountpointsOut","");
|
---|
[8870] | 207 | setValue_p("uploadSamplRtcmEph", "5");
|
---|
[4251] | 208 | }
|
---|
| 209 | }
|
---|
| 210 |
|
---|
[7297] | 211 | //
|
---|
[4070] | 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 |
|
---|
[7297] | 225 | //
|
---|
[4070] | 226 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 227 | void bncSettings::setValue(const QString &key, const QVariant& value) {
|
---|
[4078] | 228 | QMutexLocker locker(&_mutex);
|
---|
| 229 | setValue_p(key, value);
|
---|
| 230 | }
|
---|
| 231 |
|
---|
[7297] | 232 | //
|
---|
[4078] | 233 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 234 | void bncSettings::setValue_p(const QString &key, const QVariant& value) {
|
---|
[5068] | 235 | BNC_CORE->_settings[key] = value;
|
---|
[4070] | 236 | }
|
---|
| 237 |
|
---|
[7297] | 238 | //
|
---|
[4070] | 239 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 240 | void bncSettings::remove(const QString& key ) {
|
---|
[4073] | 241 | QMutexLocker locker(&_mutex);
|
---|
[5068] | 242 | BNC_CORE->_settings.remove(key);
|
---|
[4070] | 243 | }
|
---|
| 244 |
|
---|
[7297] | 245 | //
|
---|
[4070] | 246 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6411] | 247 | bool bncSettings::contains(const QString& key) const {
|
---|
| 248 | QMutexLocker locker(&_mutex);
|
---|
| 249 | return BNC_CORE->_settings.contains(key);
|
---|
| 250 | }
|
---|
| 251 |
|
---|
[7297] | 252 | //
|
---|
[6411] | 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);
|
---|
[9854] | 259 |
|
---|
[4075] | 260 | while (it.hasNext()) {
|
---|
| 261 | it.next();
|
---|
| 262 | settings.setValue(it.key(), it.value());
|
---|
| 263 | }
|
---|
[9854] | 264 |
|
---|
[4075] | 265 | settings.sync();
|
---|
[4070] | 266 | }
|
---|