Subversion Repositories Projects

Rev

Rev 279 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 279 Rev 305
1
/***************************************************************************
1
/***************************************************************************
2
 *   Copyright (C) 2008 by Manuel Schrape                                  *
2
 *   Copyright (C) 2008 by Manuel Schrape                                  *
3
 *   manuel.schrape@gmx.de                                                 *
3
 *   manuel.schrape@gmx.de                                                 *
4
 *                                                                         *
4
 *                                                                         *
5
 *   This program is free software; you can redistribute it and/or modify  *
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  *
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.        *
7
 *   the Free Software Foundation; either version 2 of the License.        *
8
 *                                                                         *
8
 *                                                                         *
9
 *   This program is distributed in the hope that it will be useful,       *
9
 *   This program is distributed in the hope that it will be useful,       *
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12
 *   GNU General Public License for more details.                          *
12
 *   GNU General Public License for more details.                          *
13
 *                                                                         *
13
 *                                                                         *
14
 *   You should have received a copy of the GNU General Public License     *
14
 *   You should have received a copy of the GNU General Public License     *
15
 *   along with this program; if not, write to the                         *
15
 *   along with this program; if not, write to the                         *
16
 *   Free Software Foundation, Inc.,                                       *
16
 *   Free Software Foundation, Inc.,                                       *
17
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
17
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
18
 ***************************************************************************/
18
 ***************************************************************************/
19
 
19
 
20
// TODO: Wiederholungssenden wieder einbauen
20
// TODO: Wiederholungssenden wieder einbauen
21
 
21
 
22
#include <QtGui>
22
#include <QtGui>
23
 
23
 
24
#include <QLineEdit>
24
#include <QLineEdit>
25
#include <QString>
25
#include <QString>
26
#include <QTimer>
26
#include <QTimer>
27
#include <QIcon>
27
#include <QIcon>
28
#include <QToolButton>
28
#include <QToolButton>
29
#include <QSpinBox>
29
#include <QSpinBox>
30
#include <QAction>
30
#include <QAction>
31
#include <QPalette>
31
#include <QPalette>
32
 
32
 
33
#include "mktool.h"
33
#include "mktool.h"
34
#include "dlg_Config.h"
34
#include "dlg_Config.h"
35
#include "dlg_Motortest.h"
35
#include "dlg_Motortest.h"
36
#include "dlg_Preferences.h"
36
#include "dlg_Preferences.h"
37
#include "../global.h"
37
#include "../global.h"
38
#include "../Classes/ToolBox.h"
38
#include "../Classes/ToolBox.h"
39
 
39
 
40
#include <stdlib.h>
40
#include <stdlib.h>
41
 
41
 
42
MKTool::MKTool()
42
MKTool::MKTool()
43
{
43
{
44
    setupUi(this);
44
    setupUi(this);
45
 
45
 
46
    Settings = new cSettings;
46
    Settings = new cSettings;
47
 
47
 
48
    init_Arrays();
48
    init_Arrays();
49
    init_GUI();
49
    init_GUI();
50
 
50
 
51
    init_Objects();
51
    init_Objects();
52
    init_Connections();
52
    init_Connections();
53
 
53
 
54
    init_Plot();
54
    init_Plot();
55
}
55
}
56
 
56
 
57
void MKTool::init_GUI()
57
void MKTool::init_GUI()
58
{
58
{
59
    setWindowTitle(QA_NAME + " v" + QA_VERSION);
59
    setWindowTitle(QA_NAME + " v" + QA_VERSION);
60
 
60
 
61
    // Tab mit Debug-Elementen verbergen
61
    // Tab mit Debug-Elementen verbergen
62
    tab_Main->removeTab(6);
62
    tab_Main->removeTab(6);
63
    // Develop - Nicht gebrauchte sachen abschalten.
63
    // Develop - Nicht gebrauchte sachen abschalten.
64
    pb_SettingsReset->hide();
64
    pb_SettingsReset->hide();
65
    pb_Flash->hide();
65
    pb_Flash->hide();
66
    rb_NC->hide();
66
    rb_NC->hide();
67
 
67
 
68
    // Beta-Sachen einschalten.
68
    // Beta-Sachen einschalten.
69
#ifdef _BETA_
69
#ifdef _BETA_
70
    ac_QMKServer->setEnabled(true);
70
    ac_QMKServer->setEnabled(true);
71
#endif
71
#endif
72
 
-
 
73
    // Settings-Tab hinzufügen.
72
    // Settings-Tab hinzufügen.
74
    f_Settings = new wdg_Settings( this );
73
    f_Settings = new wdg_Settings( this );
75
    f_Settings->set_Config(Settings);
74
    f_Settings->set_Config(Settings);
76
    tab_Main->insertTab ( 2, f_Settings, ac_View2->icon(), "FC-Settings");
75
    tab_Main->insertTab ( 2, f_Settings, ac_View2->icon(), "FC-Settings");
77
    tab_Main->widget(2)->setObjectName("Tab_2");
76
    tab_Main->widget(2)->setObjectName("Tab_2");
78
 
77
 
79
    // Zusätzliche Widgets in die Toolbar.
78
    // Zusätzliche Widgets in die Toolbar.
80
    tb_TTY->addWidget(lb_Port);
79
    tb_TTY->addWidget(lb_Port);
81
    tb_TTY->addWidget(le_Port);
80
    tb_TTY->addWidget(le_Port);
82
 
81
 
83
    tb_Hardware->addWidget(rb_SelFC);
82
    tb_Hardware->addWidget(rb_SelFC);
84
    tb_Hardware->addWidget(rb_SelNC);
83
    tb_Hardware->addWidget(rb_SelNC);
85
    tb_Hardware->addWidget(rb_SelMag);
84
    tb_Hardware->addWidget(rb_SelMag);
86
 
85
 
87
    tb_Allgemein->setVisible(Settings->GUI.ToolViews[0]);
86
    tb_Allgemein->setVisible(Settings->GUI.ToolViews[0]);
88
    tb_Werkzeuge->setVisible(Settings->GUI.ToolViews[1]);
87
    tb_Werkzeuge->setVisible(Settings->GUI.ToolViews[1]);
89
    tb_Debug->setVisible(Settings->GUI.ToolViews[2]);
88
    tb_Debug->setVisible(Settings->GUI.ToolViews[2]);
90
    tb_TTY->setVisible(Settings->GUI.ToolViews[3]);
89
    tb_TTY->setVisible(Settings->GUI.ToolViews[3]);
91
    tb_Hardware->setVisible(Settings->GUI.ToolViews[4]);
90
    tb_Hardware->setVisible(Settings->GUI.ToolViews[4]);
92
 
91
 
93
#ifdef _EEEPC_
92
#ifdef _EEEPC_
94
    lb_Status->hide();
93
    lb_Status->hide();
95
#endif
94
#endif
96
 
95
 
97
    lb_Status->setText(tr("Hallo bei QMK-Groundstation...!!!"));
96
    lb_Status->setText(tr("Hallo bei QMK-Groundstation...!!!"));
98
 
97
 
99
    // Cockpit-Elemente
98
    // Cockpit-Elemente
100
    QPalette newPalette;
99
    QPalette newPalette;
101
 
100
 
102
    newPalette.setColor(QPalette::Base, Qt::darkBlue);
101
    newPalette.setColor(QPalette::Base, Qt::darkBlue);
103
    newPalette.setColor(QPalette::Foreground, QColor(Qt::darkBlue).dark(120));
102
    newPalette.setColor(QPalette::Foreground, QColor(Qt::darkBlue).dark(120));
104
    newPalette.setColor(QPalette::Text, Qt::white);
103
    newPalette.setColor(QPalette::Text, Qt::white);
105
 
104
 
106
    Compass->setScaleOptions(QwtDial::ScaleTicks | QwtDial::ScaleLabel);
105
    Compass->setScaleOptions(QwtDial::ScaleTicks | QwtDial::ScaleLabel);
107
    Compass->setScaleTicks(0, 0, 3);
106
    Compass->setScaleTicks(0, 0, 3);
108
    Compass->setScale(36, 5, 0);
107
    Compass->setScale(36, 5, 0);
109
 
108
 
110
    Compass->setNeedle(new QwtDialSimpleNeedle(QwtDialSimpleNeedle::Arrow, true, Qt::red, QColor(Qt::gray).light(130)));
109
    Compass->setNeedle(new QwtDialSimpleNeedle(QwtDialSimpleNeedle::Arrow, true, Qt::red, QColor(Qt::gray).light(130)));
111
    Compass->setPalette(newPalette);
110
    Compass->setPalette(newPalette);
112
    Compass->setMaximumSize(QSize(MeterSize, MeterSize));
111
    Compass->setMaximumSize(QSize(MeterSize, MeterSize));
113
    Compass->setMinimumSize(QSize(MeterSize, MeterSize));
112
    Compass->setMinimumSize(QSize(MeterSize, MeterSize));
114
 
113
 
115
    QPalette newPalette1;
114
    QPalette newPalette1;
116
 
115
 
117
    newPalette1.setColor(QPalette::Base, Qt::darkBlue);
116
    newPalette1.setColor(QPalette::Base, Qt::darkBlue);
118
    newPalette1.setColor(QPalette::Foreground, QColor(255,128,0).dark(120));
117
    newPalette1.setColor(QPalette::Foreground, QColor(255,128,0).dark(120));
119
    newPalette1.setColor(QPalette::Text, Qt::white);
118
    newPalette1.setColor(QPalette::Text, Qt::white);
120
 
119
 
121
    Attitude = new AttitudeIndicator(this);
120
    Attitude = new AttitudeIndicator(this);
122
    Attitude->setMaximumSize(QSize(MeterSize, MeterSize));
121
    Attitude->setMaximumSize(QSize(MeterSize, MeterSize));
123
    Attitude->setMinimumSize(QSize(MeterSize, MeterSize));
122
    Attitude->setMinimumSize(QSize(MeterSize, MeterSize));
124
    Attitude->setPalette(newPalette1);
123
    Attitude->setPalette(newPalette1);
125
 
124
 
126
    verticalLayout->addWidget(Attitude);
125
    verticalLayout->addWidget(Attitude);
127
 
126
 
128
    qwt_Rate->setRange(-10.0, 10.0, 0.1, 0);
127
    qwt_Rate->setRange(-10.0, 10.0, 0.1, 0);
129
 
128
 
130
    newPalette1.setColor(QPalette::Foreground, QColor(Qt::darkBlue).dark(120));
129
    newPalette1.setColor(QPalette::Foreground, QColor(Qt::darkBlue).dark(120));
131
 
130
 
132
    SpeedMeter = new cSpeedMeter(this);
131
    SpeedMeter = new cSpeedMeter(this);
133
    SpeedMeter->setMaximumSize(QSize(MeterSize, MeterSize));
132
    SpeedMeter->setMaximumSize(QSize(MeterSize, MeterSize));
134
    SpeedMeter->setMinimumSize(QSize(MeterSize, MeterSize));
133
    SpeedMeter->setMinimumSize(QSize(MeterSize, MeterSize));
135
    SpeedMeter->setPalette(newPalette1);
134
    SpeedMeter->setPalette(newPalette1);
136
    SpeedMeter->setRange(0.0, 5.0);
135
    SpeedMeter->setRange(0.0, 5.0);
137
    SpeedMeter->setScale(1, 2, 0.5);
136
    SpeedMeter->setScale(1, 2, 0.5);
138
    SpeedMeter->setProperty("END", 5);
137
    SpeedMeter->setProperty("END", 5);
139
 
138
 
140
    LayOut_Speed->addWidget(SpeedMeter);
139
    LayOut_Speed->addWidget(SpeedMeter);
141
 
140
 
142
    resize(Settings->GUI.Size);
141
    resize(Settings->GUI.Size);
143
    move(Settings->GUI.Point);
142
    move(Settings->GUI.Point);
144
 
143
 
145
    if (Settings->GUI.isMax)
144
    if (Settings->GUI.isMax)
146
    {
145
    {
147
        showMaximized();
146
        showMaximized();
148
    }
147
    }
149
 
148
 
150
    // Analoglabels anzeigen
149
    // Analoglabels anzeigen
151
    for (int a = 0; a < MaxAnalog; a++)
150
    for (int a = 0; a < MaxAnalog; a++)
152
    {
151
    {
153
        lb_Analog[a]->setText(Settings->Analog1.Label[a]);
152
        lb_Analog[a]->setText(Settings->Analog1.Label[a]);
154
    }
153
    }
155
 
154
 
156
    // Kopie der Tabs anlegen
155
    // Kopie der Tabs anlegen
157
    for (int b = 0; b < 7; b++)
156
    for (int b = 0; b < 7; b++)
158
    {
157
    {
159
        TabWidgets[b] = tab_Main->widget(b);
158
        TabWidgets[b] = tab_Main->widget(b);
160
    }
159
    }
161
 
160
 
162
    // Ausgeblendete Tabs ausblenden
161
    // Ausgeblendete Tabs ausblenden
163
    for (int c = 0; c < 7; c++)
162
    for (int c = 0; c < 7; c++)
164
    {
163
    {
165
        if (Settings->GUI.TabViews[c] == false)
164
        if (Settings->GUI.TabViews[c] == false)
166
        {
165
        {
167
            QString TabName = QString("Tab_%1").arg(c);
166
            QString TabName = QString("Tab_%1").arg(c);
168
 
167
 
169
            for (int d = 0; d < tab_Main->count(); d++)
168
            for (int d = 0; d < tab_Main->count(); d++)
170
            {
169
            {
171
                if (tab_Main->widget(d)->objectName() == TabName)
170
                if (tab_Main->widget(d)->objectName() == TabName)
172
                {
171
                {
173
                    tab_Main->removeTab(d);
172
                    tab_Main->removeTab(d);
174
                }
173
                }
175
            }
174
            }
176
        }
175
        }
177
    }
176
    }
178
 
177
 
179
    ac_View0->setChecked(Settings->GUI.TabViews[0]);
178
    ac_View0->setChecked(Settings->GUI.TabViews[0]);
180
    ac_View1->setChecked(Settings->GUI.TabViews[1]);
179
    ac_View1->setChecked(Settings->GUI.TabViews[1]);
181
    ac_View2->setChecked(Settings->GUI.TabViews[2]);
180
    ac_View2->setChecked(Settings->GUI.TabViews[2]);
182
    ac_View3->setChecked(Settings->GUI.TabViews[3]);
181
    ac_View3->setChecked(Settings->GUI.TabViews[3]);
183
    ac_View4->setChecked(Settings->GUI.TabViews[4]);
182
    ac_View4->setChecked(Settings->GUI.TabViews[4]);
184
    ac_View5->setChecked(Settings->GUI.TabViews[5]);
183
    ac_View5->setChecked(Settings->GUI.TabViews[5]);
185
    ac_View6->setChecked(Settings->GUI.TabViews[6]);
184
    ac_View6->setChecked(Settings->GUI.TabViews[6]);
186
 
185
 
187
    le_Port->setText(Settings->TTY.Port);
186
    le_Port->setText(Settings->TTY.Port);
188
 
187
 
189
    cb_ShowMSG->setChecked(Settings->GUI.Term_Info);
188
    cb_ShowMSG->setChecked(Settings->GUI.Term_Info);
190
    cb_ShowData->setChecked(Settings->GUI.Term_Data);
189
    cb_ShowData->setChecked(Settings->GUI.Term_Data);
191
    cb_ShowAlways->setChecked(Settings->GUI.Term_Always);
190
    cb_ShowAlways->setChecked(Settings->GUI.Term_Always);
192
}
191
}
193
 
192
 
194
void MKTool::init_Objects()
193
void MKTool::init_Objects()
195
{
194
{
196
    // QTimer-Instanzen
195
    // QTimer-Instanzen
197
    Ticker = new QTimer(this);
196
    Ticker = new QTimer(this);
198
 
197
 
199
    Conn = new cConnection();
198
    Conn = new cConnection();
200
 
199
 
201
    // neuer Logger
200
    // neuer Logger
202
    logger = new Logger(Settings, &Mode);
201
    logger = new Logger(Settings, &Mode);
203
 
202
 
204
    // LCD-Dialog
203
    // LCD-Dialog
205
    f_LCD = new dlg_LCD(this);
204
    f_LCD = new dlg_LCD(this);
-
 
205
 
-
 
206
    // LCD-Dialog
-
 
207
    f_Map = new dlg_Map(this);
206
 
208
 
207
    GE_Server = new cServer();
209
    GE_Server = new cServer();
208
 
210
 
209
    QMK_Server = new cQMK_Server();
211
    QMK_Server = new cQMK_Server();
210
    QMK_Server->setProperty("Connect", false);
212
    QMK_Server->setProperty("Connect", false);
211
 
213
 
212
    if (Settings->Server.StartServer)
214
    if (Settings->Server.StartServer)
213
    {
215
    {
214
        ac_StartServer->setChecked(true);
216
        ac_StartServer->setChecked(true);
215
        GE_Server->start_Server(Settings->Server.Port.toInt(), Settings);
217
        GE_Server->start_Server(Settings->Server.Port.toInt(), Settings);
216
    }
218
    }
217
}
219
}
218
 
220
 
219
void MKTool::init_Connections()
221
void MKTool::init_Connections()
220
{
222
{
221
    connect(Dec, SIGNAL(clicked()), this, SLOT(slot_Test()));
223
    connect(Dec, SIGNAL(clicked()), this, SLOT(slot_Test()));
222
 
224
 
223
    // Daten Senden / Empfangen
225
    // Daten Senden / Empfangen
224
    connect(Conn, SIGNAL(newData(sRxData)), this, SLOT(slot_newData(sRxData)));
226
    connect(Conn, SIGNAL(newData(sRxData)), this, SLOT(slot_newData(sRxData)));
225
    connect(Conn, SIGNAL(showTerminal(int, QString)), this, SLOT(slot_showTerminal(int, QString)));
227
    connect(Conn, SIGNAL(showTerminal(int, QString)), this, SLOT(slot_showTerminal(int, QString)));
226
 
228
 
227
    // Serielle Verbundung öffnen / schließen
229
    // Serielle Verbundung öffnen / schließen
228
    connect(ac_ConnectTTY, SIGNAL(triggered()), this, SLOT(slot_OpenPort()));
230
    connect(ac_ConnectTTY, SIGNAL(triggered()), this, SLOT(slot_OpenPort()));
229
 
231
 
230
    // TCP-Connection verbinden / trennen
232
    // TCP-Connection verbinden / trennen
231
    connect(ac_QMKServer, SIGNAL(triggered()), this, SLOT(slot_QMKS_Connect()));
233
    connect(ac_QMKServer, SIGNAL(triggered()), this, SLOT(slot_QMKS_Connect()));
232
 
234
 
233
    // Buttons Settings lesen / schreiben
235
    // Buttons Settings lesen / schreiben
234
    connect(f_Settings->pb_Read,   SIGNAL(clicked()), this, SLOT(slot_GetFCSettings()));
236
    connect(f_Settings->pb_Read,   SIGNAL(clicked()), this, SLOT(slot_GetFCSettings()));
235
    connect(f_Settings->pb_Write,  SIGNAL(clicked()), this, SLOT(slot_SetFCSettings()));
237
    connect(f_Settings->pb_Write,  SIGNAL(clicked()), this, SLOT(slot_SetFCSettings()));
236
 
238
 
237
    // Actions
239
    // Actions
238
    connect(ac_Config,       SIGNAL(triggered()), this, SLOT(slot_ac_Config()));
240
    connect(ac_Config,       SIGNAL(triggered()), this, SLOT(slot_ac_Config()));
239
    connect(ac_Preferences,  SIGNAL(triggered()), this, SLOT(slot_ac_Preferences()));
241
    connect(ac_Preferences,  SIGNAL(triggered()), this, SLOT(slot_ac_Preferences()));
240
    connect(ac_Motortest,    SIGNAL(triggered()), this, SLOT(slot_ac_Motortest()));
242
    connect(ac_Motortest,    SIGNAL(triggered()), this, SLOT(slot_ac_Motortest()));
241
    connect(ac_LCD,          SIGNAL(triggered()), this, SLOT(slot_ac_LCD()));
243
    connect(ac_LCD,          SIGNAL(triggered()), this, SLOT(slot_ac_LCD()));
-
 
244
    connect(ac_Map,          SIGNAL(triggered()), this, SLOT(slot_ac_Map()));
242
    connect(ac_FastDebug,    SIGNAL(triggered()), this, SLOT(slot_ac_FastDebug()));
245
    connect(ac_FastDebug,    SIGNAL(triggered()), this, SLOT(slot_ac_FastDebug()));
243
    connect(ac_NoDebug,      SIGNAL(triggered()), this, SLOT(slot_ac_NoDebug()));
246
    connect(ac_NoDebug,      SIGNAL(triggered()), this, SLOT(slot_ac_NoDebug()));
244
    connect(ac_FastNavi,     SIGNAL(triggered()), this, SLOT(slot_ac_FastNavi()));
247
    connect(ac_FastNavi,     SIGNAL(triggered()), this, SLOT(slot_ac_FastNavi()));
245
    connect(ac_NoNavi,       SIGNAL(triggered()), this, SLOT(slot_ac_NoNavi()));
248
    connect(ac_NoNavi,       SIGNAL(triggered()), this, SLOT(slot_ac_NoNavi()));
246
    connect(ac_GetLabels,    SIGNAL(triggered()), this, SLOT(slot_ac_GetLabels()));
249
    connect(ac_GetLabels,    SIGNAL(triggered()), this, SLOT(slot_ac_GetLabels()));
247
 
250
 
248
    // Plotter starten / scrollen
251
    // Plotter starten / scrollen
249
    connect(scroll_plot,     SIGNAL(valueChanged(int)), this, SLOT(slot_ScrollPlot(int)));
252
    connect(scroll_plot,     SIGNAL(valueChanged(int)), this, SLOT(slot_ScrollPlot(int)));
250
    connect(ac_StartPlotter, SIGNAL(triggered()), this, SLOT(slot_ac_StartPlotter()));
253
    connect(ac_StartPlotter, SIGNAL(triggered()), this, SLOT(slot_ac_StartPlotter()));
251
    connect(ac_StartServer,  SIGNAL(triggered()), this, SLOT(slot_ac_StartServer()));
254
    connect(ac_StartServer,  SIGNAL(triggered()), this, SLOT(slot_ac_StartServer()));
252
 
255
 
253
    // Tabs ein & ausblenden
256
    // Tabs ein & ausblenden
254
    connect(ac_View0,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
257
    connect(ac_View0,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
255
    connect(ac_View1,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
258
    connect(ac_View1,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
256
    connect(ac_View2,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
259
    connect(ac_View2,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
257
    connect(ac_View3,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
260
    connect(ac_View3,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
258
    connect(ac_View4,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
261
    connect(ac_View4,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
259
    connect(ac_View5,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
262
    connect(ac_View5,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
260
    connect(ac_View6,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
263
    connect(ac_View6,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
261
 
264
 
262
    connect(ac_SelNC,        SIGNAL(triggered()), this, SLOT(slot_ac_Hardware()));
265
    connect(ac_SelNC,        SIGNAL(triggered()), this, SLOT(slot_ac_Hardware()));
263
    connect(ac_SelFC,        SIGNAL(triggered()), this, SLOT(slot_ac_Hardware()));
266
    connect(ac_SelFC,        SIGNAL(triggered()), this, SLOT(slot_ac_Hardware()));
264
    connect(ac_SelMag,       SIGNAL(triggered()), this, SLOT(slot_ac_Hardware()));
267
    connect(ac_SelMag,       SIGNAL(triggered()), this, SLOT(slot_ac_Hardware()));
265
 
268
 
266
    connect(rb_SelNC,        SIGNAL(clicked()), this, SLOT(slot_rb_Hardware()));
269
    connect(rb_SelNC,        SIGNAL(clicked()), this, SLOT(slot_rb_Hardware()));
267
    connect(rb_SelFC,        SIGNAL(clicked()), this, SLOT(slot_rb_Hardware()));
270
    connect(rb_SelFC,        SIGNAL(clicked()), this, SLOT(slot_rb_Hardware()));
268
    connect(rb_SelMag,       SIGNAL(clicked()), this, SLOT(slot_rb_Hardware()));
271
    connect(rb_SelMag,       SIGNAL(clicked()), this, SLOT(slot_rb_Hardware()));
269
 
272
 
270
    // firmeware Updateen / flashen
273
    // firmeware Updateen / flashen
271
    connect(pb_Update,   SIGNAL(clicked()), this, SLOT(slot_pb_Update()));
274
    connect(pb_Update,   SIGNAL(clicked()), this, SLOT(slot_pb_Update()));
272
    connect(pb_HexFile,  SIGNAL(clicked()), this, SLOT(slot_pb_HexFile()));
275
    connect(pb_HexFile,  SIGNAL(clicked()), this, SLOT(slot_pb_HexFile()));
273
 
276
 
274
    // Wegpunkt-Befehl
277
    // Wegpunkt-Befehl
275
    connect(pb_FlyTo,        SIGNAL(clicked()), this, SLOT(slot_pb_SendWaypoint()));
278
    connect(pb_FlyTo,        SIGNAL(clicked()), this, SLOT(slot_pb_SendWaypoint()));
276
 
279
 
277
    // CVS-Record starten / stoppen
280
    // CVS-Record starten / stoppen
278
    connect(ac_RecordCSV,  SIGNAL(triggered()), this, SLOT(slot_RecordLog()));
281
    connect(ac_RecordCSV,  SIGNAL(triggered()), this, SLOT(slot_RecordLog()));
279
 
282
 
280
    // Timer-Events
283
    // Timer-Events
281
    connect(Ticker,   SIGNAL(timeout()),       SLOT(slot_Ticker()));
284
    connect(Ticker,   SIGNAL(timeout()),       SLOT(slot_Ticker()));
282
 
285
 
283
    // Seitenwechsel
286
    // Seitenwechsel
284
    connect(tab_Main,             SIGNAL(currentChanged(int)), this, SLOT(slot_TabChanged(int)));
287
    connect(tab_Main,             SIGNAL(currentChanged(int)), this, SLOT(slot_TabChanged(int)));
285
    connect(f_Settings->tab_Par,  SIGNAL(currentChanged(int)), this, SLOT(slot_TabChanged(int)));
288
    connect(f_Settings->tab_Par,  SIGNAL(currentChanged(int)), this, SLOT(slot_TabChanged(int)));
286
 
289
 
287
    // About QMK & About-QT Dialog einfügen
290
    // About QMK & About-QT Dialog einfügen
288
    connect(ac_About, SIGNAL(triggered()), this, SLOT(slot_ac_About()));
291
    connect(ac_About, SIGNAL(triggered()), this, SLOT(slot_ac_About()));
289
    menu_Help->addAction(trUtf8("Über &Qt"), qApp, SLOT(aboutQt()));
292
    menu_Help->addAction(trUtf8("Über &Qt"), qApp, SLOT(aboutQt()));
290
}
293
}
291
 
294
 
292
void MKTool::init_Arrays()
295
void MKTool::init_Arrays()
293
{
296
{
294
    lb_Analog[0]  = lb_A_0;
297
    lb_Analog[0]  = lb_A_0;
295
    lb_Analog[1]  = lb_A_1;
298
    lb_Analog[1]  = lb_A_1;
296
    lb_Analog[2]  = lb_A_2;
299
    lb_Analog[2]  = lb_A_2;
297
    lb_Analog[3]  = lb_A_3;
300
    lb_Analog[3]  = lb_A_3;
298
    lb_Analog[4]  = lb_A_4;
301
    lb_Analog[4]  = lb_A_4;
299
    lb_Analog[5]  = lb_A_5;
302
    lb_Analog[5]  = lb_A_5;
300
    lb_Analog[6]  = lb_A_6;
303
    lb_Analog[6]  = lb_A_6;
301
    lb_Analog[7]  = lb_A_7;
304
    lb_Analog[7]  = lb_A_7;
302
    lb_Analog[8]  = lb_A_8;
305
    lb_Analog[8]  = lb_A_8;
303
    lb_Analog[9]  = lb_A_9;
306
    lb_Analog[9]  = lb_A_9;
304
    lb_Analog[10] = lb_A_10;
307
    lb_Analog[10] = lb_A_10;
305
    lb_Analog[11] = lb_A_11;
308
    lb_Analog[11] = lb_A_11;
306
    lb_Analog[12] = lb_A_12;
309
    lb_Analog[12] = lb_A_12;
307
    lb_Analog[13] = lb_A_13;
310
    lb_Analog[13] = lb_A_13;
308
    lb_Analog[14] = lb_A_14;
311
    lb_Analog[14] = lb_A_14;
309
    lb_Analog[15] = lb_A_15;
312
    lb_Analog[15] = lb_A_15;
310
    lb_Analog[16] = lb_A_16;
313
    lb_Analog[16] = lb_A_16;
311
    lb_Analog[17] = lb_A_17;
314
    lb_Analog[17] = lb_A_17;
312
    lb_Analog[18] = lb_A_18;
315
    lb_Analog[18] = lb_A_18;
313
    lb_Analog[19] = lb_A_19;
316
    lb_Analog[19] = lb_A_19;
314
    lb_Analog[20] = lb_A_20;
317
    lb_Analog[20] = lb_A_20;
315
    lb_Analog[21] = lb_A_21;
318
    lb_Analog[21] = lb_A_21;
316
    lb_Analog[22] = lb_A_22;
319
    lb_Analog[22] = lb_A_22;
317
    lb_Analog[23] = lb_A_23;
320
    lb_Analog[23] = lb_A_23;
318
    lb_Analog[24] = lb_A_24;
321
    lb_Analog[24] = lb_A_24;
319
    lb_Analog[25] = lb_A_25;
322
    lb_Analog[25] = lb_A_25;
320
    lb_Analog[26] = lb_A_26;
323
    lb_Analog[26] = lb_A_26;
321
    lb_Analog[27] = lb_A_27;
324
    lb_Analog[27] = lb_A_27;
322
    lb_Analog[28] = lb_A_28;
325
    lb_Analog[28] = lb_A_28;
323
    lb_Analog[29] = lb_A_29;
326
    lb_Analog[29] = lb_A_29;
324
    lb_Analog[30] = lb_A_30;
327
    lb_Analog[30] = lb_A_30;
325
    lb_Analog[31] = lb_A_31;
328
    lb_Analog[31] = lb_A_31;
326
}
329
}
327
 
330
 
328
void MKTool::init_Plot()
331
void MKTool::init_Plot()
329
{
332
{
330
    NextPlot = 0;
333
    NextPlot = 0;
331
 
334
 
332
    qwtPlot->setCanvasBackground(QColor(QRgb(0x00000000)));
335
    qwtPlot->setCanvasBackground(QColor(QRgb(0x00000000)));
333
 
336
 
334
    qwtPlot->insertLegend(new QwtLegend(), QwtPlot::RightLegend);
337
    qwtPlot->insertLegend(new QwtLegend(), QwtPlot::RightLegend);
335
 
338
 
336
    QwtPlotGrid *Grid = new QwtPlotGrid();
339
    QwtPlotGrid *Grid = new QwtPlotGrid();
337
    Grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine));
340
    Grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine));
338
 
341
 
339
    Grid->attach(qwtPlot);
342
    Grid->attach(qwtPlot);
340
 
343
 
341
    qwtPlot->setAxisScale(QwtPlot::xBottom,0,Settings->Data.Plotter_Count,0);
344
    qwtPlot->setAxisScale(QwtPlot::xBottom,0,Settings->Data.Plotter_Count,0);
342
 
345
 
343
    for (int a = 0; a < MaxAnalog; a++)
346
    for (int a = 0; a < MaxAnalog; a++)
344
    {
347
    {
345
        Plot[a] = new QwtPlotCurve(Settings->Analog1.Label[a]);
348
        Plot[a] = new QwtPlotCurve(Settings->Analog1.Label[a]);
346
        Plot[a]->setPen(QPen(QColor(Def_Colors[a])));
349
        Plot[a]->setPen(QPen(QColor(Def_Colors[a])));
347
//        Plot[a]->setRenderHint(QwtPlotItem::RenderAntialiased);
350
//        Plot[a]->setRenderHint(QwtPlotItem::RenderAntialiased);
348
 
351
 
349
        if (Settings->Analog1.PlotView[a])
352
        if (Settings->Analog1.PlotView[a])
350
            Plot[a]->attach(qwtPlot);
353
            Plot[a]->attach(qwtPlot);
351
    }
354
    }
352
    qwtPlot->replot();
355
    qwtPlot->replot();
353
}
356
}
354
 
357
 
355
void MKTool::slot_Test()
358
void MKTool::slot_Test()
356
{
359
{
357
//    qDebug("Decode Data");
360
//    qDebug("Decode Data");
358
    sRxData RX;
361
    sRxData RX;
359
 
362
 
360
    RX.String = IN->text();
363
    RX.String = IN->text();
361
 
364
 
362
//    qDebug(RX.String.toLatin1().data());
365
//    qDebug(RX.String.toLatin1().data());
363
 
366
 
364
//    if (ToolBox::check_CRC(RX.String))
367
//    if (ToolBox::check_CRC(RX.String))
365
    {
368
    {
366
        qDebug("Decode Data CRC OK");
369
        qDebug("Decode Data CRC OK");
367
        RX.Input = RX.String.toLatin1().data();
370
        RX.Input = RX.String.toLatin1().data();
368
 
371
 
369
//        qDebug(RX.Input);
372
//        qDebug(RX.Input);
370
 
373
 
371
        slot_newData(RX);
374
        slot_newData(RX);
372
    }
375
    }
373
}
376
}
374
 
377
 
375
// KML-Datei nach Wegpunkt parsen
378
// KML-Datei nach Wegpunkt parsen
376
// TODO: Richtigen KML-Parser bauen
379
// TODO: Richtigen KML-Parser bauen
377
void MKTool::parse_TargetKML()
380
void MKTool::parse_TargetKML()
378
{
381
{
379
    QString Tmp = te_KML->toPlainText().simplified();
382
    QString Tmp = te_KML->toPlainText().simplified();
380
    QStringList List;
383
    QStringList List;
381
 
384
 
382
    if ((Tmp.contains("<kml xmlns=\"http://earth.google.com/kml/2.2\">"))  && (Tmp.contains("<coordinates>")))
385
    if ((Tmp.contains("<kml xmlns=\"http://earth.google.com/kml/2.2\">"))  && (Tmp.contains("<coordinates>")))
383
    {
386
    {
384
        List = Tmp.split("<coordinates>");
387
        List = Tmp.split("<coordinates>");
385
        List = List[1].split(",");
388
        List = List[1].split(",");
386
 
389
 
387
        le_TarLong->setText(ToolBox::get_Float((List[0].toDouble() * 10000000), 10000000));
390
        le_TarLong->setText(ToolBox::get_Float((List[0].toDouble() * 10000000), 10000000));
388
        le_TarLat->setText(ToolBox::get_Float((List[1].toDouble() * 10000000), 10000000));
391
        le_TarLat->setText(ToolBox::get_Float((List[1].toDouble() * 10000000), 10000000));
389
    }
392
    }
390
}
393
}
391
 
394
 
392
// Waypoint zur NC Senden.
395
// Waypoint zur NC Senden.
393
void MKTool::slot_pb_SendWaypoint()
396
void MKTool::slot_pb_SendWaypoint()
394
{
397
{
395
    if ((Navi.Current.Longitude == 0) && (Navi.Current.Latitude == 0))
398
    if ((Navi.Current.Longitude == 0) && (Navi.Current.Latitude == 0))
396
    {
399
    {
397
        QMessageBox msgB;
400
        QMessageBox msgB;
398
        QString msg;
401
        QString msg;
399
        msgB.setText("Fehler: Es konnten keine GPS-Daten vom Mikrokopter empfangen werden");
402
        msgB.setText("Fehler: Es konnten keine GPS-Daten vom Mikrokopter empfangen werden");
400
        msgB.exec();
403
        msgB.exec();
401
        return;
404
        return;
402
    }
405
    }
403
 
406
 
404
    //erstelle einen Wegpunkt, den die NaviCtrl auswerten kann
407
    //erstelle einen Wegpunkt, den die NaviCtrl auswerten kann
405
    Waypoint_t desired_pos;
408
    Waypoint_t desired_pos;
406
    bool ok_lat, ok_lon;
409
    bool ok_lat, ok_lon;
407
 
410
 
408
    //eingegebene Daten holen
411
    //eingegebene Daten holen
409
    double desired_long, desired_lat;
412
    double desired_long, desired_lat;
410
 
413
 
411
    desired_long = le_TarLong->text().toDouble(&ok_lon);
414
    desired_long = le_TarLong->text().toDouble(&ok_lon);
412
    desired_lat  = le_TarLat->text().toDouble(&ok_lat);
415
    desired_lat  = le_TarLat->text().toDouble(&ok_lat);
413
 
416
 
414
    if (ok_lon && desired_long < 100)
417
    if (ok_lon && desired_long < 100)
415
        desired_long *= 10000000+0.5;
418
        desired_long *= 10000000+0.5;
416
 
419
 
417
    if (ok_lat && desired_lat < 100)
420
    if (ok_lat && desired_lat < 100)
418
        desired_lat *= 10000000+0.5;
421
        desired_lat *= 10000000+0.5;
419
 
422
 
420
    //fülle Wegpunkt-Daten
423
    //fülle Wegpunkt-Daten
421
    desired_pos.Position.Altitude = 0;
424
    desired_pos.Position.Altitude = 0;
422
    desired_pos.Position.Longitude = int32_t(desired_long);
425
    desired_pos.Position.Longitude = int32_t(desired_long);
423
    desired_pos.Position.Latitude =  int32_t(desired_lat);
426
    desired_pos.Position.Latitude =  int32_t(desired_lat);
424
    desired_pos.Position.Status = NEWDATA;
427
    desired_pos.Position.Status = NEWDATA;
425
    desired_pos.Heading = -1;
428
    desired_pos.Heading = -1;
426
    desired_pos.ToleranceRadius = 1;
429
    desired_pos.ToleranceRadius = 1;
427
    desired_pos.HoldTime = 60;
430
    desired_pos.HoldTime = 60;
428
    desired_pos.Event_Flag = 0;
431
    desired_pos.Event_Flag = 0;
429
    desired_pos.reserve[0] = 0; // reserve
432
    desired_pos.reserve[0] = 0; // reserve
430
    desired_pos.reserve[1] = 0; // reserve
433
    desired_pos.reserve[1] = 0; // reserve
431
    desired_pos.reserve[2] = 0; // reserve
434
    desired_pos.reserve[2] = 0; // reserve
432
    desired_pos.reserve[3] = 0; // reserve
435
    desired_pos.reserve[3] = 0; // reserve
433
 
436
 
434
    //...und sende ihn an die NaviCtrl
437
    //...und sende ihn an die NaviCtrl
435
    int max_radius = 10000;
438
    int max_radius = 10000;
436
    if (ok_lat && ok_lon &&
439
    if (ok_lat && ok_lon &&
437
        abs(Navi.Current.Longitude - desired_pos.Position.Longitude) < max_radius &&
440
        abs(Navi.Current.Longitude - desired_pos.Position.Longitude) < max_radius &&
438
        abs(Navi.Current.Latitude  - desired_pos.Position.Latitude) < max_radius)
441
        abs(Navi.Current.Latitude  - desired_pos.Position.Latitude) < max_radius)
439
    {
442
    {
440
            Conn->send_Cmd('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false);
443
            Conn->send_Cmd('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false);
441
    }
444
    }
442
    else
445
    else
443
    {
446
    {
444
        QMessageBox msgB;
447
        QMessageBox msgB;
445
        QString msg;
448
        QString msg;
446
        msg += "Bitte die Eingabe ueberpruefen!\n";
449
        msg += "Bitte die Eingabe ueberpruefen!\n";
447
        msg += "Die Werte muessen sich in der Naehe der aktuellen Koordinaten befinden\n";
450
        msg += "Die Werte muessen sich in der Naehe der aktuellen Koordinaten befinden\n";
448
        msg += "(Lon: ";
451
        msg += "(Lon: ";
449
        msg += ToolBox::get_Float(Navi.Current.Longitude,10000000);
452
        msg += ToolBox::get_Float(Navi.Current.Longitude,10000000);
450
        msg += ", ";
453
        msg += ", ";
451
        msg += "Lat: ";
454
        msg += "Lat: ";
452
        msg += ToolBox::get_Float(Navi.Current.Latitude,10000000);
455
        msg += ToolBox::get_Float(Navi.Current.Latitude,10000000);
453
        msg += ")";
456
        msg += ")";
454
        msgB.setText(msg);
457
        msgB.setText(msg);
455
        msgB.exec();
458
        msgB.exec();
456
    }
459
    }
457
}
460
}
458
 
461
 
459
void MKTool::slot_ac_Hardware()
462
void MKTool::slot_ac_Hardware()
460
{
463
{
461
    QAction *Action = (QAction*)sender();
464
    QAction *Action = (QAction*)sender();
462
 
465
 
463
    if (Action->isChecked() == false)
466
    if (Action->isChecked() == false)
464
    {
467
    {
465
        Action->setChecked(true);
468
        Action->setChecked(true);
466
    }
469
    }
467
 
470
 
468
    slot_rb_Hardware();
471
    slot_rb_Hardware();
469
}
472
}
470
 
473
 
471
void MKTool::slot_rb_Hardware()
474
void MKTool::slot_rb_Hardware()
472
{
475
{
473
    if ((rb_SelNC->isChecked() == false) && (Mode.ID != ADDRESS_NC))
476
    if ((rb_SelNC->isChecked() == false) && (Mode.ID != ADDRESS_NC))
474
    {
477
    {
475
        lb_Status->setText(tr("Schalte um auf NaviCtrl."));
478
        lb_Status->setText(tr("Schalte um auf NaviCtrl."));
476
        TX_Data[0] = 0x1B;
479
        TX_Data[0] = 0x1B;
477
        TX_Data[1] = 0x1B;
480
        TX_Data[1] = 0x1B;
478
        TX_Data[2] = 0x55;
481
        TX_Data[2] = 0x55;
479
        TX_Data[3] = 0xAA;
482
        TX_Data[3] = 0xAA;
480
        TX_Data[4] = 0x00;
483
        TX_Data[4] = 0x00;
481
        TX_Data[5] = '\r';
484
        TX_Data[5] = '\r';
482
        Conn->send_Cmd('#', ADDRESS_NC, TX_Data, 6, false);
485
        Conn->send_Cmd('#', ADDRESS_NC, TX_Data, 6, false);
483
        ToolBox::Wait(SLEEP);
486
        ToolBox::Wait(SLEEP);
484
    }
487
    }
485
 
488
 
486
    if (rb_SelFC->isChecked())
489
    if (rb_SelFC->isChecked())
487
    {
490
    {
488
        lb_Status->setText(tr("Schalte um auf FlightCtrl."));
491
        lb_Status->setText(tr("Schalte um auf FlightCtrl."));
489
        TX_Data[0] = 0;
492
        TX_Data[0] = 0;
490
        Conn->send_Cmd('u', ADDRESS_NC, TX_Data, 1, false);
493
        Conn->send_Cmd('u', ADDRESS_NC, TX_Data, 1, false);
491
    }
494
    }
492
    else
495
    else
493
    if (rb_SelMag->isChecked())
496
    if (rb_SelMag->isChecked())
494
    {
497
    {
495
        lb_Status->setText(tr("Schalte um auf MK3MAG."));
498
        lb_Status->setText(tr("Schalte um auf MK3MAG."));
496
        TX_Data[0] = 1;
499
        TX_Data[0] = 1;
497
        Conn->send_Cmd('u', ADDRESS_NC, TX_Data, 1, false);
500
        Conn->send_Cmd('u', ADDRESS_NC, TX_Data, 1, false);
498
    }
501
    }
499
    else
502
    else
500
    if (rb_SelNC->isChecked())
503
    if (rb_SelNC->isChecked())
501
    {
504
    {
502
        lb_Status->setText(tr("Schalte um auf NaviCtrl."));
505
        lb_Status->setText(tr("Schalte um auf NaviCtrl."));
503
        TX_Data[0] = 0x1B;
506
        TX_Data[0] = 0x1B;
504
        TX_Data[1] = 0x1B;
507
        TX_Data[1] = 0x1B;
505
        TX_Data[2] = 0x55;
508
        TX_Data[2] = 0x55;
506
        TX_Data[3] = 0xAA;
509
        TX_Data[3] = 0xAA;
507
        TX_Data[4] = 0x00;
510
        TX_Data[4] = 0x00;
508
        TX_Data[5] = '\r';
511
        TX_Data[5] = '\r';
509
        Conn->send_Cmd('#', ADDRESS_NC, TX_Data, 6, false);
512
        Conn->send_Cmd('#', ADDRESS_NC, TX_Data, 6, false);
510
    }
513
    }
511
    ToolBox::Wait(SLEEP);
514
    ToolBox::Wait(SLEEP);
512
 
515
 
513
//    qDebug("Select RB Hardware");
516
//    qDebug("Select RB Hardware");
514
    Conn->send_Cmd('v', ADDRESS_ALL, TX_Data, 0, true);
517
    Conn->send_Cmd('v', ADDRESS_ALL, TX_Data, 0, true);
515
}
518
}
516
 
519
 
517
// Ticker-Event
520
// Ticker-Event
518
///////////////
521
///////////////
519
void MKTool::slot_Ticker()
522
void MKTool::slot_Ticker()
520
{
523
{
521
    if (TickerDiv)
524
    if (TickerDiv)
522
        TickerDiv = false;
525
        TickerDiv = false;
523
    else
526
    else
524
        TickerDiv = true;
527
        TickerDiv = true;
525
 
528
 
526
    if (cb_ClipBoard->isChecked())
529
    if (cb_ClipBoard->isChecked())
527
    {
530
    {
528
        QString s_OLD = te_KML->toPlainText();
531
        QString s_OLD = te_KML->toPlainText();
529
        te_KML->clear();
532
        te_KML->clear();
530
        te_KML->paste();
533
        te_KML->paste();
531
        if (s_OLD != te_KML->toPlainText())
534
        if (s_OLD != te_KML->toPlainText())
532
        {
535
        {
533
            parse_TargetKML();
536
            parse_TargetKML();
534
        }
537
        }
535
    }
538
    }
536
 
539
 
537
    for (int a = 0; a < MaxTickerEvents; a++)
540
    for (int a = 0; a < MaxTickerEvents; a++)
538
    {
541
    {
539
        if (TickerEvent[a] == true)
542
        if (TickerEvent[a] == true)
540
        {
543
        {
541
            switch(a)
544
            switch(a)
542
            {
545
            {
543
                case 0 :
546
                case 0 :
544
                    if (TickerDiv)
547
                    if (TickerDiv)
545
                    {
548
                    {
546
                        QByteArray Temp(LastSend.toUtf8());
549
                        QByteArray Temp(LastSend.toUtf8());
547
//                        serialPort->sendData(Temp);
550
//                        serialPort->sendData(Temp);
548
                    }
551
                    }
549
                break;
552
                break;
550
                case 1 :
553
                case 1 :
551
                    TX_Data[0] = 0;
554
                    TX_Data[0] = 0;
552
                    Conn->send_Cmd('p', ADDRESS_FC, TX_Data, 0, false);
555
                    Conn->send_Cmd('p', ADDRESS_FC, TX_Data, 0, false);
553
                break;
556
                break;
554
                case 2 :
557
                case 2 :
555
                    if (f_LCD->cb_LCD->isChecked())
558
                    if (f_LCD->cb_LCD->isChecked())
556
                    {
559
                    {
557
                        if (!f_LCD->isVisible())
560
                        if (!f_LCD->isVisible())
558
                        {
561
                        {
559
                            Ticker->setInterval(2000);
562
                            Ticker->setInterval(2000);
560
                            TickerEvent[2] = false;
563
                            TickerEvent[2] = false;
561
                        }
564
                        }
562
                        TX_Data[0] = LCD_Page;
565
                        TX_Data[0] = LCD_Page;
563
                        TX_Data[1] = 0;
566
                        TX_Data[1] = 0;
564
                        Conn->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true);
567
                        Conn->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true);
565
                    }
568
                    }
566
                break;
569
                break;
567
                case 3 :
570
                case 3 :
568
                    if (ac_FastDebug->isChecked())
571
                    if (ac_FastDebug->isChecked())
569
                    {
572
                    {
570
                        TX_Data[0] = Settings->Data.Debug_Fast / 10;
573
                        TX_Data[0] = Settings->Data.Debug_Fast / 10;
571
                        Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
574
                        Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
572
                    }
575
                    }
573
                    else
576
                    else
574
                    {
577
                    {
575
                        TX_Data[0] = Settings->Data.Debug_Slow / 10;
578
                        TX_Data[0] = Settings->Data.Debug_Slow / 10;
576
                        Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
579
                        Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
577
                    }
580
                    }
578
                break;
581
                break;
579
            }
582
            }
580
        }
583
        }
581
    }
584
    }
582
}
585
}
583
 
586
 
584
void MKTool::slot_QMKS_Connect()
587
void MKTool::slot_QMKS_Connect()
585
{
588
{
586
    if (ac_QMKServer->isChecked())
589
    if (ac_QMKServer->isChecked())
587
    {
590
    {
588
        lb_Status->setText(tr("Verbinde zum QMK-Datenserver."));
591
        lb_Status->setText(tr("Verbinde zum QMK-Datenserver."));
589
 
592
 
590
        QMK_Server->Connect(Settings->Server.QMKS_Host, Settings->Server.QMKS_Port.toInt(), Settings->Server.QMKS_Login, Settings->Server.QMKS_Password);
593
        QMK_Server->Connect(Settings->Server.QMKS_Host, Settings->Server.QMKS_Port.toInt(), Settings->Server.QMKS_Login, Settings->Server.QMKS_Password);
591
 
594
 
592
        connect(QMK_Server, SIGNAL(sig_Connected()), this, SLOT(slot_QMKS_Connected()));
595
        connect(QMK_Server, SIGNAL(sig_Connected()), this, SLOT(slot_QMKS_Connected()));
593
        connect(QMK_Server, SIGNAL(sig_Disconnected(int)), this, SLOT(slot_QMKS_Disconnected(int)));
596
        connect(QMK_Server, SIGNAL(sig_Disconnected(int)), this, SLOT(slot_QMKS_Disconnected(int)));
594
    }
597
    }
595
    else
598
    else
596
    {
599
    {
597
        if ((QMK_Server->property("Connect")) == true)
600
        if ((QMK_Server->property("Connect")) == true)
598
        {
601
        {
599
            disconnect(QMK_Server, SIGNAL(sig_Disconnected(int)), 0, 0);
602
            disconnect(QMK_Server, SIGNAL(sig_Disconnected(int)), 0, 0);
600
            lb_Status->setText(tr("Trenne vom QMK-Datenserver."));
603
            lb_Status->setText(tr("Trenne vom QMK-Datenserver."));
601
 
604
 
602
            QMK_Server->Disconnect();
605
            QMK_Server->Disconnect();
603
            QMK_Server->setProperty("Connect", false);
606
            QMK_Server->setProperty("Connect", false);
604
            ac_QMKServer->setText("QMK-Server Verbinden");
607
            ac_QMKServer->setText("QMK-Server Verbinden");
605
        }
608
        }
606
    }
609
    }
607
}
610
}
608
 
611
 
609
void MKTool::slot_QMKS_Connected()
612
void MKTool::slot_QMKS_Connected()
610
{
613
{
611
    QMK_Server->setProperty("Connect", true);
614
    QMK_Server->setProperty("Connect", true);
612
    ac_QMKServer->setText("QMK-Server Trennnen");
615
    ac_QMKServer->setText("QMK-Server Trennnen");
613
    lb_Status->setText(tr("Verbunden mit QMK-Datenserver."));
616
    lb_Status->setText(tr("Verbunden mit QMK-Datenserver."));
614
}
617
}
615
 
618
 
616
void MKTool::slot_QMKS_Disconnected(int Error)
619
void MKTool::slot_QMKS_Disconnected(int Error)
617
{
620
{
618
    QMK_Server->setProperty("Connect", false);
621
    QMK_Server->setProperty("Connect", false);
619
    ac_QMKServer->setText("QMK-Server Verbinden");
622
    ac_QMKServer->setText("QMK-Server Verbinden");
620
    ac_QMKServer->setChecked(false);
623
    ac_QMKServer->setChecked(false);
621
 
624
 
622
    disconnect(QMK_Server, SIGNAL(sig_Disconnected(int)), 0, 0);
625
    disconnect(QMK_Server, SIGNAL(sig_Disconnected(int)), 0, 0);
623
 
626
 
624
    switch (Error)
627
    switch (Error)
625
    {
628
    {
626
        case 1 :
629
        case 1 :
627
        {
630
        {
628
            lb_Status->setText(tr("Verbindung vom Server beendet."));
631
            lb_Status->setText(tr("Verbindung vom Server beendet."));
629
            QMessageBox::warning(this, QA_NAME,"QMK-Datenserver: Verbindung wurde vom Server beendet.", QMessageBox::Ok);
632
            QMessageBox::warning(this, QA_NAME,"QMK-Datenserver: Verbindung wurde vom Server beendet.", QMessageBox::Ok);
630
        }
633
        }
631
        break;
634
        break;
632
        case 2 :
635
        case 2 :
633
        {
636
        {
634
            lb_Status->setText(tr("Server nicht gefunden."));
637
            lb_Status->setText(tr("Server nicht gefunden."));
635
            QMessageBox::warning(this, QA_NAME,"QMK-Datenserver: Kann nicht zum Server verbinden.", QMessageBox::Ok);
638
            QMessageBox::warning(this, QA_NAME,"QMK-Datenserver: Kann nicht zum Server verbinden.", QMessageBox::Ok);
636
        }
639
        }
637
        break;
640
        break;
638
        case 3 :
641
        case 3 :
639
        {
642
        {
640
            lb_Status->setText(tr("Serververbindung getrennt. Logindaten falsch."));
643
            lb_Status->setText(tr("Serververbindung getrennt. Logindaten falsch."));
641
            QMessageBox::warning(this, QA_NAME,"QMK-Datenserver: Loginname oder Password falsch.", QMessageBox::Ok);
644
            QMessageBox::warning(this, QA_NAME,"QMK-Datenserver: Loginname oder Password falsch.", QMessageBox::Ok);
642
        }
645
        }
643
        break;
646
        break;
644
        default :
647
        default :
645
        {
648
        {
646
            lb_Status->setText(tr("Getrennt vom QMK-Datenserver."));
649
            lb_Status->setText(tr("Getrennt vom QMK-Datenserver."));
647
        }
650
        }
648
        break;
651
        break;
649
    }
652
    }
650
}
653
}
651
 
654
 
652
// Slots der Actions (Menüpunkte, Buttons)
655
// Slots der Actions (Menüpunkte, Buttons)
653
//////////////////////////////////////////
656
//////////////////////////////////////////
654
void MKTool::slot_ac_Motortest()
657
void MKTool::slot_ac_Motortest()
655
{
658
{
656
    dlg_Motortest *f_Motortest = new dlg_Motortest(this);
659
    dlg_Motortest *f_Motortest = new dlg_Motortest(this);
657
 
660
 
658
    connect(f_Motortest, SIGNAL(updateMotor(int, int, int, int)), this, SLOT(slot_Motortest(int, int, int, int)));
661
    connect(f_Motortest, SIGNAL(updateMotor(int, int, int, int)), this, SLOT(slot_Motortest(int, int, int, int)));
659
 
662
 
660
    if (f_Motortest->exec()==QDialog::Accepted)
663
    if (f_Motortest->exec()==QDialog::Accepted)
661
    {
664
    {
662
    }
665
    }
663
 
666
 
664
    disconnect(f_Motortest, 0,0,0);
667
    disconnect(f_Motortest, 0,0,0);
665
    slot_Motortest(0,0,0,0);
668
    slot_Motortest(0,0,0,0);
666
}
669
}
667
 
670
 
668
void MKTool::slot_ac_LCD()
671
void MKTool::slot_ac_LCD()
669
{
672
{
670
    if (!f_LCD->isVisible())
673
    if (!f_LCD->isVisible())
671
    {
674
    {
672
        f_LCD = new dlg_LCD(this);
675
        f_LCD = new dlg_LCD(this);
673
 
676
 
674
        // LCD auf / ab
677
        // LCD auf / ab
675
        connect(f_LCD->pb_LCDup,   SIGNAL(clicked()), this, SLOT(slot_LCD_UP()));
678
        connect(f_LCD->pb_LCDup,   SIGNAL(clicked()), this, SLOT(slot_LCD_UP()));
676
        connect(f_LCD->pb_LCDdown, SIGNAL(clicked()), this, SLOT(slot_LCD_DOWN()));
679
        connect(f_LCD->pb_LCDdown, SIGNAL(clicked()), this, SLOT(slot_LCD_DOWN()));
677
 
680
 
678
        f_LCD->show();
681
        f_LCD->show();
679
        TX_Data[0] = 0;
682
        TX_Data[0] = 0;
680
        TX_Data[1] = 0;
683
        TX_Data[1] = 0;
681
        Conn->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true);
684
        Conn->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true);
682
 
685
 
683
        Ticker->setInterval(500);
686
        Ticker->setInterval(500);
684
        TickerEvent[2] = true;
687
        TickerEvent[2] = true;
685
    }
688
    }
686
}
689
}
-
 
690
 
-
 
691
void MKTool::slot_ac_Map()
-
 
692
{
-
 
693
    if (!f_Map->isVisible())
-
 
694
    {
-
 
695
        f_Map = new dlg_Map(this);
-
 
696
 
-
 
697
        f_Map->show();
-
 
698
    }
-
 
699
}
-
 
700
 
687
 
701
 
688
void MKTool::slot_Motortest(int Motor1, int Motor2, int Motor3, int Motor4)
702
void MKTool::slot_Motortest(int Motor1, int Motor2, int Motor3, int Motor4)
689
{
703
{
690
    TX_Data[0] = Motor1;
704
    TX_Data[0] = Motor1;
691
    TX_Data[1] = Motor2;
705
    TX_Data[1] = Motor2;
692
    TX_Data[2] = Motor3;
706
    TX_Data[2] = Motor3;
693
    TX_Data[3] = Motor4;
707
    TX_Data[3] = Motor4;
694
    Conn->send_Cmd('t', ADDRESS_FC, TX_Data, 4, false);
708
    Conn->send_Cmd('t', ADDRESS_FC, TX_Data, 4, false);
695
}
709
}
696
 
710
 
697
void MKTool::slot_ac_Config()
711
void MKTool::slot_ac_Config()
698
{
712
{
699
    set_Analog Old_Analog1;
713
    set_Analog Old_Analog1;
700
 
714
 
701
    Old_Analog1 = Settings->Analog1;
715
    Old_Analog1 = Settings->Analog1;
702
 
716
 
703
    dlg_Config *f_Config = new dlg_Config(this);
717
    dlg_Config *f_Config = new dlg_Config(this);
704
    f_Config->set_Settings(Settings, Mode.ID);
718
    f_Config->set_Settings(Settings, Mode.ID);
705
 
719
 
706
    if (f_Config->exec()==QDialog::Accepted)
720
    if (f_Config->exec()==QDialog::Accepted)
707
    {
721
    {
708
        Settings = f_Config->get_Settings();
722
        Settings = f_Config->get_Settings();
709
        Settings->write_Settings_Analog(Mode.ID);
723
        Settings->write_Settings_Analog(Mode.ID);
710
 
724
 
711
        // Plotter neu einrichten
725
        // Plotter neu einrichten
712
        if (Old_Analog1.PlotView != Settings->Analog1.PlotView)
726
        if (Old_Analog1.PlotView != Settings->Analog1.PlotView)
713
        {
727
        {
714
            config_Plot();
728
            config_Plot();
715
        }
729
        }
716
 
730
 
717
        // CVS-Datei neu anlegen.
731
        // CVS-Datei neu anlegen.
718
        if ((logger->is_active()) && (Old_Analog1.LogView != Settings->Analog1.LogView))
732
        if ((logger->is_active()) && (Old_Analog1.LogView != Settings->Analog1.LogView))
719
        {
733
        {
720
            logger->close();
734
            logger->close();
721
            logger->start_Log();
735
            logger->start_Log();
722
        }
736
        }
723
 
737
 
724
    }
738
    }
725
}
739
}
726
 
740
 
727
//aktualisiere Logging-Status
741
//aktualisiere Logging-Status
728
void MKTool::update_Log()
742
void MKTool::update_Log()
729
{
743
{
730
    if (logger->is_active())
744
    if (logger->is_active())
731
    {
745
    {
732
 
746
 
733
        ac_RecordCSV->setText("Log Stop");
747
        ac_RecordCSV->setText("Log Stop");
734
        lb_Status->setText(tr("Log-Record gestartet."));
748
        lb_Status->setText(tr("Log-Record gestartet."));
735
    }
749
    }
736
    else
750
    else
737
    {
751
    {
738
        ac_RecordCSV->setText("Log Aufzeichnen");
752
        ac_RecordCSV->setText("Log Aufzeichnen");
739
        lb_Status->setText(tr("Log-Record gestopt."));
753
        lb_Status->setText(tr("Log-Record gestopt."));
740
    }
754
    }
741
}
755
}
742
 
756
 
743
//starte/stoppe Logging, wenn auf den entsprechenden Button gedrückt wurde
757
//starte/stoppe Logging, wenn auf den entsprechenden Button gedrückt wurde
744
void MKTool::slot_RecordLog()
758
void MKTool::slot_RecordLog()
745
{
759
{
746
    if (!logger->is_active())
760
    if (!logger->is_active())
747
        logger->start_Log();
761
        logger->start_Log();
748
    else
762
    else
749
        logger->close();
763
        logger->close();
750
 
764
 
751
    update_Log();
765
    update_Log();
752
}
766
}
753
 
767
 
754
void MKTool::slot_ac_Preferences()
768
void MKTool::slot_ac_Preferences()
755
{
769
{
756
    dlg_Preferences *f_Preferences = new dlg_Preferences(this);
770
    dlg_Preferences *f_Preferences = new dlg_Preferences(this);
757
 
771
 
758
    Settings->TTY.Port = le_Port->text();
772
    Settings->TTY.Port = le_Port->text();
759
    f_Preferences->set_Settings(Settings);
773
    f_Preferences->set_Settings(Settings);
760
 
774
 
761
    if (f_Preferences->exec()==QDialog::Accepted)
775
    if (f_Preferences->exec()==QDialog::Accepted)
762
    {
776
    {
763
        Settings = f_Preferences->get_Settings();
777
        Settings = f_Preferences->get_Settings();
764
        Settings->write_Settings();
778
        Settings->write_Settings();
765
        le_Port->setText(Settings->TTY.Port);
779
        le_Port->setText(Settings->TTY.Port);
766
        config_Plot();
780
        config_Plot();
767
    }
781
    }
768
}
782
}
769
 
783
 
770
void MKTool::slot_ac_StartPlotter()
784
void MKTool::slot_ac_StartPlotter()
771
{
785
{
772
    if (ac_StartPlotter->isChecked())
786
    if (ac_StartPlotter->isChecked())
773
    {
787
    {
774
        lb_Status->setText(tr("Datenplotter gestartet."));
788
        lb_Status->setText(tr("Datenplotter gestartet."));
775
        ac_StartPlotter->setText("Stop Plotter");
789
        ac_StartPlotter->setText("Stop Plotter");
776
        pb_StartPlotter->setText("Stop Plotter");
790
        pb_StartPlotter->setText("Stop Plotter");
777
    }
791
    }
778
    else
792
    else
779
    {
793
    {
780
        lb_Status->setText(tr("Datenplotter gestopt."));
794
        lb_Status->setText(tr("Datenplotter gestopt."));
781
        ac_StartPlotter->setText("Start Plotter");
795
        ac_StartPlotter->setText("Start Plotter");
782
        pb_StartPlotter->setText("Start Plotter");
796
        pb_StartPlotter->setText("Start Plotter");
783
    }
797
    }
784
}
798
}
785
 
799
 
786
void MKTool::slot_ac_View()
800
void MKTool::slot_ac_View()
787
{
801
{
788
    int Aktive = -1;
802
    int Aktive = -1;
789
 
803
 
790
    QAction *Action = (QAction*)sender();
804
    QAction *Action = (QAction*)sender();
791
 
805
 
792
    if (Action->objectName() == QString("ac_View0"))
806
    if (Action->objectName() == QString("ac_View0"))
793
        Aktive = 0;
807
        Aktive = 0;
794
    if (Action->objectName() == QString("ac_View1"))
808
    if (Action->objectName() == QString("ac_View1"))
795
        Aktive = 1;
809
        Aktive = 1;
796
    if (Action->objectName() == QString("ac_View2"))
810
    if (Action->objectName() == QString("ac_View2"))
797
        Aktive = 2;
811
        Aktive = 2;
798
    if (Action->objectName() == QString("ac_View3"))
812
    if (Action->objectName() == QString("ac_View3"))
799
        Aktive = 3;
813
        Aktive = 3;
800
    if (Action->objectName() == QString("ac_View4"))
814
    if (Action->objectName() == QString("ac_View4"))
801
        Aktive = 4;
815
        Aktive = 4;
802
    if (Action->objectName() == QString("ac_View5"))
816
    if (Action->objectName() == QString("ac_View5"))
803
        Aktive = 5;
817
        Aktive = 5;
804
    if (Action->objectName() == QString("ac_View6"))
818
    if (Action->objectName() == QString("ac_View6"))
805
        Aktive = 6;
819
        Aktive = 6;
806
 
820
 
807
    QString TabName = QString("Tab_%1").arg(Aktive);
821
    QString TabName = QString("Tab_%1").arg(Aktive);
808
 
822
 
809
    if (!Action->isChecked())
823
    if (!Action->isChecked())
810
    {
824
    {
811
        for (int a = 0; a < tab_Main->count(); a++)
825
        for (int a = 0; a < tab_Main->count(); a++)
812
        {
826
        {
813
            if (tab_Main->widget(a)->objectName() == TabName)
827
            if (tab_Main->widget(a)->objectName() == TabName)
814
            {
828
            {
815
                tab_Main->removeTab(a);
829
                tab_Main->removeTab(a);
816
            }
830
            }
817
        }
831
        }
818
    }
832
    }
819
    else
833
    else
820
    {
834
    {
821
        tab_Main->insertTab(Aktive, TabWidgets[Aktive], Action->icon(), Action->text());
835
        tab_Main->insertTab(Aktive, TabWidgets[Aktive], Action->icon(), Action->text());
822
    }
836
    }
823
}
837
}
824
 
838
 
825
void MKTool::slot_ac_FastNavi() // DONE NC 0.12i
839
void MKTool::slot_ac_FastNavi() // DONE NC 0.12i
826
{
840
{
827
    if (!ac_NoNavi->isChecked())
841
    if (!ac_NoNavi->isChecked())
828
    {
842
    {
829
        if (ac_FastNavi->isChecked())
843
        if (ac_FastNavi->isChecked())
830
        {
844
        {
831
            lb_Status->setText(tr("Fordere schnelle NaviDaten an."));
845
            lb_Status->setText(tr("Fordere schnelle NaviDaten an."));
832
            TX_Data[0] = Settings->Data.Navi_Fast / 10;
846
            TX_Data[0] = Settings->Data.Navi_Fast / 10;
833
        }
847
        }
834
        else
848
        else
835
        {
849
        {
836
            lb_Status->setText(tr("Fordere langsame NaviDaten an."));
850
            lb_Status->setText(tr("Fordere langsame NaviDaten an."));
837
            TX_Data[0] = Settings->Data.Navi_Slow / 10;
851
            TX_Data[0] = Settings->Data.Navi_Slow / 10;
838
        }
852
        }
839
        Conn->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false);
853
        Conn->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false);
840
    }
854
    }
841
}
855
}
842
 
856
 
843
void MKTool::slot_ac_NoNavi() // DONE NC 0.12i
857
void MKTool::slot_ac_NoNavi() // DONE NC 0.12i
844
{
858
{
845
    if (ac_NoNavi->isChecked())
859
    if (ac_NoNavi->isChecked())
846
    {
860
    {
847
        lb_Status->setText(tr("NaviDaten abstellen."));
861
        lb_Status->setText(tr("NaviDaten abstellen."));
848
        TX_Data[0] = 0;
862
        TX_Data[0] = 0;
849
    }
863
    }
850
    else
864
    else
851
    {
865
    {
852
        if (ac_FastNavi->isChecked())
866
        if (ac_FastNavi->isChecked())
853
        {
867
        {
854
            lb_Status->setText(tr("Fordere schnelle NaviDaten an."));
868
            lb_Status->setText(tr("Fordere schnelle NaviDaten an."));
855
            TX_Data[0] = Settings->Data.Navi_Fast / 10;
869
            TX_Data[0] = Settings->Data.Navi_Fast / 10;
856
        }
870
        }
857
        else
871
        else
858
        {
872
        {
859
            lb_Status->setText(tr("Fordere langsame NaviDaten an."));
873
            lb_Status->setText(tr("Fordere langsame NaviDaten an."));
860
            TX_Data[0] = Settings->Data.Navi_Slow / 10;
874
            TX_Data[0] = Settings->Data.Navi_Slow / 10;
861
        }
875
        }
862
    }
876
    }
863
    Conn->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false);
877
    Conn->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false);
864
}
878
}
865
 
879
 
866
void MKTool::slot_ac_FastDebug() // DONE 0.71g
880
void MKTool::slot_ac_FastDebug() // DONE 0.71g
867
{
881
{
868
    if (!ac_NoDebug->isChecked())
882
    if (!ac_NoDebug->isChecked())
869
    {
883
    {
870
        if (ac_FastDebug->isChecked())
884
        if (ac_FastDebug->isChecked())
871
        {
885
        {
872
            lb_Status->setText(tr("Fordere schnelle DebugDaten an."));
886
            lb_Status->setText(tr("Fordere schnelle DebugDaten an."));
873
            TX_Data[0] = Settings->Data.Debug_Fast / 10;
887
            TX_Data[0] = Settings->Data.Debug_Fast / 10;
874
        }
888
        }
875
        else
889
        else
876
        {
890
        {
877
            lb_Status->setText(tr("Fordere langsame DebugDaten an."));
891
            lb_Status->setText(tr("Fordere langsame DebugDaten an."));
878
            TX_Data[0] = Settings->Data.Debug_Slow / 10;
892
            TX_Data[0] = Settings->Data.Debug_Slow / 10;
879
        }
893
        }
880
        Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
894
        Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
881
    }
895
    }
882
}
896
}
883
 
897
 
884
void MKTool::slot_ac_NoDebug() // DONE 0.71g
898
void MKTool::slot_ac_NoDebug() // DONE 0.71g
885
{
899
{
886
    if (ac_NoDebug->isChecked())
900
    if (ac_NoDebug->isChecked())
887
    {
901
    {
888
        lb_Status->setText(tr("DebugDaten abstellen."));
902
        lb_Status->setText(tr("DebugDaten abstellen."));
889
        TickerEvent[3] = false;
903
        TickerEvent[3] = false;
890
        TX_Data[0] = 0;
904
        TX_Data[0] = 0;
891
    }
905
    }
892
    else
906
    else
893
    {
907
    {
894
        // Wenn MK3MAG dann andauernd Daten neu anfragen.
908
        // Wenn MK3MAG dann andauernd Daten neu anfragen.
895
        if (Mode.ID == ADDRESS_MK3MAG)
909
        if (Mode.ID == ADDRESS_MK3MAG)
896
            TickerEvent[3] = true;
910
            TickerEvent[3] = true;
897
 
911
 
898
        if (ac_FastDebug->isChecked())
912
        if (ac_FastDebug->isChecked())
899
        {
913
        {
900
            lb_Status->setText(tr("Fordere schnelle DebugDaten an."));
914
            lb_Status->setText(tr("Fordere schnelle DebugDaten an."));
901
            TX_Data[0] = Settings->Data.Debug_Fast / 10;
915
            TX_Data[0] = Settings->Data.Debug_Fast / 10;
902
        }
916
        }
903
        else
917
        else
904
        {
918
        {
905
            lb_Status->setText(tr("Fordere langsame DebugDaten an."));
919
            lb_Status->setText(tr("Fordere langsame DebugDaten an."));
906
            TX_Data[0] = Settings->Data.Debug_Slow / 10;
920
            TX_Data[0] = Settings->Data.Debug_Slow / 10;
907
        }
921
        }
908
    }
922
    }
909
    Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
923
    Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
910
}
924
}
911
 
925
 
912
void MKTool::slot_ac_About()
926
void MKTool::slot_ac_About()
913
{
927
{
914
    QMessageBox::about(this, trUtf8(("Über ")) + QA_NAME, QA_ABOUT);
928
    QMessageBox::about(this, trUtf8(("Über ")) + QA_NAME, QA_ABOUT);
915
}
929
}
916
 
930
 
917
void MKTool::slot_ac_GetLabels() // DONE 0.71g
931
void MKTool::slot_ac_GetLabels() // DONE 0.71g
918
{
932
{
919
    lb_Status->setText(tr("Analoglabels auslesen."));
933
    lb_Status->setText(tr("Analoglabels auslesen."));
920
    TX_Data[0] = 0;
934
    TX_Data[0] = 0;
921
    Conn->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true);
935
    Conn->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true);
922
}
936
}
923
 
937
 
924
void MKTool::slot_ac_StartServer()
938
void MKTool::slot_ac_StartServer()
925
{
939
{
926
    if (ac_StartServer->isChecked())
940
    if (ac_StartServer->isChecked())
927
    {
941
    {
928
        lb_Status->setText(tr("GoogleEarth-Server gestartet."));
942
        lb_Status->setText(tr("GoogleEarth-Server gestartet."));
929
        GE_Server->start_Server(Settings->Server.Port.toInt(), Settings);
943
        GE_Server->start_Server(Settings->Server.Port.toInt(), Settings);
930
    }
944
    }
931
    else
945
    else
932
    {
946
    {
933
        lb_Status->setText(tr("GoogleEarth-Server gestopt."));
947
        lb_Status->setText(tr("GoogleEarth-Server gestopt."));
934
        GE_Server->stop_Server();
948
        GE_Server->stop_Server();
935
    }
949
    }
936
}
950
}
937
 
951
 
938
 
952
 
939
//  Daten-Plotter
953
//  Daten-Plotter
940
/////////////////
954
/////////////////
941
void MKTool::update_Plot()
955
void MKTool::update_Plot()
942
{
956
{
943
    for (int a = 0; a < MaxAnalog; a++)
957
    for (int a = 0; a < MaxAnalog; a++)
944
    {
958
    {
945
        Plot[a]->setData(aID,aData[a],NextPlot - 1);
959
        Plot[a]->setData(aID,aData[a],NextPlot - 1);
946
    }
960
    }
947
 
961
 
948
    if ((NextPlot > Settings->Data.Plotter_Count))
962
    if ((NextPlot > Settings->Data.Plotter_Count))
949
    {
963
    {
950
        scroll_plot->setMaximum(NextPlot - Settings->Data.Plotter_Count);
964
        scroll_plot->setMaximum(NextPlot - Settings->Data.Plotter_Count);
951
    }
965
    }
952
 
966
 
953
    if ((scroll_plot->value() == NextPlot - (Settings->Data.Plotter_Count + 1)))
967
    if ((scroll_plot->value() == NextPlot - (Settings->Data.Plotter_Count + 1)))
954
    {
968
    {
955
        qwtPlot->setAxisScale(QwtPlot::xBottom,NextPlot - Settings->Data.Plotter_Count,NextPlot,0);
969
        qwtPlot->setAxisScale(QwtPlot::xBottom,NextPlot - Settings->Data.Plotter_Count,NextPlot,0);
956
        scroll_plot->setValue(NextPlot - Settings->Data.Plotter_Count);
970
        scroll_plot->setValue(NextPlot - Settings->Data.Plotter_Count);
957
    }
971
    }
958
 
972
 
959
    qwtPlot->replot();
973
    qwtPlot->replot();
960
}
974
}
961
 
975
 
962
void MKTool::config_Plot()
976
void MKTool::config_Plot()
963
{
977
{
964
//    qDebug("Plotter rekonfiguriert..!!");
978
//    qDebug("Plotter rekonfiguriert..!!");
965
    qwtPlot->setAxisScale(QwtPlot::xBottom,0,Settings->Data.Plotter_Count,0);
979
    qwtPlot->setAxisScale(QwtPlot::xBottom,0,Settings->Data.Plotter_Count,0);
966
 
980
 
967
    for (int a = 0; a < MaxAnalog; a++)
981
    for (int a = 0; a < MaxAnalog; a++)
968
    {
982
    {
969
        Plot[a]->detach();
983
        Plot[a]->detach();
970
        Plot[a]->setPen(QPen(QColor(Def_Colors[a])));
984
        Plot[a]->setPen(QPen(QColor(Def_Colors[a])));
971
 
985
 
972
        if (Settings->Analog1.PlotView[a])
986
        if (Settings->Analog1.PlotView[a])
973
        {
987
        {
974
            Plot[a]->setTitle(Settings->Analog1.Label[a]);
988
            Plot[a]->setTitle(Settings->Analog1.Label[a]);
975
            Plot[a]->attach(qwtPlot);
989
            Plot[a]->attach(qwtPlot);
976
        }
990
        }
977
    }
991
    }
978
    qwtPlot->replot();
992
    qwtPlot->replot();
979
}
993
}
980
 
994
 
981
void MKTool::slot_ScrollPlot(int Pos)
995
void MKTool::slot_ScrollPlot(int Pos)
982
{
996
{
983
    qwtPlot->setAxisScale(QwtPlot::xBottom,Pos,Pos + Settings->Data.Plotter_Count,0);
997
    qwtPlot->setAxisScale(QwtPlot::xBottom,Pos,Pos + Settings->Data.Plotter_Count,0);
984
    qwtPlot->replot();
998
    qwtPlot->replot();
985
}
999
}
986
 
1000
 
987
 
1001
 
988
// Firmeware-Update
1002
// Firmeware-Update
989
///////////////////
1003
///////////////////
990
void MKTool::slot_pb_Update()
1004
void MKTool::slot_pb_Update()
991
{
1005
{
992
    QString Device;
1006
    QString Device;
993
    QString Hardware;
1007
    QString Hardware;
994
 
1008
 
995
    if (rb_FC->isChecked())
1009
    if (rb_FC->isChecked())
996
    {
1010
    {
997
        Device   = "m644";
1011
        Device   = "m644";
998
        Hardware = "FlightCtrl";
1012
        Hardware = "FlightCtrl";
999
    }
1013
    }
1000
    else if (rb_MK3MAG->isChecked())
1014
    else if (rb_MK3MAG->isChecked())
1001
    {
1015
    {
1002
        Device   = "m168";
1016
        Device   = "m168";
1003
        Hardware = "MK3MAG";
1017
        Hardware = "MK3MAG";
1004
    }
1018
    }
1005
    else if (rb_BL->isChecked())
1019
    else if (rb_BL->isChecked())
1006
    {
1020
    {
1007
        Device   = "m8";
1021
        Device   = "m8";
1008
        Hardware = "BL-Ctrl";
1022
        Hardware = "BL-Ctrl";
1009
    }
1023
    }
1010
 
1024
 
1011
    QString Message = "Firmeware-Datei \n\n";
1025
    QString Message = "Firmeware-Datei \n\n";
1012
    Message = Message + le_HexFile->text() + "\n\n";
1026
    Message = Message + le_HexFile->text() + "\n\n";
1013
    Message = Message + "an " + Hardware + trUtf8(" mit AVRDUDE - Seriel & Bootloader über ") + le_Port->text() + trUtf8(" übertragen?\n");
1027
    Message = Message + "an " + Hardware + trUtf8(" mit AVRDUDE - Seriel & Bootloader über ") + le_Port->text() + trUtf8(" übertragen?\n");
1014
 
1028
 
1015
    if (le_HexFile->text() == "")
1029
    if (le_HexFile->text() == "")
1016
    {
1030
    {
1017
        QMessageBox::warning(this, QA_NAME, trUtf8("Bitte Firmeware-Datei wählen."), QMessageBox::Ok);
1031
        QMessageBox::warning(this, QA_NAME, trUtf8("Bitte Firmeware-Datei wählen."), QMessageBox::Ok);
1018
    }
1032
    }
1019
    else if (QMessageBox::warning(this, QA_NAME, Message, QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
1033
    else if (QMessageBox::warning(this, QA_NAME, Message, QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
1020
    {
1034
    {
1021
        QString Programm = "avrdude" ;
1035
        QString Programm = "avrdude" ;
1022
 
1036
 
1023
        QStringList Argumente;
1037
        QStringList Argumente;
1024
 
1038
 
1025
        Update = new QProcess();
1039
        Update = new QProcess();
1026
 
1040
 
1027
        if (Conn->isOpen())
1041
        if (Conn->isOpen())
1028
        {
1042
        {
1029
            slot_OpenPort();
1043
            slot_OpenPort();
1030
        }
1044
        }
1031
 
1045
 
1032
        Argumente << "-P";
1046
        Argumente << "-P";
1033
        Argumente << le_Port->text();
1047
        Argumente << le_Port->text();
1034
        Argumente << "-p";
1048
        Argumente << "-p";
1035
        Argumente << Device;
1049
        Argumente << Device;
1036
        Argumente << "-c";
1050
        Argumente << "-c";
1037
        Argumente << "butterfly";
1051
        Argumente << "butterfly";
1038
        Argumente << "-b";
1052
        Argumente << "-b";
1039
        Argumente << "57600";
1053
        Argumente << "57600";
1040
        Argumente << "-U";
1054
        Argumente << "-U";
1041
        Argumente << "flash:w:" + le_HexFile->text();
1055
        Argumente << "flash:w:" + le_HexFile->text();
1042
 
1056
 
1043
//    QString Programm = "/home/Manuel/bin/avrdude -p m644 -P /dev/ttyS0 -c butterfly -b 57600 -U flash:w:/home/Manuel/Documents/Mikrokopter/Firmeware/FlightCtrl/Flight-Ctrl_MEGA644_V0_71h.hex";
1057
//    QString Programm = "/home/Manuel/bin/avrdude -p m644 -P /dev/ttyS0 -c butterfly -b 57600 -U flash:w:/home/Manuel/Documents/Mikrokopter/Firmeware/FlightCtrl/Flight-Ctrl_MEGA644_V0_71h.hex";
1044
 
1058
 
1045
        te_Shell->setText(""); // Ausgabefenster säubern
1059
        te_Shell->setText(""); // Ausgabefenster säubern
1046
 
1060
 
1047
        connect(Update, SIGNAL(readyReadStandardOutput()), this, SLOT(slot_UpdateShell()) );
1061
        connect(Update, SIGNAL(readyReadStandardOutput()), this, SLOT(slot_UpdateShell()) );
1048
        connect(Update, SIGNAL(readyReadStandardError()), this, SLOT(slot_UpdateShell()) );
1062
        connect(Update, SIGNAL(readyReadStandardError()), this, SLOT(slot_UpdateShell()) );
1049
 
1063
 
1050
        Update->start(Programm, Argumente); // Programmaufruf
1064
        Update->start(Programm, Argumente); // Programmaufruf
1051
    }
1065
    }
1052
}
1066
}
1053
 
1067
 
1054
void MKTool::slot_UpdateShell()
1068
void MKTool::slot_UpdateShell()
1055
{
1069
{
1056
    QByteArray Output;
1070
    QByteArray Output;
1057
 
1071
 
1058
    Output = Update->readAllStandardError(); // Shellausgabe an Variable
1072
    Output = Update->readAllStandardError(); // Shellausgabe an Variable
1059
    te_Shell->moveCursor(QTextCursor::End,  QTextCursor::MoveAnchor);
1073
    te_Shell->moveCursor(QTextCursor::End,  QTextCursor::MoveAnchor);
1060
    te_Shell->insertPlainText(QString::fromUtf8(Output));
1074
    te_Shell->insertPlainText(QString::fromUtf8(Output));
1061
 
1075
 
1062
    Output = Update->readAll();
1076
    Output = Update->readAll();
1063
    te_Shell->moveCursor(QTextCursor::End,  QTextCursor::MoveAnchor);
1077
    te_Shell->moveCursor(QTextCursor::End,  QTextCursor::MoveAnchor);
1064
    te_Shell->insertPlainText(QString::fromUtf8(Output));
1078
    te_Shell->insertPlainText(QString::fromUtf8(Output));
1065
}
1079
}
1066
 
1080
 
1067
void MKTool::slot_pb_HexFile()
1081
void MKTool::slot_pb_HexFile()
1068
{
1082
{
1069
    QString FileName = QFileDialog::getOpenFileName(this,trUtf8(("Firmeware-Datei wählen")),"",
1083
    QString FileName = QFileDialog::getOpenFileName(this,trUtf8(("Firmeware-Datei wählen")),"",
1070
                                tr("Intel Hex(*.hex);;Alle Dateien (*)"));
1084
                                tr("Intel Hex(*.hex);;Alle Dateien (*)"));
1071
    if (!FileName.isEmpty())
1085
    if (!FileName.isEmpty())
1072
    {
1086
    {
1073
        le_HexFile->setText(FileName);
1087
        le_HexFile->setText(FileName);
1074
    }
1088
    }
1075
}
1089
}
1076
 
1090
 
1077
 
1091
 
1078
// Wechsel der Tabs erkennen
1092
// Wechsel der Tabs erkennen
1079
void MKTool::slot_TabChanged(int Tab) // DONE 0.71g
1093
void MKTool::slot_TabChanged(int Tab) // DONE 0.71g
1080
{
1094
{
1081
    Tab = Tab;
1095
    Tab = Tab;
1082
    if (tab_Main->count() != 0)
1096
    if (tab_Main->count() != 0)
1083
    {
1097
    {
1084
        if ((tab_Main->currentWidget()->objectName() == QString("Tab_2")) && (f_Settings->tab_Par->currentIndex() == 1))
1098
        if ((tab_Main->currentWidget()->objectName() == QString("Tab_2")) && (f_Settings->tab_Par->currentIndex() == 1))
1085
        {
1099
        {
1086
            TX_Data[0] = 0;
1100
            TX_Data[0] = 0;
1087
            Conn->send_Cmd('p', ADDRESS_FC, TX_Data, 0, true);
1101
            Conn->send_Cmd('p', ADDRESS_FC, TX_Data, 0, true);
1088
 
1102
 
1089
            Ticker->setInterval(500);
1103
            Ticker->setInterval(500);
1090
            TickerEvent[1] = true;
1104
            TickerEvent[1] = true;
1091
        }
1105
        }
1092
        else
1106
        else
1093
        {
1107
        {
1094
            Ticker->setInterval(2000);
1108
            Ticker->setInterval(2000);
1095
            TickerEvent[1] = false;
1109
            TickerEvent[1] = false;
1096
        }
1110
        }
1097
/*
1111
/*
1098
        if ((tab_Main->currentWidget()->objectName() == QString("Tab_4")))
1112
        if ((tab_Main->currentWidget()->objectName() == QString("Tab_4")))
1099
        {
1113
        {
1100
            TX_Data[0] = 0;
1114
            TX_Data[0] = 0;
1101
            TX_Data[1] = 0;
1115
            TX_Data[1] = 0;
1102
            send_Data('l', ADDRESS_ALL, TX_Data, 1, true);
1116
            send_Data('l', ADDRESS_ALL, TX_Data, 1, true);
1103
 
1117
 
1104
            Ticker->setInterval(500);
1118
            Ticker->setInterval(500);
1105
            TickerEvent[2] = true;
1119
            TickerEvent[2] = true;
1106
        }
1120
        }
1107
        else
1121
        else
1108
        {
1122
        {
1109
            Ticker->setInterval(2000);
1123
            Ticker->setInterval(2000);
1110
            TickerEvent[2] = false;
1124
            TickerEvent[2] = false;
1111
        }
1125
        }
1112
*/
1126
*/
1113
    }
1127
    }
1114
}
1128
}
1115
 
1129
 
1116
// LCD-Seiten weiterschalten
1130
// LCD-Seiten weiterschalten
1117
void MKTool::slot_LCD_UP() // DONE 0.71g
1131
void MKTool::slot_LCD_UP() // DONE 0.71g
1118
{
1132
{
1119
    if (LCD_Page == LCD_MAX_Page)
1133
    if (LCD_Page == LCD_MAX_Page)
1120
        TX_Data[0] = 0;
1134
        TX_Data[0] = 0;
1121
    else
1135
    else
1122
        TX_Data[0] = LCD_Page + 1;
1136
        TX_Data[0] = LCD_Page + 1;
1123
 
1137
 
1124
    TX_Data[1] = 0;
1138
    TX_Data[1] = 0;
1125
    Conn->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true);
1139
    Conn->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true);
1126
}
1140
}
1127
 
1141
 
1128
void MKTool::slot_LCD_DOWN() // DONE 0.71g
1142
void MKTool::slot_LCD_DOWN() // DONE 0.71g
1129
{
1143
{
1130
    if (LCD_Page == 0)
1144
    if (LCD_Page == 0)
1131
        TX_Data[0] = LCD_MAX_Page;
1145
        TX_Data[0] = LCD_MAX_Page;
1132
    else
1146
    else
1133
        TX_Data[0] = LCD_Page - 1;
1147
        TX_Data[0] = LCD_Page - 1;
1134
 
1148
 
1135
    TX_Data[1] = 0;
1149
    TX_Data[1] = 0;
1136
    Conn->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true);
1150
    Conn->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true);
1137
}
1151
}
1138
 
1152
 
1139
// Settings aus MK lesen / in MK schreiben
1153
// Settings aus MK lesen / in MK schreiben
1140
void MKTool::slot_GetFCSettings() // DONE 0.71g
1154
void MKTool::slot_GetFCSettings() // DONE 0.71g
1141
{
1155
{
1142
    lb_Status->setText(tr("Lese FlightCtrl-Settings aus."));
1156
    lb_Status->setText(tr("Lese FlightCtrl-Settings aus."));
1143
    TX_Data[0] = f_Settings->sb_Set->value();
1157
    TX_Data[0] = f_Settings->sb_Set->value();
1144
    TX_Data[1] = 0;
1158
    TX_Data[1] = 0;
1145
    Conn->send_Cmd('q', ADDRESS_FC, TX_Data, 1);
1159
    Conn->send_Cmd('q', ADDRESS_FC, TX_Data, 1);
1146
}
1160
}
1147
 
1161
 
1148
void MKTool::slot_SetFCSettings() // DONE 0.71g
1162
void MKTool::slot_SetFCSettings() // DONE 0.71g
1149
{
1163
{
1150
    char *TX_Data2 = f_Settings->GetFCSettings();
1164
    char *TX_Data2 = f_Settings->GetFCSettings();
1151
 
1165
 
1152
    lb_Status->setText(tr("Schreibe FlightCtrl-Settings."));
1166
    lb_Status->setText(tr("Schreibe FlightCtrl-Settings."));
1153
 
1167
 
1154
    Conn->send_Cmd('s', ADDRESS_FC, TX_Data2, MaxParameter + 2, false);
1168
    Conn->send_Cmd('s', ADDRESS_FC, TX_Data2, MaxParameter + 2, false);
1155
}
1169
}
1156
 
1170
 
1157
 
1171
 
1158
// Save GUI-Preferences
1172
// Save GUI-Preferences
1159
///////////////////////
1173
///////////////////////
1160
void MKTool::set_Preferences()
1174
void MKTool::set_Preferences()
1161
{
1175
{
1162
    Settings->GUI.TabViews.setBit(0, ac_View0->isChecked());
1176
    Settings->GUI.TabViews.setBit(0, ac_View0->isChecked());
1163
    Settings->GUI.TabViews.setBit(1, ac_View1->isChecked());
1177
    Settings->GUI.TabViews.setBit(1, ac_View1->isChecked());
1164
    Settings->GUI.TabViews.setBit(2, ac_View2->isChecked());
1178
    Settings->GUI.TabViews.setBit(2, ac_View2->isChecked());
1165
    Settings->GUI.TabViews.setBit(3, ac_View3->isChecked());
1179
    Settings->GUI.TabViews.setBit(3, ac_View3->isChecked());
1166
    Settings->GUI.TabViews.setBit(4, ac_View4->isChecked());
1180
    Settings->GUI.TabViews.setBit(4, ac_View4->isChecked());
1167
    Settings->GUI.TabViews.setBit(5, ac_View5->isChecked());
1181
    Settings->GUI.TabViews.setBit(5, ac_View5->isChecked());
1168
    Settings->GUI.TabViews.setBit(6, ac_View6->isChecked());
1182
    Settings->GUI.TabViews.setBit(6, ac_View6->isChecked());
1169
 
1183
 
1170
    Settings->GUI.ToolViews.setBit(0, tb_Allgemein->isVisibleTo(this));
1184
    Settings->GUI.ToolViews.setBit(0, tb_Allgemein->isVisibleTo(this));
1171
    Settings->GUI.ToolViews.setBit(1, tb_Werkzeuge->isVisibleTo(this));
1185
    Settings->GUI.ToolViews.setBit(1, tb_Werkzeuge->isVisibleTo(this));
1172
    Settings->GUI.ToolViews.setBit(2, tb_Debug->isVisibleTo(this));
1186
    Settings->GUI.ToolViews.setBit(2, tb_Debug->isVisibleTo(this));
1173
    Settings->GUI.ToolViews.setBit(3, tb_TTY->isVisibleTo(this));
1187
    Settings->GUI.ToolViews.setBit(3, tb_TTY->isVisibleTo(this));
1174
    Settings->GUI.ToolViews.setBit(4, tb_Hardware->isVisibleTo(this));
1188
    Settings->GUI.ToolViews.setBit(4, tb_Hardware->isVisibleTo(this));
1175
 
1189
 
1176
    Settings->GUI.Term_Info   = cb_ShowMSG->isChecked();
1190
    Settings->GUI.Term_Info   = cb_ShowMSG->isChecked();
1177
    Settings->GUI.Term_Data   = cb_ShowData->isChecked();
1191
    Settings->GUI.Term_Data   = cb_ShowData->isChecked();
1178
    Settings->GUI.Term_Always = cb_ShowAlways->isChecked();
1192
    Settings->GUI.Term_Always = cb_ShowAlways->isChecked();
1179
    Settings->GUI.Term_Send   = cb_ShowSend->isChecked();
1193
    Settings->GUI.Term_Send   = cb_ShowSend->isChecked();
1180
    Settings->GUI.isMax       = isMaximized();
1194
    Settings->GUI.isMax       = isMaximized();
1181
    Settings->GUI.Size        = size();
1195
    Settings->GUI.Size        = size();
1182
    Settings->GUI.Point       = pos();
1196
    Settings->GUI.Point       = pos();
1183
 
1197
 
1184
    Settings->TTY.Port = le_Port->text();
1198
    Settings->TTY.Port = le_Port->text();
1185
}
1199
}
1186
 
1200
 
1187
void MKTool::show_DebugData()
1201
void MKTool::show_DebugData()
1188
{
1202
{
1189
    if (logger->is_active())
1203
    if (logger->is_active())
1190
        logger->write(AnalogData);
1204
        logger->write(AnalogData);
1191
 
1205
 
1192
    if (ac_StartPlotter->isChecked())
1206
    if (ac_StartPlotter->isChecked())
1193
    {
1207
    {
1194
        aID[NextPlot] = NextPlot;
1208
        aID[NextPlot] = NextPlot;
1195
 
1209
 
1196
        for (int a = 0; a < MaxAnalog; a++)
1210
        for (int a = 0; a < MaxAnalog; a++)
1197
        {
1211
        {
1198
            aData[a][NextPlot] = AnalogData[a];
1212
            aData[a][NextPlot] = AnalogData[a];
1199
        }
1213
        }
1200
        NextPlot++;
1214
        NextPlot++;
1201
 
1215
 
1202
        if ((tab_Main->currentWidget()->objectName() == QString("Tab_1")))
1216
        if ((tab_Main->currentWidget()->objectName() == QString("Tab_1")))
1203
            update_Plot();
1217
            update_Plot();
1204
    }
1218
    }
1205
 
1219
 
1206
    le_A_0->setText(QString("%1").arg(AnalogData[0]));
1220
    le_A_0->setText(QString("%1").arg(AnalogData[0]));
1207
    le_A_1->setText(QString("%1").arg(AnalogData[1]));
1221
    le_A_1->setText(QString("%1").arg(AnalogData[1]));
1208
    le_A_2->setText(QString("%1").arg(AnalogData[2]));
1222
    le_A_2->setText(QString("%1").arg(AnalogData[2]));
1209
    le_A_3->setText(QString("%1").arg(AnalogData[3]));
1223
    le_A_3->setText(QString("%1").arg(AnalogData[3]));
1210
    le_A_4->setText(QString("%1").arg(AnalogData[4]));
1224
    le_A_4->setText(QString("%1").arg(AnalogData[4]));
1211
    le_A_5->setText(QString("%1").arg(AnalogData[5]));
1225
    le_A_5->setText(QString("%1").arg(AnalogData[5]));
1212
    le_A_6->setText(QString("%1").arg(AnalogData[6]));
1226
    le_A_6->setText(QString("%1").arg(AnalogData[6]));
1213
    le_A_7->setText(QString("%1").arg(AnalogData[7]));
1227
    le_A_7->setText(QString("%1").arg(AnalogData[7]));
1214
    le_A_8->setText(QString("%1").arg(AnalogData[8]));
1228
    le_A_8->setText(QString("%1").arg(AnalogData[8]));
1215
    le_A_9->setText(QString("%1").arg(AnalogData[9]));
1229
    le_A_9->setText(QString("%1").arg(AnalogData[9]));
1216
    le_A_10->setText(QString("%1").arg(AnalogData[10]));
1230
    le_A_10->setText(QString("%1").arg(AnalogData[10]));
1217
    le_A_11->setText(QString("%1").arg(AnalogData[11]));
1231
    le_A_11->setText(QString("%1").arg(AnalogData[11]));
1218
    le_A_12->setText(QString("%1").arg(AnalogData[12]));
1232
    le_A_12->setText(QString("%1").arg(AnalogData[12]));
1219
    le_A_13->setText(QString("%1").arg(AnalogData[13]));
1233
    le_A_13->setText(QString("%1").arg(AnalogData[13]));
1220
    le_A_14->setText(QString("%1").arg(AnalogData[14]));
1234
    le_A_14->setText(QString("%1").arg(AnalogData[14]));
1221
    le_A_15->setText(QString("%1").arg(AnalogData[15]));
1235
    le_A_15->setText(QString("%1").arg(AnalogData[15]));
1222
    le_A_16->setText(QString("%1").arg(AnalogData[16]));
1236
    le_A_16->setText(QString("%1").arg(AnalogData[16]));
1223
    le_A_17->setText(QString("%1").arg(AnalogData[17]));
1237
    le_A_17->setText(QString("%1").arg(AnalogData[17]));
1224
    le_A_18->setText(QString("%1").arg(AnalogData[18]));
1238
    le_A_18->setText(QString("%1").arg(AnalogData[18]));
1225
    le_A_19->setText(QString("%1").arg(AnalogData[19]));
1239
    le_A_19->setText(QString("%1").arg(AnalogData[19]));
1226
    le_A_20->setText(QString("%1").arg(AnalogData[20]));
1240
    le_A_20->setText(QString("%1").arg(AnalogData[20]));
1227
    le_A_21->setText(QString("%1").arg(AnalogData[21]));
1241
    le_A_21->setText(QString("%1").arg(AnalogData[21]));
1228
    le_A_22->setText(QString("%1").arg(AnalogData[22]));
1242
    le_A_22->setText(QString("%1").arg(AnalogData[22]));
1229
    le_A_23->setText(QString("%1").arg(AnalogData[23]));
1243
    le_A_23->setText(QString("%1").arg(AnalogData[23]));
1230
    le_A_24->setText(QString("%1").arg(AnalogData[24]));
1244
    le_A_24->setText(QString("%1").arg(AnalogData[24]));
1231
    le_A_25->setText(QString("%1").arg(AnalogData[25]));
1245
    le_A_25->setText(QString("%1").arg(AnalogData[25]));
1232
    le_A_26->setText(QString("%1").arg(AnalogData[26]));
1246
    le_A_26->setText(QString("%1").arg(AnalogData[26]));
1233
    le_A_27->setText(QString("%1").arg(AnalogData[27]));
1247
    le_A_27->setText(QString("%1").arg(AnalogData[27]));
1234
    le_A_28->setText(QString("%1").arg(AnalogData[28]));
1248
    le_A_28->setText(QString("%1").arg(AnalogData[28]));
1235
    le_A_29->setText(QString("%1").arg(AnalogData[29]));
1249
    le_A_29->setText(QString("%1").arg(AnalogData[29]));
1236
    le_A_30->setText(QString("%1").arg(AnalogData[30]));
1250
    le_A_30->setText(QString("%1").arg(AnalogData[30]));
1237
    le_A_31->setText(QString("%1").arg(AnalogData[31]));
1251
    le_A_31->setText(QString("%1").arg(AnalogData[31]));
1238
 
1252
 
1239
    if ((Mode.ID == ADDRESS_FC) && (FCSettings[P_GYRO_ACC_FAKTOR] > 0))
1253
    if ((Mode.ID == ADDRESS_FC) && (FCSettings[P_GYRO_ACC_FAKTOR] > 0))
1240
    {
1254
    {
1241
        bar_UBAT->setValue(AnalogData[9]);
1255
        bar_UBAT->setValue(AnalogData[9]);
1242
        bar_RX->setValue(AnalogData[10]);
1256
        bar_RX->setValue(AnalogData[10]);
1243
 
1257
 
1244
        Compass->setValue(AnalogData[8]);
1258
        Compass->setValue(AnalogData[8]);
1245
 
1259
 
1246
        int Roll = (AnalogData[1] * FCSettings[P_GYRO_ACC_FAKTOR]) / 1024;
1260
        int Roll = (AnalogData[1] * FCSettings[P_GYRO_ACC_FAKTOR]) / 1024;
1247
        int Nick = (AnalogData[0] * FCSettings[P_GYRO_ACC_FAKTOR]) / 1024;
1261
        int Nick = (AnalogData[0] * FCSettings[P_GYRO_ACC_FAKTOR]) / 1024;
1248
 
1262
 
1249
        if (Roll > 128)
1263
        if (Roll > 128)
1250
            Roll = Roll - 255;
1264
            Roll = Roll - 255;
1251
 
1265
 
1252
        if (Nick > 128)
1266
        if (Nick > 128)
1253
            Nick = Nick - 255;
1267
            Nick = Nick - 255;
1254
 
1268
 
1255
        Attitude->setAngle(Roll);
1269
        Attitude->setAngle(Roll);
1256
        Attitude->setGradient(double(double(Nick) / 100.0));
1270
        Attitude->setGradient(double(double(Nick) / 100.0));
1257
    }
1271
    }
1258
}
1272
}
1259
 
1273
 
1260
void MKTool::new_NaviData(sRxData RX)
1274
void MKTool::new_NaviData(sRxData RX)
1261
{
1275
{
1262
    Navi.Current.Longitude = ToolBox::Data2Long(RX.Decode, N_CUR_LONGITUDE, true);
1276
    Navi.Current.Longitude = ToolBox::Data2Long(RX.Decode, N_CUR_LONGITUDE, true);
1263
    Navi.Current.Latitude  = ToolBox::Data2Long(RX.Decode, N_CUR_LATITUDE,  true);
1277
    Navi.Current.Latitude  = ToolBox::Data2Long(RX.Decode, N_CUR_LATITUDE,  true);
1264
    Navi.Current.Altitude  = ToolBox::Data2Long(RX.Decode, N_CUR_ALTITUDE,  true);
1278
    Navi.Current.Altitude  = ToolBox::Data2Long(RX.Decode, N_CUR_ALTITUDE,  true);
1265
    Navi.Target.Longitude  = ToolBox::Data2Long(RX.Decode, N_TAR_LONGITUDE, true);
1279
    Navi.Target.Longitude  = ToolBox::Data2Long(RX.Decode, N_TAR_LONGITUDE, true);
1266
    Navi.Target.Latitude   = ToolBox::Data2Long(RX.Decode, N_TAR_LATITUDE,  true);
1280
    Navi.Target.Latitude   = ToolBox::Data2Long(RX.Decode, N_TAR_LATITUDE,  true);
1267
    Navi.Target.Altitude   = ToolBox::Data2Long(RX.Decode, N_TAR_ALTITUDE,  true);
1281
    Navi.Target.Altitude   = ToolBox::Data2Long(RX.Decode, N_TAR_ALTITUDE,  true);
1268
 
1282
 
1269
    le_CDistance->setText(QString("%1 cm").arg(ToolBox::Data2Int(RX.Decode, N_HOME_DISTANCE)));
1283
    le_CDistance->setText(QString("%1 cm").arg(ToolBox::Data2Int(RX.Decode, N_HOME_DISTANCE)));
1270
    le_CWPA->setText(QString("%1").arg(RX.Decode[N_WP_INDEX]));
1284
    le_CWPA->setText(QString("%1").arg(RX.Decode[N_WP_INDEX]));
1271
    le_CWPT->setText(QString("%1").arg(RX.Decode[N_WP_NUMBER]));
1285
    le_CWPT->setText(QString("%1").arg(RX.Decode[N_WP_NUMBER]));
1272
    le_CSats->setText(QString("%1").arg(RX.Decode[N_SATS_IN_USER]));
1286
    le_CSats->setText(QString("%1").arg(RX.Decode[N_SATS_IN_USER]));
1273
 
1287
 
1274
    qwt_Rate->setValue(double(ToolBox::Data2Int(RX.Decode, N_VARIOMETER, true)));
1288
    qwt_Rate->setValue(double(ToolBox::Data2Int(RX.Decode, N_VARIOMETER, true)));
1275
 
1289
 
1276
    le_CTime->setText(QString("%1 sec.").arg(ToolBox::Data2Int(RX.Decode, N_FLYING_TIME)));
1290
    le_CTime->setText(QString("%1 sec.").arg(ToolBox::Data2Int(RX.Decode, N_FLYING_TIME)));
1277
 
1291
 
1278
    bar_UBAT->setValue(RX.Decode[N_UBAT]);
1292
    bar_UBAT->setValue(RX.Decode[N_UBAT]);
1279
 
1293
 
1280
    double Speed = double((ToolBox::Data2Int(RX.Decode, N_GROUND_SPEED)) / 10.0);
1294
    double Speed = double((ToolBox::Data2Int(RX.Decode, N_GROUND_SPEED)) / 10.0);
1281
 
1295
 
1282
    if ((Speed > 4.5) && SpeedMeter->property("END") == 5)
1296
    if ((Speed > 4.5) && SpeedMeter->property("END") == 5)
1283
    {
1297
    {
1284
        SpeedMeter->setRange(0.0, 10.0);
1298
        SpeedMeter->setRange(0.0, 10.0);
1285
        SpeedMeter->setScale(1, 2, 1);
1299
        SpeedMeter->setScale(1, 2, 1);
1286
        SpeedMeter->setProperty("END", 10);
1300
        SpeedMeter->setProperty("END", 10);
1287
    }
1301
    }
1288
 
1302
 
1289
    if ((Speed > 9) && SpeedMeter->property("END") == 10)
1303
    if ((Speed > 9) && SpeedMeter->property("END") == 10)
1290
    {
1304
    {
1291
        SpeedMeter->setRange(0.0, 20.0);
1305
        SpeedMeter->setRange(0.0, 20.0);
1292
        SpeedMeter->setScale(1, 2, 2);
1306
        SpeedMeter->setScale(1, 2, 2);
1293
        SpeedMeter->setProperty("END", 20);
1307
        SpeedMeter->setProperty("END", 20);
1294
    }
1308
    }
1295
 
1309
 
1296
    SpeedMeter->setValue(Speed);
1310
    SpeedMeter->setValue(Speed);
1297
 
1311
 
1298
    Compass->setValue(ToolBox::Data2Int(RX.Decode, N_COMAPSS_HEADING)); //(68)
1312
    Compass->setValue(ToolBox::Data2Int(RX.Decode, N_COMAPSS_HEADING)); //(68)
1299
 
1313
 
1300
    bar_RX->setValue(RX.Decode[N_RC_QUALITY]);
1314
    bar_RX->setValue(RX.Decode[N_RC_QUALITY]);
1301
 
1315
 
1302
    int Nick = RX.Decode[N_ANGLE_NICK];
1316
    int Nick = RX.Decode[N_ANGLE_NICK];
1303
    int Roll = RX.Decode[N_ANGLE_ROLL];
1317
    int Roll = RX.Decode[N_ANGLE_ROLL];
1304
 
1318
 
1305
    if (Roll > 128)
1319
    if (Roll > 128)
1306
        Roll = Roll - 255;
1320
        Roll = Roll - 255;
1307
 
1321
 
1308
    if (Nick > 128)
1322
    if (Nick > 128)
1309
        Nick = Nick - 255;
1323
        Nick = Nick - 255;
1310
 
1324
 
1311
    Attitude->setAngle(Roll);
1325
    Attitude->setAngle(Roll);
1312
    Attitude->setGradient(double(0.0 - (double(Nick) / 100.0)));
1326
    Attitude->setGradient(double(0.0 - (double(Nick) / 100.0)));
1313
 
1327
 
1314
    sNaviString NaviString;
1328
    sNaviString NaviString;
1315
 
1329
 
1316
    NaviString.Longitude = ToolBox::get_Float(Navi.Current.Longitude,10000000);
1330
    NaviString.Longitude = ToolBox::get_Float(Navi.Current.Longitude,10000000);
1317
    NaviString.Latitude  = ToolBox::get_Float(Navi.Current.Latitude,10000000);
1331
    NaviString.Latitude  = ToolBox::get_Float(Navi.Current.Latitude,10000000);
1318
    NaviString.Altitude  = ToolBox::get_Float(Navi.Current.Altitude,1000);
1332
    NaviString.Altitude  = ToolBox::get_Float(Navi.Current.Altitude,1000);
1319
 
1333
 
1320
    GE_Server->store_NaviString(NaviString);
1334
    GE_Server->store_NaviString(NaviString);
-
 
1335
 
-
 
1336
    f_Map->add_Position(NaviString.Longitude.toDouble(), NaviString.Latitude.toDouble());
1321
 
1337
 
1322
    if ((QMK_Server->property("Connect")) == true)
1338
    if ((QMK_Server->property("Connect")) == true)
1323
    {
1339
    {
1324
//        qDebug("Send Data to Server..!!");
1340
//        qDebug("Send Data to Server..!!");
1325
        QMK_Server->NewPosition(NaviString);
1341
        QMK_Server->NewPosition(NaviString);
1326
    }
1342
    }
1327
}
1343
}
1328
 
1344
 
1329
// Kopter-Kommunikations-Bereich, Befehle senden und Daten empfangen
1345
// Kopter-Kommunikations-Bereich, Befehle senden und Daten empfangen
1330
////////////////////////////////////////////////////////////////////
1346
////////////////////////////////////////////////////////////////////
1331
 
1347
 
1332
// Neues Datenpacket empfangen -> Verarbeiten
1348
// Neues Datenpacket empfangen -> Verarbeiten
1333
void MKTool::slot_newData(sRxData RX) // DONE 0.71g
1349
void MKTool::slot_newData(sRxData RX) // DONE 0.71g
1334
{
1350
{
1335
    if (LastSend.length() > 2)
1351
    if (LastSend.length() > 2)
1336
    {
1352
    {
1337
    }
1353
    }
1338
    int HardwareID = RX.Input[1] - 'a';
1354
    int HardwareID = RX.Input[1] - 'a';
1339
 
1355
 
1340
    switch(HardwareID)
1356
    switch(HardwareID)
1341
    {
1357
    {
1342
        case ADDRESS_FC :
1358
        case ADDRESS_FC :
1343
            switch(RX.Input[2])
1359
            switch(RX.Input[2])
1344
            {
1360
            {
1345
                // Stick-Belegung der Fernsteuerung
1361
                // Stick-Belegung der Fernsteuerung
1346
                case 'P' : // DONE 0.71g
1362
                case 'P' : // DONE 0.71g
1347
                    if (ToolBox::Decode64(RX))
1363
                    if (ToolBox::Decode64(RX))
1348
                    {
1364
                    {
1349
                        f_Settings->pb_K1->setValue(ToolBox::Data2Int(RX.Decode,  2,true));
1365
                        f_Settings->pb_K1->setValue(ToolBox::Data2Int(RX.Decode,  2,true));
1350
                        f_Settings->pb_K2->setValue(ToolBox::Data2Int(RX.Decode,  4,true));
1366
                        f_Settings->pb_K2->setValue(ToolBox::Data2Int(RX.Decode,  4,true));
1351
                        f_Settings->pb_K3->setValue(ToolBox::Data2Int(RX.Decode,  6,true));
1367
                        f_Settings->pb_K3->setValue(ToolBox::Data2Int(RX.Decode,  6,true));
1352
                        f_Settings->pb_K4->setValue(ToolBox::Data2Int(RX.Decode,  8,true));
1368
                        f_Settings->pb_K4->setValue(ToolBox::Data2Int(RX.Decode,  8,true));
1353
                        f_Settings->pb_K5->setValue(ToolBox::Data2Int(RX.Decode, 10 ,true));
1369
                        f_Settings->pb_K5->setValue(ToolBox::Data2Int(RX.Decode, 10 ,true));
1354
                        f_Settings->pb_K6->setValue(ToolBox::Data2Int(RX.Decode, 12,true));
1370
                        f_Settings->pb_K6->setValue(ToolBox::Data2Int(RX.Decode, 12,true));
1355
                        f_Settings->pb_K7->setValue(ToolBox::Data2Int(RX.Decode, 14,true));
1371
                        f_Settings->pb_K7->setValue(ToolBox::Data2Int(RX.Decode, 14,true));
1356
                        f_Settings->pb_K8->setValue(ToolBox::Data2Int(RX.Decode, 16,true));
1372
                        f_Settings->pb_K8->setValue(ToolBox::Data2Int(RX.Decode, 16,true));
1357
                    }
1373
                    }
1358
                break;
1374
                break;
1359
                // Settings lesen
1375
                // Settings lesen
1360
                case 'Q' : // DONE 0.71g
1376
                case 'Q' : // DONE 0.71g
1361
                    if (ToolBox::Decode64(RX))
1377
                    if (ToolBox::Decode64(RX))
1362
                    {
1378
                    {
1363
                        TickerEvent[0] = false;
1379
                        TickerEvent[0] = false;
1364
 
1380
 
1365
                        if (RX.Decode[1] == VERSION_SETTINGS)
1381
                        if (RX.Decode[1] == VERSION_SETTINGS)
1366
                        {
1382
                        {
1367
                            int Settings_ID = RX.Decode[0];
1383
                            int Settings_ID = RX.Decode[0];
1368
                            for (int a = 0; a < MaxParameter; a++)
1384
                            for (int a = 0; a < MaxParameter; a++)
1369
                            {
1385
                            {
1370
                                FCSettings[a] = RX.Decode[a + 2];
1386
                                FCSettings[a] = RX.Decode[a + 2];
1371
                            }
1387
                            }
1372
                            //show_ParameterSet(Settings_ID);
1388
                            //show_ParameterSet(Settings_ID);
1373
                            f_Settings->show_FCSettings(Settings_ID, FCSettings);
1389
                            f_Settings->show_FCSettings(Settings_ID, FCSettings);
1374
                            f_Settings->pb_Read->setEnabled(true);
1390
                            f_Settings->pb_Read->setEnabled(true);
1375
                            f_Settings->pb_Write->setEnabled(true);
1391
                            f_Settings->pb_Write->setEnabled(true);
1376
                        }
1392
                        }
1377
                        else
1393
                        else
1378
                        {
1394
                        {
1379
                            f_Settings->pb_Read->setDisabled(true);
1395
                            f_Settings->pb_Read->setDisabled(true);
1380
                            f_Settings->pb_Write->setDisabled(true);
1396
                            f_Settings->pb_Write->setDisabled(true);
1381
 
1397
 
1382
                            QMessageBox::warning(this, QA_NAME,
1398
                            QMessageBox::warning(this, QA_NAME,
1383
                                   "Versionen inkompatibel. \nParameterbearbeitung nicht moeglich.", QMessageBox::Ok);
1399
                                   "Versionen inkompatibel. \nParameterbearbeitung nicht moeglich.", QMessageBox::Ok);
1384
                        }
1400
                        }
1385
                    }
1401
                    }
1386
                break;
1402
                break;
1387
                // Settings geschrieben
1403
                // Settings geschrieben
1388
                case 'S' : // DONE 0.71g
1404
                case 'S' : // DONE 0.71g
1389
                    TickerEvent[0] = false;
1405
                    TickerEvent[0] = false;
1390
                break;
1406
                break;
1391
            }
1407
            }
1392
 
1408
 
1393
        case ADDRESS_NC :
1409
        case ADDRESS_NC :
1394
            switch(RX.Input[2])
1410
            switch(RX.Input[2])
1395
            {
1411
            {
1396
                // Navigationsdaten
1412
                // Navigationsdaten
1397
                case 'O' : // NOT DONE 0.12h
1413
                case 'O' : // NOT DONE 0.12h
1398
                    if (ToolBox::Decode64(RX))
1414
                    if (ToolBox::Decode64(RX))
1399
                    {
1415
                    {
1400
                        new_NaviData(RX);
1416
                        new_NaviData(RX);
1401
                    }
1417
                    }
1402
                break;
1418
                break;
1403
            }
1419
            }
1404
//        case ADDRESS_MK3MAG :
1420
//        case ADDRESS_MK3MAG :
1405
 
1421
 
1406
        default :
1422
        default :
1407
            switch(RX.Input[2])
1423
            switch(RX.Input[2])
1408
            {
1424
            {
1409
                // LCD-Anzeige
1425
                // LCD-Anzeige
1410
                case 'L' : // DONE 0.71g
1426
                case 'L' : // DONE 0.71g
1411
                    if (ToolBox::Decode64(RX))
1427
                    if (ToolBox::Decode64(RX))
1412
                    {
1428
                    {
1413
                        int LCD[150];
1429
                        int LCD[150];
1414
                        memcpy(LCD,RX.Decode, sizeof(RX.Decode));
1430
                        memcpy(LCD,RX.Decode, sizeof(RX.Decode));
1415
 
1431
 
1416
                        f_LCD->show_Data(LCD);
1432
                        f_LCD->show_Data(LCD);
1417
 
1433
 
1418
                        LCD_Page     = RX.Decode[0];
1434
                        LCD_Page     = RX.Decode[0];
1419
                        LCD_MAX_Page = RX.Decode[1];
1435
                        LCD_MAX_Page = RX.Decode[1];
1420
 
1436
 
1421
                        TickerEvent[0] = false;
1437
                        TickerEvent[0] = false;
1422
                    }
1438
                    }
1423
                break;
1439
                break;
1424
                // Analoglabels
1440
                // Analoglabels
1425
                case 'A' : // DONE 0.71g
1441
                case 'A' : // DONE 0.71g
1426
                    if (ToolBox::Decode64(RX))
1442
                    if (ToolBox::Decode64(RX))
1427
                    {
1443
                    {
1428
                        int Position = RX.Decode[0];
1444
                        int Position = RX.Decode[0];
1429
                        if (Position != 31)
1445
                        if (Position != 31)
1430
                        {
1446
                        {
1431
                            Settings->Analog1.Label[Position] = ToolBox::Data2QString(RX.Decode,1,17).trimmed();
1447
                            Settings->Analog1.Label[Position] = ToolBox::Data2QString(RX.Decode,1,17).trimmed();
1432
                            if (Settings->Analog1.Label[Position] == "")
1448
                            if (Settings->Analog1.Label[Position] == "")
1433
                            {
1449
                            {
1434
                                Settings->Analog1.Label[Position] = "A-" + QString("%1").arg(Position);
1450
                                Settings->Analog1.Label[Position] = "A-" + QString("%1").arg(Position);
1435
                            }
1451
                            }
1436
                            Position ++;
1452
                            Position ++;
1437
                            TX_Data[0] = Position;
1453
                            TX_Data[0] = Position;
1438
                            Conn->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true);
1454
                            Conn->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true);
1439
                        }
1455
                        }
1440
                        if (Position == 31)
1456
                        if (Position == 31)
1441
                        {
1457
                        {
1442
                            for (int a = 0; a < MaxAnalog; a++)
1458
                            for (int a = 0; a < MaxAnalog; a++)
1443
                            {
1459
                            {
1444
                                lb_Analog[a]->setText(Settings->Analog1.Label[a]);
1460
                                lb_Analog[a]->setText(Settings->Analog1.Label[a]);
1445
                            }
1461
                            }
1446
                            Settings->Analog1.Version = Mode.Version;
1462
                            Settings->Analog1.Version = Mode.Version;
1447
                            Settings->write_Settings_AnalogLabels(HardwareID);
1463
                            Settings->write_Settings_AnalogLabels(HardwareID);
1448
                            config_Plot();
1464
                            config_Plot();
1449
                        }
1465
                        }
1450
                    }
1466
                    }
1451
                break;
1467
                break;
1452
                // Debug-Daten
1468
                // Debug-Daten
1453
                case 'D' : // DONE 0.71g
1469
                case 'D' : // DONE 0.71g
1454
                    if (ToolBox::Decode64(RX))
1470
                    if (ToolBox::Decode64(RX))
1455
                    {
1471
                    {
1456
                        for (int i = 0; i < MaxAnalog; i++)
1472
                        for (int i = 0; i < MaxAnalog; i++)
1457
                        {
1473
                        {
1458
                            AnalogData[i] = ToolBox::Data2Int(RX.Decode, (i * 2) + 2);
1474
                            AnalogData[i] = ToolBox::Data2Int(RX.Decode, (i * 2) + 2);
1459
                        }
1475
                        }
1460
                        show_DebugData();
1476
                        show_DebugData();
1461
                    }
1477
                    }
1462
                break;
1478
                break;
1463
                // Version
1479
                // Version
1464
                case 'V' : // DONE 0.71h
1480
                case 'V' : // DONE 0.71h
1465
                    if (ToolBox::Decode64(RX))
1481
                    if (ToolBox::Decode64(RX))
1466
                    {
1482
                    {
1467
                        TickerEvent[0] = false;
1483
                        TickerEvent[0] = false;
1468
 
1484
 
1469
                        Mode.ID            = HardwareID;
1485
                        Mode.ID            = HardwareID;
1470
                        Mode.VERSION_MAJOR = RX.Decode[0];
1486
                        Mode.VERSION_MAJOR = RX.Decode[0];
1471
                        Mode.VERSION_MINOR = RX.Decode[1];
1487
                        Mode.VERSION_MINOR = RX.Decode[1];
1472
                        Mode.VERSION_PATCH = RX.Decode[4];
1488
                        Mode.VERSION_PATCH = RX.Decode[4];
1473
                        Mode.VERSION_SERIAL_MAJOR = RX.Decode[2];
1489
                        Mode.VERSION_SERIAL_MAJOR = RX.Decode[2];
1474
                        Mode.VERSION_SERIAL_MINOR = RX.Decode[3];
1490
                        Mode.VERSION_SERIAL_MINOR = RX.Decode[3];
1475
 
1491
 
1476
                        Mode.Hardware   = HardwareType[Mode.ID];
1492
                        Mode.Hardware   = HardwareType[Mode.ID];
1477
                        Mode.Version    = QString("%1").arg(RX.Decode[0]) + "." + QString("%1").arg(RX.Decode[1]) + QString(RX.Decode[4] + 'a');
1493
                        Mode.Version    = QString("%1").arg(RX.Decode[0]) + "." + QString("%1").arg(RX.Decode[1]) + QString(RX.Decode[4] + 'a');
1478
 
1494
 
1479
                        setWindowTitle(QA_NAME + " v" + QA_VERSION + " - " + Mode.Hardware + " " + Mode.Version);
1495
                        setWindowTitle(QA_NAME + " v" + QA_VERSION + " - " + Mode.Hardware + " " + Mode.Version);
1480
 
1496
 
1481
                        if (Mode.VERSION_SERIAL_MAJOR != VERSION_SERIAL_MAJOR)
1497
                        if (Mode.VERSION_SERIAL_MAJOR != VERSION_SERIAL_MAJOR)
1482
                        {
1498
                        {
1483
//                                AllowSend = false;
1499
//                                AllowSend = false;
1484
                                QMessageBox::warning(this, QA_NAME,
1500
                                QMessageBox::warning(this, QA_NAME,
1485
                                   "Serielles Protokoll Inkompatibel. \nBitte neue Programmversion installieren,", QMessageBox::Ok);
1501
                                   "Serielles Protokoll Inkompatibel. \nBitte neue Programmversion installieren,", QMessageBox::Ok);
1486
                        }
1502
                        }
1487
 
1503
 
1488
                        if (ac_NoDebug->isChecked())
1504
                        if (ac_NoDebug->isChecked())
1489
                        {
1505
                        {
1490
                            TX_Data[0] = 0;
1506
                            TX_Data[0] = 0;
1491
                        }
1507
                        }
1492
                        else
1508
                        else
1493
                        if (ac_FastDebug->isChecked())
1509
                        if (ac_FastDebug->isChecked())
1494
                        {
1510
                        {
1495
                            TX_Data[0] = Settings->Data.Debug_Fast / 10;
1511
                            TX_Data[0] = Settings->Data.Debug_Fast / 10;
1496
                        }
1512
                        }
1497
                        else
1513
                        else
1498
                        {
1514
                        {
1499
                            TX_Data[0] = Settings->Data.Debug_Slow / 10;
1515
                            TX_Data[0] = Settings->Data.Debug_Slow / 10;
1500
                        }
1516
                        }
1501
 
1517
 
1502
                        Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
1518
                        Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
1503
 
1519
 
1504
                        // Wenn MK3MAG dann andauernd Daten neu anfragen.
1520
                        // Wenn MK3MAG dann andauernd Daten neu anfragen.
1505
                        if (Mode.ID == ADDRESS_MK3MAG)
1521
                        if (Mode.ID == ADDRESS_MK3MAG)
1506
                        {
1522
                        {
1507
                            TickerEvent[3] = true;
1523
                            TickerEvent[3] = true;
1508
                            rb_SelMag->setChecked(true);
1524
                            rb_SelMag->setChecked(true);
1509
                        }
1525
                        }
1510
 
1526
 
1511
                        // Wenn NaviCtrl dann hier.
1527
                        // Wenn NaviCtrl dann hier.
1512
                        if (Mode.ID == ADDRESS_NC)
1528
                        if (Mode.ID == ADDRESS_NC)
1513
                        {
1529
                        {
1514
                            rb_SelNC->setChecked(true);
1530
                            rb_SelNC->setChecked(true);
1515
 
1531
 
1516
                            if (ac_NoNavi->isChecked())
1532
                            if (ac_NoNavi->isChecked())
1517
                            {
1533
                            {
1518
                                TX_Data[0] = 0;
1534
                                TX_Data[0] = 0;
1519
                            }
1535
                            }
1520
                            else
1536
                            else
1521
                            if (ac_FastNavi->isChecked())
1537
                            if (ac_FastNavi->isChecked())
1522
                            {
1538
                            {
1523
                                TX_Data[0] = Settings->Data.Navi_Fast / 10;
1539
                                TX_Data[0] = Settings->Data.Navi_Fast / 10;
1524
                            }
1540
                            }
1525
                            else
1541
                            else
1526
                            {
1542
                            {
1527
                                TX_Data[0] = Settings->Data.Navi_Slow / 10;
1543
                                TX_Data[0] = Settings->Data.Navi_Slow / 10;
1528
                            }
1544
                            }
1529
 
1545
 
1530
                            Conn->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false);
1546
                            Conn->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false);
1531
                        }
1547
                        }
1532
 
1548
 
1533
 
1549
 
1534
                        // Wenn FlightCtrl dann Settings abfragen.
1550
                        // Wenn FlightCtrl dann Settings abfragen.
1535
                        if (Mode.ID == ADDRESS_FC)
1551
                        if (Mode.ID == ADDRESS_FC)
1536
                        {
1552
                        {
1537
                            rb_SelFC->setChecked(true);
1553
                            rb_SelFC->setChecked(true);
1538
                            {
1554
                            {
1539
                                TX_Data[0] = 0xff;
1555
                                TX_Data[0] = 0xff;
1540
                                TX_Data[1] = 0;
1556
                                TX_Data[1] = 0;
1541
 
1557
 
1542
                                // DEP: Raus wenn Resend implementiert.
1558
                                // DEP: Raus wenn Resend implementiert.
1543
                                ToolBox::Wait(SLEEP);
1559
                                ToolBox::Wait(SLEEP);
1544
                                Conn->send_Cmd('q', ADDRESS_FC, TX_Data, 1, true);
1560
                                Conn->send_Cmd('q', ADDRESS_FC, TX_Data, 1, true);
1545
                                qDebug("FC - Get Settings");
1561
                                qDebug("FC - Get Settings");
1546
                            }
1562
                            }
1547
                        }
1563
                        }
1548
                        // Wenn nicht Lesen und Schreiben der Settings deaktivieren.
1564
                        // Wenn nicht Lesen und Schreiben der Settings deaktivieren.
1549
                        else
1565
                        else
1550
                        {
1566
                        {
1551
                                f_Settings->pb_Read->setDisabled(true);
1567
                                f_Settings->pb_Read->setDisabled(true);
1552
                                f_Settings->pb_Write->setDisabled(true);
1568
                                f_Settings->pb_Write->setDisabled(true);
1553
                        }
1569
                        }
1554
 
1570
 
1555
                        Settings->read_Settings_Analog(HardwareID);
1571
                        Settings->read_Settings_Analog(HardwareID);
1556
                        Settings->read_Settings_AnalogLabels(HardwareID);
1572
                        Settings->read_Settings_AnalogLabels(HardwareID);
1557
 
1573
 
1558
                        if (Settings->Analog1.Version != Mode.Version)
1574
                        if (Settings->Analog1.Version != Mode.Version)
1559
                        {
1575
                        {
1560
                            lb_Status->setText("Analoglabel-Version unterschiedlich. Lese Analoglabels neu aus.");
1576
                            lb_Status->setText("Analoglabel-Version unterschiedlich. Lese Analoglabels neu aus.");
1561
                            slot_ac_GetLabels();
1577
                            slot_ac_GetLabels();
1562
                        }
1578
                        }
1563
                        else
1579
                        else
1564
                        for (int a = 0; a < MaxAnalog; a++)
1580
                        for (int a = 0; a < MaxAnalog; a++)
1565
                        {
1581
                        {
1566
                            lb_Analog[a]->setText(Settings->Analog1.Label[a]);
1582
                            lb_Analog[a]->setText(Settings->Analog1.Label[a]);
1567
                        }
1583
                        }
1568
                        config_Plot();
1584
                        config_Plot();
1569
                    }
1585
                    }
1570
                break;
1586
                break;
1571
            }
1587
            }
1572
    }
1588
    }
1573
 
1589
 
1574
    // TODO: Roh-Daten senden zum QMK-Server dazu Sendebuffer bauen.
1590
    // TODO: Roh-Daten senden zum QMK-Server dazu Sendebuffer bauen.
1575
    if ((QMK_Server->property("Connect")) == true)
1591
    if ((QMK_Server->property("Connect")) == true)
1576
    {
1592
    {
1577
//        QMK_Server->send_RawData(RX.String);
1593
//        QMK_Server->send_RawData(RX.String);
1578
    }
1594
    }
1579
 
1595
 
1580
    slot_showTerminal(1, RX.String);
1596
    slot_showTerminal(1, RX.String);
1581
}
1597
}
1582
 
1598
 
1583
void MKTool::slot_showTerminal(int Typ, QString Text)
1599
void MKTool::slot_showTerminal(int Typ, QString Text)
1584
{
1600
{
1585
    switch(Typ)
1601
    switch(Typ)
1586
    {
1602
    {
1587
        case 1 :
1603
        case 1 :
1588
        {
1604
        {
1589
            if ((cb_ShowData->isChecked()) && ((tab_Main->currentWidget()->objectName() == QString("Tab_3")) || (cb_ShowAlways->isChecked())))
1605
            if ((cb_ShowData->isChecked()) && ((tab_Main->currentWidget()->objectName() == QString("Tab_3")) || (cb_ShowAlways->isChecked())))
1590
            {
1606
            {
1591
                te_RX->moveCursor(QTextCursor::End,  QTextCursor::MoveAnchor);
1607
                te_RX->moveCursor(QTextCursor::End,  QTextCursor::MoveAnchor);
1592
                te_RX->insertHtml("<span style=\"color:#00008b;\">" + Text + "<br /></span>");
1608
                te_RX->insertHtml("<span style=\"color:#00008b;\">" + Text + "<br /></span>");
1593
            }
1609
            }
1594
        }
1610
        }
1595
        break;
1611
        break;
1596
        case 2 :
1612
        case 2 :
1597
        {
1613
        {
1598
            if ((cb_ShowMSG->isChecked()) && ((tab_Main->currentWidget()->objectName() == QString("Tab_3")) || (cb_ShowAlways->isChecked())))
1614
            if ((cb_ShowMSG->isChecked()) && ((tab_Main->currentWidget()->objectName() == QString("Tab_3")) || (cb_ShowAlways->isChecked())))
1599
            {
1615
            {
1600
                te_RX->moveCursor(QTextCursor::End,  QTextCursor::MoveAnchor);
1616
                te_RX->moveCursor(QTextCursor::End,  QTextCursor::MoveAnchor);
1601
                te_RX->insertHtml("<span style=\"color:#008b00;\">" + Text + "</span>");
1617
                te_RX->insertHtml("<span style=\"color:#008b00;\">" + Text + "</span>");
1602
            }
1618
            }
1603
        }
1619
        }
1604
        break;
1620
        break;
1605
        case 3 :
1621
        case 3 :
1606
        {
1622
        {
1607
            if (cb_ShowSend->isChecked())
1623
            if (cb_ShowSend->isChecked())
1608
            {
1624
            {
1609
                te_RX->moveCursor(QTextCursor::End,  QTextCursor::MoveAnchor);
1625
                te_RX->moveCursor(QTextCursor::End,  QTextCursor::MoveAnchor);
1610
                te_RX->insertHtml("<span style='color:#8b0000;'>" + Text + "<br /></span>");
1626
                te_RX->insertHtml("<span style='color:#8b0000;'>" + Text + "<br /></span>");
1611
            }
1627
            }
1612
        }
1628
        }
1613
        break;
1629
        break;
1614
    }
1630
    }
1615
}
1631
}
1616
 
1632
 
1617
// Verbindung zum Kopter herstellen / Trennen
1633
// Verbindung zum Kopter herstellen / Trennen
1618
void MKTool::slot_OpenPort()
1634
void MKTool::slot_OpenPort()
1619
{
1635
{
1620
    if (Conn->isOpen())
1636
    if (Conn->isOpen())
1621
    {
1637
    {
1622
        TX_Data[0] = Settings->Data.Debug_Off / 10;
1638
        TX_Data[0] = Settings->Data.Debug_Off / 10;
1623
        Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
1639
        Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
1624
        ToolBox::Wait(SLEEP);
1640
        ToolBox::Wait(SLEEP);
1625
 
1641
 
1626
        if (Mode.ID == ADDRESS_NC)
1642
        if (Mode.ID == ADDRESS_NC)
1627
        {
1643
        {
1628
            TX_Data[0] = Settings->Data.Navi_Off / 10;
1644
            TX_Data[0] = Settings->Data.Navi_Off / 10;
1629
            Conn->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false);
1645
            Conn->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false);
1630
            ToolBox::Wait(SLEEP);
1646
            ToolBox::Wait(SLEEP);
1631
        }
1647
        }
1632
 
1648
 
1633
        if (Mode.ID == ADDRESS_FC)
1649
        if (Mode.ID == ADDRESS_FC)
1634
        {
1650
        {
1635
            TX_Data[0] = 0;
1651
            TX_Data[0] = 0;
1636
            TX_Data[1] = 0;
1652
            TX_Data[1] = 0;
1637
            TX_Data[2] = 0;
1653
            TX_Data[2] = 0;
1638
            TX_Data[3] = 0;
1654
            TX_Data[3] = 0;
1639
            Conn->send_Cmd('t', ADDRESS_FC, TX_Data, 4, false);
1655
            Conn->send_Cmd('t', ADDRESS_FC, TX_Data, 4, false);
1640
            ToolBox::Wait(SLEEP);
1656
            ToolBox::Wait(SLEEP);
1641
        }
1657
        }
1642
 
1658
 
1643
        Conn->Close();
1659
        Conn->Close();
1644
 
1660
 
1645
        ac_ConnectTTY->setText("Kopter Verbinden");
1661
        ac_ConnectTTY->setText("Kopter Verbinden");
1646
        le_Port->setEnabled(true);
1662
        le_Port->setEnabled(true);
1647
 
1663
 
1648
        Ticker->stop();
1664
        Ticker->stop();
1649
    }
1665
    }
1650
    else
1666
    else
1651
    {
1667
    {
1652
        int i_Type;
1668
        int i_Type;
1653
        if (le_Port->text().contains(QString("IP:")))
1669
        if (le_Port->text().contains(QString("IP:")))
1654
        {
1670
        {
1655
            i_Type = C_IP;
1671
            i_Type = C_IP;
1656
        }
1672
        }
1657
        else
1673
        else
1658
        {
1674
        {
1659
            i_Type = C_TTY;
1675
            i_Type = C_TTY;
1660
        }
1676
        }
1661
 
1677
 
1662
        if (Conn->Open(i_Type, le_Port->text()))
1678
        if (Conn->Open(i_Type, le_Port->text()))
1663
        {
1679
        {
1664
            ac_ConnectTTY->setText("Kopter Trennen");
1680
            ac_ConnectTTY->setText("Kopter Trennen");
1665
            le_Port->setEnabled(false);
1681
            le_Port->setEnabled(false);
1666
 
1682
 
1667
            Conn->send_Cmd('v', ADDRESS_ALL, TX_Data, 0, true);
1683
            Conn->send_Cmd('v', ADDRESS_ALL, TX_Data, 0, true);
1668
 
1684
 
1669
            Ticker->start(2000);
1685
            Ticker->start(2000);
1670
        }
1686
        }
1671
    }
1687
    }
1672
}
1688
}
1673
 
1689
 
1674
// Programm beenden
1690
// Programm beenden
1675
///////////////////
1691
///////////////////
1676
 
1692
 
1677
MKTool::~MKTool()
1693
MKTool::~MKTool()
1678
{
1694
{
1679
    if (Conn->isOpen())
1695
    if (Conn->isOpen())
1680
    {
1696
    {
1681
        Conn->Close();
1697
        Conn->Close();
1682
    }
1698
    }
1683
 
1699
 
1684
    set_Preferences();
1700
    set_Preferences();
1685
    Settings->write_Settings();
1701
    Settings->write_Settings();
1686
 
1702
 
1687
    logger->close();
1703
    logger->close();
1688
}
1704
}
1689
 
1705