Subversion Repositories Projects

Rev

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

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