Subversion Repositories Projects

Rev

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

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