Subversion Repositories Projects

Rev

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

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