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