Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
158 KeyOz 1
/***************************************************************************
2
 *   Copyright (C) 2008 by Manuel Schrape                                  *
3
 *   manuel.schrape@gmx.de                                                 *
4
 *                                                                         *
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  *
7
 *   the Free Software Foundation; either version 2 of the License.        *
8
 *                                                                         *
9
 *   This program is distributed in the hope that it will be useful,       *
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12
 *   GNU General Public License for more details.                          *
13
 *                                                                         *
14
 *   You should have received a copy of the GNU General Public License     *
15
 *   along with this program; if not, write to the                         *
16
 *   Free Software Foundation, Inc.,                                       *
17
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
18
 ***************************************************************************/
19
 
20
#include <QtGui>
21
 
22
#include <QLineEdit>
23
#include <QString>
24
#include <QTimer>
25
#include <QIcon>
26
#include <QToolButton>
27
#include <QSpinBox>
28
 
29
#include "mktool.h"
30
#include "dlg_Config.h"
31
#include "dlg_Motortest.h"
159 KeyOz 32
#include "dlg_Preferences.h"
158 KeyOz 33
#include "../global.h"
34
#include "../ToolBox.h"
35
 
36
#include <stdlib.h>
37
 
38
MKTool::MKTool()
39
{
40
    setupUi(this);
41
 
42
    Settings = new cSettings;
162 KeyOz 43
//    Settings->read_Settings();
44
//    Settings->read_Settings_FC();
158 KeyOz 45
 
46
    init_Arrays();
47
    init_Icons();
48
    init_GUI();
49
 
50
    init_Objects();
51
    init_Connections();
52
 
53
    init_Plot();
54
 
159 KeyOz 55
    Ticker->start(2000);
158 KeyOz 56
}
57
 
58
void MKTool::init_GUI()
59
{
60
    setWindowTitle(QA_NAME + " v" + QA_VERSION);
61
 
62
#ifdef _EEEPC_
63
    toolBar->hide();
64
#endif
65
 
66
    resize(Settings->GUI.Size);
67
    move(Settings->GUI.Point);
68
 
69
    if (Settings->GUI.isMax)
70
    {
71
        showMaximized();
72
    }
73
 
74
    for (int a = 0; a < MaxAnalog; a++)
75
    {
162 KeyOz 76
        lb_Analog[a]->setText(Settings->Analog1.Label[a]);
158 KeyOz 77
    }
78
 
79
    for (int b = 0; b < 6; b++)
80
    {
81
        TabWidgets[b] = tab_Main->widget(b);
82
    }
83
 
84
    for (int c = 0; c < 6; c++)
85
    {
86
        if (Settings->GUI.TabViews[c] == false)
87
        {
88
            QString TabName = QString("Tab_%1").arg(c);
89
 
90
            for (int d = 0; d < tab_Main->count(); d++)
91
            {
92
                if (tab_Main->widget(d)->objectName() == TabName)
93
                {
94
                    tab_Main->removeTab(d);
95
                }
96
            }
97
        }
98
    }
99
 
100
    ac_View0->setChecked(Settings->GUI.TabViews[0]);
101
    ac_View1->setChecked(Settings->GUI.TabViews[1]);
102
    ac_View2->setChecked(Settings->GUI.TabViews[2]);
103
    ac_View3->setChecked(Settings->GUI.TabViews[3]);
104
    ac_View4->setChecked(Settings->GUI.TabViews[4]);
105
    ac_View5->setChecked(Settings->GUI.TabViews[5]);
106
 
107
    le_Port->setText(Settings->TTY.Port);
162 KeyOz 108
 
109
    cb_ShowMSG->setChecked(Settings->GUI.Term_Info);
110
    cb_ShowData->setChecked(Settings->GUI.Term_Data);
111
    cb_ShowAlways->setChecked(Settings->GUI.Term_Always);
158 KeyOz 112
}
113
 
114
void MKTool::init_Objects()
115
{
116
    // QTimer-Instanzen
117
    Ticker  = new QTimer(this);
118
 
119
    // Seriell-Port
120
    serialPort = new ManageSerialPort;
121
 
122
    // QFile-Instanz (Log-Datei)
123
    CSVFile = new QFile("");
159 KeyOz 124
 
125
    AllowSend = true;
158 KeyOz 126
}
127
 
128
void MKTool::init_Connections()
129
{
130
    // Seriel-Port Empfang
131
    connect(serialPort, SIGNAL(newDataReceived(const QByteArray &)), this, SLOT(slot_newDataReceived(const QByteArray &)));
132
 
133
    // Buttons und Menüpunkte / Toolbar
134
    connect(pb_Load,   SIGNAL(clicked()), this, SLOT(slot_LoadParameter()));
135
    connect(pb_Save,   SIGNAL(clicked()), this, SLOT(slot_SaveParameter()));
136
    connect(pb_Read,   SIGNAL(clicked()), this, SLOT(slot_GetParameter()));
137
    connect(pb_Write,  SIGNAL(clicked()), this, SLOT(slot_SetParameter()));
138
 
159 KeyOz 139
    connect(pb_LCDup,   SIGNAL(clicked()), this, SLOT(slot_LCD_UP()));
140
    connect(pb_LCDdown, SIGNAL(clicked()), this, SLOT(slot_LCD_DOWN()));
141
 
158 KeyOz 142
    // Actions
143
    connect(ac_Config,       SIGNAL(triggered()), this, SLOT(slot_ac_Config()));
159 KeyOz 144
    connect(ac_Preferences,  SIGNAL(triggered()), this, SLOT(slot_ac_Preferences()));
145
 
158 KeyOz 146
    connect(ac_Motortest,    SIGNAL(triggered()), this, SLOT(slot_ac_Motortest()));
147
    connect(ac_StartPlotter, SIGNAL(triggered()), this, SLOT(slot_ac_StartPlotter()));
148
    connect(ac_MehrDaten,    SIGNAL(triggered()), this, SLOT(slot_ac_MehrDaten()));
149
    connect(ac_About,        SIGNAL(triggered()), this, SLOT(slot_ac_About()));
150
    connect(ac_GetLabels,    SIGNAL(triggered()), this, SLOT(slot_ac_GetLabels()));
151
 
152
    // Tabs ein & ausblenden
153
    connect(ac_View0,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
154
    connect(ac_View1,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
155
    connect(ac_View2,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
156
    connect(ac_View3,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
157
    connect(ac_View4,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
158
    connect(ac_View5,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
159
 
162 KeyOz 160
//    connect(pb_Update,  SIGNAL(clicked()), this, SLOT(slot_pb_Update()));
158 KeyOz 161
 
162
    connect(ac_ConnectTTY, SIGNAL(triggered()), this, SLOT(slot_OpenPort()));
163
    connect(ac_RecordCSV,  SIGNAL(triggered()), this, SLOT(slot_RecordCSV()));
164
 
165
    connect(ac_LogDir,       SIGNAL(triggered()), this, SLOT(slot_SetLogDir()));
166
    connect(ac_ParameterDir, SIGNAL(triggered()), this, SLOT(slot_SetParDir()));
167
 
168
    // Timer-Events
169
    connect(Ticker,   SIGNAL(timeout()),       SLOT(slot_Ticker()));
170
 
171
    // Seitenwechsel :)
172
    connect(tab_Main, SIGNAL(currentChanged(int)), this, SLOT(slot_TabChanged(int)));
173
    connect(tab_Par,  SIGNAL(currentChanged(int)), this, SLOT(slot_TabChanged(int)));
174
 
175
    // Parameterevents
176
    connect(tb_9_6,  SIGNAL(clicked()), this, SLOT(slot_tbUp()));
177
    connect(tb_9_7,  SIGNAL(clicked()), this, SLOT(slot_tbDown()));
178
    connect(tb_9_8,  SIGNAL(clicked()), this, SLOT(slot_tbLeft()));
179
    connect(tb_9_9,  SIGNAL(clicked()), this, SLOT(slot_tbRight()));
180
 
181
    connect(J16_0,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
182
    connect(J16_1,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
183
    connect(J16_2,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
184
    connect(J16_3,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
185
    connect(J16_4,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
186
    connect(J16_5,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
187
    connect(J16_6,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
188
    connect(J16_7,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
189
 
190
    connect(J17_0,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
191
    connect(J17_1,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
192
    connect(J17_2,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
193
    connect(J17_3,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
194
    connect(J17_4,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
195
    connect(J17_5,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
196
    connect(J17_6,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
197
    connect(J17_7,  SIGNAL(clicked()), this, SLOT(slot_LEDtoValue()));
198
 
199
    connect(sb_11_1, SIGNAL(valueChanged(int)), this, SLOT(slot_ValuetoLED16(int)));
200
    connect(sb_11_3, SIGNAL(valueChanged(int)), this, SLOT(slot_ValuetoLED17(int)));
201
 
202
    // Plotter
203
    connect(scroll_plot, SIGNAL(valueChanged(int)), this, SLOT(slot_ScrollPlot(int)));
204
 
205
    // About-QT Dialog einfügen
206
    menu_Help->addAction(trUtf8("Über &Qt"), qApp, SLOT(aboutQt()));
207
}
208
 
209
void MKTool::init_Arrays()
210
{
211
    lb_Analog[0]  = lb_A_0;
212
    lb_Analog[1]  = lb_A_1;
213
    lb_Analog[2]  = lb_A_2;
214
    lb_Analog[3]  = lb_A_3;
215
    lb_Analog[4]  = lb_A_4;
216
    lb_Analog[5]  = lb_A_5;
217
    lb_Analog[6]  = lb_A_6;
218
    lb_Analog[7]  = lb_A_7;
219
    lb_Analog[8]  = lb_A_8;
220
    lb_Analog[9]  = lb_A_9;
221
    lb_Analog[10] = lb_A_10;
222
    lb_Analog[11] = lb_A_11;
223
    lb_Analog[12] = lb_A_12;
224
    lb_Analog[13] = lb_A_13;
225
    lb_Analog[14] = lb_A_14;
226
    lb_Analog[15] = lb_A_15;
227
    lb_Analog[16] = lb_A_16;
228
    lb_Analog[17] = lb_A_17;
229
    lb_Analog[18] = lb_A_18;
230
    lb_Analog[19] = lb_A_19;
231
    lb_Analog[20] = lb_A_20;
232
    lb_Analog[21] = lb_A_21;
233
    lb_Analog[22] = lb_A_22;
234
    lb_Analog[23] = lb_A_23;
235
    lb_Analog[24] = lb_A_24;
236
    lb_Analog[25] = lb_A_25;
237
    lb_Analog[26] = lb_A_26;
238
    lb_Analog[27] = lb_A_27;
239
    lb_Analog[28] = lb_A_28;
240
    lb_Analog[29] = lb_A_29;
241
    lb_Analog[30] = lb_A_30;
242
    lb_Analog[31] = lb_A_31;
243
}
244
 
245
void MKTool::init_Plot()
246
{
247
    NextPlot = 0;
248
 
249
    qwtPlot->setCanvasBackground(QColor(QRgb(0x00000000)));
250
 
251
    qwtPlot->insertLegend(new QwtLegend(), QwtPlot::RightLegend);
252
 
253
    QwtPlotGrid *Grid = new QwtPlotGrid();
254
    Grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine));
255
 
256
 
257
    Grid->attach(qwtPlot);
258
 
259
    qwtPlot->setAxisScale(QwtPlot::xBottom,0,PlotWide,0);
260
 
261
    for (int a = 0; a < MaxAnalog; a++)
262
    {
162 KeyOz 263
        Plot[a] = new QwtPlotCurve(Settings->Analog1.Label[a]);
264
        Plot[a]->setPen(QPen(QColor(Def_Colors[a])));
158 KeyOz 265
//        Plot[a]->setRenderHint(QwtPlotItem::RenderAntialiased);
266
 
162 KeyOz 267
        if (Settings->Analog1.PlotView[a])
158 KeyOz 268
            Plot[a]->attach(qwtPlot);
269
    }
270
    qwtPlot->replot();
271
}
272
 
273
void MKTool::init_Icons()
274
{
275
    Icons[0].addPixmap(QPixmap(QString::fromUtf8(":/LED/Images/16X16/ledred.png")), QIcon::Normal, QIcon::Off);
276
    Icons[1].addPixmap(QPixmap(QString::fromUtf8(":/LED/Images/16X16/ledyellow.png")), QIcon::Normal, QIcon::Off);
277
    Icons[3].addPixmap(QPixmap(QString::fromUtf8(":/LED/Images/16X16/ledyellow.png")), QIcon::Normal, QIcon::Off);
278
    Icons[4].addPixmap(QPixmap(QString::fromUtf8(":/LED/Images/16X16/ledoff.png")), QIcon::Normal, QIcon::Off);
279
 
280
    Icons[5].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/application-exit.png")), QIcon::Normal, QIcon::Off);
281
    Icons[6].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/media-playback-stop.png")), QIcon::Normal, QIcon::Off);
282
    Icons[7].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/media-record.png")), QIcon::Normal, QIcon::Off);
283
    Icons[8].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/network-connect.png")), QIcon::Normal, QIcon::Off);
284
    Icons[9].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/network-disconnect.png")), QIcon::Normal, QIcon::Off);
285
    Icons[10].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/utilities-system-monitor.png")), QIcon::Normal, QIcon::Off);
286
 
287
    Icons[20].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-up-double.png")), QIcon::Normal, QIcon::Off);
288
    Icons[21].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-up.png")), QIcon::Normal, QIcon::Off);
289
    Icons[22].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-down-double.png")), QIcon::Normal, QIcon::Off);
290
    Icons[23].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-down.png")), QIcon::Normal, QIcon::Off);
291
    Icons[24].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-left-double.png")), QIcon::Normal, QIcon::Off);
292
    Icons[25].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-left.png")), QIcon::Normal, QIcon::Off);
293
    Icons[26].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-right-double.png")), QIcon::Normal, QIcon::Off);
294
    Icons[27].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-right.png")), QIcon::Normal, QIcon::Off);
295
}
296
 
297
 
298
// Ticker-Event
299
///////////////
300
void MKTool::slot_Ticker()
301
{
302
    if (TickerDiv)
303
        TickerDiv = false;
304
    else
305
        TickerDiv = true;
306
 
307
    for (int a = 0; a < MaxTickerEvents; a++)
308
    {
309
        if (TickerEvent[a] == true)
310
        {
311
            switch(a)
312
            {
313
                case 0 :
314
                    if (TickerDiv)
315
                    {
316
                        QByteArray Temp(LastSend.toUtf8());
317
                        serialPort->sendData(Temp);
318
                    }
319
                break;
320
                case 1 :
159 KeyOz 321
                    TX_Data[0] = 0;
322
                    send_Data('p', ADDRESS_FC, TX_Data, 0, false);
158 KeyOz 323
                break;
159 KeyOz 324
                case 2 :
325
                    TX_Data[0] = LCD_Page;
326
                    TX_Data[1] = 0;
327
                    send_Data('l', ADDRESS_ALL, TX_Data, 1, true);
328
                break;
158 KeyOz 329
            }
330
        }
331
    }
332
}
333
 
334
 
335
// Slots der Actions (Menüpunkte, Buttons)
336
//////////////////////////////////////////
337
void MKTool::slot_ac_Motortest()
338
{
339
    dlg_Motortest *f_Motortest = new dlg_Motortest(this);
340
 
341
    connect(f_Motortest, SIGNAL(updateMotor(int, int, int, int)), this, SLOT(slot_Motortest(int, int, int, int)));
342
 
343
    if (f_Motortest->exec()==QDialog::Accepted)
344
    {
345
    }
346
 
347
    disconnect(f_Motortest, 0,0,0);
348
    slot_Motortest(0,0,0,0);
349
}
350
 
351
void MKTool::slot_Motortest(int Motor1, int Motor2, int Motor3, int Motor4)
352
{
353
    TX_Data[0] = Motor1;
354
    TX_Data[1] = Motor2;
355
    TX_Data[2] = Motor3;
356
    TX_Data[3] = Motor4;
159 KeyOz 357
    send_Data('t', ADDRESS_FC, TX_Data, 4, false);
158 KeyOz 358
}
359
 
360
void MKTool::slot_ac_Config()
361
{
162 KeyOz 362
    set_Analog Old_Analog1;
158 KeyOz 363
 
162 KeyOz 364
    Old_Analog1 = Settings->Analog1;
365
 
158 KeyOz 366
    dlg_Config *f_Config = new dlg_Config(this);
162 KeyOz 367
    f_Config->set_Settings(Settings, Mode.ID);
158 KeyOz 368
 
369
    if (f_Config->exec()==QDialog::Accepted)
370
    {
371
        Settings = f_Config->get_Settings();
162 KeyOz 372
        Settings->write_Settings_Analog(Mode.ID);
158 KeyOz 373
 
374
        for (int a = 0; a < MaxAnalog; a++)
375
        {
162 KeyOz 376
            if (Old_Analog1.PlotView[a] == Settings->Analog1.PlotView[a])
158 KeyOz 377
                continue;
378
            else
379
            {
380
                config_Plot();
381
                break;
382
            }
383
        }
384
 
385
        if (CSVFile->isOpen())
386
        {
387
            for (int a = 0; a < MaxAnalog; a++)
388
            {
162 KeyOz 389
                if (Old_Analog1.LogView[a] == Settings->Analog1.LogView[a])
158 KeyOz 390
                    continue;
391
                else
392
                {
393
                    slot_RecordCSV();
394
                    slot_RecordCSV();
395
                    break;
396
                }
397
            }
398
        }
399
 
400
    }
401
}
402
 
159 KeyOz 403
void MKTool::slot_ac_Preferences()
404
{
405
    dlg_Preferences *f_Preferences = new dlg_Preferences(this);
406
 
407
    if (f_Preferences->exec()==QDialog::Accepted)
408
    {
409
 
410
    }
411
}
412
 
158 KeyOz 413
void MKTool::slot_ac_StartPlotter()
414
{
415
    if (ac_StartPlotter->isChecked())
416
    {
417
        ac_StartPlotter->setText("Stop Plotter");
418
        pb_StartPlotter->setText("Stop Plotter");
419
    }
420
    else
421
    {
422
        ac_StartPlotter->setText("Start Plotter");
423
        pb_StartPlotter->setText("Start Plotter");
424
    }
425
}
426
 
427
void MKTool::slot_ac_View()
428
{
429
    int Aktive;
430
 
431
    QAction *Action = (QAction*)sender();
432
 
433
    if (Action->objectName() == QString("ac_View0"))
434
        Aktive = 0;
435
    if (Action->objectName() == QString("ac_View1"))
436
        Aktive = 1;
437
    if (Action->objectName() == QString("ac_View2"))
438
        Aktive = 2;
439
    if (Action->objectName() == QString("ac_View3"))
440
        Aktive = 3;
441
    if (Action->objectName() == QString("ac_View4"))
442
        Aktive = 4;
443
    if (Action->objectName() == QString("ac_View5"))
444
        Aktive = 5;
445
 
446
    QString TabName = QString("Tab_%1").arg(Aktive);
447
 
448
    if (!Action->isChecked())
449
    {
450
        for (int a = 0; a < tab_Main->count(); a++)
451
        {
452
            if (tab_Main->widget(a)->objectName() == TabName)
453
            {
454
                tab_Main->removeTab(a);
455
            }
456
        }
457
 
458
//        Action->setChecked(false);
459
    }
460
    else
461
    {
462
//        Action->setChecked(true);
463
        tab_Main->insertTab(Aktive, TabWidgets[Aktive], Action->text());
464
    }
465
}
466
 
159 KeyOz 467
void MKTool::slot_ac_MehrDaten() // DONE 0.71g
158 KeyOz 468
{
469
    if (ac_MehrDaten->isChecked())
470
    {
159 KeyOz 471
        TX_Data[0] = 10;
472
        send_Data('d', ADDRESS_ALL, TX_Data, 1, false);    }
158 KeyOz 473
    else
474
    {
159 KeyOz 475
        TX_Data[0] = 50;
476
        send_Data('d', ADDRESS_ALL, TX_Data, 1, false);    }
158 KeyOz 477
}
478
 
479
void MKTool::slot_ac_About()
480
{
481
    QMessageBox::about(this, trUtf8(("Über ")) + QA_NAME, QA_ABOUT);
482
}
483
 
159 KeyOz 484
void MKTool::slot_ac_GetLabels() // DONE 0.71g
158 KeyOz 485
{
486
    TX_Data[0] = 0;
159 KeyOz 487
    send_Data('a', ADDRESS_ALL, TX_Data, 1, false);
158 KeyOz 488
}
489
 
159 KeyOz 490
 
158 KeyOz 491
//  Daten-Plotter
492
/////////////////
493
void MKTool::update_Plot()
494
{
495
    for (int a = 0; a < MaxAnalog; a++)
496
    {
497
        Plot[a]->setData(aID,aData[a],NextPlot - 1);
498
    }
499
 
500
    if ((NextPlot > PlotWide))
501
    {
502
        scroll_plot->setMaximum(NextPlot - PlotWide);
503
    }
504
 
505
    if ((scroll_plot->value() == NextPlot - (PlotWide + 1)))
506
    {
507
        qwtPlot->setAxisScale(QwtPlot::xBottom,NextPlot - PlotWide,NextPlot,0);
508
        scroll_plot->setValue(NextPlot - PlotWide);
509
    }
510
 
511
    qwtPlot->replot();
512
}
513
 
514
void MKTool::config_Plot()
515
{
516
    for (int a = 0; a < MaxAnalog; a++)
517
    {
518
        Plot[a]->detach();
162 KeyOz 519
        Plot[a]->setPen(QPen(QColor(Def_Colors[a])));
158 KeyOz 520
 
162 KeyOz 521
        if (Settings->Analog1.PlotView[a])
522
        {
523
            Plot[a]->setTitle(Settings->Analog1.Label[a]);
158 KeyOz 524
            Plot[a]->attach(qwtPlot);
162 KeyOz 525
        }
158 KeyOz 526
    }
527
}
528
 
529
void MKTool::slot_ScrollPlot(int Pos)
530
{
531
    qwtPlot->setAxisScale(QwtPlot::xBottom,Pos,Pos + PlotWide,0);
532
    qwtPlot->replot();
533
}
534
 
535
 
536
// Firmeware-Update
537
///////////////////
538
void MKTool::slot_pb_Update()
539
{
162 KeyOz 540
    qDebug("Update");
158 KeyOz 541
 
162 KeyOz 542
    if (serialPort->isOpen())
543
    {
544
        slot_OpenPort();
545
    }
546
 
547
    Update = new QProcess();
548
 
549
    const QString Programm = "avrdude -p m644 -P /dev/ttyS0 -c butterfly -b 57600 -U flash:w:Flight-Ctrl_MEGA644_V0_71f.hex";
550
    const QStringList Argumente = (QStringList() << "-?");
551
 
552
    te_Shell->setText(""); // Ausgabefenster säubern
553
    Update->start(Programm); // Programmaufruf
554
//   Update.waitForFinished(); // auf Rückmeldung warten
555
//   Update.close(); // Kanal schließen
556
     connect(Update, SIGNAL(readyReadStandardOutput()), this, SLOT(slot_UpdateShell()) );
158 KeyOz 557
}
558
 
559
void MKTool::slot_UpdateShell()
560
{
162 KeyOz 561
    QByteArray Output;
158 KeyOz 562
//   te_Shell->setText(""); // Ausgabefenster säubern
162 KeyOz 563
    Output = Update->readAllStandardOutput(); // Shellausgabe an Variable
158 KeyOz 564
 
162 KeyOz 565
    te_Shell->moveCursor(QTextCursor::End,  QTextCursor::MoveAnchor);
566
    te_Shell->insertPlainText(QString::fromUtf8(Output));
158 KeyOz 567
 
162 KeyOz 568
    te_Shell->setText(QString::fromUtf8(Output)); // ...und endlich: Ausgabe im QLabel
569
    qDebug("Shell");
158 KeyOz 570
}
571
 
572
// Configuration -> Verzeichnisse
573
/////////////////////////////////
574
void MKTool::slot_SetLogDir()
575
{
576
    QString directory = QFileDialog::getExistingDirectory(this, "Verzeichniss für CSV-Logdateien", Settings->DIR.Logging, QFileDialog::DontResolveSymlinks | QFileDialog::ShowDirsOnly);
577
 
578
    if ((!directory.isEmpty()) && (Settings->DIR.Logging != directory))
579
    {
580
        Settings->DIR.Logging = directory;
581
        Settings->write_Settings();
582
    }
583
}
584
 
585
void MKTool::slot_SetParDir()
586
{
587
    QString directory = QFileDialog::getExistingDirectory(this, "Verzeichniss für Parameter-Dateien", Settings->DIR.Parameter, QFileDialog::DontResolveSymlinks | QFileDialog::ShowDirsOnly);
588
 
589
    if ((!directory.isEmpty()) && (Settings->DIR.Parameter != directory))
590
    {
591
        Settings->DIR.Parameter = directory;
592
        Settings->write_Settings();
593
    }
594
 
595
}
596
 
597
 
598
// Settings-Bereich
599
///////////////////
600
 
601
void MKTool::slot_LEDtoValue()
602
{
603
    QToolButton *ToolButton = (QToolButton*)sender();
604
    if (ToolButton->text() == QString("0"))
605
    {
606
        set_LED(ToolButton, true);
607
        sb_11_1->setValue(sb_11_1->value() + ToolButton->toolTip().toInt());
608
    }
609
    else if (ToolButton->text() == QString("1"))
610
    {
611
        set_LED(ToolButton);
612
        sb_11_1->setValue(sb_11_1->value() - ToolButton->toolTip().toInt());
613
    }
614
    else if (ToolButton->text() == QString("00"))
615
    {
616
        set_LED(ToolButton, true);
617
        sb_11_3->setValue(sb_11_3->value() + ToolButton->toolTip().toInt());
618
    }
619
    else if (ToolButton->text() == QString("11"))
620
    {
621
        set_LED(ToolButton);
622
        sb_11_3->setValue(sb_11_3->value() - ToolButton->toolTip().toInt());
623
    }
624
}
625
 
626
void MKTool::slot_ValuetoLED16(int Wert)
627
{
628
//    QSpinBox *SpinBox = (QSpinBox*)sender();
629
 
630
//    int Wert = SpinBox->value();
631
 
632
    set_LED(J16_0);
633
    set_LED(J16_1);
634
    set_LED(J16_2);
635
    set_LED(J16_3);
636
    set_LED(J16_4);
637
    set_LED(J16_5);
638
    set_LED(J16_6);
639
    set_LED(J16_7);
640
 
641
    for (int a = 0; a < 8; a++)
642
    {
643
        if (Wert > 127)
644
        {
645
            set_LED(J16_0, true);
646
            Wert = Wert - 128;
647
        }
648
        if (Wert > 63)
649
        {
650
            set_LED(J16_1, true);
651
            Wert = Wert - 64;
652
        }
653
        if (Wert > 31)
654
        {
655
            set_LED(J16_2, true);
656
            Wert = Wert - 32;
657
        }
658
        if (Wert > 15)
659
        {
660
            set_LED(J16_3, true);
661
            Wert = Wert - 16;
662
        }
663
        if (Wert > 7)
664
        {
665
            set_LED(J16_4, true);
666
            Wert = Wert - 8;
667
        }
668
        if (Wert > 3)
669
        {
670
            set_LED(J16_5, true);
671
            Wert = Wert - 4;
672
        }
673
        if (Wert > 1)
674
        {
675
            set_LED(J16_6, true);
676
            Wert = Wert - 2;
677
        }
678
        if (Wert > 0)
679
        {
680
            set_LED(J16_7, true);
681
            Wert = Wert - 1;
682
        }
683
    }
684
}
685
 
686
void MKTool::slot_ValuetoLED17(int Wert)
687
{
688
//    QSpinBox *SpinBox = (QSpinBox*)sender();
689
 
690
//    int Wert = SpinBox->value();
691
 
692
    set_LED(J17_0);
693
    set_LED(J17_1);
694
    set_LED(J17_2);
695
    set_LED(J17_3);
696
    set_LED(J17_4);
697
    set_LED(J17_5);
698
    set_LED(J17_6);
699
    set_LED(J17_7);
700
 
701
    for (int a = 0; a < 8; a++)
702
    {
703
        if (Wert > 127)
704
        {
705
            set_LED(J17_0, true);
706
            Wert = Wert - 128;
707
        }
708
        if (Wert > 63)
709
        {
710
            set_LED(J17_1, true);
711
            Wert = Wert - 64;
712
        }
713
        if (Wert > 31)
714
        {
715
            set_LED(J17_2, true);
716
            Wert = Wert - 32;
717
        }
718
        if (Wert > 15)
719
        {
720
            set_LED(J17_3, true);
721
            Wert = Wert - 16;
722
        }
723
        if (Wert > 7)
724
        {
725
            set_LED(J17_4, true);
726
            Wert = Wert - 8;
727
        }
728
        if (Wert > 3)
729
        {
730
            set_LED(J17_5, true);
731
            Wert = Wert - 4;
732
        }
733
        if (Wert > 1)
734
        {
735
            set_LED(J17_6, true);
736
            Wert = Wert - 2;
737
        }
738
        if (Wert > 0)
739
        {
740
            set_LED(J17_7, true);
741
            Wert = Wert - 1;
742
        }
743
    }
744
}
745
 
746
void MKTool::set_LED(QToolButton *ToolButton, bool On)
747
{
748
    if (ToolButton->text() == QString("0") && On)
749
    {
750
        ToolButton->setIcon(Icons[0]);
751
        ToolButton->setText("1");
752
    }
753
    else if (ToolButton->text() == QString("1") && !On)
754
    {
755
        ToolButton->setIcon(Icons[4]);
756
        ToolButton->setText("0");
757
    }
758
    else if (ToolButton->text() == QString("00") && On)
759
    {
760
        ToolButton->setIcon(Icons[0]);
761
        ToolButton->setText("11");
762
    }
763
    else if (ToolButton->text() == QString("11") && !On)
764
    {
765
        ToolButton->setIcon(Icons[4]);
766
        ToolButton->setText("00");
767
    }
768
}
769
 
770
void MKTool::slot_tbUp()
771
{
772
    if (tb_9_6->text() == QString("0"))
773
    {
774
        tb_9_6->setIcon(Icons[20]);
775
        tb_9_6->setText("1");
776
    }
777
    else
778
    {
779
        tb_9_6->setIcon(Icons[21]);
780
        tb_9_6->setText("0");
781
    }
782
}
783
 
784
void MKTool::slot_tbDown()
785
{
786
    if (tb_9_7->text() == QString("0"))
787
    {
788
        tb_9_7->setIcon(Icons[22]);
789
        tb_9_7->setText("1");
790
    }
791
    else
792
    {
793
        tb_9_7->setIcon(Icons[23]);
794
        tb_9_7->setText("0");
795
    }
796
}
797
 
798
void MKTool::slot_tbLeft()
799
{
800
    if (tb_9_8->text() == QString("0"))
801
    {
802
        tb_9_8->setIcon(Icons[24]);
803
        tb_9_8->setText("1");
804
    }
805
    else
806
    {
807
        tb_9_8->setIcon(Icons[25]);
808
        tb_9_8->setText("0");
809
    }
810
}
811
 
812
void MKTool::slot_tbRight()
813
{
814
    if (tb_9_9->text() == QString("0"))
815
    {
816
        tb_9_9->setIcon(Icons[26]);
817
        tb_9_9->setText("1");
818
    }
819
    else
820
    {
821
        tb_9_9->setIcon(Icons[27]);
822
        tb_9_9->setText("0");
823
    }
824
}
825
 
826
QComboBox *MKTool::setCombo(QComboBox *Combo, int Set, int Wert)
827
{
828
    if (ParameterSet[Set][Wert] <= 250)
829
    {
830
        Combo->setItemText(4, QString("%1").arg(ParameterSet[Set][Wert]));
831
        Combo->setCurrentIndex(4);
832
    }
833
    else
834
    {
835
        Combo->setCurrentIndex(ParameterSet[Set][Wert] - 251);
836
    }
837
    return Combo;
838
}
839
 
840
int MKTool::get_Value(QComboBox *Combo)
841
{
842
    if (Combo->currentText() == QString("Poti 1"))
843
        return 251;
844
    if (Combo->currentText() == QString("Poti 2"))
845
        return 252;
846
    if (Combo->currentText() == QString("Poti 3"))
847
        return 253;
848
    if (Combo->currentText() == QString("Poti 4"))
849
        return 254;
850
    return Combo->currentText().toInt();
851
}
852
 
159 KeyOz 853
void MKTool::store_ParameterSet(int Set) // DONE 0.71g
158 KeyOz 854
{
855
    char *Name = le_SetName->text().toLatin1().data();
856
 
857
    int a;
858
 
859
    for (a = 0; a < le_SetName->text().length(); a++)
860
    {
861
        ParameterSet[Set][P_NAME+a] = Name[a];
862
    }
863
 
864
    while(a < 12)
865
    {
866
        ParameterSet[Set][P_NAME+a] = 0;
867
        a++;
868
    }
869
 
870
    // Seite 1
871
    ParameterSet[Set][P_GLOBAL_CONF] = 0;
872
 
873
    if (cb_1_1->isChecked())
874
        ParameterSet[Set][P_GLOBAL_CONF] = ParameterSet[Set][P_GLOBAL_CONF] | 0x01;
875
    if (cb_1_2->isChecked())
876
        ParameterSet[Set][P_GLOBAL_CONF] = ParameterSet[Set][P_GLOBAL_CONF] | 0x02;
877
    if (cb_1_3->isChecked())
878
        ParameterSet[Set][P_GLOBAL_CONF] = ParameterSet[Set][P_GLOBAL_CONF] | 0x04;
879
    if (cb_1_4->isChecked())
880
        ParameterSet[Set][P_GLOBAL_CONF] = ParameterSet[Set][P_GLOBAL_CONF] | 0x08;
881
    if (cb_1_5->isChecked())
882
        ParameterSet[Set][P_GLOBAL_CONF] = ParameterSet[Set][P_GLOBAL_CONF] | 0x10;
883
    if (cb_1_6->isChecked())
884
        ParameterSet[Set][P_GLOBAL_CONF] = ParameterSet[Set][P_GLOBAL_CONF] | 0x20;
885
    if (cb_1_7->isChecked())
886
        ParameterSet[Set][P_GLOBAL_CONF] = ParameterSet[Set][P_GLOBAL_CONF] | 0x40;
887
    if (cb_1_8->isChecked())
888
        ParameterSet[Set][P_GLOBAL_CONF] = ParameterSet[Set][P_GLOBAL_CONF] | 0x80;
889
 
890
    // Seite 2
891
    ParameterSet[Set][P_KANAL_NICK]  = sb_2_1->value();
892
    ParameterSet[Set][P_KANAL_ROLL]  = sb_2_2->value();
893
    ParameterSet[Set][P_KANAL_GAS]   = sb_2_3->value();
894
    ParameterSet[Set][P_KANAL_GIER]  = sb_2_4->value();
895
    ParameterSet[Set][P_KANAL_POTI1] = sb_2_5->value();
896
    ParameterSet[Set][P_KANAL_POTI2] = sb_2_6->value();
897
    ParameterSet[Set][P_KANAL_POTI3] = sb_2_7->value();
898
    ParameterSet[Set][P_KANAL_POTI4] = sb_2_8->value();
899
 
900
    // Seite 3
901
    ParameterSet[Set][P_STICK_P]  = sb_3_1->value();
902
    ParameterSet[Set][P_STICK_D]  = sb_3_2->value();
903
    ParameterSet[Set][P_GIER_P]   = get_Value(cb_3_3);
904
    ParameterSet[Set][P_EXTERNAL] = get_Value(cb_3_4);
905
 
906
    // Seite 4
907
    ParameterSet[Set][P_MAXHOEHE]   = get_Value(cb_4_1);
908
    ParameterSet[Set][P_MIN_GAS]    = sb_4_2->value();
909
    ParameterSet[Set][P_HOEHE_P]    = get_Value(cb_4_3);
910
    ParameterSet[Set][P_DRUCK_D]    = get_Value(cb_4_4);
911
    ParameterSet[Set][P_HOEHE_ACC]  = get_Value(cb_4_5);
912
    ParameterSet[Set][P_HOEHE_GAIN] = sb_4_6->value();
913
 
914
    // Seite 5
915
    ParameterSet[Set][P_GYRO_P]          = get_Value(cb_5_1);
916
    ParameterSet[Set][P_GYRO_I]          = get_Value(cb_5_2);
917
    ParameterSet[Set][P_DYNAMIC_STAB]    = get_Value(cb_5_3);
918
    ParameterSet[Set][P_GYRO_ACC_FAKTOR] = sb_5_4->value();
919
    ParameterSet[Set][P_GYRO_ACC_ABGL]   = sb_5_5->value();
920
    ParameterSet[Set][P_FAKTOR_I]        = get_Value(cb_5_6);
921
    ParameterSet[Set][P_DRIFT_KOMP]      = sb_5_7->value();
922
 
923
    // Seite 6
924
    ParameterSet[Set][P_SERVO_NICK_CONT]  = get_Value(cb_6_1);
925
    ParameterSet[Set][P_SERVO_NICK_COMP]  = sb_6_2->value();
926
    ParameterSet[Set][P_SERVO_NICK_MIN]   = sb_6_3->value();
927
    ParameterSet[Set][P_SERVO_NICK_MAX]   = sb_6_4->value();
928
    ParameterSet[Set][P_SERVO_NICK_REFR]  = sb_6_5->value();
929
    ParameterSet[Set][P_SERVO_NICK_COMPI] = cb_6_6->isChecked();
930
 
931
    // Seite 7
932
    ParameterSet[Set][P_GAS_MIN]         = sb_7_1->value();
933
    ParameterSet[Set][P_GAS_MAX]         = sb_7_2->value();
934
    ParameterSet[Set][P_KOMPASS_WIRKUNG] = get_Value(cb_7_3);
935
    ParameterSet[Set][P_UNTERSPANNUNG]   = sb_7_4->value();
936
    ParameterSet[Set][P_NOTGASZEIT]      = sb_7_5->value();
937
    ParameterSet[Set][P_NOTGAS]          = sb_7_6->value();
938
 
939
    // Seite 8
940
    ParameterSet[Set][P_ACHS_KOPPLUNG]  = get_Value(cb_8_1);
941
    ParameterSet[Set][P_ACHS_GKOPPLUNG] = get_Value(cb_8_2);
942
 
943
    // Seite 9
944
    ParameterSet[Set][P_LOOP_CONFIG] = 0;
945
    if (tb_9_6->text() == QString("1"))
946
        ParameterSet[Set][P_LOOP_CONFIG] = ParameterSet[Set][P_LOOP_CONFIG] | 0x01;
947
    if (tb_9_7->text() == QString("1"))
948
        ParameterSet[Set][P_LOOP_CONFIG] = ParameterSet[Set][P_LOOP_CONFIG] | 0x02;
949
    if (tb_9_8->text() == QString("1"))
950
        ParameterSet[Set][P_LOOP_CONFIG] = ParameterSet[Set][P_LOOP_CONFIG] | 0x04;
951
    if (tb_9_9->text() == QString("1"))
952
        ParameterSet[Set][P_LOOP_CONFIG] = ParameterSet[Set][P_LOOP_CONFIG] | 0x08;
953
    if (cb_4_7->isChecked())
954
        ParameterSet[Set][P_LOOP_CONFIG] = ParameterSet[Set][P_LOOP_CONFIG] | 0x10;
955
 
956
    ParameterSet[Set][P_LOOP_GAS_LIMIT] = get_Value(cb_9_1);
957
    ParameterSet[Set][P_LOOP_THRESHOLD] = sb_9_2->value();
958
    ParameterSet[Set][P_WINKEL_NICK]    = sb_9_3->value();
959
    ParameterSet[Set][P_LOOP_HYSTERESE] = sb_9_4->value();
960
    ParameterSet[Set][P_WINKEL_ROLL]    = sb_9_5->value();
961
 
962
    // Seite 10
963
    ParameterSet[Set][P_USER_1] = get_Value(cb_10_1);
964
    ParameterSet[Set][P_USER_2] = get_Value(cb_10_2);
965
    ParameterSet[Set][P_USER_3] = get_Value(cb_10_3);
966
    ParameterSet[Set][P_USER_4] = get_Value(cb_10_4);
967
    ParameterSet[Set][P_USER_5] = get_Value(cb_10_5);
968
    ParameterSet[Set][P_USER_6] = get_Value(cb_10_6);
969
    ParameterSet[Set][P_USER_7] = get_Value(cb_10_7);
970
    ParameterSet[Set][P_USER_8] = get_Value(cb_10_8);
971
 
972
    // Seite 11
973
    ParameterSet[Set][P_J16_BITMASK] = sb_11_1->value();
974
    ParameterSet[Set][P_J16_TIMING]  = get_Value(cb_11_2);
975
    ParameterSet[Set][P_J17_BITMASK] = sb_11_3->value();
976
    ParameterSet[Set][P_J17_TIMING]  = get_Value(cb_11_4);
977
 
978
    // Seite 12
979
    ParameterSet[Set][P_NAV_GPS_MODE]   = get_Value(cb_12_1);
980
    ParameterSet[Set][P_NAV_GPS_GAIN]   = get_Value(cb_12_2);
981
    ParameterSet[Set][P_NAV_STICK_THRE] = sb_12_3->value();
982
    ParameterSet[Set][P_NAV_GPS_MIN]    = sb_12_4->value();
983
    ParameterSet[Set][P_NAV_GPS_P]      = get_Value(cb_12_5);
984
    ParameterSet[Set][P_NAV_GPS_I]      = get_Value(cb_12_6);
985
    ParameterSet[Set][P_NAV_GPS_D]      = get_Value(cb_12_7);
986
    ParameterSet[Set][P_NAV_GPS_ACC]    = get_Value(cb_12_8);
987
 
988
    //Seite 13
989
    ParameterSet[Set][P_NAV_WIND_CORR]  = get_Value(cb_13_1);
990
    ParameterSet[Set][P_NAV_SPEED_COMP] = get_Value(cb_13_2);
991
    ParameterSet[Set][P_NAV_RADIUS]     = get_Value(cb_13_3);
992
}
993
 
159 KeyOz 994
void MKTool::slot_SaveParameter() // DONE 0.71g
158 KeyOz 995
{
996
    int Set = sb_Set->value() + 5;
997
 
998
    QString Filename = QFileDialog::getSaveFileName(this, "Mikrokopter Parameter speichern", Settings->DIR.Parameter + le_SetName->text(), "Mikrokopter Parameter(*.mkp);;Alle Dateien (*)");
999
 
1000
    if (!Filename.isEmpty())
1001
    {
1002
        if (!(Filename.endsWith(".mkp", Qt::CaseInsensitive)))
1003
        {
1004
            Filename = Filename + QString(".mkp");
1005
        }
1006
        store_ParameterSet(Set);
1007
        QSettings Setting(Filename, QSettings::IniFormat);
1008
 
1009
        Setting.beginGroup("Setup");
1010
            Setting.setValue("Name",         le_SetName->text());
1011
            Setting.setValue("GlobalConfig", ParameterSet[Set][P_GLOBAL_CONF]);
1012
        Setting.endGroup();
1013
 
1014
        Setting.beginGroup("Channels");
1015
            Setting.setValue("Nick",   ParameterSet[Set][P_KANAL_NICK]);
1016
            Setting.setValue("Roll",   ParameterSet[Set][P_KANAL_ROLL]);
1017
            Setting.setValue("Gas",    ParameterSet[Set][P_KANAL_GAS]);
1018
            Setting.setValue("Gier",   ParameterSet[Set][P_KANAL_GIER]);
1019
            Setting.setValue("Poti_1", ParameterSet[Set][P_KANAL_POTI1]);
1020
            Setting.setValue("Poti_2", ParameterSet[Set][P_KANAL_POTI2]);
1021
            Setting.setValue("Poti_3", ParameterSet[Set][P_KANAL_POTI3]);
1022
            Setting.setValue("Poti_4", ParameterSet[Set][P_KANAL_POTI4]);
1023
        Setting.endGroup();
1024
 
1025
        Setting.beginGroup("Stick");
1026
            Setting.setValue("Nick_Roll-P",     ParameterSet[Set][P_STICK_P]);
1027
            Setting.setValue("Nick_Roll-D",     ParameterSet[Set][P_STICK_D]);
1028
            Setting.setValue("Gier-P",          ParameterSet[Set][P_GIER_P]);
1029
            Setting.setValue("ExternalControl", ParameterSet[Set][P_EXTERNAL]);
1030
        Setting.endGroup();
1031
 
1032
        Setting.beginGroup("Altitude");
1033
            Setting.setValue("Setpoint",     ParameterSet[Set][P_MAXHOEHE]);
1034
            Setting.setValue("MinGas",       ParameterSet[Set][P_MIN_GAS]);
1035
            Setting.setValue("P",            ParameterSet[Set][P_HOEHE_P]);
1036
            Setting.setValue("Barometric-D", ParameterSet[Set][P_DRUCK_D]);
1037
            Setting.setValue("Z-ACC-Effect", ParameterSet[Set][P_HOEHE_ACC]);
1038
            Setting.setValue("Gain",         ParameterSet[Set][P_HOEHE_GAIN]);
1039
        Setting.endGroup();
1040
 
1041
        Setting.beginGroup("Gyro");
1042
            Setting.setValue("P",                     ParameterSet[Set][P_GYRO_P]);
1043
            Setting.setValue("I",                     ParameterSet[Set][P_GYRO_I]);
1044
            Setting.setValue("DynamicStability",      ParameterSet[Set][P_DYNAMIC_STAB]);
1045
            Setting.setValue("ACC_Gyro-Factor",       ParameterSet[Set][P_GYRO_ACC_FAKTOR]);
1046
            Setting.setValue("ACC_Gyro-Compensation", ParameterSet[Set][P_GYRO_ACC_ABGL]);
1047
            Setting.setValue("DriftCompensation",     ParameterSet[Set][P_DRIFT_KOMP]);
1048
            Setting.setValue("Main-I",                ParameterSet[Set][P_FAKTOR_I]);
1049
        Setting.endGroup();
1050
 
1051
        Setting.beginGroup("Camera");
1052
            Setting.setValue("ServoNickControl",      ParameterSet[Set][P_SERVO_NICK_CONT]);
1053
            Setting.setValue("ServoNickCompensation", ParameterSet[Set][P_SERVO_NICK_COMP]);
1054
            Setting.setValue("ServoNickInvert",       ParameterSet[Set][P_SERVO_NICK_COMPI]);
1055
            Setting.setValue("ServoNickMin",          ParameterSet[Set][P_SERVO_NICK_MIN]);
1056
            Setting.setValue("ServoNickMax",          ParameterSet[Set][P_SERVO_NICK_MAX]);
1057
            Setting.setValue("ServoNickRefreshRate",  ParameterSet[Set][P_SERVO_NICK_REFR]);
1058
        Setting.endGroup();
1059
 
1060
        Setting.beginGroup("Others");
1061
            Setting.setValue("MinGas",         ParameterSet[Set][P_GAS_MIN]);
1062
            Setting.setValue("MaxGas",         ParameterSet[Set][P_GAS_MAX]);
1063
            Setting.setValue("Compass-Effect", ParameterSet[Set][P_KOMPASS_WIRKUNG]);
1064
            Setting.setValue("UnderVoltage",   ParameterSet[Set][P_UNTERSPANNUNG]);
1065
            Setting.setValue("NotGas",         ParameterSet[Set][P_NOTGAS]);
1066
            Setting.setValue("NotGasTime",     ParameterSet[Set][P_NOTGASZEIT]);
1067
        Setting.endGroup();
1068
 
1069
        Setting.beginGroup("Coupling");
1070
            Setting.setValue("YawPosFeedback", ParameterSet[Set][P_ACHS_KOPPLUNG]);
1071
            Setting.setValue("YawNegFeedback", ParameterSet[Set][P_ACHS_GKOPPLUNG]);
1072
        Setting.endGroup();
1073
 
1074
        Setting.beginGroup("Loop");
1075
            Setting.setValue("Config", ParameterSet[Set][P_LOOP_CONFIG]);
1076
            Setting.setValue("GasLimit", ParameterSet[Set][P_LOOP_GAS_LIMIT]);
1077
            Setting.setValue("StickThreshold", ParameterSet[Set][P_LOOP_THRESHOLD]);
1078
            Setting.setValue("LoopHysteresis", ParameterSet[Set][P_LOOP_HYSTERESE]);
1079
            Setting.setValue("TurnOverNick", ParameterSet[Set][P_WINKEL_NICK]);
1080
            Setting.setValue("TurnOverRoll", ParameterSet[Set][P_WINKEL_ROLL]);
1081
        Setting.endGroup();
1082
 
1083
        Setting.beginGroup("User");
1084
             Setting.setValue("Parameter_1", ParameterSet[Set][P_USER_1]);
1085
             Setting.setValue("Parameter_2", ParameterSet[Set][P_USER_2]);
1086
             Setting.setValue("Parameter_3", ParameterSet[Set][P_USER_3]);
1087
             Setting.setValue("Parameter_4", ParameterSet[Set][P_USER_4]);
1088
             Setting.setValue("Parameter_5", ParameterSet[Set][P_USER_5]);
1089
             Setting.setValue("Parameter_6", ParameterSet[Set][P_USER_6]);
1090
             Setting.setValue("Parameter_7", ParameterSet[Set][P_USER_7]);
1091
             Setting.setValue("Parameter_8", ParameterSet[Set][P_USER_8]);
1092
        Setting.endGroup();
1093
 
1094
        Setting.beginGroup("Output");
1095
            Setting.setValue("J16_Bitmask", ParameterSet[Set][P_J16_BITMASK]);
1096
            Setting.setValue("J16_Timing",  ParameterSet[Set][P_J16_TIMING]);
1097
            Setting.setValue("J17_Bitmask", ParameterSet[Set][P_J17_BITMASK]);
1098
            Setting.setValue("J17_Timing",  ParameterSet[Set][P_J17_TIMING]);
1099
        Setting.endGroup();
1100
 
1101
        Setting.beginGroup("NaviCtrl");
1102
            Setting.setValue("GPS_ModeControl",       ParameterSet[Set][P_NAV_GPS_MODE]);
1103
            Setting.setValue("GPS_Gain",              ParameterSet[Set][P_NAV_GPS_GAIN]);
1104
            Setting.setValue("GPS_P",                 ParameterSet[Set][P_NAV_GPS_P]);
1105
            Setting.setValue("GPS_I",                 ParameterSet[Set][P_NAV_GPS_I]);
1106
            Setting.setValue("GPS_D",                 ParameterSet[Set][P_NAV_GPS_D]);
1107
            Setting.setValue("GPS_Acc",               ParameterSet[Set][P_NAV_GPS_ACC]);
1108
            Setting.setValue("GPS_MinSat",            ParameterSet[Set][P_NAV_GPS_MIN]);
1109
            Setting.setValue("GPS_StickThreshold",    ParameterSet[Set][P_NAV_STICK_THRE]);
1110
            Setting.setValue("GPS_WindCorrection",    ParameterSet[Set][P_NAV_WIND_CORR]);
1111
            Setting.setValue("GPS_SpeedCompensation", ParameterSet[Set][P_NAV_SPEED_COMP]);
1112
            Setting.setValue("GPS_MaxRadius",         ParameterSet[Set][P_NAV_RADIUS]);
1113
        Setting.endGroup();
1114
    }
1115
}
1116
 
159 KeyOz 1117
void MKTool::slot_LoadParameter() // DONE 0.71g
158 KeyOz 1118
{
1119
    QString Filename = QFileDialog::getOpenFileName(this, "Mikrokopter Parameter laden", Settings->DIR.Parameter, "Mikrokopter Parameter(*.mkp);;Alle Dateien (*)");
1120
 
1121
    if (!Filename.isEmpty())
1122
    {
1123
        int Set = sb_Set->value();
1124
        QSettings Setting(Filename, QSettings::IniFormat);
1125
 
1126
        Setting.beginGroup("Setup");
1127
            QString Name = Setting.value("Name", QString("--noname--")).toString();
1128
            char *CName = Name.toLatin1().data();
1129
            int a;
1130
 
1131
            for (a=0; a < Name.length(); a++)
1132
            {
1133
                ParameterSet[Set][P_NAME+a] = CName[a];
1134
            }
1135
            while (a < 12)
1136
            {
1137
                ParameterSet[Set][P_NAME+a] = 0;
1138
                a++;
1139
            }
1140
 
1141
            ParameterSet[Set][P_GLOBAL_CONF] = Setting.value("GlobalConfig", 0).toInt();
1142
        Setting.endGroup();
1143
 
1144
        Setting.beginGroup("Channels");
1145
            ParameterSet[Set][P_KANAL_NICK]  = Setting.value("Nick", 1).toInt();
1146
            ParameterSet[Set][P_KANAL_ROLL]  = Setting.value("Roll", 2).toInt();
1147
            ParameterSet[Set][P_KANAL_GAS]   = Setting.value("Gas", 3).toInt();
1148
            ParameterSet[Set][P_KANAL_GIER]  = Setting.value("Gier", 4).toInt();
1149
            ParameterSet[Set][P_KANAL_POTI1] = Setting.value("Poti_1", 5).toInt();
1150
            ParameterSet[Set][P_KANAL_POTI2] = Setting.value("Poti_2", 6).toInt();
1151
            ParameterSet[Set][P_KANAL_POTI3] = Setting.value("Poti_3", 7).toInt();
1152
            ParameterSet[Set][P_KANAL_POTI4] = Setting.value("Poti_4", 8).toInt();
1153
        Setting.endGroup();
1154
 
1155
        Setting.beginGroup("Stick");
1156
            ParameterSet[Set][P_STICK_P]  = Setting.value("Nick_Roll-P", 4).toInt();
1157
            ParameterSet[Set][P_STICK_D]  = Setting.value("Nick_Roll-D", 8).toInt();
1158
            ParameterSet[Set][P_GIER_P]   = Setting.value("Gier-P", 1).toInt();
1159
            ParameterSet[Set][P_EXTERNAL] = Setting.value("ExternalControl", 1).toInt();
1160
        Setting.endGroup();
1161
 
1162
        Setting.beginGroup("Altitude");
1163
            ParameterSet[Set][P_MAXHOEHE]   = Setting.value("Setpoint", 251).toInt();
1164
            ParameterSet[Set][P_MIN_GAS]    = Setting.value("MinGas", 30).toInt();
1165
            ParameterSet[Set][P_HOEHE_P]    = Setting.value("P", 10).toInt();
1166
            ParameterSet[Set][P_DRUCK_D]    = Setting.value("Barometric-D", 30).toInt();
1167
            ParameterSet[Set][P_HOEHE_ACC]  = Setting.value("Z-ACC-Effect", 30).toInt();
1168
            ParameterSet[Set][P_HOEHE_GAIN] = Setting.value("Gain", 3).toInt();
1169
        Setting.endGroup();
1170
 
1171
        Setting.beginGroup("Gyro");
1172
            ParameterSet[Set][P_GYRO_P]          = Setting.value("P", 80).toInt();
1173
            ParameterSet[Set][P_GYRO_I]          = Setting.value("I", 120).toInt();
1174
            ParameterSet[Set][P_DYNAMIC_STAB]    = Setting.value("DynamicStability", 75).toInt();
1175
            ParameterSet[Set][P_GYRO_ACC_FAKTOR] = Setting.value("ACC_Gyro-Factor", 30).toInt();
1176
            ParameterSet[Set][P_GYRO_ACC_ABGL]   = Setting.value("ACC_Gyro-Compensation", 32).toInt();
1177
            ParameterSet[Set][P_DRIFT_KOMP]      = Setting.value("DriftCompensation", 4).toInt();
1178
            ParameterSet[Set][P_FAKTOR_I]        = Setting.value("Main-I", 32).toInt();
1179
        Setting.endGroup();
1180
 
1181
        Setting.beginGroup("Camera");
1182
            ParameterSet[Set][P_SERVO_NICK_CONT]  = Setting.value("ServoNickControl", 100).toInt();
1183
            ParameterSet[Set][P_SERVO_NICK_COMP]  = Setting.value("ServoNickCompensation", 40).toInt();
1184
            ParameterSet[Set][P_SERVO_NICK_COMPI] = Setting.value("ServoNickInvert", 0).toInt();
1185
            ParameterSet[Set][P_SERVO_NICK_MIN]   = Setting.value("ServoNickMin", 50).toInt();
1186
            ParameterSet[Set][P_SERVO_NICK_MAX]   = Setting.value("ServoNickMax", 150).toInt();
1187
            ParameterSet[Set][P_SERVO_NICK_REFR]  = Setting.value("ServoNickRefreshRate", 5).toInt();
1188
        Setting.endGroup();
1189
 
1190
        Setting.beginGroup("Others");
1191
            ParameterSet[Set][P_GAS_MIN]         = Setting.value("MinGas", 8).toInt();
1192
            ParameterSet[Set][P_GAS_MAX]         = Setting.value("MaxGas", 230).toInt();
1193
            ParameterSet[Set][P_KOMPASS_WIRKUNG] = Setting.value("Compass-Effect", 128).toInt();
1194
            ParameterSet[Set][P_UNTERSPANNUNG]   = Setting.value("UnderVoltage", 94).toInt();
1195
            ParameterSet[Set][P_NOTGAS]          = Setting.value("NotGas", 35).toInt();
1196
            ParameterSet[Set][P_NOTGASZEIT]      = Setting.value("NotGasTime", 30).toInt();
1197
        Setting.endGroup();
1198
 
1199
        Setting.beginGroup("Coupling");
1200
            ParameterSet[Set][P_ACHS_KOPPLUNG]  = Setting.value("YawPosFeedback", 90).toInt();
1201
            ParameterSet[Set][P_ACHS_GKOPPLUNG] = Setting.value("YawNegFeedback", 5).toInt();
1202
        Setting.endGroup();
1203
 
1204
        Setting.beginGroup("Loop");
1205
            ParameterSet[Set][P_LOOP_CONFIG]    = Setting.value("Config", 0).toInt();
1206
            ParameterSet[Set][P_LOOP_GAS_LIMIT] = Setting.value("GasLimit", 50).toInt();
1207
            ParameterSet[Set][P_LOOP_THRESHOLD] = Setting.value("StickThreshold", 90).toInt();
1208
            ParameterSet[Set][P_LOOP_HYSTERESE] = Setting.value("LoopHysteresis", 50).toInt();
1209
            ParameterSet[Set][P_WINKEL_NICK]    = Setting.value("TurnOverNick", 85).toInt();
1210
            ParameterSet[Set][P_WINKEL_ROLL]    = Setting.value("TurnOverRoll", 85).toInt();
1211
        Setting.endGroup();
1212
 
1213
        Setting.beginGroup("User");
1214
            ParameterSet[Set][P_USER_1] = Setting.value("Parameter_1", 0).toInt();
1215
            ParameterSet[Set][P_USER_2] = Setting.value("Parameter_2", 0).toInt();
1216
            ParameterSet[Set][P_USER_3] = Setting.value("Parameter_3", 0).toInt();
1217
            ParameterSet[Set][P_USER_4] = Setting.value("Parameter_4", 0).toInt();
1218
            ParameterSet[Set][P_USER_5] = Setting.value("Parameter_5", 0).toInt();
1219
            ParameterSet[Set][P_USER_6] = Setting.value("Parameter_6", 0).toInt();
1220
            ParameterSet[Set][P_USER_7] = Setting.value("Parameter_7", 0).toInt();
1221
            ParameterSet[Set][P_USER_8] = Setting.value("Parameter_8", 0).toInt();
1222
        Setting.endGroup();
1223
 
1224
        Setting.beginGroup("Output");
1225
            ParameterSet[Set][P_J16_BITMASK] = Setting.value("J16_Bitmask", 255).toInt();
1226
            ParameterSet[Set][P_J16_TIMING]  = Setting.value("J16_Timing", 251).toInt();
1227
            ParameterSet[Set][P_J17_BITMASK] = Setting.value("J17_Bitmask", 255).toInt();
1228
            ParameterSet[Set][P_J17_TIMING]  = Setting.value("J17_Timing", 251).toInt();
1229
        Setting.endGroup();
1230
 
1231
        Setting.beginGroup("NaviCtrl");
1232
            ParameterSet[Set][P_NAV_GPS_MODE]   = Setting.value("GPS_ModeControl", 253).toInt();
1233
            ParameterSet[Set][P_NAV_GPS_GAIN]   = Setting.value("GPS_Gain", 100).toInt();
1234
            ParameterSet[Set][P_NAV_GPS_P]      = Setting.value("GPS_P", 90).toInt();
1235
            ParameterSet[Set][P_NAV_GPS_I]      = Setting.value("GPS_I", 90).toInt();
1236
            ParameterSet[Set][P_NAV_GPS_D]      = Setting.value("GPS_D", 90).toInt();
1237
            ParameterSet[Set][P_NAV_GPS_ACC]    = Setting.value("GPS_Acc", 0).toInt();
1238
            ParameterSet[Set][P_NAV_GPS_MIN]    = Setting.value("GPS_MinSat", 6).toInt();
1239
            ParameterSet[Set][P_NAV_STICK_THRE] = Setting.value("GPS_StickThreshold", 8).toInt();
1240
            ParameterSet[Set][P_NAV_WIND_CORR]  = Setting.value("GPS_WindCorrection", 90).toInt();
1241
            ParameterSet[Set][P_NAV_SPEED_COMP] = Setting.value("GPS_SpeedCompensation", 30).toInt();
1242
            ParameterSet[Set][P_NAV_RADIUS]     = Setting.value("GPS_MaxRadius", 100).toInt();
1243
        Setting.endGroup();
1244
 
1245
        show_ParameterSet(Set);
1246
    }
1247
}
1248
 
159 KeyOz 1249
void MKTool::show_ParameterSet(int Set) // DONE 0.71g
158 KeyOz 1250
{
1251
    char Name[12];
1252
    for (int a = 0; a < 12; a++)
1253
    {
1254
        Name[a] = ParameterSet[Set][P_NAME+a];
1255
    }
1256
    le_SetName->setText(QString(Name));
1257
 
1258
    // Seite 1
1259
{
1260
    cb_1_1->setChecked(ParameterSet[Set][P_GLOBAL_CONF] & 0x01);
1261
    cb_1_2->setChecked(ParameterSet[Set][P_GLOBAL_CONF] & 0x02);
1262
    cb_1_3->setChecked(ParameterSet[Set][P_GLOBAL_CONF] & 0x04);
1263
    cb_1_4->setChecked(ParameterSet[Set][P_GLOBAL_CONF] & 0x08);
1264
    cb_1_5->setChecked(ParameterSet[Set][P_GLOBAL_CONF] & 0x10);
1265
    cb_1_6->setChecked(ParameterSet[Set][P_GLOBAL_CONF] & 0x20);
1266
    cb_1_7->setChecked(ParameterSet[Set][P_GLOBAL_CONF] & 0x40);
1267
    cb_1_8->setChecked(ParameterSet[Set][P_GLOBAL_CONF] & 0x80);
1268
}
1269
    // Seite 2
1270
{
1271
    sb_2_1->setValue(ParameterSet[Set][P_KANAL_NICK]);
1272
    sb_2_2->setValue(ParameterSet[Set][P_KANAL_ROLL]);
1273
    sb_2_3->setValue(ParameterSet[Set][P_KANAL_GAS]);
1274
    sb_2_4->setValue(ParameterSet[Set][P_KANAL_GIER]);
1275
    sb_2_5->setValue(ParameterSet[Set][P_KANAL_POTI1]);
1276
    sb_2_6->setValue(ParameterSet[Set][P_KANAL_POTI2]);
1277
    sb_2_7->setValue(ParameterSet[Set][P_KANAL_POTI3]);
1278
    sb_2_8->setValue(ParameterSet[Set][P_KANAL_POTI4]);
1279
}
1280
    // Seite 3
1281
{
1282
    sb_3_1->setValue(ParameterSet[Set][P_STICK_P]);
1283
    sb_3_2->setValue(ParameterSet[Set][P_STICK_D]);
1284
    cb_3_3 = setCombo(cb_3_3, Set, P_GIER_P);
1285
    cb_3_4 = setCombo(cb_3_4, Set, P_EXTERNAL);
1286
}
1287
    // Seite 4
1288
{
1289
    cb_4_1 = setCombo(cb_4_1, Set, P_MAXHOEHE);
1290
    sb_4_2->setValue(ParameterSet[Set][P_MIN_GAS]);
1291
    cb_4_3 = setCombo(cb_4_3, Set, P_HOEHE_P);
1292
    cb_4_4 = setCombo(cb_4_4, Set, P_DRUCK_D);
1293
    cb_4_5 = setCombo(cb_4_5, Set, P_HOEHE_ACC);
1294
    sb_4_6->setValue(ParameterSet[Set][P_HOEHE_GAIN]);
1295
    cb_4_7->setChecked(ParameterSet[Set][P_LOOP_CONFIG] & 0x10);
1296
}
1297
    // Seite 5
1298
{
1299
    cb_5_1 = setCombo(cb_5_1, Set, P_GYRO_P);
1300
    cb_5_2 = setCombo(cb_5_2, Set, P_GYRO_I);
1301
    cb_5_3 = setCombo(cb_5_3, Set, P_DYNAMIC_STAB);
1302
    sb_5_4->setValue(ParameterSet[Set][P_GYRO_ACC_FAKTOR]);
1303
    sb_5_5->setValue(ParameterSet[Set][P_GYRO_ACC_ABGL]);
1304
    cb_5_6 = setCombo(cb_5_6, Set, P_FAKTOR_I);
1305
    sb_5_7->setValue(ParameterSet[Set][P_DRIFT_KOMP]);
1306
}
1307
    // Seite 6
1308
{
1309
    cb_6_1 = setCombo(cb_6_1, Set, P_SERVO_NICK_CONT);
1310
    sb_6_2->setValue(ParameterSet[Set][P_SERVO_NICK_COMP]);
1311
    sb_6_3->setValue(ParameterSet[Set][P_SERVO_NICK_MIN]);
1312
    sb_6_4->setValue(ParameterSet[Set][P_SERVO_NICK_MAX]);
1313
    sb_6_5->setValue(ParameterSet[Set][P_SERVO_NICK_REFR]);
1314
    cb_6_6->setChecked(ParameterSet[Set][P_SERVO_NICK_COMPI]);
1315
}
1316
    // Seite 7
1317
{
1318
    sb_7_1->setValue(ParameterSet[Set][P_GAS_MIN]);
1319
    sb_7_2->setValue(ParameterSet[Set][P_GAS_MAX]);
1320
    cb_7_3 = setCombo(cb_7_3, Set, P_KOMPASS_WIRKUNG);
1321
    sb_7_4->setValue(ParameterSet[Set][P_UNTERSPANNUNG]);
1322
    sb_7_5->setValue(ParameterSet[Set][P_NOTGASZEIT]);
1323
    sb_7_6->setValue(ParameterSet[Set][P_NOTGAS]);
1324
}
1325
    // Seite 8
1326
{
1327
    cb_8_1 = setCombo(cb_8_1, Set, P_ACHS_KOPPLUNG);
1328
    cb_8_2 = setCombo(cb_8_2, Set, P_ACHS_GKOPPLUNG);
1329
}
1330
    // Seite 9
1331
{
1332
    if (ParameterSet[Set][P_LOOP_CONFIG] & 0x01)
1333
    {
1334
        tb_9_6->setIcon(Icons[20]);
1335
        tb_9_6->setText("1");
1336
    }
1337
    else
1338
    {
1339
        tb_9_6->setIcon(Icons[21]);
1340
        tb_9_6->setText("0");
1341
    }
1342
 
1343
    if (ParameterSet[Set][P_LOOP_CONFIG] & 0x02)
1344
    {
1345
        tb_9_7->setIcon(Icons[22]);
1346
        tb_9_7->setText("1");
1347
    }
1348
    else
1349
    {
1350
        tb_9_7->setIcon(Icons[23]);
1351
        tb_9_7->setText("0");
1352
    }
1353
 
1354
    if (ParameterSet[Set][P_LOOP_CONFIG] & 0x04)
1355
    {
1356
        tb_9_8->setIcon(Icons[24]);
1357
        tb_9_8->setText("1");
1358
    }
1359
    else
1360
    {
1361
        tb_9_8->setIcon(Icons[25]);
1362
        tb_9_8->setText("0");
1363
    }
1364
 
1365
    if (ParameterSet[Set][P_LOOP_CONFIG] & 0x08)
1366
    {
1367
        tb_9_9->setIcon(Icons[26]);
1368
        tb_9_9->setText("1");
1369
    }
1370
    else
1371
    {
1372
        tb_9_9->setIcon(Icons[27]);
1373
        tb_9_9->setText("0");
1374
    }
1375
 
1376
    cb_9_1 = setCombo(cb_9_1, Set, P_LOOP_GAS_LIMIT);
1377
    sb_9_2->setValue(ParameterSet[Set][P_LOOP_THRESHOLD]);
1378
    sb_9_3->setValue(ParameterSet[Set][P_WINKEL_NICK]);
1379
    sb_9_4->setValue(ParameterSet[Set][P_LOOP_HYSTERESE]);
1380
    sb_9_5->setValue(ParameterSet[Set][P_WINKEL_ROLL]);
1381
}
1382
    // Seite 10
1383
{
1384
    cb_10_1 = setCombo(cb_10_1, Set, P_USER_1);
1385
    cb_10_2 = setCombo(cb_10_2, Set, P_USER_2);
1386
    cb_10_3 = setCombo(cb_10_3, Set, P_USER_3);
1387
    cb_10_4 = setCombo(cb_10_4, Set, P_USER_4);
1388
    cb_10_5 = setCombo(cb_10_5, Set, P_USER_5);
1389
    cb_10_6 = setCombo(cb_10_6, Set, P_USER_6);
1390
    cb_10_7 = setCombo(cb_10_7, Set, P_USER_7);
1391
    cb_10_8 = setCombo(cb_10_8, Set, P_USER_8);
1392
}
1393
    // Seite 11
1394
{
1395
    sb_11_1->setValue(ParameterSet[Set][P_J16_BITMASK]);
1396
    cb_11_2 = setCombo(cb_11_2, Set, P_J16_TIMING);
1397
    sb_11_3->setValue(ParameterSet[Set][P_J17_BITMASK]);
1398
    cb_11_4 = setCombo(cb_11_4, Set, P_J17_TIMING);
1399
}
1400
    // Seite 12
1401
{
1402
    cb_12_1 = setCombo(cb_12_1, Set, P_NAV_GPS_MODE);
1403
    cb_12_2 = setCombo(cb_12_2, Set, P_NAV_GPS_GAIN);
1404
    sb_12_3->setValue(ParameterSet[Set][P_NAV_STICK_THRE]);
1405
    sb_12_4->setValue(ParameterSet[Set][P_NAV_GPS_MIN]);
1406
    cb_12_5 = setCombo(cb_12_5, Set, P_NAV_GPS_P);
1407
    cb_12_6 = setCombo(cb_12_6, Set, P_NAV_GPS_I);
1408
    cb_12_7 = setCombo(cb_12_7, Set, P_NAV_GPS_D);
1409
    cb_12_8 = setCombo(cb_12_8, Set, P_NAV_GPS_ACC);
1410
}
1411
 
1412
    // Seite 13
1413
{
1414
    cb_13_1 = setCombo(cb_13_1, Set, P_NAV_WIND_CORR);
1415
    cb_13_2 = setCombo(cb_13_2, Set, P_NAV_SPEED_COMP);
1416
    cb_13_3 = setCombo(cb_13_3, Set, P_NAV_RADIUS);
1417
}
1418
 
1419
 
1420
}
1421
 
159 KeyOz 1422
void MKTool::slot_TabChanged(int Tab) // DONE 0.71g
158 KeyOz 1423
{
1424
    Tab = Tab;
162 KeyOz 1425
    if (tab_Main->count() != 0)
158 KeyOz 1426
    {
162 KeyOz 1427
        if ((tab_Main->currentWidget()->objectName() == QString("Tab_2")) && (tab_Par->currentIndex() == 1))
1428
        {
1429
            TX_Data[0] = 0;
1430
            send_Data('p', ADDRESS_FC, TX_Data, 0, true);
159 KeyOz 1431
 
162 KeyOz 1432
            Ticker->setInterval(500);
1433
            TickerEvent[1] = true;
1434
        }
1435
        else
1436
        {
1437
            Ticker->setInterval(2000);
1438
            TickerEvent[1] = false;
1439
        }
159 KeyOz 1440
 
162 KeyOz 1441
        if ((tab_Main->currentWidget()->objectName() == QString("Tab_4")))
1442
        {
1443
            TX_Data[0] = 0;
1444
            TX_Data[1] = 0;
1445
            send_Data('l', ADDRESS_ALL, TX_Data, 1, true);
159 KeyOz 1446
 
162 KeyOz 1447
            Ticker->setInterval(500);
1448
            TickerEvent[2] = true;
1449
        }
1450
        else
1451
        {
1452
            Ticker->setInterval(2000);
1453
            TickerEvent[2] = false;
1454
        }
159 KeyOz 1455
    }
158 KeyOz 1456
}
1457
 
159 KeyOz 1458
void MKTool::slot_LCD_UP() // DONE 0.71g
158 KeyOz 1459
{
159 KeyOz 1460
    if (LCD_Page == LCD_MAX_Page)
1461
        TX_Data[0] = 0;
1462
    else
1463
        TX_Data[0] = LCD_Page + 1;
1464
 
1465
    TX_Data[1] = 0;
1466
    send_Data('l', ADDRESS_ALL, TX_Data, 1, true);
1467
}
1468
 
1469
void MKTool::slot_LCD_DOWN() // DONE 0.71g
1470
{
1471
    if (LCD_Page == 0)
1472
        TX_Data[0] = LCD_MAX_Page;
1473
    else
1474
        TX_Data[0] = LCD_Page - 1;
1475
 
1476
    TX_Data[1] = 0;
1477
    send_Data('l', ADDRESS_ALL, TX_Data, 1, true);
1478
}
1479
 
1480
void MKTool::slot_GetParameter() // DONE 0.71g
1481
{
158 KeyOz 1482
    TX_Data[0] = sb_Set->value();
1483
    TX_Data[1] = 0;
159 KeyOz 1484
    send_Data('q', ADDRESS_FC, TX_Data, 1);
158 KeyOz 1485
}
1486
 
159 KeyOz 1487
void MKTool::slot_SetParameter() // DONE 0.71g
158 KeyOz 1488
{
1489
    store_ParameterSet(sb_Set->value());
1490
 
159 KeyOz 1491
    TX_Data[0] = sb_Set->value();
1492
    TX_Data[1] = VERSION_SETTINGS;
1493
 
1494
    for (int a = 0; a < MaxParameter; a++)
158 KeyOz 1495
    {
159 KeyOz 1496
        TX_Data[a + 2] = ParameterSet[sb_Set->value()][a];
158 KeyOz 1497
    }
1498
 
1499
    store_ParameterSet(sb_Set->value());
1500
 
159 KeyOz 1501
    send_Data('s', ADDRESS_FC, TX_Data, MaxParameter + 2, false);
158 KeyOz 1502
}
1503
 
159 KeyOz 1504
 
1505
// Save GUI-Settings
1506
////////////////////
158 KeyOz 1507
void MKTool::write_Settings()
1508
{
1509
    QBitArray TabViews(6);
1510
    TabViews.setBit(0, ac_View0->isChecked());
1511
    TabViews.setBit(1, ac_View1->isChecked());
1512
    TabViews.setBit(2, ac_View2->isChecked());
1513
    TabViews.setBit(3, ac_View3->isChecked());
1514
    TabViews.setBit(4, ac_View4->isChecked());
1515
    TabViews.setBit(5, ac_View5->isChecked());
1516
 
162 KeyOz 1517
    Settings->GUI.Term_Info   = cb_ShowMSG->isChecked();
1518
    Settings->GUI.Term_Data   = cb_ShowData->isChecked();
1519
    Settings->GUI.Term_Always = cb_ShowAlways->isChecked();
1520
 
158 KeyOz 1521
    QSettings Setting("KeyOz-Net", "QMK-Groundstation");
1522
 
1523
    Setting.beginGroup("Port");
1524
        Setting.setValue("TTY", le_Port->text());
1525
    Setting.endGroup();
1526
 
1527
    Setting.beginGroup("GUI");
1528
        Setting.setValue("IsMax", isMaximized());
1529
        Setting.setValue("Size",  size());
1530
        Setting.setValue("Point", pos());
1531
        Setting.setValue("TabViews", QBitArray(TabViews));
1532
    Setting.endGroup();
1533
}
1534
 
159 KeyOz 1535
 
158 KeyOz 1536
// Debug-Daten anzeigen und Aufzeichnen
1537
///////////////////////////////////////
1538
void MKTool::write_CSV()
1539
{
1540
    QTextStream Out(CSVFile);
1541
    for (int a=0; a<MaxAnalog; a++)
1542
    {
162 KeyOz 1543
        if (Settings->Analog1.LogView[a])
158 KeyOz 1544
        {
1545
            Out << AnalogData[a];
1546
            if (a < MaxAnalog - 1)
1547
                Out << ';';
1548
        }
1549
    }
1550
    Out << "\n";
1551
}
1552
 
159 KeyOz 1553
void MKTool::slot_RecordCSV() // DONE 0.71g
158 KeyOz 1554
{
1555
    if (!CSVFile->isOpen())
1556
    {
159 KeyOz 1557
        QString Filename = Settings->DIR.Logging + Mode.Hardware + " - " + QDate::currentDate().toString(("yyyy-MM-dd")) + " -- " + QTime::currentTime().toString("hh-mm") + ".csv";
158 KeyOz 1558
 
1559
        CSVFile = new QFile(Filename);
1560
        if (!CSVFile->exists())
1561
        {
1562
            CSVFile->open(QIODevice::Append | QIODevice::Text);
1563
 
1564
            QTextStream Out(CSVFile);
1565
 
1566
            for (int a = 0; a < MaxAnalog; a++)
1567
            {
162 KeyOz 1568
                if (Settings->Analog1.LogView[a])
158 KeyOz 1569
                {
162 KeyOz 1570
                    Out << Settings->Analog1.Label[a];
158 KeyOz 1571
 
1572
                    if (a < MaxAnalog - 1)
1573
                        Out << ';';
1574
                }
1575
            }
1576
            Out << "\n";
1577
        }
1578
        else
1579
        {
1580
            CSVFile->open(QIODevice::Append | QIODevice::Text);
1581
        }
1582
 
1583
        pb_Record->setIcon(Icons[6]);
1584
        pb_Record->setText("CSV Stop");
1585
        ac_RecordCSV->setIcon(Icons[6]);
1586
        ac_RecordCSV->setText("CSV Stop");
1587
    }
1588
    else
1589
    {
1590
        CSVFile->close();
1591
        pb_Record->setIcon(Icons[7]);
1592
        pb_Record->setText("CSV Aufzeichnen");
1593
        ac_RecordCSV->setIcon(Icons[7]);
1594
        ac_RecordCSV->setText("CSV  Aufzeichnen");
1595
    }
1596
}
1597
 
1598
void MKTool::show_DebugData()
1599
{
1600
    if (CSVFile->isOpen())
1601
    {
1602
        write_CSV();
1603
    }
1604
 
1605
    if (ac_StartPlotter->isChecked())
1606
    {
1607
        aID[NextPlot] = NextPlot;
1608
 
1609
        for (int a = 0; a < MaxAnalog; a++)
1610
        {
1611
            aData[a][NextPlot] = AnalogData[a];
1612
        }
1613
        NextPlot++;
1614
 
1615
        if ((tab_Main->currentWidget()->objectName() == QString("Tab_1")))
1616
            update_Plot();
1617
    }
1618
 
1619
    le_A_0->setText(QString("%1").arg(AnalogData[0]));
1620
    le_A_1->setText(QString("%1").arg(AnalogData[1]));
1621
    le_A_2->setText(QString("%1").arg(AnalogData[2]));
1622
    le_A_3->setText(QString("%1").arg(AnalogData[3]));
1623
    le_A_4->setText(QString("%1").arg(AnalogData[4]));
1624
    le_A_5->setText(QString("%1").arg(AnalogData[5]));
1625
    le_A_6->setText(QString("%1").arg(AnalogData[6]));
1626
    le_A_7->setText(QString("%1").arg(AnalogData[7]));
1627
    le_A_8->setText(QString("%1").arg(AnalogData[8]));
1628
    le_A_9->setText(QString("%1").arg(AnalogData[9]));
1629
    le_A_10->setText(QString("%1").arg(AnalogData[10]));
1630
    le_A_11->setText(QString("%1").arg(AnalogData[11]));
1631
    le_A_12->setText(QString("%1").arg(AnalogData[12]));
1632
    le_A_13->setText(QString("%1").arg(AnalogData[13]));
1633
    le_A_14->setText(QString("%1").arg(AnalogData[14]));
1634
    le_A_15->setText(QString("%1").arg(AnalogData[15]));
1635
    le_A_16->setText(QString("%1").arg(AnalogData[16]));
1636
    le_A_17->setText(QString("%1").arg(AnalogData[17]));
1637
    le_A_18->setText(QString("%1").arg(AnalogData[18]));
1638
    le_A_19->setText(QString("%1").arg(AnalogData[19]));
1639
    le_A_20->setText(QString("%1").arg(AnalogData[20]));
1640
    le_A_21->setText(QString("%1").arg(AnalogData[21]));
1641
    le_A_22->setText(QString("%1").arg(AnalogData[22]));
1642
    le_A_23->setText(QString("%1").arg(AnalogData[23]));
1643
    le_A_24->setText(QString("%1").arg(AnalogData[24]));
1644
    le_A_25->setText(QString("%1").arg(AnalogData[25]));
1645
    le_A_26->setText(QString("%1").arg(AnalogData[26]));
1646
    le_A_27->setText(QString("%1").arg(AnalogData[27]));
1647
    le_A_28->setText(QString("%1").arg(AnalogData[28]));
1648
    le_A_29->setText(QString("%1").arg(AnalogData[29]));
1649
    le_A_30->setText(QString("%1").arg(AnalogData[30]));
1650
    le_A_31->setText(QString("%1").arg(AnalogData[31]));
1651
}
1652
 
159 KeyOz 1653
 
158 KeyOz 1654
// Seriel-Port Bereich, Befehle senden und Daten empfangen
1655
//////////////////////////////////////////////////////////
1656
 
1657
// Neues Datenpacket empfangen -> Verarbeiten
159 KeyOz 1658
void MKTool::new_RXData(sRxData RX) // DONE 0.71g
158 KeyOz 1659
{
1660
 
1661
    if (LastSend.length() > 2)
1662
    {
1663
    }
1664
 
162 KeyOz 1665
    int HardwareID = RX.Input[1] - 'a';
1666
 
158 KeyOz 1667
    switch(RX.Input[2])
1668
    {
159 KeyOz 1669
        case 'L' : // DONE 0.71g
158 KeyOz 1670
                    if (ToolBox::Decode64(RX, true))
1671
                    {
159 KeyOz 1672
                        int LCD[150];
1673
                        memcpy(LCD,RX.Decode, sizeof(RX.Decode));
1674
 
1675
                        LCD_Page     = RX.Decode[0];
1676
                        LCD_MAX_Page = RX.Decode[1];
1677
 
1678
                        le_LCD0->setText(ToolBox::Data2QString(LCD,2,22));
1679
                        le_LCD1->setText(ToolBox::Data2QString(LCD,22,42));
1680
                        le_LCD2->setText(ToolBox::Data2QString(LCD,42,62));
1681
                        le_LCD3->setText(ToolBox::Data2QString(LCD,62,82));
1682
 
1683
                        TickerEvent[0] = false;
158 KeyOz 1684
                    }
1685
                break;
159 KeyOz 1686
        case 'P' : // DONE 0.71g
158 KeyOz 1687
                    if (ToolBox::Decode64(RX, true))
1688
                    {
159 KeyOz 1689
                        pb_K1->setValue(ToolBox::Data2Int(RX.Decode,  0,true));
1690
                        pb_K2->setValue(ToolBox::Data2Int(RX.Decode,  2,true));
1691
                        pb_K3->setValue(ToolBox::Data2Int(RX.Decode,  4,true));
1692
                        pb_K4->setValue(ToolBox::Data2Int(RX.Decode,  6,true));
1693
                        pb_K5->setValue(ToolBox::Data2Int(RX.Decode,  8,true));
1694
                        pb_K6->setValue(ToolBox::Data2Int(RX.Decode, 10,true));
1695
                        pb_K7->setValue(ToolBox::Data2Int(RX.Decode, 12,true));
1696
                        pb_K8->setValue(ToolBox::Data2Int(RX.Decode, 14,true));
158 KeyOz 1697
                    }
1698
                break;
159 KeyOz 1699
        case 'A' : // DONE 0.71g
158 KeyOz 1700
                    if (ToolBox::Decode64(RX, true))
1701
                    {
159 KeyOz 1702
                        int Position = RX.Decode[0];
158 KeyOz 1703
                        if (Position < 32)
1704
                        {
162 KeyOz 1705
                            Settings->Analog1.Label[Position] = ToolBox::Data2QString(RX.Decode,1,17).trimmed();
158 KeyOz 1706
                            Position ++;
1707
                            TX_Data[0] = Position;
159 KeyOz 1708
                            send_Data('a', ADDRESS_ALL, TX_Data, 1, false);
158 KeyOz 1709
                        }
1710
                        if (Position == 32)
1711
                        {
1712
                            for (int a = 0; a < MaxAnalog; a++)
1713
                            {
162 KeyOz 1714
                                lb_Analog[a]->setText(Settings->Analog1.Label[a]);
158 KeyOz 1715
                            }
162 KeyOz 1716
                            Settings->write_Settings_AnalogLabels(HardwareID);
158 KeyOz 1717
                            config_Plot();
1718
                        }
1719
                    }
1720
                break;
159 KeyOz 1721
        case 'D' : // DONE 0.71g
158 KeyOz 1722
                    if (ToolBox::Decode64(RX, true))
1723
                    {
1724
                        for (int i = 0; i < MaxAnalog; i++)
1725
                        {
1726
                            AnalogData[i] = ToolBox::Data2Int(RX.Decode, (i * 2) + 2);
1727
                        }
1728
                        show_DebugData();
1729
                    }
1730
                break;
159 KeyOz 1731
        case 'Q' : // DONE 0.71g
158 KeyOz 1732
                    TickerEvent[0] = false;
1733
 
1734
                    ToolBox::Decode64(RX, true);
159 KeyOz 1735
 
1736
                    if (RX.Decode[1] == VERSION_SETTINGS)
1737
                    {
1738
                        int Settings_ID = RX.Decode[0];
1739
                        for (int a = 0; a < MaxParameter; a++)
1740
                        {
1741
                            ParameterSet[Settings_ID][a] = RX.Decode[a + 2];
1742
                        }
1743
//                        memcpy(ParameterSet[Settings_ID],RX.Decode, sizeof(RX.Decode));
1744
                        show_ParameterSet(Settings_ID);
1745
                    }
1746
                    else
1747
                    {
1748
                        pb_Read->setDisabled(true);
1749
                        pb_Write->setDisabled(true);
1750
 
1751
                        QMessageBox::warning(this, QA_NAME,
1752
                               "Versionen inkompatibel. \nParameterbearbeitung nicht moeglich.", QMessageBox::Ok);
1753
                    }
1754
 
158 KeyOz 1755
                break;
159 KeyOz 1756
        case 'S' : // DONE 0.71g
158 KeyOz 1757
                    TickerEvent[0] = false;
159 KeyOz 1758
                    qDebug("Settings set...!!!");
1759
                break;
1760
        case 'V' : // DONE 0.71g
1761
                    TickerEvent[0] = false;
158 KeyOz 1762
 
1763
                    ToolBox::Decode64(RX, true);
1764
 
159 KeyOz 1765
                    Mode.ID            = RX.Input[1] - 'a';
1766
                    Mode.VERSION_MAJOR = RX.Decode[0];
1767
                    Mode.VERSION_MINOR = RX.Decode[1];
1768
                    Mode.VERSION_PATCH = RX.Decode[4];
1769
                    Mode.VERSION_SERIAL_MAJOR = RX.Decode[2];
1770
                    Mode.VERSION_SERIAL_MINOR = RX.Decode[3];
1771
 
158 KeyOz 1772
                    Mode.Hardware   = HardwareType[Mode.ID];
1773
                    Mode.Version    = QString("%1").arg(RX.Decode[0]) + "." + QString("%1").arg(RX.Decode[1]) + QString(RX.Decode[4] + 'a');
1774
 
1775
                    setWindowTitle(QA_NAME + " v" + QA_VERSION + " - " + Mode.Hardware + " " + Mode.Version);
1776
 
159 KeyOz 1777
                    if (Mode.VERSION_SERIAL_MAJOR != VERSION_SERIAL_MAJOR)
158 KeyOz 1778
                    {
159 KeyOz 1779
                            AllowSend = false;
1780
                            QMessageBox::warning(this, QA_NAME,
1781
                               "Serielles Protokoll Inkompatibel. \nBitte neue Programmversion installieren,", QMessageBox::Ok);
1782
                    }
158 KeyOz 1783
 
159 KeyOz 1784
                    TX_Data[0] = 50;
1785
                    send_Data('d', ADDRESS_ALL, TX_Data, 1, false);
1786
 
1787
                    if (Mode.ID == ADDRESS_FC)
1788
                    {
158 KeyOz 1789
                        {
159 KeyOz 1790
                            TX_Data[0] = 0xff;
158 KeyOz 1791
                            TX_Data[1] = 0;
159 KeyOz 1792
                            send_Data('q', ADDRESS_FC, TX_Data, 1);
158 KeyOz 1793
                        }
1794
                    }
1795
                    else
1796
                    {
1797
                            pb_Read->setDisabled(true);
1798
                            pb_Write->setDisabled(true);
1799
 
159 KeyOz 1800
//                            QMessageBox::warning(this, QA_NAME,
1801
//                               "Keine Verbindung zur FlightCtrl. \nParameterbearbeitung nicht moeglich.", QMessageBox::Ok);
158 KeyOz 1802
                    }
162 KeyOz 1803
 
1804
                    Settings->read_Settings_AnalogLabels(HardwareID);
1805
                    Settings->read_Settings_Analog(HardwareID);
1806
                    for (int a = 0; a < MaxAnalog; a++)
1807
                    {
1808
                        lb_Analog[a]->setText(Settings->Analog1.Label[a]);
1809
                    }
1810
                    config_Plot();
1811
 
158 KeyOz 1812
                break;
1813
    }
1814
}
1815
 
1816
// Neue Daten an der Schnittstelle
159 KeyOz 1817
void MKTool::slot_newDataReceived(const QByteArray &dataReceived) // DONE 0.71g
158 KeyOz 1818
{
1819
    const char *RXt;
1820
    RXt = dataReceived.data();
1821
    int a = 0;
1822
 
1823
    while (RXt[a] != '\0')
1824
    {
1825
        if (RXt[a] == '\r')
1826
        {
1827
            while ((RxData.String.length() > 1) && (RxData.String.at(1) == '#'))
1828
            {
1829
                RxData.String.remove(0,1);
1830
            }
1831
 
1832
            if (ToolBox::check_CRC(RxData.String))
1833
            {
1834
                RxData.Input = RxData.String.toLatin1().data();
1835
                new_RXData(RxData);
1836
 
162 KeyOz 1837
                if ((cb_ShowData->isChecked()) && ((tab_Main->currentWidget()->objectName() == QString("Tab_3")) || (cb_ShowAlways->isChecked())))
158 KeyOz 1838
                {
1839
                    te_RX->moveCursor(QTextCursor::End,  QTextCursor::MoveAnchor);
1840
                    te_RX->insertPlainText(RxData.String + '\r');
1841
                }
1842
            }
1843
            else
1844
            {
162 KeyOz 1845
                if ((cb_ShowMSG->isChecked()) && ((tab_Main->currentWidget()->objectName() == QString("Tab_3")) || (cb_ShowAlways->isChecked())))
158 KeyOz 1846
                {
1847
                    te_RX->moveCursor(QTextCursor::End,  QTextCursor::MoveAnchor);
1848
                    te_RX->insertPlainText(RxData.String + '\r');
1849
                }
1850
            }
1851
            RxData.String = QString("");
1852
        }
1853
        else
1854
        {
1855
            {
1856
                RxData.String = RxData.String + QString(RXt[a]);
1857
            }
1858
        }
1859
        a++;
1860
    }
1861
}
1862
 
1863
// Seriellen Port öffnen
1864
void MKTool::slot_OpenPort()
1865
{
1866
    if (serialPort->isOpen())
1867
    {
1868
        TX_Data[0] = 0;
1869
        TX_Data[1] = 0;
1870
        TX_Data[2] = 0;
1871
        TX_Data[3] = 0;
159 KeyOz 1872
        send_Data('t', ADDRESS_FC, TX_Data, 4, false);
158 KeyOz 1873
 
1874
        serialPort->close();
1875
        pb_Open->setText("Verbinden");
1876
        ac_ConnectTTY->setText("Verbinden");
1877
        pb_Open->setIcon(Icons[9]);
1878
        ac_ConnectTTY->setIcon(Icons[9]);
1879
    }
1880
    else
1881
    {
1882
        serialPort->setPort(le_Port->text()); //Port
1883
 
1884
        serialPort->setBaudRate(BAUD57600); //BaudRate
1885
        serialPort->setDataBits(DATA_8); //DataBits
1886
        serialPort->setParity(PAR_NONE); //Parity
1887
        serialPort->setStopBits(STOP_1); //StopBits
1888
        serialPort->setFlowControl(FLOW_OFF); //FlowControl
1889
 
1890
        serialPort->setTimeout(0, 10);
1891
        serialPort->enableSending();
1892
        serialPort->enableReceiving();
1893
 
1894
        serialPort->open();
1895
        if (serialPort->isOpen())
1896
        {
1897
            serialPort->receiveData();
1898
 
159 KeyOz 1899
            send_Data('v', ADDRESS_ALL, TX_Data, 0, true);
1900
 
158 KeyOz 1901
            pb_Open->setText("Trennen");
1902
            ac_ConnectTTY->setText("Trennen");
1903
            pb_Open->setIcon(Icons[8]);
1904
            ac_ConnectTTY->setIcon(Icons[8]);
1905
        }
1906
    }
1907
}
1908
 
1909
// Daten senden
159 KeyOz 1910
void MKTool::send_Data(char CMD, int Address, char Data[150],unsigned int Length, bool Resend) // DONE 0.71g
158 KeyOz 1911
{
159 KeyOz 1912
    if (serialPort->isOpen() && AllowSend)
158 KeyOz 1913
    {
1914
        QString TX_Data = ToolBox::Encode64(Data, Length);
1915
 
159 KeyOz 1916
        TX_Data = QString("#") + (QString('a' + Address)) + QString(CMD) + TX_Data;
158 KeyOz 1917
 
1918
//    qDebug(TX_Data.toLatin1().data());
1919
 
1920
        TX_Data = ToolBox::add_CRC(TX_Data) + '\r';
1921
 
1922
//    qDebug(TX_Data.toLatin1().data());
1923
 
1924
        if (Resend)
1925
        {
1926
            LastSend = TX_Data;
1927
            TickerEvent[0] = true;
1928
        }
1929
 
1930
        QByteArray Temp(TX_Data.toUtf8());
1931
        serialPort->sendData(Temp);
1932
    }
1933
}
1934
 
1935
 
1936
// Programm beenden
1937
///////////////////
162 KeyOz 1938
 
1939
MKTool::~MKTool()
158 KeyOz 1940
{
162 KeyOz 1941
    qDebug(" Programm Ende ..!! ");
158 KeyOz 1942
    if (serialPort->isOpen())
1943
    {
1944
        serialPort->close();
1945
    }
1946
 
1947
    write_Settings();
162 KeyOz 1948
    Settings->write_Settings();
158 KeyOz 1949
 
1950
    if (CSVFile->isOpen())
1951
    {
1952
        CSVFile->close();
1953
    }
1954
 
162 KeyOz 1955
//    close();
158 KeyOz 1956
}
1957