Subversion Repositories Projects

Rev

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

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