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