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