Subversion Repositories Projects

Rev

Rev 167 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 167 Rev 199
Line 23... Line 23...
23
#include <QString>
23
#include <QString>
24
#include <QTimer>
24
#include <QTimer>
25
#include <QIcon>
25
#include <QIcon>
26
#include <QToolButton>
26
#include <QToolButton>
27
#include <QSpinBox>
27
#include <QSpinBox>
-
 
28
#include <QAction>
Line 28... Line 29...
28
 
29
 
29
#include "mktool.h"
30
#include "mktool.h"
30
#include "dlg_Config.h"
31
#include "dlg_Config.h"
31
#include "dlg_Motortest.h"
32
#include "dlg_Motortest.h"
Line 40... Line 41...
40
    setupUi(this);
41
    setupUi(this);
Line 41... Line 42...
41
 
42
 
Line 42... Line 43...
42
    Settings = new cSettings;
43
    Settings = new cSettings;
43
 
-
 
44
    init_Arrays();
44
 
Line 45... Line 45...
45
    init_Icons();
45
    init_Arrays();
46
    init_GUI();
46
    init_GUI();
Line 55... Line 55...
55
{
55
{
56
    setWindowTitle(QA_NAME + " v" + QA_VERSION);
56
    setWindowTitle(QA_NAME + " v" + QA_VERSION);
Line 57... Line 57...
57
 
57
 
58
    // Tab mit Debug-Elementen verbergen
58
    // Tab mit Debug-Elementen verbergen
59
    tab_Main->removeTab(5);
-
 
Line 60... Line 59...
60
//    tab_Main->removeTab(2);
59
    tab_Main->removeTab(5);
61
 
60
 
62
    // Settings-Tab hinzufügen.
-
 
63
    f_Settings = new wdg_Settings( this );
61
    // Settings-Tab hinzufügen.
64
 
62
    f_Settings = new wdg_Settings( this );
Line 65... Line 63...
65
    tab_Main->insertTab ( 2, f_Settings, "Parameter");
63
    tab_Main->insertTab ( 2, f_Settings, "FC-Settings");
66
    tab_Main->widget(2)->setObjectName("Tab_2");
-
 
67
 
64
    tab_Main->widget(2)->setObjectName("Tab_2");
68
    // Develop - Nicht gebrauchte sachen abschalten.
65
 
69
    ac_StartServer->setVisible(false);
66
    // Develop - Nicht gebrauchte sachen abschalten.
70
    box_Flugdaten->hide();
67
    box_Flugdaten->hide();
71
    box_System->hide();
68
    box_System->hide();
Line 72... Line 69...
72
    pb_SettingsReset->hide();
69
    pb_SettingsReset->hide();
73
    pb_Flash->hide();
70
    pb_Flash->hide();
74
    rb_NC->hide();
71
    rb_NC->hide();
75
 
72
 
76
    // Zusätzliche Widgets in die Toolbar.
-
 
Line -... Line 73...
-
 
73
    // Zusätzliche Widgets in die Toolbar.
-
 
74
    toolBar->addWidget(lb_Port);
-
 
75
    toolBar->addWidget(le_Port);
-
 
76
    toolBar->addSeparator();
77
    toolBar->addWidget(lb_Port);
77
 
-
 
78
    toolBar->addWidget(rb_SelFC);
Line 78... Line 79...
78
    toolBar->addWidget(le_Port);
79
    toolBar->addWidget(rb_SelNC);
79
    toolBar->addSeparator();
80
    toolBar->addWidget(rb_SelMag);
80
//    toolBar->addWidget(cb_Hardware);
81
 
81
 
82
    lb_Status->setText(tr("Hallo bei QMK-Groundstation...!!!"));
Line 92... Line 93...
92
    if (Settings->GUI.isMax)
93
    if (Settings->GUI.isMax)
93
    {
94
    {
94
        showMaximized();
95
        showMaximized();
95
    }
96
    }
Line -... Line 97...
-
 
97
 
96
 
98
    // Analoglabels anzeigen
97
    for (int a = 0; a < MaxAnalog; a++)
99
    for (int a = 0; a < MaxAnalog; a++)
98
    {
100
    {
99
        lb_Analog[a]->setText(Settings->Analog1.Label[a]);
101
        lb_Analog[a]->setText(Settings->Analog1.Label[a]);
Line -... Line 102...
-
 
102
    }
100
    }
103
 
101
 
104
    // Kopie der Tabs anlegen
102
    for (int b = 0; b < 6; b++)
105
    for (int b = 0; b < 6; b++)
103
    {
106
    {
Line -... Line 107...
-
 
107
        TabWidgets[b] = tab_Main->widget(b);
104
        TabWidgets[b] = tab_Main->widget(b);
108
    }
105
    }
109
 
106
 
110
    // Ausgeblendete Tabs ausblenden
107
    for (int c = 0; c < 6; c++)
111
    for (int c = 0; c < 6; c++)
108
    {
112
    {
Line 135... Line 139...
135
}
139
}
Line 136... Line 140...
136
 
140
 
137
void MKTool::init_Objects()
141
void MKTool::init_Objects()
138
{
142
{
139
    // QTimer-Instanzen
143
    // QTimer-Instanzen
Line 140... Line 144...
140
    Ticker  = new QTimer(this);
144
    Ticker = new QTimer(this);
141
 
145
 
Line 142... Line 146...
142
    // Seriell-Port
146
    // Seriell-Port
143
    serialPort = new ManageSerialPort;
147
    serialPort = new ManageSerialPort;
Line -... Line 148...
-
 
148
 
144
 
149
    // QFile-Instanz (Log-Datei)
-
 
150
    CSVFile = new QFile("");
-
 
151
 
-
 
152
    // Senden erlauben (Warum auch immer)
-
 
153
    AllowSend = true;
-
 
154
 
-
 
155
    Server = new cServer();
-
 
156
 
-
 
157
    if (Settings->Server.StartServer)
145
    // QFile-Instanz (Log-Datei)
158
    {
Line 146... Line 159...
146
    CSVFile = new QFile("");
159
        ac_StartServer->setChecked(true);
147
 
160
        Server->start_Server(Settings->Server.Port.toInt(), Settings);
-
 
161
    }
-
 
162
}
148
    AllowSend = true;
163
 
149
}
164
void MKTool::init_Connections()
Line -... Line 165...
-
 
165
{
-
 
166
    connect(Dec,   SIGNAL(clicked()), this, SLOT(slot_Test()));
-
 
167
 
150
 
168
    // Seriel-Port Empfang
151
void MKTool::init_Connections()
169
    connect(serialPort, SIGNAL(newDataReceived(const QByteArray &)), this, SLOT(slot_newDataReceived(const QByteArray &)));
152
{
170
 
Line 153... Line 171...
153
    // Seriel-Port Empfang
171
    // Serielle Verbundung öffnen / schließen
154
    connect(serialPort, SIGNAL(newDataReceived(const QByteArray &)), this, SLOT(slot_newDataReceived(const QByteArray &)));
172
    connect(ac_ConnectTTY, SIGNAL(triggered()), this, SLOT(slot_OpenPort()));
155
 
173
 
Line 156... Line 174...
156
    // Buttons Settings lesen / schreiben
174
    // Buttons Settings lesen / schreiben
157
    connect(f_Settings->pb_Read,   SIGNAL(clicked()), this, SLOT(slot_GetParameter()));
175
    connect(f_Settings->pb_Read,   SIGNAL(clicked()), this, SLOT(slot_GetFCSettings()));
158
    connect(f_Settings->pb_Write,  SIGNAL(clicked()), this, SLOT(slot_SetParameter()));
176
    connect(f_Settings->pb_Write,  SIGNAL(clicked()), this, SLOT(slot_SetFCSettings()));
159
 
177
 
160
    // LCD auf / ab
178
    // LCD auf / ab
-
 
179
    connect(pb_LCDup,   SIGNAL(clicked()), this, SLOT(slot_LCD_UP()));
161
    connect(pb_LCDup,   SIGNAL(clicked()), this, SLOT(slot_LCD_UP()));
180
    connect(pb_LCDdown, SIGNAL(clicked()), this, SLOT(slot_LCD_DOWN()));
-
 
181
 
162
    connect(pb_LCDdown, SIGNAL(clicked()), this, SLOT(slot_LCD_DOWN()));
182
    // Actions
Line 163... Line 183...
163
 
183
    connect(ac_Config,       SIGNAL(triggered()), this, SLOT(slot_ac_Config()));
164
    // Actions
184
    connect(ac_Preferences,  SIGNAL(triggered()), this, SLOT(slot_ac_Preferences()));
165
    connect(ac_Config,       SIGNAL(triggered()), this, SLOT(slot_ac_Config()));
185
    connect(ac_Motortest,    SIGNAL(triggered()), this, SLOT(slot_ac_Motortest()));
-
 
186
    connect(ac_FastDebug,    SIGNAL(triggered()), this, SLOT(slot_ac_FastDebug()));
Line 166... Line 187...
166
    connect(ac_Preferences,  SIGNAL(triggered()), this, SLOT(slot_ac_Preferences()));
187
    connect(ac_NoDebug,      SIGNAL(triggered()), this, SLOT(slot_ac_NoDebug()));
167
    connect(ac_Motortest,    SIGNAL(triggered()), this, SLOT(slot_ac_Motortest()));
188
    connect(ac_FastNavi,     SIGNAL(triggered()), this, SLOT(slot_ac_FastNavi()));
168
    connect(ac_MehrDaten,    SIGNAL(triggered()), this, SLOT(slot_ac_MehrDaten()));
189
    connect(ac_NoNavi,       SIGNAL(triggered()), this, SLOT(slot_ac_NoNavi()));
169
    connect(ac_KeineDaten,   SIGNAL(triggered()), this, SLOT(slot_ac_KeineDaten()));
190
    connect(ac_GetLabels,    SIGNAL(triggered()), this, SLOT(slot_ac_GetLabels()));
170
    connect(ac_GetLabels,    SIGNAL(triggered()), this, SLOT(slot_ac_GetLabels()));
191
 
171
 
192
    // Plotter starten / scrollen
172
    // Plotter starten / scrollen
193
    connect(scroll_plot,     SIGNAL(valueChanged(int)), this, SLOT(slot_ScrollPlot(int)));
Line -... Line 194...
-
 
194
    connect(ac_StartPlotter, SIGNAL(triggered()), this, SLOT(slot_ac_StartPlotter()));
-
 
195
    connect(ac_StartServer,  SIGNAL(triggered()), this, SLOT(slot_ac_StartServer()));
-
 
196
 
-
 
197
    // Tabs ein & ausblenden
-
 
198
    connect(ac_View0,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
-
 
199
    connect(ac_View1,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
-
 
200
    connect(ac_View2,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
-
 
201
    connect(ac_View3,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
173
    connect(scroll_plot,     SIGNAL(valueChanged(int)), this, SLOT(slot_ScrollPlot(int)));
202
    connect(ac_View4,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
174
    connect(ac_StartPlotter, SIGNAL(triggered()), this, SLOT(slot_ac_StartPlotter()));
203
    connect(ac_View5,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
175
 
204
 
Line 176... Line -...
176
    // Tabs ein & ausblenden
-
 
177
    connect(ac_View0,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
-
 
178
    connect(ac_View1,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
-
 
179
    connect(ac_View2,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
205
    connect(ac_SelNC,        SIGNAL(triggered()), this, SLOT(slot_ac_Hardware()));
180
    connect(ac_View3,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
206
    connect(ac_SelFC,        SIGNAL(triggered()), this, SLOT(slot_ac_Hardware()));
Line 181... Line 207...
181
    connect(ac_View4,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
207
    connect(ac_SelMag,       SIGNAL(triggered()), this, SLOT(slot_ac_Hardware()));
182
    connect(ac_View5,        SIGNAL(triggered()), this, SLOT(slot_ac_View()));
208
 
Line 183... Line 209...
183
 
209
    connect(rb_SelNC,        SIGNAL(clicked()), this, SLOT(slot_rb_Hardware()));
184
    // firmeware Updateen / flashen
210
    connect(rb_SelFC,        SIGNAL(clicked()), this, SLOT(slot_rb_Hardware()));
185
    connect(pb_Update,  SIGNAL(clicked()), this, SLOT(slot_pb_Update()));
211
    connect(rb_SelMag,       SIGNAL(clicked()), this, SLOT(slot_rb_Hardware()));
Line 186... Line 212...
186
    connect(pb_HexFile,  SIGNAL(clicked()), this, SLOT(slot_pb_HexFile()));
212
 
187
 
213
    // firmeware Updateen / flashen
188
    // Serielle Verbundung öffnen / schließen
214
    connect(pb_Update,   SIGNAL(clicked()), this, SLOT(slot_pb_Update()));
Line 264... Line 290...
264
            Plot[a]->attach(qwtPlot);
290
            Plot[a]->attach(qwtPlot);
265
    }
291
    }
266
    qwtPlot->replot();
292
    qwtPlot->replot();
267
}
293
}
Line -... Line 294...
-
 
294
 
268
 
295
 
-
 
296
void MKTool::slot_Test()
-
 
297
{
-
 
298
    sRxData RX;
-
 
299
 
-
 
300
    RX.String = IN->text();
-
 
301
    RX.Input  = IN->text().toLatin1().data();
-
 
302
 
-
 
303
    new_RXData(RX);
-
 
304
}
-
 
305
 
269
void MKTool::init_Icons()
306
void MKTool::slot_ac_Hardware()
270
{
-
 
271
    Icons[0].addPixmap(QPixmap(QString::fromUtf8(":/LED/Images/16X16/ledred.png")), QIcon::Normal, QIcon::Off);
-
 
272
    Icons[1].addPixmap(QPixmap(QString::fromUtf8(":/LED/Images/16X16/ledyellow.png")), QIcon::Normal, QIcon::Off);
-
 
273
    Icons[3].addPixmap(QPixmap(QString::fromUtf8(":/LED/Images/16X16/ledyellow.png")), QIcon::Normal, QIcon::Off);
307
{
274
    Icons[4].addPixmap(QPixmap(QString::fromUtf8(":/LED/Images/16X16/ledoff.png")), QIcon::Normal, QIcon::Off);
308
    QAction *Action = (QAction*)sender();
275
 
-
 
276
    Icons[5].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/application-exit.png")), QIcon::Normal, QIcon::Off);
-
 
277
    Icons[6].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/media-playback-stop.png")), QIcon::Normal, QIcon::Off);
309
 
-
 
310
    if (Action->isChecked() == false)
278
    Icons[7].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/media-record.png")), QIcon::Normal, QIcon::Off);
311
    {
279
    Icons[8].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/network-connect.png")), QIcon::Normal, QIcon::Off);
-
 
280
    Icons[9].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/network-disconnect.png")), QIcon::Normal, QIcon::Off);
-
 
-
 
312
        Action->setChecked(true);
281
    Icons[10].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/utilities-system-monitor.png")), QIcon::Normal, QIcon::Off);
313
    }
282
 
-
 
283
    Icons[20].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-up-double.png")), QIcon::Normal, QIcon::Off);
-
 
284
    Icons[21].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-up.png")), QIcon::Normal, QIcon::Off);
-
 
285
    Icons[22].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-down-double.png")), QIcon::Normal, QIcon::Off);
314
 
286
    Icons[23].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-down.png")), QIcon::Normal, QIcon::Off);
-
 
287
    Icons[24].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-left-double.png")), QIcon::Normal, QIcon::Off);
315
    slot_rb_Hardware();
288
    Icons[25].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-left.png")), QIcon::Normal, QIcon::Off);
-
 
289
    Icons[26].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-right-double.png")), QIcon::Normal, QIcon::Off);
-
 
290
    Icons[27].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-right.png")), QIcon::Normal, QIcon::Off);
316
//    qDebug("Select AC Hardware");
Line -... Line 317...
-
 
317
}
-
 
318
 
-
 
319
void MKTool::slot_rb_Hardware()
-
 
320
{
-
 
321
    if ((rb_SelNC->isChecked() == false) && (Mode.ID != ADDRESS_NC))
-
 
322
    {
-
 
323
        lb_Status->setText(tr("Schalte um auf NaviCtrl."));
-
 
324
        TX_Data[0] = 0x1B;
-
 
325
        TX_Data[1] = 0x1B;
-
 
326
        TX_Data[2] = 0x55;
-
 
327
        TX_Data[3] = 0xAA;
-
 
328
        TX_Data[4] = 0x00;
-
 
329
        TX_Data[5] = '\r';
-
 
330
        send_Data('#', ADDRESS_NC, TX_Data, 6, false);
-
 
331
        usleep(Sleep);
-
 
332
    }
-
 
333
 
-
 
334
    if (rb_SelFC->isChecked())
-
 
335
    {
-
 
336
        lb_Status->setText(tr("Schalte um auf FlightCtrl."));
-
 
337
        TX_Data[0] = 0;
-
 
338
        send_Data('u', ADDRESS_NC, TX_Data, 1, false);
-
 
339
    }
-
 
340
    else
-
 
341
    if (rb_SelMag->isChecked())
-
 
342
    {
-
 
343
        lb_Status->setText(tr("Schalte um auf MK3MAG."));
-
 
344
        TX_Data[0] = 1;
-
 
345
        send_Data('u', ADDRESS_NC, TX_Data, 1, false);
-
 
346
    }
-
 
347
    else
-
 
348
    if (rb_SelNC->isChecked())
-
 
349
    {
-
 
350
        lb_Status->setText(tr("Schalte um auf NaviCtrl."));
-
 
351
        TX_Data[0] = 0x1B;
-
 
352
        TX_Data[1] = 0x1B;
-
 
353
        TX_Data[2] = 0x55;
-
 
354
        TX_Data[3] = 0xAA;
-
 
355
        TX_Data[4] = 0x00;
-
 
356
        TX_Data[5] = '\r';
-
 
357
        send_Data('#', ADDRESS_NC, TX_Data, 6, false);
-
 
358
    }
-
 
359
    usleep(Sleep);
-
 
360
 
-
 
361
//    qDebug("Select RB Hardware");
Line 291... Line 362...
291
}
362
    send_Data('v', ADDRESS_ALL, TX_Data, 0, true);
292
 
363
}
293
 
364
 
294
// Ticker-Event
365
// Ticker-Event
Line 324... Line 395...
324
                        TX_Data[1] = 0;
395
                        TX_Data[1] = 0;
325
                        send_Data('l', ADDRESS_ALL, TX_Data, 1, true);
396
                        send_Data('l', ADDRESS_ALL, TX_Data, 1, true);
326
                    }
397
                    }
327
                break;
398
                break;
328
                case 3 :
399
                case 3 :
329
                    if (ac_MehrDaten->isChecked())
400
                    if (ac_FastDebug->isChecked())
330
                    {
401
                    {
331
                        TX_Data[0] = Settings->Data.Debug_Fast / 10;
402
                        TX_Data[0] = Settings->Data.Debug_Fast / 10;
332
                        send_Data('d', ADDRESS_ALL, TX_Data, 1, false);
403
                        send_Data('d', ADDRESS_ALL, TX_Data, 1, false);
333
                    }
404
                    }
334
                    else
405
                    else
Line 416... Line 487...
416
 
487
 
417
void MKTool::slot_ac_StartPlotter()
488
void MKTool::slot_ac_StartPlotter()
418
{
489
{
419
    if (ac_StartPlotter->isChecked())
490
    if (ac_StartPlotter->isChecked())
-
 
491
    {
420
    {
492
        lb_Status->setText(tr("Datenplotter gestartet."));
421
        ac_StartPlotter->setText("Stop Plotter");
493
        ac_StartPlotter->setText("Stop Plotter");
422
        pb_StartPlotter->setText("Stop Plotter");
494
        pb_StartPlotter->setText("Stop Plotter");
423
    }
495
    }
424
    else
496
    else
-
 
497
    {
425
    {
498
        lb_Status->setText(tr("Datenplotter gestopt."));
426
        ac_StartPlotter->setText("Start Plotter");
499
        ac_StartPlotter->setText("Start Plotter");
427
        pb_StartPlotter->setText("Start Plotter");
500
        pb_StartPlotter->setText("Start Plotter");
428
    }
501
    }
Line 466... Line 539...
466
//        Action->setChecked(true);
539
//        Action->setChecked(true);
467
        tab_Main->insertTab(Aktive, TabWidgets[Aktive], Action->text());
540
        tab_Main->insertTab(Aktive, TabWidgets[Aktive], Action->text());
468
    }
541
    }
469
}
542
}
Line -... Line 543...
-
 
543
 
-
 
544
void MKTool::slot_ac_FastNavi() // DONE NC 0.12i
-
 
545
{
-
 
546
    if (!ac_NoNavi->isChecked())
-
 
547
    {
-
 
548
        if (ac_FastNavi->isChecked())
-
 
549
        {
-
 
550
            lb_Status->setText(tr("Fordere schnelle NaviDaten an."));
-
 
551
            TX_Data[0] = Settings->Data.Navi_Fast / 10;
-
 
552
        }
-
 
553
        else
-
 
554
        {
-
 
555
            lb_Status->setText(tr("Fordere langsame NaviDaten an."));
-
 
556
            TX_Data[0] = Settings->Data.Navi_Slow / 10;
-
 
557
        }
-
 
558
        send_Data('o', ADDRESS_NC, TX_Data, 1, false);
-
 
559
    }
-
 
560
}
-
 
561
 
-
 
562
void MKTool::slot_ac_NoNavi() // DONE NC 0.12i
-
 
563
{
-
 
564
    if (ac_NoNavi->isChecked())
-
 
565
    {
-
 
566
        lb_Status->setText(tr("NaviDaten abstellen."));
-
 
567
        TX_Data[0] = 0;
-
 
568
    }
-
 
569
    else
-
 
570
    {
-
 
571
        if (ac_FastNavi->isChecked())
-
 
572
        {
-
 
573
            lb_Status->setText(tr("Fordere schnelle NaviDaten an."));
-
 
574
            TX_Data[0] = Settings->Data.Navi_Fast / 10;
-
 
575
        }
-
 
576
        else
-
 
577
        {
-
 
578
            lb_Status->setText(tr("Fordere langsame NaviDaten an."));
-
 
579
            TX_Data[0] = Settings->Data.Navi_Slow / 10;
-
 
580
        }
-
 
581
    }
-
 
582
    send_Data('o', ADDRESS_NC, TX_Data, 1, false);
-
 
583
}
470
 
584
 
471
void MKTool::slot_ac_MehrDaten() // DONE 0.71g
585
void MKTool::slot_ac_FastDebug() // DONE 0.71g
472
{
586
{
473
    if (!ac_KeineDaten->isChecked())
587
    if (!ac_NoDebug->isChecked())
474
    {
588
    {
475
        if (ac_MehrDaten->isChecked())
589
        if (ac_FastDebug->isChecked())
-
 
590
        {
476
        {
591
            lb_Status->setText(tr("Fordere schnelle DebugDaten an."));
477
            TX_Data[0] = Settings->Data.Debug_Fast / 10;
-
 
478
            send_Data('d', ADDRESS_ALL, TX_Data, 1, false);
592
            TX_Data[0] = Settings->Data.Debug_Fast / 10;
479
        }
593
        }
480
        else
594
        else
-
 
595
        {
481
        {
596
            lb_Status->setText(tr("Fordere langsame DebugDaten an."));
482
            TX_Data[0] = Settings->Data.Debug_Slow / 10;
-
 
483
            send_Data('d', ADDRESS_ALL, TX_Data, 1, false);
597
            TX_Data[0] = Settings->Data.Debug_Slow / 10;
-
 
598
        }
484
        }
599
        send_Data('d', ADDRESS_ALL, TX_Data, 1, false);
485
    }
600
    }
Line 486... Line 601...
486
}
601
}
487
 
602
 
488
void MKTool::slot_ac_KeineDaten() // DONE 0.71g
603
void MKTool::slot_ac_NoDebug() // DONE 0.71g
489
{
604
{
-
 
605
    if (ac_NoDebug->isChecked())
490
    if (ac_KeineDaten->isChecked())
606
    {
491
    {
607
        lb_Status->setText(tr("DebugDaten abstellen."));
492
        TickerEvent[3] = false;
-
 
493
        TX_Data[0] = 0;
608
        TickerEvent[3] = false;
494
        send_Data('d', ADDRESS_ALL, TX_Data, 1, false);
609
        TX_Data[0] = 0;
495
    }
610
    }
496
    else
611
    else
497
    {
612
    {
498
        // Wenn MK3MAG dann andauernd Daten neu anfragen.
613
        // Wenn MK3MAG dann andauernd Daten neu anfragen.
Line 499... Line 614...
499
        if (Mode.ID == ADDRESS_MK3MAG)
614
        if (Mode.ID == ADDRESS_MK3MAG)
500
            TickerEvent[3] = true;
615
            TickerEvent[3] = true;
-
 
616
 
501
 
617
        if (ac_FastDebug->isChecked())
502
        if (ac_MehrDaten->isChecked())
-
 
503
        {
618
        {
504
            TX_Data[0] = Settings->Data.Debug_Fast / 10;
619
            lb_Status->setText(tr("Fordere schnelle DebugDaten an."));
505
            send_Data('d', ADDRESS_ALL, TX_Data, 1, false);
620
            TX_Data[0] = Settings->Data.Debug_Fast / 10;
-
 
621
        }
506
        }
622
        else
507
        else
-
 
508
        {
623
        {
509
            TX_Data[0] = Settings->Data.Debug_Slow / 10;
624
            lb_Status->setText(tr("Fordere langsame DebugDaten an."));
-
 
625
            TX_Data[0] = Settings->Data.Debug_Slow / 10;
510
            send_Data('d', ADDRESS_ALL, TX_Data, 1, false);
626
        }
Line 511... Line 627...
511
        }
627
    }
512
    }
628
    send_Data('d', ADDRESS_ALL, TX_Data, 1, false);
513
}
629
}
514
 
630
 
Line 515... Line 631...
515
void MKTool::slot_ac_About()
631
void MKTool::slot_ac_About()
516
{
632
{
-
 
633
    QMessageBox::about(this, trUtf8(("Über ")) + QA_NAME, QA_ABOUT);
517
    QMessageBox::about(this, trUtf8(("Über ")) + QA_NAME, QA_ABOUT);
634
}
518
}
635
 
519
 
636
void MKTool::slot_ac_GetLabels() // DONE 0.71g
Line -... Line 637...
-
 
637
{
-
 
638
    lb_Status->setText(tr("Analoglabels auslesen."));
-
 
639
    TX_Data[0] = 0;
-
 
640
    send_Data('a', ADDRESS_ALL, TX_Data, 1, true);
-
 
641
}
-
 
642
 
-
 
643
void MKTool::slot_ac_StartServer()
-
 
644
{
-
 
645
    if (ac_StartServer->isChecked())
-
 
646
    {
-
 
647
        lb_Status->setText(tr("GoogleEarth-Server gestartet."));
-
 
648
        Server->start_Server(Settings->Server.Port.toInt(), Settings);
-
 
649
    }
Line 520... Line 650...
520
void MKTool::slot_ac_GetLabels() // DONE 0.71g
650
    else
521
{
651
    {
522
    TX_Data[0] = 0;
652
        lb_Status->setText(tr("GoogleEarth-Server gestopt."));
523
    send_Data('a', ADDRESS_ALL, TX_Data, 1, true);
653
        Server->stop_Server();
Line 722... Line 852...
722
    TX_Data[1] = 0;
852
    TX_Data[1] = 0;
723
    send_Data('l', ADDRESS_ALL, TX_Data, 1, true);
853
    send_Data('l', ADDRESS_ALL, TX_Data, 1, true);
724
}
854
}
Line 725... Line 855...
725
 
855
 
726
// Settings aus MK lesen / in MK schreiben
856
// Settings aus MK lesen / in MK schreiben
727
void MKTool::slot_GetParameter() // DONE 0.71g
857
void MKTool::slot_GetFCSettings() // DONE 0.71g
-
 
858
{
728
{
859
    lb_Status->setText(tr("Lese FlightCtrl-Settings aus."));
729
    TX_Data[0] = f_Settings->sb_Set->value();
860
    TX_Data[0] = f_Settings->sb_Set->value();
730
    TX_Data[1] = 0;
861
    TX_Data[1] = 0;
731
    send_Data('q', ADDRESS_FC, TX_Data, 1);
862
    send_Data('q', ADDRESS_FC, TX_Data, 1);
Line 732... Line 863...
732
}
863
}
733
 
864
 
734
void MKTool::slot_SetParameter() // DONE 0.71g
-
 
735
{
-
 
736
//    store_ParameterSet(sb_Set->value());
-
 
737
/*
-
 
738
 
865
void MKTool::slot_SetFCSettings() // DONE 0.71g
739
 
-
 
740
    TX_Data[0] = sb_Set->value();
-
 
741
    TX_Data[1] = VERSION_SETTINGS;
-
 
742
 
-
 
743
    for (int a = 0; a < MaxParameter; a++)
-
 
744
    {
-
 
Line 745... Line -...
745
        TX_Data[a + 2] = ParameterSet[sb_Set->value()][a];
-
 
746
    }
-
 
747
 
-
 
748
//    store_ParameterSet(sb_Set->value());
866
{
Line 749... Line 867...
749
*/
867
    char *TX_Data2 = f_Settings->GetFCSettings();
750
 
868
 
Line 795... Line 913...
795
}
913
}
Line 796... Line 914...
796
 
914
 
797
void MKTool::slot_RecordCSV() // DONE 0.71g
915
void MKTool::slot_RecordCSV() // DONE 0.71g
798
{
916
{
799
    if (!CSVFile->isOpen())
917
    if (!CSVFile->isOpen())
800
    {
918
    {      
Line 801... Line 919...
801
        QString Filename = Settings->DIR.Logging + Mode.Hardware + " - " + QDate::currentDate().toString(("yyyy-MM-dd")) + " -- " + QTime::currentTime().toString("hh-mm") + ".csv";
919
        QString Filename = Settings->DIR.Logging + Mode.Hardware + " - " + QDate::currentDate().toString(("yyyy-MM-dd")) + " -- " + QTime::currentTime().toString("hh-mm") + ".csv";
802
 
920
 
803
        CSVFile = new QFile(Filename);
921
        CSVFile = new QFile(Filename);
Line 822... Line 940...
822
        else
940
        else
823
        {
941
        {
824
            CSVFile->open(QIODevice::Append | QIODevice::Text);
942
            CSVFile->open(QIODevice::Append | QIODevice::Text);
825
        }
943
        }
Line 826... Line 944...
826
 
944
 
827
        pb_Record->setIcon(Icons[6]);
945
        pb_Record->setIcon(ToolBox::Icon(6));
828
        pb_Record->setText("CSV Stop");
946
        pb_Record->setText("CSV Stop");
829
        ac_RecordCSV->setIcon(Icons[6]);
947
        ac_RecordCSV->setIcon(ToolBox::Icon(6));
-
 
948
        ac_RecordCSV->setText("CSV Stop");
830
        ac_RecordCSV->setText("CSV Stop");
949
        lb_Status->setText(tr("CVS-Record gestartet."));
831
    }
950
    }
832
    else
951
    else
833
    {
952
    {
834
        CSVFile->close();
953
        CSVFile->close();
835
        pb_Record->setIcon(Icons[7]);
954
        pb_Record->setIcon(ToolBox::Icon(7));
836
        pb_Record->setText("CSV Aufzeichnen");
955
        pb_Record->setText("CSV Aufzeichnen");
837
        ac_RecordCSV->setIcon(Icons[7]);
956
        ac_RecordCSV->setIcon(ToolBox::Icon(7));
-
 
957
        ac_RecordCSV->setText("CSV  Aufzeichnen");
838
        ac_RecordCSV->setText("CSV  Aufzeichnen");
958
        lb_Status->setText(tr("CVS-Record gestopt."));
839
    }
959
    }
Line 840... Line 960...
840
}
960
}
841
 
961
 
Line 893... Line 1013...
893
    le_A_30->setText(QString("%1").arg(AnalogData[30]));
1013
    le_A_30->setText(QString("%1").arg(AnalogData[30]));
894
    le_A_31->setText(QString("%1").arg(AnalogData[31]));
1014
    le_A_31->setText(QString("%1").arg(AnalogData[31]));
895
}
1015
}
Line -... Line 1016...
-
 
1016
 
-
 
1017
 
-
 
1018
void MKTool::new_NaviData(sRxData RX)
-
 
1019
{
-
 
1020
    Navi.Current.Longitude = ToolBox::Data2Long(RX.Decode, 0, true);
-
 
1021
    Navi.Current.Latitude  = ToolBox::Data2Long(RX.Decode, 4, true);
-
 
1022
    Navi.Current.Altitude  = ToolBox::Data2Long(RX.Decode, 8, true);
-
 
1023
    Navi.Target.Longitude  = ToolBox::Data2Long(RX.Decode, 10, true);
-
 
1024
    Navi.Target.Latitude   = ToolBox::Data2Long(RX.Decode, 14, true);
-
 
1025
    Navi.Target.Altitude   = ToolBox::Data2Long(RX.Decode, 18, true);
-
 
1026
 
-
 
1027
    sNaviString NaviString;
-
 
1028
 
-
 
1029
    NaviString.Longitude = ToolBox::get_Float(Navi.Current.Longitude,10000000);
-
 
1030
    NaviString.Latitude  = ToolBox::get_Float(Navi.Current.Latitude,10000000);
-
 
1031
    NaviString.Altitude  = ToolBox::get_Float(Navi.Current.Altitude,1000);
-
 
1032
 
-
 
1033
    Server->store_NaviString(NaviString);
-
 
1034
 
-
 
1035
    /*
-
 
1036
    qDebug(NaviString.Longitude.toLatin1().data());
-
 
1037
    qDebug(NaviString.Latitude.toLatin1().data());
-
 
1038
    qDebug(NaviString.Altitude.toLatin1().data());
-
 
1039
    */
896
 
1040
}
897
 
1041
 
Line 898... Line 1042...
898
// Seriel-Port Bereich, Befehle senden und Daten empfangen
1042
// Seriel-Port Bereich, Befehle senden und Daten empfangen
899
//////////////////////////////////////////////////////////
1043
//////////////////////////////////////////////////////////
Line 936... Line 1080...
936
                        if (RX.Decode[1] == VERSION_SETTINGS)
1080
                        if (RX.Decode[1] == VERSION_SETTINGS)
937
                        {
1081
                        {
938
                            int Settings_ID = RX.Decode[0];
1082
                            int Settings_ID = RX.Decode[0];
939
                            for (int a = 0; a < MaxParameter; a++)
1083
                            for (int a = 0; a < MaxParameter; a++)
940
                            {
1084
                            {
941
                                ParameterSet[Settings_ID][a] = RX.Decode[a + 2];
1085
                                FCSettings[a] = RX.Decode[a + 2];
942
                            }
1086
                            }
943
                            //show_ParameterSet(Settings_ID);
1087
                            //show_ParameterSet(Settings_ID);
944
                            f_Settings->show_ParameterSet(Settings_ID, ParameterSet);
1088
                            f_Settings->show_FCSettings(Settings_ID, FCSettings);
-
 
1089
                            f_Settings->pb_Read->setEnabled(true);
-
 
1090
                            f_Settings->pb_Write->setEnabled(true);
945
                        }
1091
                        }
946
                        else
1092
                        else
947
                        {
1093
                        {
948
                            f_Settings->pb_Read->setDisabled(true);
1094
                            f_Settings->pb_Read->setDisabled(true);
949
                            f_Settings->pb_Write->setDisabled(true);
1095
                            f_Settings->pb_Write->setDisabled(true);
Line 964... Line 1110...
964
            {
1110
            {
965
                // Navigationsdaten
1111
                // Navigationsdaten
966
                case 'O' : // NOT DONE 0.12h
1112
                case 'O' : // NOT DONE 0.12h
967
                    if (ToolBox::Decode64(RX))
1113
                    if (ToolBox::Decode64(RX))
968
                    {
1114
                    {
-
 
1115
                        new_NaviData(RX);
969
                    }
1116
                    }
970
                break;
1117
                break;
971
            }
1118
            }
972
//        case ADDRESS_MK3MAG :
1119
//        case ADDRESS_MK3MAG :
Line 1054... Line 1201...
1054
                                AllowSend = false;
1201
                                AllowSend = false;
1055
                                QMessageBox::warning(this, QA_NAME,
1202
                                QMessageBox::warning(this, QA_NAME,
1056
                                   "Serielles Protokoll Inkompatibel. \nBitte neue Programmversion installieren,", QMessageBox::Ok);
1203
                                   "Serielles Protokoll Inkompatibel. \nBitte neue Programmversion installieren,", QMessageBox::Ok);
1057
                        }
1204
                        }
Line -... Line 1205...
-
 
1205
 
-
 
1206
                        if (ac_NoDebug->isChecked())
-
 
1207
                        {
-
 
1208
                            TX_Data[0] = 0;
-
 
1209
                        }
-
 
1210
                        else
-
 
1211
                        if (ac_FastDebug->isChecked())
-
 
1212
                        {
-
 
1213
                            TX_Data[0] = Settings->Data.Debug_Fast / 10;
-
 
1214
                        }
-
 
1215
                        else
-
 
1216
                        {
-
 
1217
                            TX_Data[0] = Settings->Data.Debug_Slow / 10;
-
 
1218
                        }
-
 
1219
 
-
 
1220
                        send_Data('d', ADDRESS_ALL, TX_Data, 1, false);
1058
 
1221
 
1059
                        // Wenn MK3MAG dann andauernd Daten neu anfragen.
1222
                        // Wenn MK3MAG dann andauernd Daten neu anfragen.
1060
                        if (Mode.ID == ADDRESS_MK3MAG)
1223
                        if (Mode.ID == ADDRESS_MK3MAG)
1061
                        {
1224
                        {
-
 
1225
                            TickerEvent[3] = true;
-
 
1226
                            rb_SelMag->setChecked(true);
-
 
1227
                        }
-
 
1228
 
-
 
1229
                        // Wenn NaviCtrl dann hier.
-
 
1230
                        if (Mode.ID == ADDRESS_NC)
-
 
1231
                        {
-
 
1232
                            rb_SelNC->setChecked(true);
-
 
1233
 
-
 
1234
                            if (ac_NoNavi->isChecked())
-
 
1235
                            {
-
 
1236
                                TX_Data[0] = 0;
-
 
1237
                            }
-
 
1238
                            else
-
 
1239
                            if (ac_FastNavi->isChecked())
-
 
1240
                            {
-
 
1241
                                TX_Data[0] = Settings->Data.Navi_Fast / 10;
-
 
1242
                            }
-
 
1243
                            else
-
 
1244
                            {
-
 
1245
                                TX_Data[0] = Settings->Data.Navi_Slow / 10;
-
 
1246
                            }
-
 
1247
 
1062
                            TickerEvent[3] = true;
1248
                            send_Data('o', ADDRESS_NC, TX_Data, 1, false);
Line 1063... Line -...
1063
                        }
-
 
1064
 
-
 
Line 1065... Line 1249...
1065
                        TX_Data[0] = Settings->Data.Debug_Slow / 10;
1249
                        }
1066
                        send_Data('d', ADDRESS_ALL, TX_Data, 1, false);
1250
 
1067
 
1251
 
-
 
1252
                        // Wenn FlightCtrl dann Settings abfragen.
1068
                        // Wenn FlightCtrl dann Settings abfragen.
1253
                        if (Mode.ID == ADDRESS_FC)
1069
                        if (Mode.ID == ADDRESS_FC)
1254
                        {
1070
                        {
1255
                            rb_SelFC->setChecked(true);
1071
                            {
1256
                            {
1072
                                TX_Data[0] = 0xff;
1257
                                TX_Data[0] = 0xff;
Line 1153... Line 1338...
1153
// Seriellen Port öffnen
1338
// Seriellen Port öffnen
1154
void MKTool::slot_OpenPort()
1339
void MKTool::slot_OpenPort()
1155
{
1340
{
1156
    if (serialPort->isOpen())
1341
    if (serialPort->isOpen())
1157
    {
1342
    {
1158
        TX_Data[0] = 0;
1343
        TX_Data[0] = Settings->Data.Debug_Off / 10;
1159
        TX_Data[1] = 0;
1344
        send_Data('d', ADDRESS_ALL, TX_Data, 1, false);
1160
        TX_Data[2] = 0;
-
 
1161
        TX_Data[3] = 0;
1345
        usleep(Sleep);
1162
        send_Data('t', ADDRESS_FC, TX_Data, 4, false);
-
 
Line -... Line 1346...
-
 
1346
 
-
 
1347
        if (Mode.ID == ADDRESS_NC)
-
 
1348
        {
-
 
1349
            TX_Data[0] = Settings->Data.Navi_Off / 10;
-
 
1350
            send_Data('o', ADDRESS_NC, TX_Data, 1, false);
-
 
1351
            usleep(Sleep);
-
 
1352
        }
-
 
1353
 
-
 
1354
        if (Mode.ID == ADDRESS_NC)
-
 
1355
        {
-
 
1356
            TX_Data[0] = 0;
-
 
1357
            TX_Data[1] = 0;
-
 
1358
            TX_Data[2] = 0;
-
 
1359
            TX_Data[3] = 0;
-
 
1360
            send_Data('t', ADDRESS_FC, TX_Data, 4, false);
-
 
1361
            usleep(Sleep);
1163
 
1362
        }
1164
        serialPort->close();
1363
        serialPort->close();
1165
        pb_Open->setText("Verbinden");
1364
        pb_Open->setText("Verbinden");
1166
        ac_ConnectTTY->setText("Verbinden");
1365
        ac_ConnectTTY->setText("Verbinden");
1167
        pb_Open->setIcon(Icons[9]);
1366
        pb_Open->setIcon(ToolBox::Icon(9));
-
 
1367
        ac_ConnectTTY->setIcon(ToolBox::Icon(9));
-
 
1368
 
Line 1168... Line 1369...
1168
        ac_ConnectTTY->setIcon(Icons[9]);
1369
        le_Port->setEnabled(true);
1169
 
1370
 
1170
        Ticker->stop();
1371
        Ticker->stop();
1171
    }
1372
    }
Line 1184... Line 1385...
1184
        serialPort->enableReceiving();
1385
        serialPort->enableReceiving();
Line 1185... Line 1386...
1185
 
1386
 
1186
        serialPort->open();
1387
        serialPort->open();
1187
        if (serialPort->isOpen())
1388
        if (serialPort->isOpen())
-
 
1389
        {
1188
        {
1390
            le_Port->setEnabled(false);
Line 1189... Line 1391...
1189
            serialPort->receiveData();
1391
            serialPort->receiveData();
Line 1190... Line 1392...
1190
 
1392
 
1191
            send_Data('v', ADDRESS_ALL, TX_Data, 0, true);
1393
            send_Data('v', ADDRESS_ALL, TX_Data, 0, true);
1192
 
1394
 
1193
            pb_Open->setText("Trennen");
1395
            pb_Open->setText("Trennen");
Line 1194... Line 1396...
1194
            ac_ConnectTTY->setText("Trennen");
1396
            ac_ConnectTTY->setText("Trennen");
1195
            pb_Open->setIcon(Icons[8]);
1397
            pb_Open->setIcon(ToolBox::Icon(8));
1196
            ac_ConnectTTY->setIcon(Icons[8]);
1398
            ac_ConnectTTY->setIcon(ToolBox::Icon(8));
1197
 
1399
 
Line 1203... Line 1405...
1203
// Daten senden
1405
// Daten senden
1204
void MKTool::send_Data(char CMD, int Address, char Data[150],unsigned int Length, bool Resend) // DONE 0.71g
1406
void MKTool::send_Data(char CMD, int Address, char Data[150],unsigned int Length, bool Resend) // DONE 0.71g
1205
{
1407
{
1206
    if (serialPort->isOpen() && AllowSend)
1408
    if (serialPort->isOpen() && AllowSend)
1207
    {
1409
    {
-
 
1410
        QByteArray Temp;
1208
        QString TX_Data = ToolBox::Encode64(Data, Length);
1411
        QString TX_Data;
Line -... Line 1412...
-
 
1412
 
-
 
1413
        if (CMD != '#')
-
 
1414
        {
-
 
1415
//            qDebug("Send data..");
-
 
1416
            TX_Data = ToolBox::Encode64(Data, Length);
1209
 
1417
 
Line 1210... Line 1418...
1210
        TX_Data = QString("#") + (QString('a' + Address)) + QString(CMD) + TX_Data;
1418
            TX_Data = QString("#") + (QString('a' + Address)) + QString(CMD) + TX_Data;
Line 1211... Line 1419...
1211
 
1419
 
Line 1212... Line 1420...
1212
//    qDebug(TX_Data.toLatin1().data());
1420
//    qDebug(TX_Data.toLatin1().data());
Line 1213... Line 1421...
1213
 
1421
 
-
 
1422
            TX_Data = ToolBox::add_CRC(TX_Data) + '\r';
-
 
1423
 
-
 
1424
//    qDebug(TX_Data.toLatin1().data());
-
 
1425
 
-
 
1426
            if (Resend)
-
 
1427
            {
-
 
1428
                LastSend = TX_Data;
1214
        TX_Data = ToolBox::add_CRC(TX_Data) + '\r';
1429
                TickerEvent[0] = true;
1215
 
1430
            }
-
 
1431
            Temp = QByteArray(TX_Data.toUtf8());
-
 
1432
        }
1216
//    qDebug(TX_Data.toLatin1().data());
1433
        else
-
 
1434
        {
-
 
1435
//            qDebug("Send Raw..");
1217
 
1436
            for (unsigned int a = 0; a < Length; a++)
Line 1218... Line -...
1218
        if (Resend)
-
 
1219
        {
1437
            {
Line 1220... Line 1438...
1220
            LastSend = TX_Data;
1438
                Temp[a] = Data[a];
1221
            TickerEvent[0] = true;
1439
//                qDebug(QString("%1").arg(Temp[a]).toLatin1().data());
1222
        }
1440
            }
1223
 
1441
        }
1224
        QByteArray Temp(TX_Data.toUtf8());
1442
 
1225
        serialPort->sendData(Temp);
1443
        serialPort->sendData(Temp);