Subversion Repositories Projects

Rev

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

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