Subversion Repositories Projects

Rev

Rev 227 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 KeyOz 1
/***************************************************************************
2
 *   Copyright (C) 2008 by Manuel Schrape                                  *
3
 *   manuel.schrape@gmx.de                                                 *
4
 *                                                                         *
5
 *   This program is free software; you can redistribute it and/or modify  *
6
 *   it under the terms of the GNU General Public License as published by  *
7
 *   the Free Software Foundation; either version 2 of the License.        *
8
 *                                                                         *
9
 *   This program is distributed in the hope that it will be useful,       *
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12
 *   GNU General Public License for more details.                          *
13
 *                                                                         *
14
 *   You should have received a copy of the GNU General Public License     *
15
 *   along with this program; if not, write to the                         *
16
 *   Free Software Foundation, Inc.,                                       *
17
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
18
 ***************************************************************************/
19
#include <QCoreApplication>
20
#include <QSettings>
21
#include <QDir>
22
 
23
#include "cSettings.h"
24
 
25
cSettings::cSettings()
26
{
27
    read_SettingsID();
28
 
29
    if (Settings_ID < 3)
30
    {
31
        QBitArray Def_TabViews;
32
        Def_TabViews.fill(true, 6);
33
 
34
        qDebug("Konvertiere Einstellungen Version 1+2 -> 3");
35
        QSettings Setting("KeyOz-Net", "QMK-Groundstation");
36
 
37
        Setting.beginGroup("GUI");
38
            GUI.TabViews    = Setting.value("TabViews", QBitArray(Def_TabViews)).value<QBitArray>();
39
 
40
            GUI.TabViews.resize(10);
41
            GUI.TabViews[6] = true;
42
 
43
            Setting.setValue("TabViews", QBitArray(GUI.TabViews));
44
        Setting.endGroup();
45
    }
46
 
47
    read_Settings();
48
 
49
    Analog1.LogView.resize(MaxAnalog);
50
    Analog1.PlotView.resize(MaxAnalog);
51
 
52
    // Alte Settingsstruktur Löschen.
53
    if (Settings_ID < 2)
54
    {
55
        qDebug("Konvertiere Einstellungen Version 1 -> 2");
56
        QSettings Setting("KeyOz-Net", "QMK-Groundstation");
57
 
58
        Setting.beginGroup("AnalogWerte");
59
            for (int a = 0; a < MaxAnalog; a++)
60
            {
61
                Analog1.LogView.setBit(a, Setting.value(("Analog_" + QString("%1").arg(a) + "_Log"),   Def_Log[a]).toBool());
62
                Analog1.PlotView.setBit(a, Setting.value(("Analog_" + QString("%1").arg(a) + "_Plot"),   Def_Plot_Show[a]).toBool());
63
                Analog1.Label[a] = Setting.value(("Analog_" + QString("%1").arg(a)), Def_AnalogNames[a]).toString();
64
            }
65
        Setting.endGroup();
66
 
67
        Setting.remove("AnalogWerte-FC");
68
        Setting.remove("AnalogWerte");
69
 
70
        write_Settings_Analog();
71
        write_Settings_AnalogLabels();
72
    }
73
    else
74
    {
75
        read_Settings_Analog();
76
        read_Settings_AnalogLabels();
77
    }
78
 
79
    Settings_ID = 3;
80
}
81
 
82
// Config der Analogwert-Anzeige (Plotter / CVS)
83
void cSettings::write_Settings_Analog(int ID)
84
{
85
    QString Hardware = HardwareType[ID];
86
 
87
    QSettings Setting("KeyOz-Net", "QMK-Groundstation");
88
 
89
    Setting.beginGroup("Analog-Werte");
90
        Setting.setValue(Hardware + "-LogView",  QBitArray(Analog1.LogView));
91
        Setting.setValue(Hardware + "-PlotView", QBitArray(Analog1.PlotView));
92
    Setting.endGroup();
93
}
94
 
95
void cSettings::read_Settings_Analog(int ID)
96
{
97
    QBitArray Def_View;
98
    Def_View.fill(true,MaxAnalog);
99
 
100
    QString Hardware = HardwareType[ID];
101
 
102
    QSettings Setting("KeyOz-Net", "QMK-Groundstation");
103
 
104
    Setting.beginGroup("Analog-Werte");
105
        Analog1.LogView  = Setting.value(Hardware + "-LogView", QBitArray(Def_View)).value<QBitArray>();
106
        Analog1.PlotView = Setting.value(Hardware + "-PlotView", QBitArray(Def_View)).value<QBitArray>();
107
    Setting.endGroup();
108
}
109
 
110
// Labels der Analogwerte.
111
void cSettings::write_Settings_AnalogLabels(int ID)
112
{
113
    QString Hardware = HardwareType[ID];
114
 
115
    QSettings Setting("KeyOz-Net", "QMK-Groundstation-Labels");
116
 
117
    Setting.beginGroup("Analog-Labels-" + Hardware);
118
        Setting.setValue("Version", Analog1.Version);
119
        for (int a=0; a<MaxAnalog; a++)
120
        {
121
            Setting.setValue("Label_" + QString("%1").arg(a), Analog1.Label[a]);
122
        }
123
    Setting.endGroup();
124
}
125
 
126
void cSettings::read_Settings_AnalogLabels(int ID)
127
{
128
    QString Hardware = HardwareType[ID];
129
 
130
    QSettings Setting("KeyOz-Net", "QMK-Groundstation-Labels");
131
 
132
    Setting.beginGroup("Analog-Labels-" + Hardware);
133
        Analog1.Version  = Setting.value(("Version"), "0").toString();
134
        for (int a=0; a<MaxAnalog; a++)
135
        {
136
            Analog1.Label[a]  = Setting.value(("Label_" + QString("%1").arg(a)), Def_AnalogNames[a]).toString();
137
        }
138
    Setting.endGroup();
139
}
140
 
141
// Programmeinstellungen
142
void cSettings::read_SettingsID()
143
{
144
    QSettings Setting("KeyOz-Net", "QMK-Groundstation");
145
 
146
    Setting.beginGroup("Global");
147
        Settings_ID  = Setting.value("Settings ID", 1).toInt();
148
    Setting.endGroup();
149
}
150
 
151
 
152
// Programmeinstellungen
153
void cSettings::read_Settings()
154
{
155
    QBitArray Def_BitArray;
156
    Def_BitArray.fill(true, 10);
157
 
158
    QDir Dir;
159
 
160
    QString HomeDir = (QString(Dir.homePath() + "/"));
161
 
162
    QSettings Setting("KeyOz-Net", "QMK-Groundstation");
163
 
164
    Setting.beginGroup("Global");
165
        Settings_ID  = Setting.value("Settings ID", 1).toInt();
166
    Setting.endGroup();
167
 
168
    Setting.beginGroup("Port");
169
        TTY.Port     = Setting.value("TTY", QString(OS_PORT)).toString();
170
    Setting.endGroup();
171
 
172
    Setting.beginGroup("GUI");
173
        GUI.isMax       = Setting.value("IsMax",false).toBool();
174
        GUI.Size        = Setting.value("Size", QSize(700, 300)).toSize();
175
        GUI.Point       = Setting.value("Point",QPoint(1,1)).toPoint();
176
        GUI.TabViews    = Setting.value("TabViews", QBitArray(Def_BitArray)).value<QBitArray>();
177
        GUI.ToolViews   = Setting.value("ToolViews", QBitArray(Def_BitArray)).value<QBitArray>();
178
        GUI.Term_Info   = Setting.value("Terminal_Info",false).toBool();
179
        GUI.Term_Data   = Setting.value("Terminal_Data",true).toBool();
180
        GUI.Term_Always = Setting.value("Terminal_Always",false).toBool();
181
        GUI.Term_Send   = Setting.value("Terminal_Send",true).toBool();
182
    Setting.endGroup();
183
 
184
    Setting.beginGroup("Dirs");
185
        DIR.Logging   = Setting.value("LogDir", HomeDir).toString();
186
        DIR.Parameter = Setting.value("ParDir", HomeDir).toString();
187
    Setting.endGroup();
188
 
189
    Setting.beginGroup("MKData");
190
        Data.Plotter_Count  = Setting.value("Plotter_Count", 100).toInt();
191
        Data.Debug_Fast     = Setting.value("Debug_Fast", 100).toInt();
192
        Data.Debug_Slow     = Setting.value("Debug_Slow", 500).toInt();
193
        Data.Debug_Off      = Setting.value("Debug_Off", 1000).toInt();
194
        Data.Navi_Fast      = Setting.value("Navi_Fast", 100).toInt();
195
        Data.Navi_Slow      = Setting.value("Navi_Slow", 500).toInt();
196
        Data.Navi_Off       = Setting.value("Navi_Off", 1000).toInt();
197
    Setting.endGroup();
198
 
199
    Setting.beginGroup("GoogleEarth-Server");
200
        Server.Port        = Setting.value("Port", 10664).toString();
201
        Server.StartServer = Setting.value("StartServer", false).toBool();
202
        Server.ToGround    = Setting.value("ToGround",  false).toBool();
203
    Setting.endGroup();
204
 
205
    Setting.beginGroup("QMK-Server");
206
        Server.QMKS_Login    = Setting.value("Login", "").toString();
207
        Server.QMKS_Password = Setting.value("Password", "").toString();
208
    Setting.endGroup();
209
 
210
}
211
 
212
void cSettings::write_Settings()
213
{
214
    QSettings Setting("KeyOz-Net", "QMK-Groundstation");
215
 
216
    Setting.beginGroup("Global");
217
        Setting.setValue("Settings ID", Settings_ID);
218
    Setting.endGroup();
219
 
220
    Setting.beginGroup("Port");
221
        Setting.setValue("TTY", TTY.Port);
222
    Setting.endGroup();
223
 
224
    Setting.beginGroup("Dirs");
225
        Setting.setValue("LogDir", DIR.Logging);
226
        Setting.setValue("ParDir", DIR.Parameter);
227
    Setting.endGroup();
228
 
229
    Setting.beginGroup("GUI");
230
        Setting.setValue("IsMax", GUI.isMax);
231
        Setting.setValue("Size", GUI.Size);
232
        Setting.setValue("Point", GUI.Point);
233
        Setting.setValue("TabViews", QBitArray(GUI.TabViews));
234
        Setting.setValue("ToolViews", QBitArray(GUI.ToolViews));
235
        Setting.setValue("Terminal_Info", GUI.Term_Info);
236
        Setting.setValue("Terminal_Data", GUI.Term_Data);
237
        Setting.setValue("Terminal_Always", GUI.Term_Always);
238
        Setting.setValue("Terminal_Send", GUI.Term_Send);
239
    Setting.endGroup();
240
 
241
    Setting.beginGroup("MKData");
242
        Setting.setValue("Plotter_Count", Data.Plotter_Count);
243
        Setting.setValue("Debug_Fast", Data.Debug_Fast);
244
        Setting.setValue("Debug_Slow", Data.Debug_Slow);
245
        Setting.setValue("Debug_Off",  Data.Debug_Off);
246
        Setting.setValue("Navi_Fast", Data.Navi_Fast);
247
        Setting.setValue("Navi_Slow", Data.Navi_Slow);
248
        Setting.setValue("Navi_Off",  Data.Navi_Off);
249
    Setting.endGroup();
250
 
251
    Setting.beginGroup("GoogleEarth-Server");
252
        Setting.setValue("Port", Server.Port);
253
        Setting.setValue("StartServer", Server.StartServer);
254
        Setting.setValue("ToGround",  Server.ToGround);
255
    Setting.endGroup();
256
 
257
    Setting.beginGroup("QMK-Server");
258
        Setting.setValue("Login", Server.QMKS_Login);
259
        Setting.setValue("Password", Server.QMKS_Password);
260
    Setting.endGroup();
261
}
262
 
263
cSettings::~cSettings()
264
{
265
}
266
 
267