Subversion Repositories Projects

Rev

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

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