[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 |
|
---|
[5080] | 47 | #ifdef GNSSCENTER_PLUGIN
|
---|
| 48 | settings.beginGroup("BNC");
|
---|
| 49 | #endif
|
---|
| 50 |
|
---|
[4251] | 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();
|
---|
[5068] | 57 | BNC_CORE->_settings[key] = settings.value(key);
|
---|
[4251] | 58 | }
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | // Set Defaults
|
---|
| 62 | // ------------
|
---|
| 63 | else {
|
---|
| 64 | setValue_p("startTab", "0");
|
---|
| 65 | setValue_p("statusTab", "0");
|
---|
[6828] | 66 | setValue_p("font", "");
|
---|
[7297] | 67 | setValue_p("casterUrlList", (QStringList()
|
---|
| 68 | << "http://user:pass@www.euref-ip.net:2101"
|
---|
| 69 | << "http://user:pass@www.igs-ip.net:2101"
|
---|
[4251] | 70 | << "http://user:pass@products.igs-ip.net:2101"
|
---|
| 71 | << "http://user:pass@mgex.igs-ip.net:2101"));
|
---|
| 72 | setValue_p("mountPoints", "");
|
---|
[7175] | 73 | setValue_p("ntripVersion", "2");
|
---|
[4251] | 74 | // Network
|
---|
| 75 | setValue_p("proxyHost", "");
|
---|
| 76 | setValue_p("proxyPort", "");
|
---|
| 77 | setValue_p("sslCaCertPath", "");
|
---|
[7513] | 78 | setValue_p("sslIgnoreErrors", "0");
|
---|
[4251] | 79 | // General
|
---|
| 80 | setValue_p("logFile", "");
|
---|
| 81 | setValue_p("rnxAppend", "0");
|
---|
[8119] | 82 | setValue_p("onTheFlyInterval", "no");
|
---|
[4251] | 83 | setValue_p("autoStart", "0");
|
---|
| 84 | setValue_p("rawOutFile", "");
|
---|
| 85 | // RINEX Observations
|
---|
| 86 | setValue_p("rnxPath", "");
|
---|
| 87 | setValue_p("rnxIntr", "1 day");
|
---|
[6827] | 88 | setValue_p("rnxOnlyWithSKL", "");
|
---|
[8397] | 89 | setValue_p("rnxSampl", "1 sec");
|
---|
[4251] | 90 | setValue_p("rnxSkel", "SKL");
|
---|
[6827] | 91 | setValue_p("rnxV2Priority", "");
|
---|
[4251] | 92 | setValue_p("rnxScript", "");
|
---|
| 93 | setValue_p("rnxV3", "0");
|
---|
| 94 | // RINEX Ephemeris
|
---|
| 95 | setValue_p("ephPath", "");
|
---|
| 96 | setValue_p("ephIntr", "1 day");
|
---|
[7326] | 97 | setValue_p("ephOutPort", "");
|
---|
[4251] | 98 | setValue_p("ephV3", "0");
|
---|
[6827] | 99 | // Reqc
|
---|
| 100 | setValue_p("reqcAction", "");
|
---|
| 101 | setValue_p("reqcObsFile", "");
|
---|
| 102 | setValue_p("reqcNavFile", "");
|
---|
| 103 | setValue_p("reqcOutObsFile", "");
|
---|
| 104 | setValue_p("reqcOutNavFile", "");
|
---|
| 105 | setValue_p("reqcOutLogFile", "");
|
---|
[8171] | 106 | setValue_p("reqcSkyPlotSignals", "C:2&7 E:1&5 G:1&2 J:1&2 R:1&2 S:1&5 I:5&9");
|
---|
[6827] | 107 | setValue_p("reqcPlotDir", "");
|
---|
| 108 | setValue_p("reqcRnxVersion", "");
|
---|
[8397] | 109 | setValue_p("reqcSampling", "1 sec");
|
---|
[8354] | 110 | setValue_p("reqcStartDateTime", "1967-11-02T00:00:00");
|
---|
| 111 | setValue_p("reqcEndDateTime", "2099-01-01T00:00:00");
|
---|
[6827] | 112 | setValue_p("reqcLogSummaryOnly", "");
|
---|
| 113 | setValue_p("reqcRunBy", "");
|
---|
| 114 | setValue_p("reqcComment", "");
|
---|
| 115 | setValue_p("reqcOldMarkerName", "");
|
---|
| 116 | setValue_p("reqcNewMarkerName", "");
|
---|
| 117 | setValue_p("reqcOldAntennaName", "");
|
---|
| 118 | setValue_p("reqcNewAntennaName", "");
|
---|
| 119 | setValue_p("reqcOldReceiverName", "");
|
---|
| 120 | setValue_p("reqcNewReceiverName", "");
|
---|
[8010] | 121 | setValue_p("reqcOldAntennaNumber", "");
|
---|
[6827] | 122 | setValue_p("reqcNewAntennaNumber","");
|
---|
[8010] | 123 | setValue_p("reqcOldAntennadE", "");
|
---|
[6827] | 124 | setValue_p("reqcNewAntennadE", "");
|
---|
[8010] | 125 | setValue_p("reqcOldAntennadN", "");
|
---|
[6827] | 126 | setValue_p("reqcNewAntennadN", "");
|
---|
[8010] | 127 | setValue_p("reqcOldAntennadU", "");
|
---|
[6827] | 128 | setValue_p("reqcNewAntennadU", "");
|
---|
[8010] | 129 | setValue_p("reqcOldReceiverNumber", "");
|
---|
[6827] | 130 | setValue_p("reqcNewReceiverNumber", "");
|
---|
| 131 | setValue_p("reqcUseObsTypes", "");
|
---|
[8128] | 132 | 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_");
|
---|
[7297] | 133 | // SP3
|
---|
[6827] | 134 | setValue_p("sp3CompFile", "");
|
---|
| 135 | setValue_p("sp3CompExclude", "");
|
---|
| 136 | setValue_p("sp3CompOutLogFile", "");
|
---|
[4251] | 137 | // Braodcast Corrections
|
---|
| 138 | setValue_p("corrPath", "");
|
---|
| 139 | setValue_p("corrIntr", "1 day");
|
---|
| 140 | setValue_p("corrPort", "");
|
---|
| 141 | // Feed Engine
|
---|
| 142 | setValue_p("outPort", "");
|
---|
[7390] | 143 | setValue_p("outWait", "5");
|
---|
[8397] | 144 | setValue_p("outSampl", "1 sec");
|
---|
[4251] | 145 | setValue_p("outFile", "");
|
---|
| 146 | setValue_p("outUPort", "");
|
---|
| 147 | // Serial Output
|
---|
| 148 | setValue_p("serialMountPoint", "");
|
---|
| 149 | setValue_p("serialPortName", "");
|
---|
| 150 | setValue_p("serialBaudRate", "9600");
|
---|
| 151 | setValue_p("serialFlowControl", "OFF");
|
---|
| 152 | setValue_p("serialDataBits", "8");
|
---|
| 153 | setValue_p("serialParity", "NONE");
|
---|
| 154 | setValue_p("serialStopBits", "1");
|
---|
| 155 | setValue_p("serialAutoNMEA", "Auto");
|
---|
| 156 | setValue_p("serialFileNMEA", "");
|
---|
| 157 | setValue_p("serialHeightNMEA", "");
|
---|
[6827] | 158 | setValue_p("serialManualNMEASampling", "");
|
---|
[4251] | 159 | // Outages
|
---|
[7330] | 160 | setValue_p("adviseObsRate", "");
|
---|
[4251] | 161 | setValue_p("adviseFail", "15");
|
---|
| 162 | setValue_p("adviseReco", "5");
|
---|
| 163 | setValue_p("adviseScript", "");
|
---|
| 164 | // Miscellaneous
|
---|
[7297] | 165 | setValue_p("miscMount", "");
|
---|
[7418] | 166 | setValue_p("miscIntr", "");
|
---|
| 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", "");
|
---|
[6827] | 173 | setValue_p("cmbSampl", "10");
|
---|
| 174 | setValue_p("cmbUseGlonass", "");
|
---|
[4251] | 175 | // Upload (clk)
|
---|
| 176 | setValue_p("uploadMountpointsOut","");
|
---|
| 177 | setValue_p("uploadIntr", "1 day");
|
---|
| 178 | setValue_p("uploadSamplRtcmEphCorr", "0");
|
---|
[6827] | 179 | setValue_p("uploadSamplSp3", "1");
|
---|
| 180 | setValue_p("uploadSamplClkRnx", "10");
|
---|
[4251] | 181 | setValue_p("trafo_dx", "");
|
---|
| 182 | setValue_p("trafo_dy", "");
|
---|
| 183 | setValue_p("trafo_dz", "");
|
---|
| 184 | setValue_p("trafo_dxr", "");
|
---|
| 185 | setValue_p("trafo_dyr", "");
|
---|
| 186 | setValue_p("trafo_dzr", "");
|
---|
| 187 | setValue_p("trafo_ox", "");
|
---|
| 188 | setValue_p("trafo_oy", "");
|
---|
| 189 | setValue_p("trafo_oz", "");
|
---|
| 190 | setValue_p("trafo_oxr", "");
|
---|
| 191 | setValue_p("trafo_oyr", "");
|
---|
| 192 | setValue_p("trafo_ozr", "");
|
---|
| 193 | setValue_p("trafo_sc", "");
|
---|
| 194 | setValue_p("trafo_scr", "");
|
---|
| 195 | setValue_p("trafo_t0", "");
|
---|
| 196 | // Upload (eph)
|
---|
[7889] | 197 | setValue_p("uploadEphMountpointsOut","");
|
---|
| 198 | setValue_p("uploadSamplRtcmEph", "0");
|
---|
[4251] | 199 | }
|
---|
[5080] | 200 | #ifdef GNSSCENTER_PLUGIN
|
---|
| 201 | settings.endGroup();
|
---|
| 202 | #endif
|
---|
[4251] | 203 | }
|
---|
| 204 |
|
---|
[7297] | 205 | //
|
---|
[4070] | 206 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 207 | QVariant bncSettings::value(const QString& key,
|
---|
| 208 | const QVariant& defaultValue) const {
|
---|
[4073] | 209 | QMutexLocker locker(&_mutex);
|
---|
| 210 |
|
---|
[5068] | 211 | if (BNC_CORE->_settings.contains(key)) {
|
---|
| 212 | return BNC_CORE->_settings[key];
|
---|
[4070] | 213 | }
|
---|
| 214 | else {
|
---|
| 215 | return defaultValue;
|
---|
| 216 | }
|
---|
| 217 | }
|
---|
| 218 |
|
---|
[7297] | 219 | //
|
---|
[4070] | 220 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 221 | void bncSettings::setValue(const QString &key, const QVariant& value) {
|
---|
[4078] | 222 | QMutexLocker locker(&_mutex);
|
---|
| 223 | setValue_p(key, value);
|
---|
| 224 | }
|
---|
| 225 |
|
---|
[7297] | 226 | //
|
---|
[4078] | 227 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 228 | void bncSettings::setValue_p(const QString &key, const QVariant& value) {
|
---|
[5068] | 229 | BNC_CORE->_settings[key] = value;
|
---|
[4070] | 230 | }
|
---|
| 231 |
|
---|
[7297] | 232 | //
|
---|
[4070] | 233 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 234 | void bncSettings::remove(const QString& key ) {
|
---|
[4073] | 235 | QMutexLocker locker(&_mutex);
|
---|
[5068] | 236 | BNC_CORE->_settings.remove(key);
|
---|
[4070] | 237 | }
|
---|
| 238 |
|
---|
[7297] | 239 | //
|
---|
[4070] | 240 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6411] | 241 | bool bncSettings::contains(const QString& key) const {
|
---|
| 242 | QMutexLocker locker(&_mutex);
|
---|
| 243 | return BNC_CORE->_settings.contains(key);
|
---|
| 244 | }
|
---|
| 245 |
|
---|
[7297] | 246 | //
|
---|
[6411] | 247 | ////////////////////////////////////////////////////////////////////////////
|
---|
[4070] | 248 | void bncSettings::sync() {
|
---|
[4073] | 249 | QMutexLocker locker(&_mutex);
|
---|
[5068] | 250 | QSettings settings(BNC_CORE->confFileName(), QSettings::IniFormat);
|
---|
[4075] | 251 | settings.clear();
|
---|
[5068] | 252 | QMapIterator<QString, QVariant> it(BNC_CORE->_settings);
|
---|
[5080] | 253 | #ifdef GNSSCENTER_PLUGIN
|
---|
| 254 | settings.beginGroup("BNC");
|
---|
| 255 | #endif
|
---|
[4075] | 256 | while (it.hasNext()) {
|
---|
| 257 | it.next();
|
---|
| 258 | settings.setValue(it.key(), it.value());
|
---|
| 259 | }
|
---|
[5080] | 260 | #ifdef GNSSCENTER_PLUGIN
|
---|
| 261 | settings.endGroup();
|
---|
| 262 | #endif
|
---|
[4075] | 263 | settings.sync();
|
---|
[4070] | 264 | }
|
---|