Rev 246 | Details | Compare with Previous | 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> |
||
199 | KeyOz | 28 | #include <QAction> |
227 | KeyOz | 29 | #include <QPalette> |
158 | KeyOz | 30 | |
31 | #include "mktool.h" |
||
32 | #include "dlg_Config.h" |
||
33 | #include "dlg_Motortest.h" |
||
159 | KeyOz | 34 | #include "dlg_Preferences.h" |
158 | KeyOz | 35 | #include "../global.h" |
227 | KeyOz | 36 | #include "../Classes/ToolBox.h" |
158 | KeyOz | 37 | |
38 | #include <stdlib.h> |
||
39 | |||
40 | MKTool::MKTool() |
||
41 | { |
||
42 | setupUi(this); |
||
43 | |||
44 | Settings = new cSettings; |
||
45 | |||
46 | init_Arrays(); |
||
47 | init_GUI(); |
||
48 | |||
49 | init_Objects(); |
||
50 | init_Connections(); |
||
51 | |||
52 | init_Plot(); |
||
53 | } |
||
54 | |||
55 | void MKTool::init_GUI() |
||
56 | { |
||
57 | setWindowTitle(QA_NAME + " v" + QA_VERSION); |
||
58 | |||
167 | KeyOz | 59 | // Tab mit Debug-Elementen verbergen |
227 | KeyOz | 60 | tab_Main->removeTab(6); |
167 | KeyOz | 61 | |
62 | // Settings-Tab hinzufügen. |
||
63 | f_Settings = new wdg_Settings( this ); |
||
227 | KeyOz | 64 | f_Settings->set_Config(Settings); |
65 | tab_Main->insertTab ( 2, f_Settings, ac_View2->icon(), "FC-Settings"); |
||
167 | KeyOz | 66 | tab_Main->widget(2)->setObjectName("Tab_2"); |
67 | |||
68 | // Develop - Nicht gebrauchte sachen abschalten. |
||
69 | pb_SettingsReset->hide(); |
||
70 | pb_Flash->hide(); |
||
71 | rb_NC->hide(); |
||
72 | |||
73 | // Zusätzliche Widgets in die Toolbar. |
||
227 | KeyOz | 74 | tb_TTY->addWidget(lb_Port); |
75 | tb_TTY->addWidget(le_Port); |
||
166 | KeyOz | 76 | |
227 | KeyOz | 77 | tb_Hardware->addWidget(rb_SelFC); |
78 | tb_Hardware->addWidget(rb_SelNC); |
||
79 | tb_Hardware->addWidget(rb_SelMag); |
||
166 | KeyOz | 80 | |
227 | KeyOz | 81 | tb_Allgemein->setVisible(Settings->GUI.ToolViews[0]); |
82 | tb_Werkzeuge->setVisible(Settings->GUI.ToolViews[1]); |
||
83 | tb_Debug->setVisible(Settings->GUI.ToolViews[2]); |
||
84 | tb_TTY->setVisible(Settings->GUI.ToolViews[3]); |
||
85 | tb_Hardware->setVisible(Settings->GUI.ToolViews[4]); |
||
86 | |||
199 | KeyOz | 87 | lb_Status->setText(tr("Hallo bei QMK-Groundstation...!!!")); |
88 | |||
227 | KeyOz | 89 | QPalette newPalette; |
199 | KeyOz | 90 | |
227 | KeyOz | 91 | newPalette.setColor(QPalette::Base, Qt::darkBlue); |
92 | newPalette.setColor(QPalette::Foreground, QColor(Qt::darkBlue).dark(120)); |
||
93 | newPalette.setColor(QPalette::Text, Qt::white); |
||
94 | |||
95 | Compass->setScaleOptions(QwtDial::ScaleTicks | QwtDial::ScaleLabel); |
||
96 | Compass->setScaleTicks(0, 0, 3); |
||
97 | Compass->setScale(36, 5, 0); |
||
98 | |||
99 | // Compass->setNeedle(new QwtCompassMagnetNeedle(QwtCompassMagnetNeedle::ThinStyle)); |
||
100 | Compass->setNeedle(new QwtDialSimpleNeedle(QwtDialSimpleNeedle::Arrow, true, Qt::red, QColor(Qt::gray).light(130))); |
||
101 | Compass->setPalette(newPalette); |
||
102 | Compass->setMaximumSize(QSize(MeterSize, MeterSize)); |
||
103 | Compass->setMinimumSize(QSize(MeterSize, MeterSize)); |
||
104 | |||
105 | QPalette newPalette1; |
||
106 | |||
107 | newPalette1.setColor(QPalette::Base, Qt::darkBlue); |
||
108 | newPalette1.setColor(QPalette::Foreground, QColor(255,128,0).dark(120)); |
||
109 | newPalette1.setColor(QPalette::Text, Qt::white); |
||
110 | |||
111 | Attitude = new AttitudeIndicator(this); |
||
112 | Attitude->setMaximumSize(QSize(MeterSize, MeterSize)); |
||
113 | Attitude->setMinimumSize(QSize(MeterSize, MeterSize)); |
||
114 | Attitude->setPalette(newPalette1); |
||
115 | |||
116 | verticalLayout->addWidget(Attitude); |
||
117 | |||
118 | qwt_Rate->setRange(-10.0, 10.0, 0.1, 0); |
||
119 | |||
120 | newPalette1.setColor(QPalette::Foreground, QColor(Qt::darkBlue).dark(120)); |
||
121 | |||
122 | SpeedMeter = new cSpeedMeter(this); |
||
123 | SpeedMeter->setMaximumSize(QSize(MeterSize, MeterSize)); |
||
124 | SpeedMeter->setMinimumSize(QSize(MeterSize, MeterSize)); |
||
125 | SpeedMeter->setPalette(newPalette1); |
||
126 | SpeedMeter->setRange(0.0, 5.0); |
||
127 | SpeedMeter->setScale(1, 2, 0.5); |
||
128 | SpeedMeter->setProperty("END", 5); |
||
129 | |||
130 | LayOut_Speed->addWidget(SpeedMeter); |
||
131 | |||
158 | KeyOz | 132 | #ifdef _EEEPC_ |
166 | KeyOz | 133 | lb_Status->hide(); |
158 | KeyOz | 134 | #endif |
135 | |||
136 | resize(Settings->GUI.Size); |
||
137 | move(Settings->GUI.Point); |
||
138 | |||
139 | if (Settings->GUI.isMax) |
||
140 | { |
||
141 | showMaximized(); |
||
142 | } |
||
143 | |||
199 | KeyOz | 144 | // Analoglabels anzeigen |
158 | KeyOz | 145 | for (int a = 0; a < MaxAnalog; a++) |
146 | { |
||
162 | KeyOz | 147 | lb_Analog[a]->setText(Settings->Analog1.Label[a]); |
158 | KeyOz | 148 | } |
149 | |||
199 | KeyOz | 150 | // Kopie der Tabs anlegen |
227 | KeyOz | 151 | // for (int b = 0; b < 7; b++) |
158 | KeyOz | 152 | for (int b = 0; b < 6; b++) |
153 | { |
||
154 | TabWidgets[b] = tab_Main->widget(b); |
||
155 | } |
||
156 | |||
199 | KeyOz | 157 | // Ausgeblendete Tabs ausblenden |
227 | KeyOz | 158 | // for (int c = 0; c < 7; c++) |
158 | KeyOz | 159 | for (int c = 0; c < 6; c++) |
160 | { |
||
161 | if (Settings->GUI.TabViews[c] == false) |
||
162 | { |
||
163 | QString TabName = QString("Tab_%1").arg(c); |
||
164 | |||
165 | for (int d = 0; d < tab_Main->count(); d++) |
||
166 | { |
||
167 | if (tab_Main->widget(d)->objectName() == TabName) |
||
168 | { |
||
169 | tab_Main->removeTab(d); |
||
170 | } |
||
171 | } |
||
172 | } |
||
173 | } |
||
174 | |||
175 | ac_View0->setChecked(Settings->GUI.TabViews[0]); |
||
176 | ac_View1->setChecked(Settings->GUI.TabViews[1]); |
||
177 | ac_View2->setChecked(Settings->GUI.TabViews[2]); |
||
178 | ac_View3->setChecked(Settings->GUI.TabViews[3]); |
||
179 | ac_View4->setChecked(Settings->GUI.TabViews[4]); |
||
180 | ac_View5->setChecked(Settings->GUI.TabViews[5]); |
||
227 | KeyOz | 181 | // ac_View6->setChecked(Settings->GUI.TabViews[6]); |
158 | KeyOz | 182 | |
183 | le_Port->setText(Settings->TTY.Port); |
||
162 | KeyOz | 184 | |
185 | cb_ShowMSG->setChecked(Settings->GUI.Term_Info); |
||
186 | cb_ShowData->setChecked(Settings->GUI.Term_Data); |
||
187 | cb_ShowAlways->setChecked(Settings->GUI.Term_Always); |
||
158 | KeyOz | 188 | } |
189 | |||
190 | void MKTool::init_Objects() |
||
191 | { |
||
192 | // QTimer-Instanzen |
||
199 | KeyOz | 193 | Ticker = new QTimer(this); |
158 | KeyOz | 194 | |
195 | // Seriell-Port |
||
196 | serialPort = new ManageSerialPort; |
||
197 | |||
239 | Brean | 198 | // neuer Logger |
240 | Brean | 199 | logger = new Logger(Settings, &Mode); |
159 | KeyOz | 200 | |
227 | KeyOz | 201 | // LCD-Dialog |
202 | f_LCD = new dlg_LCD(this); |
||
203 | |||
199 | KeyOz | 204 | // Senden erlauben (Warum auch immer) |
159 | KeyOz | 205 | AllowSend = true; |
199 | KeyOz | 206 | |
207 | Server = new cServer(); |
||
208 | |||
227 | KeyOz | 209 | MyServer = new cQMK_Server(); |
210 | MyServer->setProperty("Connect", false); |
||
211 | |||
212 | |||
199 | KeyOz | 213 | if (Settings->Server.StartServer) |
214 | { |
||
215 | ac_StartServer->setChecked(true); |
||
216 | Server->start_Server(Settings->Server.Port.toInt(), Settings); |
||
217 | } |
||
158 | KeyOz | 218 | } |
219 | |||
220 | void MKTool::init_Connections() |
||
221 | { |
||
199 | KeyOz | 222 | connect(Dec, SIGNAL(clicked()), this, SLOT(slot_Test())); |
223 | |||
158 | KeyOz | 224 | // Seriel-Port Empfang |
225 | connect(serialPort, SIGNAL(newDataReceived(const QByteArray &)), this, SLOT(slot_newDataReceived(const QByteArray &))); |
||
226 | |||
199 | KeyOz | 227 | // Serielle Verbundung öffnen / schließen |
228 | connect(ac_ConnectTTY, SIGNAL(triggered()), this, SLOT(slot_OpenPort())); |
||
229 | |||
227 | KeyOz | 230 | // TCP-Connection verbinden / trennen |
231 | connect(ac_QMKServer, SIGNAL(triggered()), this, SLOT(slot_QMKS_Connect())); |
||
232 | |||
167 | KeyOz | 233 | // Buttons Settings lesen / schreiben |
199 | KeyOz | 234 | connect(f_Settings->pb_Read, SIGNAL(clicked()), this, SLOT(slot_GetFCSettings())); |
235 | connect(f_Settings->pb_Write, SIGNAL(clicked()), this, SLOT(slot_SetFCSettings())); |
||
158 | KeyOz | 236 | |
237 | // Actions |
||
238 | connect(ac_Config, SIGNAL(triggered()), this, SLOT(slot_ac_Config())); |
||
159 | KeyOz | 239 | connect(ac_Preferences, SIGNAL(triggered()), this, SLOT(slot_ac_Preferences())); |
158 | KeyOz | 240 | connect(ac_Motortest, SIGNAL(triggered()), this, SLOT(slot_ac_Motortest())); |
227 | KeyOz | 241 | connect(ac_LCD, SIGNAL(triggered()), this, SLOT(slot_ac_LCD())); |
199 | KeyOz | 242 | connect(ac_FastDebug, SIGNAL(triggered()), this, SLOT(slot_ac_FastDebug())); |
243 | connect(ac_NoDebug, SIGNAL(triggered()), this, SLOT(slot_ac_NoDebug())); |
||
244 | connect(ac_FastNavi, SIGNAL(triggered()), this, SLOT(slot_ac_FastNavi())); |
||
245 | connect(ac_NoNavi, SIGNAL(triggered()), this, SLOT(slot_ac_NoNavi())); |
||
158 | KeyOz | 246 | connect(ac_GetLabels, SIGNAL(triggered()), this, SLOT(slot_ac_GetLabels())); |
247 | |||
167 | KeyOz | 248 | // Plotter starten / scrollen |
249 | connect(scroll_plot, SIGNAL(valueChanged(int)), this, SLOT(slot_ScrollPlot(int))); |
||
250 | connect(ac_StartPlotter, SIGNAL(triggered()), this, SLOT(slot_ac_StartPlotter())); |
||
199 | KeyOz | 251 | connect(ac_StartServer, SIGNAL(triggered()), this, SLOT(slot_ac_StartServer())); |
167 | KeyOz | 252 | |
158 | KeyOz | 253 | // Tabs ein & ausblenden |
254 | connect(ac_View0, SIGNAL(triggered()), this, SLOT(slot_ac_View())); |
||
255 | connect(ac_View1, SIGNAL(triggered()), this, SLOT(slot_ac_View())); |
||
256 | connect(ac_View2, SIGNAL(triggered()), this, SLOT(slot_ac_View())); |
||
257 | connect(ac_View3, SIGNAL(triggered()), this, SLOT(slot_ac_View())); |
||
258 | connect(ac_View4, SIGNAL(triggered()), this, SLOT(slot_ac_View())); |
||
259 | connect(ac_View5, SIGNAL(triggered()), this, SLOT(slot_ac_View())); |
||
227 | KeyOz | 260 | connect(ac_View6, SIGNAL(triggered()), this, SLOT(slot_ac_View())); |
158 | KeyOz | 261 | |
199 | KeyOz | 262 | connect(ac_SelNC, SIGNAL(triggered()), this, SLOT(slot_ac_Hardware())); |
263 | connect(ac_SelFC, SIGNAL(triggered()), this, SLOT(slot_ac_Hardware())); |
||
264 | connect(ac_SelMag, SIGNAL(triggered()), this, SLOT(slot_ac_Hardware())); |
||
265 | |||
266 | connect(rb_SelNC, SIGNAL(clicked()), this, SLOT(slot_rb_Hardware())); |
||
267 | connect(rb_SelFC, SIGNAL(clicked()), this, SLOT(slot_rb_Hardware())); |
||
268 | connect(rb_SelMag, SIGNAL(clicked()), this, SLOT(slot_rb_Hardware())); |
||
269 | |||
248 | Brean | 270 | // Wegpunkt-Befehl |
271 | connect(pb_FlyTo, SIGNAL(clicked()), this, SLOT(slot_ac_SendWaypoint())); |
||
272 | |||
167 | KeyOz | 273 | // firmeware Updateen / flashen |
199 | KeyOz | 274 | connect(pb_Update, SIGNAL(clicked()), this, SLOT(slot_pb_Update())); |
166 | KeyOz | 275 | connect(pb_HexFile, SIGNAL(clicked()), this, SLOT(slot_pb_HexFile())); |
158 | KeyOz | 276 | |
167 | KeyOz | 277 | // CVS-Record starten / stoppen |
239 | Brean | 278 | connect(ac_RecordCSV, SIGNAL(triggered()), this, SLOT(slot_RecordLog())); |
158 | KeyOz | 279 | |
280 | // Timer-Events |
||
281 | connect(Ticker, SIGNAL(timeout()), SLOT(slot_Ticker())); |
||
282 | |||
167 | KeyOz | 283 | // Seitenwechsel |
199 | KeyOz | 284 | connect(tab_Main, SIGNAL(currentChanged(int)), this, SLOT(slot_TabChanged(int))); |
167 | KeyOz | 285 | connect(f_Settings->tab_Par, SIGNAL(currentChanged(int)), this, SLOT(slot_TabChanged(int))); |
158 | KeyOz | 286 | |
167 | KeyOz | 287 | // About QMK & About-QT Dialog einfügen |
288 | connect(ac_About, SIGNAL(triggered()), this, SLOT(slot_ac_About())); |
||
158 | KeyOz | 289 | menu_Help->addAction(trUtf8("Über &Qt"), qApp, SLOT(aboutQt())); |
290 | } |
||
291 | |||
292 | void MKTool::init_Arrays() |
||
293 | { |
||
294 | lb_Analog[0] = lb_A_0; |
||
295 | lb_Analog[1] = lb_A_1; |
||
296 | lb_Analog[2] = lb_A_2; |
||
297 | lb_Analog[3] = lb_A_3; |
||
298 | lb_Analog[4] = lb_A_4; |
||
299 | lb_Analog[5] = lb_A_5; |
||
300 | lb_Analog[6] = lb_A_6; |
||
301 | lb_Analog[7] = lb_A_7; |
||
302 | lb_Analog[8] = lb_A_8; |
||
303 | lb_Analog[9] = lb_A_9; |
||
304 | lb_Analog[10] = lb_A_10; |
||
305 | lb_Analog[11] = lb_A_11; |
||
306 | lb_Analog[12] = lb_A_12; |
||
307 | lb_Analog[13] = lb_A_13; |
||
308 | lb_Analog[14] = lb_A_14; |
||
309 | lb_Analog[15] = lb_A_15; |
||
310 | lb_Analog[16] = lb_A_16; |
||
311 | lb_Analog[17] = lb_A_17; |
||
312 | lb_Analog[18] = lb_A_18; |
||
313 | lb_Analog[19] = lb_A_19; |
||
314 | lb_Analog[20] = lb_A_20; |
||
315 | lb_Analog[21] = lb_A_21; |
||
316 | lb_Analog[22] = lb_A_22; |
||
317 | lb_Analog[23] = lb_A_23; |
||
318 | lb_Analog[24] = lb_A_24; |
||
319 | lb_Analog[25] = lb_A_25; |
||
320 | lb_Analog[26] = lb_A_26; |
||
321 | lb_Analog[27] = lb_A_27; |
||
322 | lb_Analog[28] = lb_A_28; |
||
323 | lb_Analog[29] = lb_A_29; |
||
324 | lb_Analog[30] = lb_A_30; |
||
325 | lb_Analog[31] = lb_A_31; |
||
326 | } |
||
327 | |||
328 | void MKTool::init_Plot() |
||
329 | { |
||
330 | NextPlot = 0; |
||
331 | |||
332 | qwtPlot->setCanvasBackground(QColor(QRgb(0x00000000))); |
||
333 | |||
334 | qwtPlot->insertLegend(new QwtLegend(), QwtPlot::RightLegend); |
||
335 | |||
336 | QwtPlotGrid *Grid = new QwtPlotGrid(); |
||
337 | Grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine)); |
||
338 | |||
339 | Grid->attach(qwtPlot); |
||
340 | |||
166 | KeyOz | 341 | qwtPlot->setAxisScale(QwtPlot::xBottom,0,Settings->Data.Plotter_Count,0); |
158 | KeyOz | 342 | |
343 | for (int a = 0; a < MaxAnalog; a++) |
||
344 | { |
||
162 | KeyOz | 345 | Plot[a] = new QwtPlotCurve(Settings->Analog1.Label[a]); |
346 | Plot[a]->setPen(QPen(QColor(Def_Colors[a]))); |
||
167 | KeyOz | 347 | Plot[a]->setRenderHint(QwtPlotItem::RenderAntialiased); |
158 | KeyOz | 348 | |
162 | KeyOz | 349 | if (Settings->Analog1.PlotView[a]) |
158 | KeyOz | 350 | Plot[a]->attach(qwtPlot); |
351 | } |
||
352 | qwtPlot->replot(); |
||
353 | } |
||
354 | |||
199 | KeyOz | 355 | |
356 | void MKTool::slot_Test() |
||
158 | KeyOz | 357 | { |
227 | KeyOz | 358 | /* |
199 | KeyOz | 359 | sRxData RX; |
158 | KeyOz | 360 | |
199 | KeyOz | 361 | RX.String = IN->text(); |
362 | RX.Input = IN->text().toLatin1().data(); |
||
158 | KeyOz | 363 | |
199 | KeyOz | 364 | new_RXData(RX); |
227 | KeyOz | 365 | */ |
158 | KeyOz | 366 | } |
367 | |||
199 | KeyOz | 368 | void MKTool::slot_ac_Hardware() |
369 | { |
||
370 | QAction *Action = (QAction*)sender(); |
||
158 | KeyOz | 371 | |
199 | KeyOz | 372 | if (Action->isChecked() == false) |
373 | { |
||
374 | Action->setChecked(true); |
||
375 | } |
||
376 | |||
377 | slot_rb_Hardware(); |
||
378 | } |
||
379 | |||
380 | void MKTool::slot_rb_Hardware() |
||
381 | { |
||
382 | if ((rb_SelNC->isChecked() == false) && (Mode.ID != ADDRESS_NC)) |
||
383 | { |
||
384 | lb_Status->setText(tr("Schalte um auf NaviCtrl.")); |
||
385 | TX_Data[0] = 0x1B; |
||
386 | TX_Data[1] = 0x1B; |
||
387 | TX_Data[2] = 0x55; |
||
388 | TX_Data[3] = 0xAA; |
||
389 | TX_Data[4] = 0x00; |
||
390 | TX_Data[5] = '\r'; |
||
391 | send_Data('#', ADDRESS_NC, TX_Data, 6, false); |
||
227 | KeyOz | 392 | ToolBox::Wait(SLEEP); |
199 | KeyOz | 393 | } |
394 | |||
395 | if (rb_SelFC->isChecked()) |
||
396 | { |
||
397 | lb_Status->setText(tr("Schalte um auf FlightCtrl.")); |
||
398 | TX_Data[0] = 0; |
||
399 | send_Data('u', ADDRESS_NC, TX_Data, 1, false); |
||
400 | } |
||
401 | else |
||
402 | if (rb_SelMag->isChecked()) |
||
403 | { |
||
404 | lb_Status->setText(tr("Schalte um auf MK3MAG.")); |
||
405 | TX_Data[0] = 1; |
||
406 | send_Data('u', ADDRESS_NC, TX_Data, 1, false); |
||
407 | } |
||
408 | else |
||
409 | if (rb_SelNC->isChecked()) |
||
410 | { |
||
411 | lb_Status->setText(tr("Schalte um auf NaviCtrl.")); |
||
412 | TX_Data[0] = 0x1B; |
||
413 | TX_Data[1] = 0x1B; |
||
414 | TX_Data[2] = 0x55; |
||
415 | TX_Data[3] = 0xAA; |
||
416 | TX_Data[4] = 0x00; |
||
417 | TX_Data[5] = '\r'; |
||
418 | send_Data('#', ADDRESS_NC, TX_Data, 6, false); |
||
419 | } |
||
227 | KeyOz | 420 | ToolBox::Wait(SLEEP); |
199 | KeyOz | 421 | |
422 | // qDebug("Select RB Hardware"); |
||
423 | send_Data('v', ADDRESS_ALL, TX_Data, 0, true); |
||
424 | } |
||
425 | |||
158 | KeyOz | 426 | // Ticker-Event |
427 | /////////////// |
||
428 | void MKTool::slot_Ticker() |
||
429 | { |
||
430 | if (TickerDiv) |
||
431 | TickerDiv = false; |
||
432 | else |
||
433 | TickerDiv = true; |
||
434 | |||
435 | for (int a = 0; a < MaxTickerEvents; a++) |
||
436 | { |
||
437 | if (TickerEvent[a] == true) |
||
438 | { |
||
439 | switch(a) |
||
440 | { |
||
441 | case 0 : |
||
442 | if (TickerDiv) |
||
443 | { |
||
444 | QByteArray Temp(LastSend.toUtf8()); |
||
445 | serialPort->sendData(Temp); |
||
446 | } |
||
447 | break; |
||
448 | case 1 : |
||
159 | KeyOz | 449 | TX_Data[0] = 0; |
450 | send_Data('p', ADDRESS_FC, TX_Data, 0, false); |
||
158 | KeyOz | 451 | break; |
159 | KeyOz | 452 | case 2 : |
227 | KeyOz | 453 | if (f_LCD->cb_LCD->isChecked()) |
167 | KeyOz | 454 | { |
227 | KeyOz | 455 | if (!f_LCD->isVisible()) |
456 | { |
||
457 | Ticker->setInterval(2000); |
||
458 | TickerEvent[2] = false; |
||
459 | } |
||
167 | KeyOz | 460 | TX_Data[0] = LCD_Page; |
461 | TX_Data[1] = 0; |
||
462 | send_Data('l', ADDRESS_ALL, TX_Data, 1, true); |
||
463 | } |
||
159 | KeyOz | 464 | break; |
167 | KeyOz | 465 | case 3 : |
199 | KeyOz | 466 | if (ac_FastDebug->isChecked()) |
167 | KeyOz | 467 | { |
468 | TX_Data[0] = Settings->Data.Debug_Fast / 10; |
||
469 | send_Data('d', ADDRESS_ALL, TX_Data, 1, false); |
||
470 | } |
||
471 | else |
||
472 | { |
||
473 | TX_Data[0] = Settings->Data.Debug_Slow / 10; |
||
474 | send_Data('d', ADDRESS_ALL, TX_Data, 1, false); |
||
475 | } |
||
476 | break; |
||
158 | KeyOz | 477 | } |
478 | } |
||
479 | } |
||
480 | } |
||
481 | |||
227 | KeyOz | 482 | void MKTool::slot_QMKS_Connect() |
483 | { |
||
484 | if (ac_QMKServer->isChecked()) |
||
485 | { |
||
486 | lb_Status->setText(tr("Verbinde zum QMK-Datenserver.")); |
||
158 | KeyOz | 487 | |
227 | KeyOz | 488 | MyServer->Connect("nimari.de", 16441, Settings->Server.QMKS_Login, Settings->Server.QMKS_Password); |
489 | connect(MyServer, SIGNAL(sig_Connected()), this, SLOT(slot_QMKS_Connected())); |
||
490 | connect(MyServer, SIGNAL(sig_Disconnected(int)), this, SLOT(slot_QMKS_Disconnected(int))); |
||
491 | |||
492 | } |
||
493 | else |
||
494 | { |
||
495 | if ((MyServer->property("Connect")) == true) |
||
496 | { |
||
497 | disconnect(MyServer, SIGNAL(sig_Disconnected(int)), 0, 0); |
||
498 | lb_Status->setText(tr("Trenne vom QMK-Datenserver.")); |
||
499 | |||
500 | MyServer->Disconnect(); |
||
501 | MyServer->setProperty("Connect", false); |
||
502 | ac_QMKServer->setText("QMK-Server Verbinden"); |
||
503 | } |
||
504 | } |
||
505 | } |
||
506 | |||
507 | void MKTool::slot_QMKS_Connected() |
||
508 | { |
||
509 | MyServer->setProperty("Connect", true); |
||
510 | ac_QMKServer->setText("QMK-Server Trennnen"); |
||
511 | lb_Status->setText(tr("Verbunden mit QMK-Datenserver.")); |
||
512 | } |
||
513 | |||
514 | void MKTool::slot_QMKS_Disconnected(int Error) |
||
515 | { |
||
516 | MyServer->setProperty("Connect", false); |
||
517 | ac_QMKServer->setText("QMK-Server Verbinden"); |
||
518 | ac_QMKServer->setChecked(false); |
||
519 | |||
520 | disconnect(MyServer, SIGNAL(sig_Disconnected(int)), 0, 0); |
||
521 | |||
522 | switch (Error) |
||
523 | { |
||
524 | case 1 : |
||
525 | { |
||
526 | lb_Status->setText(tr("Verbindung vom Server beendet.")); |
||
527 | QMessageBox::warning(this, QA_NAME,"QMK-Datenserver: Verbindung wurde vom Server beendet.", QMessageBox::Ok); |
||
528 | } |
||
529 | break; |
||
530 | case 2 : |
||
531 | { |
||
532 | lb_Status->setText(tr("Server nicht gefunden.")); |
||
533 | QMessageBox::warning(this, QA_NAME,"QMK-Datenserver: Kann nicht zum Server verbinden.", QMessageBox::Ok); |
||
534 | } |
||
535 | break; |
||
536 | case 3 : |
||
537 | { |
||
538 | lb_Status->setText(tr("Serververbindung getrennt. Logindaten falsch.")); |
||
539 | QMessageBox::warning(this, QA_NAME,"QMK-Datenserver: Loginname oder Password falsch.", QMessageBox::Ok); |
||
540 | } |
||
541 | break; |
||
542 | default : |
||
543 | { |
||
544 | lb_Status->setText(tr("Getrennt vom QMK-Datenserver.")); |
||
545 | } |
||
546 | break; |
||
547 | } |
||
548 | } |
||
549 | |||
158 | KeyOz | 550 | // Slots der Actions (Menüpunkte, Buttons) |
551 | ////////////////////////////////////////// |
||
552 | void MKTool::slot_ac_Motortest() |
||
553 | { |
||
554 | dlg_Motortest *f_Motortest = new dlg_Motortest(this); |
||
555 | |||
556 | connect(f_Motortest, SIGNAL(updateMotor(int, int, int, int)), this, SLOT(slot_Motortest(int, int, int, int))); |
||
557 | |||
558 | if (f_Motortest->exec()==QDialog::Accepted) |
||
559 | { |
||
560 | } |
||
561 | |||
562 | disconnect(f_Motortest, 0,0,0); |
||
563 | slot_Motortest(0,0,0,0); |
||
564 | } |
||
565 | |||
227 | KeyOz | 566 | void MKTool::slot_ac_LCD() |
567 | { |
||
568 | if (!f_LCD->isVisible()) |
||
569 | { |
||
570 | f_LCD = new dlg_LCD(this); |
||
571 | |||
572 | // LCD auf / ab |
||
573 | connect(f_LCD->pb_LCDup, SIGNAL(clicked()), this, SLOT(slot_LCD_UP())); |
||
574 | connect(f_LCD->pb_LCDdown, SIGNAL(clicked()), this, SLOT(slot_LCD_DOWN())); |
||
575 | |||
576 | f_LCD->show(); |
||
577 | TX_Data[0] = 0; |
||
578 | TX_Data[1] = 0; |
||
579 | send_Data('l', ADDRESS_ALL, TX_Data, 1, true); |
||
580 | |||
581 | Ticker->setInterval(500); |
||
582 | TickerEvent[2] = true; |
||
583 | } |
||
584 | } |
||
585 | |||
158 | KeyOz | 586 | void MKTool::slot_Motortest(int Motor1, int Motor2, int Motor3, int Motor4) |
587 | { |
||
588 | TX_Data[0] = Motor1; |
||
589 | TX_Data[1] = Motor2; |
||
590 | TX_Data[2] = Motor3; |
||
591 | TX_Data[3] = Motor4; |
||
159 | KeyOz | 592 | send_Data('t', ADDRESS_FC, TX_Data, 4, false); |
158 | KeyOz | 593 | } |
594 | |||
595 | void MKTool::slot_ac_Config() |
||
596 | { |
||
162 | KeyOz | 597 | set_Analog Old_Analog1; |
158 | KeyOz | 598 | |
162 | KeyOz | 599 | Old_Analog1 = Settings->Analog1; |
600 | |||
158 | KeyOz | 601 | dlg_Config *f_Config = new dlg_Config(this); |
162 | KeyOz | 602 | f_Config->set_Settings(Settings, Mode.ID); |
158 | KeyOz | 603 | |
604 | if (f_Config->exec()==QDialog::Accepted) |
||
605 | { |
||
606 | Settings = f_Config->get_Settings(); |
||
162 | KeyOz | 607 | Settings->write_Settings_Analog(Mode.ID); |
158 | KeyOz | 608 | |
163 | KeyOz | 609 | // Plotter neu einrichten |
610 | if (Old_Analog1.PlotView != Settings->Analog1.PlotView) |
||
158 | KeyOz | 611 | { |
163 | KeyOz | 612 | config_Plot(); |
158 | KeyOz | 613 | } |
614 | |||
163 | KeyOz | 615 | // CVS-Datei neu anlegen. |
241 | KeyOz | 616 | if ((logger->is_active()) && (Old_Analog1.LogView != Settings->Analog1.LogView)) |
158 | KeyOz | 617 | { |
239 | Brean | 618 | logger->close(); |
240 | Brean | 619 | logger->start_Log(); |
241 | KeyOz | 620 | // update_Log(); |
158 | KeyOz | 621 | } |
622 | |||
623 | } |
||
624 | } |
||
625 | |||
239 | Brean | 626 | //aktualisiere Logging-Status |
241 | KeyOz | 627 | void MKTool::update_Log() |
628 | { |
||
239 | Brean | 629 | if (logger->is_active()) |
630 | { |
||
241 | KeyOz | 631 | // logger->write(AnalogData); |
632 | // pb_Record->setText("Log Stop"); |
||
239 | Brean | 633 | ac_RecordCSV->setText("Log Stop"); |
634 | lb_Status->setText(tr("Log-Record gestartet.")); |
||
635 | } |
||
636 | else |
||
637 | { |
||
241 | KeyOz | 638 | // pb_Record->setText("Log Aufzeichnen"); |
639 | ac_RecordCSV->setText("Log Aufzeichnen"); |
||
239 | Brean | 640 | lb_Status->setText(tr("Log-Record gestopt.")); |
641 | } |
||
642 | } |
||
643 | |||
644 | //starte/stoppe Logging, wenn auf den entsprechenden Button gedrückt wurde |
||
645 | void MKTool::slot_RecordLog() |
||
646 | { |
||
647 | if (!logger->is_active()) |
||
648 | logger->start_Log(); |
||
649 | else |
||
650 | logger->close(); |
||
241 | KeyOz | 651 | |
239 | Brean | 652 | update_Log(); |
653 | } |
||
654 | |||
159 | KeyOz | 655 | void MKTool::slot_ac_Preferences() |
656 | { |
||
657 | dlg_Preferences *f_Preferences = new dlg_Preferences(this); |
||
658 | |||
166 | KeyOz | 659 | Settings->TTY.Port = le_Port->text(); |
163 | KeyOz | 660 | f_Preferences->set_Settings(Settings); |
661 | |||
159 | KeyOz | 662 | if (f_Preferences->exec()==QDialog::Accepted) |
663 | { |
||
163 | KeyOz | 664 | Settings = f_Preferences->get_Settings(); |
665 | Settings->write_Settings(); |
||
166 | KeyOz | 666 | le_Port->setText(Settings->TTY.Port); |
667 | config_Plot(); |
||
159 | KeyOz | 668 | } |
669 | } |
||
670 | |||
158 | KeyOz | 671 | void MKTool::slot_ac_StartPlotter() |
672 | { |
||
673 | if (ac_StartPlotter->isChecked()) |
||
674 | { |
||
199 | KeyOz | 675 | lb_Status->setText(tr("Datenplotter gestartet.")); |
158 | KeyOz | 676 | ac_StartPlotter->setText("Stop Plotter"); |
677 | pb_StartPlotter->setText("Stop Plotter"); |
||
678 | } |
||
679 | else |
||
680 | { |
||
199 | KeyOz | 681 | lb_Status->setText(tr("Datenplotter gestopt.")); |
158 | KeyOz | 682 | ac_StartPlotter->setText("Start Plotter"); |
683 | pb_StartPlotter->setText("Start Plotter"); |
||
684 | } |
||
685 | } |
||
686 | |||
687 | void MKTool::slot_ac_View() |
||
688 | { |
||
227 | KeyOz | 689 | int Aktive = -1; |
158 | KeyOz | 690 | |
691 | QAction *Action = (QAction*)sender(); |
||
692 | |||
693 | if (Action->objectName() == QString("ac_View0")) |
||
694 | Aktive = 0; |
||
695 | if (Action->objectName() == QString("ac_View1")) |
||
696 | Aktive = 1; |
||
697 | if (Action->objectName() == QString("ac_View2")) |
||
698 | Aktive = 2; |
||
699 | if (Action->objectName() == QString("ac_View3")) |
||
700 | Aktive = 3; |
||
701 | if (Action->objectName() == QString("ac_View4")) |
||
702 | Aktive = 4; |
||
703 | if (Action->objectName() == QString("ac_View5")) |
||
704 | Aktive = 5; |
||
227 | KeyOz | 705 | // if (Action->objectName() == QString("ac_View6")) |
706 | // Aktive = 6; |
||
158 | KeyOz | 707 | |
708 | QString TabName = QString("Tab_%1").arg(Aktive); |
||
709 | |||
710 | if (!Action->isChecked()) |
||
711 | { |
||
712 | for (int a = 0; a < tab_Main->count(); a++) |
||
713 | { |
||
714 | if (tab_Main->widget(a)->objectName() == TabName) |
||
715 | { |
||
716 | tab_Main->removeTab(a); |
||
717 | } |
||
718 | } |
||
719 | } |
||
720 | else |
||
721 | { |
||
227 | KeyOz | 722 | tab_Main->insertTab(Aktive, TabWidgets[Aktive], Action->icon(), Action->text()); |
158 | KeyOz | 723 | } |
724 | } |
||
725 | |||
199 | KeyOz | 726 | void MKTool::slot_ac_FastNavi() // DONE NC 0.12i |
158 | KeyOz | 727 | { |
199 | KeyOz | 728 | if (!ac_NoNavi->isChecked()) |
158 | KeyOz | 729 | { |
199 | KeyOz | 730 | if (ac_FastNavi->isChecked()) |
166 | KeyOz | 731 | { |
199 | KeyOz | 732 | lb_Status->setText(tr("Fordere schnelle NaviDaten an.")); |
733 | TX_Data[0] = Settings->Data.Navi_Fast / 10; |
||
734 | } |
||
735 | else |
||
736 | { |
||
737 | lb_Status->setText(tr("Fordere langsame NaviDaten an.")); |
||
738 | TX_Data[0] = Settings->Data.Navi_Slow / 10; |
||
739 | } |
||
740 | send_Data('o', ADDRESS_NC, TX_Data, 1, false); |
||
741 | } |
||
742 | } |
||
743 | |||
744 | void MKTool::slot_ac_NoNavi() // DONE NC 0.12i |
||
745 | { |
||
746 | if (ac_NoNavi->isChecked()) |
||
747 | { |
||
748 | lb_Status->setText(tr("NaviDaten abstellen.")); |
||
749 | TX_Data[0] = 0; |
||
750 | } |
||
751 | else |
||
752 | { |
||
753 | if (ac_FastNavi->isChecked()) |
||
754 | { |
||
755 | lb_Status->setText(tr("Fordere schnelle NaviDaten an.")); |
||
756 | TX_Data[0] = Settings->Data.Navi_Fast / 10; |
||
757 | } |
||
758 | else |
||
759 | { |
||
760 | lb_Status->setText(tr("Fordere langsame NaviDaten an.")); |
||
761 | TX_Data[0] = Settings->Data.Navi_Slow / 10; |
||
762 | } |
||
763 | } |
||
764 | send_Data('o', ADDRESS_NC, TX_Data, 1, false); |
||
765 | } |
||
766 | |||
767 | void MKTool::slot_ac_FastDebug() // DONE 0.71g |
||
768 | { |
||
769 | if (!ac_NoDebug->isChecked()) |
||
770 | { |
||
771 | if (ac_FastDebug->isChecked()) |
||
772 | { |
||
773 | lb_Status->setText(tr("Fordere schnelle DebugDaten an.")); |
||
166 | KeyOz | 774 | TX_Data[0] = Settings->Data.Debug_Fast / 10; |
775 | } |
||
776 | else |
||
777 | { |
||
199 | KeyOz | 778 | lb_Status->setText(tr("Fordere langsame DebugDaten an.")); |
166 | KeyOz | 779 | TX_Data[0] = Settings->Data.Debug_Slow / 10; |
780 | } |
||
199 | KeyOz | 781 | send_Data('d', ADDRESS_ALL, TX_Data, 1, false); |
166 | KeyOz | 782 | } |
783 | } |
||
784 | |||
199 | KeyOz | 785 | void MKTool::slot_ac_NoDebug() // DONE 0.71g |
166 | KeyOz | 786 | { |
199 | KeyOz | 787 | if (ac_NoDebug->isChecked()) |
166 | KeyOz | 788 | { |
199 | KeyOz | 789 | lb_Status->setText(tr("DebugDaten abstellen.")); |
167 | KeyOz | 790 | TickerEvent[3] = false; |
166 | KeyOz | 791 | TX_Data[0] = 0; |
792 | } |
||
158 | KeyOz | 793 | else |
794 | { |
||
167 | KeyOz | 795 | // Wenn MK3MAG dann andauernd Daten neu anfragen. |
796 | if (Mode.ID == ADDRESS_MK3MAG) |
||
797 | TickerEvent[3] = true; |
||
798 | |||
199 | KeyOz | 799 | if (ac_FastDebug->isChecked()) |
166 | KeyOz | 800 | { |
199 | KeyOz | 801 | lb_Status->setText(tr("Fordere schnelle DebugDaten an.")); |
166 | KeyOz | 802 | TX_Data[0] = Settings->Data.Debug_Fast / 10; |
803 | } |
||
804 | else |
||
805 | { |
||
199 | KeyOz | 806 | lb_Status->setText(tr("Fordere langsame DebugDaten an.")); |
166 | KeyOz | 807 | TX_Data[0] = Settings->Data.Debug_Slow / 10; |
808 | } |
||
809 | } |
||
199 | KeyOz | 810 | send_Data('d', ADDRESS_ALL, TX_Data, 1, false); |
158 | KeyOz | 811 | } |
812 | |||
813 | void MKTool::slot_ac_About() |
||
814 | { |
||
815 | QMessageBox::about(this, trUtf8(("Über ")) + QA_NAME, QA_ABOUT); |
||
816 | } |
||
817 | |||
159 | KeyOz | 818 | void MKTool::slot_ac_GetLabels() // DONE 0.71g |
158 | KeyOz | 819 | { |
199 | KeyOz | 820 | lb_Status->setText(tr("Analoglabels auslesen.")); |
158 | KeyOz | 821 | TX_Data[0] = 0; |
167 | KeyOz | 822 | send_Data('a', ADDRESS_ALL, TX_Data, 1, true); |
158 | KeyOz | 823 | } |
824 | |||
199 | KeyOz | 825 | void MKTool::slot_ac_StartServer() |
826 | { |
||
827 | if (ac_StartServer->isChecked()) |
||
828 | { |
||
829 | lb_Status->setText(tr("GoogleEarth-Server gestartet.")); |
||
830 | Server->start_Server(Settings->Server.Port.toInt(), Settings); |
||
831 | } |
||
832 | else |
||
833 | { |
||
834 | lb_Status->setText(tr("GoogleEarth-Server gestopt.")); |
||
835 | Server->stop_Server(); |
||
836 | } |
||
837 | } |
||
159 | KeyOz | 838 | |
227 | KeyOz | 839 | |
158 | KeyOz | 840 | // Daten-Plotter |
841 | ///////////////// |
||
842 | void MKTool::update_Plot() |
||
843 | { |
||
844 | for (int a = 0; a < MaxAnalog; a++) |
||
845 | { |
||
846 | Plot[a]->setData(aID,aData[a],NextPlot - 1); |
||
847 | } |
||
848 | |||
166 | KeyOz | 849 | if ((NextPlot > Settings->Data.Plotter_Count)) |
158 | KeyOz | 850 | { |
166 | KeyOz | 851 | scroll_plot->setMaximum(NextPlot - Settings->Data.Plotter_Count); |
158 | KeyOz | 852 | } |
853 | |||
166 | KeyOz | 854 | if ((scroll_plot->value() == NextPlot - (Settings->Data.Plotter_Count + 1))) |
158 | KeyOz | 855 | { |
166 | KeyOz | 856 | qwtPlot->setAxisScale(QwtPlot::xBottom,NextPlot - Settings->Data.Plotter_Count,NextPlot,0); |
857 | scroll_plot->setValue(NextPlot - Settings->Data.Plotter_Count); |
||
158 | KeyOz | 858 | } |
859 | |||
860 | qwtPlot->replot(); |
||
861 | } |
||
862 | |||
863 | void MKTool::config_Plot() |
||
864 | { |
||
166 | KeyOz | 865 | // qDebug("Plotter rekonfiguriert..!!"); |
866 | qwtPlot->setAxisScale(QwtPlot::xBottom,0,Settings->Data.Plotter_Count,0); |
||
867 | |||
158 | KeyOz | 868 | for (int a = 0; a < MaxAnalog; a++) |
869 | { |
||
870 | Plot[a]->detach(); |
||
162 | KeyOz | 871 | Plot[a]->setPen(QPen(QColor(Def_Colors[a]))); |
158 | KeyOz | 872 | |
162 | KeyOz | 873 | if (Settings->Analog1.PlotView[a]) |
874 | { |
||
875 | Plot[a]->setTitle(Settings->Analog1.Label[a]); |
||
158 | KeyOz | 876 | Plot[a]->attach(qwtPlot); |
162 | KeyOz | 877 | } |
158 | KeyOz | 878 | } |
166 | KeyOz | 879 | qwtPlot->replot(); |
158 | KeyOz | 880 | } |
881 | |||
882 | void MKTool::slot_ScrollPlot(int Pos) |
||
883 | { |
||
166 | KeyOz | 884 | qwtPlot->setAxisScale(QwtPlot::xBottom,Pos,Pos + Settings->Data.Plotter_Count,0); |
158 | KeyOz | 885 | qwtPlot->replot(); |
886 | } |
||
887 | |||
888 | |||
889 | // Firmeware-Update |
||
890 | /////////////////// |
||
891 | void MKTool::slot_pb_Update() |
||
892 | { |
||
167 | KeyOz | 893 | QString Device; |
894 | QString Hardware; |
||
158 | KeyOz | 895 | |
167 | KeyOz | 896 | if (rb_FC->isChecked()) |
897 | { |
||
898 | Device = "m644"; |
||
899 | Hardware = "FlightCtrl"; |
||
900 | } |
||
901 | else if (rb_MK3MAG->isChecked()) |
||
902 | { |
||
903 | Device = "m168"; |
||
904 | Hardware = "MK3MAG"; |
||
905 | } |
||
906 | else if (rb_BL->isChecked()) |
||
907 | { |
||
908 | Device = "m8"; |
||
909 | Hardware = "BL-Ctrl"; |
||
910 | } |
||
166 | KeyOz | 911 | |
912 | QString Message = "Firmeware-Datei \n\n"; |
||
913 | Message = Message + le_HexFile->text() + "\n\n"; |
||
167 | KeyOz | 914 | Message = Message + "an " + Hardware + trUtf8(" mit AVRDUDE - Seriel & Bootloader über ") + le_Port->text() + trUtf8(" übertragen?\n"); |
166 | KeyOz | 915 | |
916 | if (le_HexFile->text() == "") |
||
162 | KeyOz | 917 | { |
166 | KeyOz | 918 | QMessageBox::warning(this, QA_NAME, trUtf8("Bitte Firmeware-Datei wählen."), QMessageBox::Ok); |
162 | KeyOz | 919 | } |
166 | KeyOz | 920 | else if (QMessageBox::warning(this, QA_NAME, Message, QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) |
921 | { |
||
922 | QString Programm = "avrdude" ; |
||
162 | KeyOz | 923 | |
166 | KeyOz | 924 | QStringList Argumente; |
162 | KeyOz | 925 | |
166 | KeyOz | 926 | Update = new QProcess(); |
162 | KeyOz | 927 | |
166 | KeyOz | 928 | if (serialPort->isOpen()) |
929 | { |
||
930 | slot_OpenPort(); |
||
931 | } |
||
932 | |||
933 | Argumente << "-P"; |
||
934 | Argumente << le_Port->text(); |
||
935 | Argumente << "-p"; |
||
936 | Argumente << Device; |
||
937 | Argumente << "-c"; |
||
938 | Argumente << "butterfly"; |
||
939 | Argumente << "-b"; |
||
940 | Argumente << "57600"; |
||
941 | Argumente << "-U"; |
||
942 | Argumente << "flash:w:" + le_HexFile->text(); |
||
943 | |||
944 | // QString Programm = "/home/Manuel/bin/avrdude -p m644 -P /dev/ttyS0 -c butterfly -b 57600 -U flash:w:/home/Manuel/Documents/Mikrokopter/Firmeware/FlightCtrl/Flight-Ctrl_MEGA644_V0_71h.hex"; |
||
945 | |||
946 | te_Shell->setText(""); // Ausgabefenster säubern |
||
947 | |||
948 | connect(Update, SIGNAL(readyReadStandardOutput()), this, SLOT(slot_UpdateShell()) ); |
||
949 | connect(Update, SIGNAL(readyReadStandardError()), this, SLOT(slot_UpdateShell()) ); |
||
950 | |||
951 | Update->start(Programm, Argumente); // Programmaufruf |
||
952 | } |
||
158 | KeyOz | 953 | } |
954 | |||
955 | void MKTool::slot_UpdateShell() |
||
956 | { |
||
162 | KeyOz | 957 | QByteArray Output; |
158 | KeyOz | 958 | |
166 | KeyOz | 959 | Output = Update->readAllStandardError(); // Shellausgabe an Variable |
162 | KeyOz | 960 | te_Shell->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); |
961 | te_Shell->insertPlainText(QString::fromUtf8(Output)); |
||
158 | KeyOz | 962 | |
166 | KeyOz | 963 | Output = Update->readAll(); |
964 | te_Shell->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); |
||
965 | te_Shell->insertPlainText(QString::fromUtf8(Output)); |
||
158 | KeyOz | 966 | } |
967 | |||
166 | KeyOz | 968 | void MKTool::slot_pb_HexFile() |
969 | { |
||
970 | QString FileName = QFileDialog::getOpenFileName(this,trUtf8(("Firmeware-Datei wählen")),"", |
||
971 | tr("Intel Hex(*.hex);;Alle Dateien (*)")); |
||
972 | if (!FileName.isEmpty()) |
||
973 | { |
||
974 | le_HexFile->setText(FileName); |
||
975 | } |
||
976 | } |
||
158 | KeyOz | 977 | |
978 | |||
167 | KeyOz | 979 | // Wechsel der Tabs erkennen |
159 | KeyOz | 980 | void MKTool::slot_TabChanged(int Tab) // DONE 0.71g |
158 | KeyOz | 981 | { |
982 | Tab = Tab; |
||
162 | KeyOz | 983 | if (tab_Main->count() != 0) |
158 | KeyOz | 984 | { |
167 | KeyOz | 985 | if ((tab_Main->currentWidget()->objectName() == QString("Tab_2")) && (f_Settings->tab_Par->currentIndex() == 1)) |
162 | KeyOz | 986 | { |
987 | TX_Data[0] = 0; |
||
988 | send_Data('p', ADDRESS_FC, TX_Data, 0, true); |
||
159 | KeyOz | 989 | |
162 | KeyOz | 990 | Ticker->setInterval(500); |
991 | TickerEvent[1] = true; |
||
992 | } |
||
993 | else |
||
994 | { |
||
995 | Ticker->setInterval(2000); |
||
996 | TickerEvent[1] = false; |
||
997 | } |
||
227 | KeyOz | 998 | /* |
162 | KeyOz | 999 | if ((tab_Main->currentWidget()->objectName() == QString("Tab_4"))) |
1000 | { |
||
1001 | TX_Data[0] = 0; |
||
1002 | TX_Data[1] = 0; |
||
1003 | send_Data('l', ADDRESS_ALL, TX_Data, 1, true); |
||
159 | KeyOz | 1004 | |
162 | KeyOz | 1005 | Ticker->setInterval(500); |
1006 | TickerEvent[2] = true; |
||
1007 | } |
||
1008 | else |
||
1009 | { |
||
1010 | Ticker->setInterval(2000); |
||
1011 | TickerEvent[2] = false; |
||
1012 | } |
||
227 | KeyOz | 1013 | */ |
159 | KeyOz | 1014 | } |
158 | KeyOz | 1015 | } |
1016 | |||
167 | KeyOz | 1017 | // LCD-Seiten weiterschalten |
159 | KeyOz | 1018 | void MKTool::slot_LCD_UP() // DONE 0.71g |
158 | KeyOz | 1019 | { |
159 | KeyOz | 1020 | if (LCD_Page == LCD_MAX_Page) |
1021 | TX_Data[0] = 0; |
||
1022 | else |
||
1023 | TX_Data[0] = LCD_Page + 1; |
||
1024 | |||
1025 | TX_Data[1] = 0; |
||
1026 | send_Data('l', ADDRESS_ALL, TX_Data, 1, true); |
||
227 | KeyOz | 1027 | |
159 | KeyOz | 1028 | } |
1029 | |||
1030 | void MKTool::slot_LCD_DOWN() // DONE 0.71g |
||
1031 | { |
||
1032 | if (LCD_Page == 0) |
||
1033 | TX_Data[0] = LCD_MAX_Page; |
||
1034 | else |
||
1035 | TX_Data[0] = LCD_Page - 1; |
||
1036 | |||
1037 | TX_Data[1] = 0; |
||
1038 | send_Data('l', ADDRESS_ALL, TX_Data, 1, true); |
||
227 | KeyOz | 1039 | |
1040 | aa--; |
||
1041 | |||
159 | KeyOz | 1042 | } |
1043 | |||
167 | KeyOz | 1044 | // Settings aus MK lesen / in MK schreiben |
199 | KeyOz | 1045 | void MKTool::slot_GetFCSettings() // DONE 0.71g |
159 | KeyOz | 1046 | { |
199 | KeyOz | 1047 | lb_Status->setText(tr("Lese FlightCtrl-Settings aus.")); |
167 | KeyOz | 1048 | TX_Data[0] = f_Settings->sb_Set->value(); |
158 | KeyOz | 1049 | TX_Data[1] = 0; |
159 | KeyOz | 1050 | send_Data('q', ADDRESS_FC, TX_Data, 1); |
158 | KeyOz | 1051 | } |
1052 | |||
199 | KeyOz | 1053 | void MKTool::slot_SetFCSettings() // DONE 0.71g |
158 | KeyOz | 1054 | { |
199 | KeyOz | 1055 | char *TX_Data2 = f_Settings->GetFCSettings(); |
158 | KeyOz | 1056 | |
199 | KeyOz | 1057 | lb_Status->setText(tr("Schreibe FlightCtrl-Settings.")); |
167 | KeyOz | 1058 | |
1059 | send_Data('s', ADDRESS_FC, TX_Data2, MaxParameter + 2, false); |
||
158 | KeyOz | 1060 | } |
1061 | |||
159 | KeyOz | 1062 | |
167 | KeyOz | 1063 | // Save GUI-Preferences |
1064 | /////////////////////// |
||
1065 | void MKTool::set_Preferences() |
||
158 | KeyOz | 1066 | { |
163 | KeyOz | 1067 | Settings->GUI.TabViews.setBit(0, ac_View0->isChecked()); |
1068 | Settings->GUI.TabViews.setBit(1, ac_View1->isChecked()); |
||
1069 | Settings->GUI.TabViews.setBit(2, ac_View2->isChecked()); |
||
1070 | Settings->GUI.TabViews.setBit(3, ac_View3->isChecked()); |
||
1071 | Settings->GUI.TabViews.setBit(4, ac_View4->isChecked()); |
||
1072 | Settings->GUI.TabViews.setBit(5, ac_View5->isChecked()); |
||
227 | KeyOz | 1073 | Settings->GUI.TabViews.setBit(6, ac_View6->isChecked()); |
158 | KeyOz | 1074 | |
227 | KeyOz | 1075 | Settings->GUI.ToolViews.setBit(0, tb_Allgemein->isVisibleTo(this)); |
1076 | Settings->GUI.ToolViews.setBit(1, tb_Werkzeuge->isVisibleTo(this)); |
||
1077 | Settings->GUI.ToolViews.setBit(2, tb_Debug->isVisibleTo(this)); |
||
1078 | Settings->GUI.ToolViews.setBit(3, tb_TTY->isVisibleTo(this)); |
||
1079 | Settings->GUI.ToolViews.setBit(4, tb_Hardware->isVisibleTo(this)); |
||
1080 | |||
162 | KeyOz | 1081 | Settings->GUI.Term_Info = cb_ShowMSG->isChecked(); |
1082 | Settings->GUI.Term_Data = cb_ShowData->isChecked(); |
||
1083 | Settings->GUI.Term_Always = cb_ShowAlways->isChecked(); |
||
166 | KeyOz | 1084 | Settings->GUI.Term_Send = cb_ShowSend->isChecked(); |
167 | KeyOz | 1085 | Settings->GUI.isMax = isMaximized(); |
1086 | Settings->GUI.Size = size(); |
||
1087 | Settings->GUI.Point = pos(); |
||
162 | KeyOz | 1088 | |
163 | KeyOz | 1089 | Settings->TTY.Port = le_Port->text(); |
158 | KeyOz | 1090 | } |
1091 | |||
159 | KeyOz | 1092 | |
158 | KeyOz | 1093 | void MKTool::show_DebugData() |
1094 | { |
||
241 | KeyOz | 1095 | if (logger->is_active()) |
1096 | logger->write(AnalogData); |
||
158 | KeyOz | 1097 | |
1098 | if (ac_StartPlotter->isChecked()) |
||
1099 | { |
||
1100 | aID[NextPlot] = NextPlot; |
||
1101 | |||
1102 | for (int a = 0; a < MaxAnalog; a++) |
||
1103 | { |
||
1104 | aData[a][NextPlot] = AnalogData[a]; |
||
1105 | } |
||
1106 | NextPlot++; |
||
1107 | |||
1108 | if ((tab_Main->currentWidget()->objectName() == QString("Tab_1"))) |
||
1109 | update_Plot(); |
||
1110 | } |
||
1111 | |||
1112 | le_A_0->setText(QString("%1").arg(AnalogData[0])); |
||
1113 | le_A_1->setText(QString("%1").arg(AnalogData[1])); |
||
1114 | le_A_2->setText(QString("%1").arg(AnalogData[2])); |
||
1115 | le_A_3->setText(QString("%1").arg(AnalogData[3])); |
||
1116 | le_A_4->setText(QString("%1").arg(AnalogData[4])); |
||
1117 | le_A_5->setText(QString("%1").arg(AnalogData[5])); |
||
1118 | le_A_6->setText(QString("%1").arg(AnalogData[6])); |
||
1119 | le_A_7->setText(QString("%1").arg(AnalogData[7])); |
||
1120 | le_A_8->setText(QString("%1").arg(AnalogData[8])); |
||
1121 | le_A_9->setText(QString("%1").arg(AnalogData[9])); |
||
1122 | le_A_10->setText(QString("%1").arg(AnalogData[10])); |
||
1123 | le_A_11->setText(QString("%1").arg(AnalogData[11])); |
||
1124 | le_A_12->setText(QString("%1").arg(AnalogData[12])); |
||
1125 | le_A_13->setText(QString("%1").arg(AnalogData[13])); |
||
1126 | le_A_14->setText(QString("%1").arg(AnalogData[14])); |
||
1127 | le_A_15->setText(QString("%1").arg(AnalogData[15])); |
||
1128 | le_A_16->setText(QString("%1").arg(AnalogData[16])); |
||
1129 | le_A_17->setText(QString("%1").arg(AnalogData[17])); |
||
1130 | le_A_18->setText(QString("%1").arg(AnalogData[18])); |
||
1131 | le_A_19->setText(QString("%1").arg(AnalogData[19])); |
||
1132 | le_A_20->setText(QString("%1").arg(AnalogData[20])); |
||
1133 | le_A_21->setText(QString("%1").arg(AnalogData[21])); |
||
1134 | le_A_22->setText(QString("%1").arg(AnalogData[22])); |
||
1135 | le_A_23->setText(QString("%1").arg(AnalogData[23])); |
||
1136 | le_A_24->setText(QString("%1").arg(AnalogData[24])); |
||
1137 | le_A_25->setText(QString("%1").arg(AnalogData[25])); |
||
1138 | le_A_26->setText(QString("%1").arg(AnalogData[26])); |
||
1139 | le_A_27->setText(QString("%1").arg(AnalogData[27])); |
||
1140 | le_A_28->setText(QString("%1").arg(AnalogData[28])); |
||
1141 | le_A_29->setText(QString("%1").arg(AnalogData[29])); |
||
1142 | le_A_30->setText(QString("%1").arg(AnalogData[30])); |
||
1143 | le_A_31->setText(QString("%1").arg(AnalogData[31])); |
||
227 | KeyOz | 1144 | |
1145 | if ((Mode.ID == ADDRESS_FC) && (FCSettings[P_GYRO_ACC_FAKTOR] > 0)) |
||
1146 | { |
||
1147 | bar_UBAT->setValue(AnalogData[9]); |
||
1148 | bar_RX->setValue(AnalogData[10]); |
||
1149 | |||
1150 | Compass->setValue(AnalogData[8]); |
||
1151 | |||
1152 | int Roll = (AnalogData[1] * FCSettings[P_GYRO_ACC_FAKTOR]) / 1024; |
||
1153 | int Nick = (AnalogData[0] * FCSettings[P_GYRO_ACC_FAKTOR]) / 1024; |
||
1154 | |||
1155 | if (Roll > 128) |
||
1156 | Roll = Roll - 255; |
||
1157 | |||
1158 | if (Nick > 128) |
||
1159 | Nick = Nick - 255; |
||
1160 | |||
1161 | Attitude->setAngle(Roll); |
||
1162 | Attitude->setGradient(double(double(Nick) / 100.0)); |
||
1163 | } |
||
158 | KeyOz | 1164 | } |
1165 | |||
159 | KeyOz | 1166 | |
199 | KeyOz | 1167 | void MKTool::new_NaviData(sRxData RX) |
1168 | { |
||
246 | KeyOz | 1169 | Navi.Current.Longitude = ToolBox::Data2Long(RX.Decode, N_CUR_LONGITUDE, true); |
1170 | Navi.Current.Latitude = ToolBox::Data2Long(RX.Decode, N_CUR_LATITUDE, true); |
||
1171 | Navi.Current.Altitude = ToolBox::Data2Long(RX.Decode, N_CUR_ALTITUDE, true); |
||
1172 | Navi.Target.Longitude = ToolBox::Data2Long(RX.Decode, N_TAR_LONGITUDE, true); |
||
1173 | Navi.Target.Latitude = ToolBox::Data2Long(RX.Decode, N_TAR_LATITUDE, true); |
||
1174 | Navi.Target.Altitude = ToolBox::Data2Long(RX.Decode, N_TAR_ALTITUDE, true); |
||
199 | KeyOz | 1175 | |
246 | KeyOz | 1176 | le_CDistance->setText(QString("%1 cm").arg(ToolBox::Data2Int(RX.Decode, N_HOME_DISTANCE))); |
1177 | le_CWPA->setText(QString("%1").arg(RX.Decode[N_WP_INDEX])); |
||
1178 | le_CWPT->setText(QString("%1").arg(RX.Decode[N_WP_NUMBER])); |
||
1179 | le_CSats->setText(QString("%1").arg(RX.Decode[N_SATS_IN_USER])); |
||
227 | KeyOz | 1180 | |
246 | KeyOz | 1181 | qwt_Rate->setValue(double(ToolBox::Data2Int(RX.Decode, N_VARIOMETER, true))); |
227 | KeyOz | 1182 | |
246 | KeyOz | 1183 | le_CTime->setText(QString("%1 sec.").arg(ToolBox::Data2Int(RX.Decode, N_FLYING_TIME))); |
227 | KeyOz | 1184 | |
246 | KeyOz | 1185 | bar_UBAT->setValue(RX.Decode[N_UBAT]); |
227 | KeyOz | 1186 | |
246 | KeyOz | 1187 | double Speed = double((ToolBox::Data2Int(RX.Decode, N_GROUND_SPEED)) / 10.0); |
227 | KeyOz | 1188 | |
1189 | if ((Speed > 4.5) && SpeedMeter->property("END") == 5) |
||
1190 | { |
||
1191 | SpeedMeter->setRange(0.0, 10.0); |
||
1192 | SpeedMeter->setScale(1, 2, 1); |
||
1193 | SpeedMeter->setProperty("END", 10); |
||
1194 | } |
||
1195 | |||
1196 | if ((Speed > 9) && SpeedMeter->property("END") == 10) |
||
1197 | { |
||
1198 | SpeedMeter->setRange(0.0, 20.0); |
||
1199 | SpeedMeter->setScale(1, 2, 2); |
||
1200 | SpeedMeter->setProperty("END", 20); |
||
1201 | } |
||
1202 | |||
1203 | SpeedMeter->setValue(Speed); |
||
1204 | |||
246 | KeyOz | 1205 | Compass->setValue(ToolBox::Data2Int(RX.Decode, N_COMAPSS_HEADING)); //(68) |
227 | KeyOz | 1206 | |
246 | KeyOz | 1207 | bar_RX->setValue(RX.Decode[N_RC_QUALITY]); |
227 | KeyOz | 1208 | |
246 | KeyOz | 1209 | int Nick = RX.Decode[N_ANGLE_NICK]; |
1210 | int Roll = RX.Decode[N_ANGLE_ROLL]; |
||
227 | KeyOz | 1211 | |
1212 | if (Roll > 128) |
||
1213 | Roll = Roll - 255; |
||
1214 | |||
1215 | if (Nick > 128) |
||
1216 | Nick = Nick - 255; |
||
1217 | |||
1218 | Attitude->setAngle(Roll); |
||
234 | KeyOz | 1219 | Attitude->setGradient(double(0.0 - (double(Nick) / 100.0))); |
227 | KeyOz | 1220 | |
199 | KeyOz | 1221 | sNaviString NaviString; |
1222 | |||
1223 | NaviString.Longitude = ToolBox::get_Float(Navi.Current.Longitude,10000000); |
||
1224 | NaviString.Latitude = ToolBox::get_Float(Navi.Current.Latitude,10000000); |
||
1225 | NaviString.Altitude = ToolBox::get_Float(Navi.Current.Altitude,1000); |
||
1226 | |||
1227 | Server->store_NaviString(NaviString); |
||
1228 | |||
227 | KeyOz | 1229 | if ((MyServer->property("Connect")) == true) |
1230 | { |
||
1231 | MyServer->NewPosition(NaviString); |
||
1232 | } |
||
1233 | |||
199 | KeyOz | 1234 | /* |
1235 | qDebug(NaviString.Longitude.toLatin1().data()); |
||
1236 | qDebug(NaviString.Latitude.toLatin1().data()); |
||
1237 | qDebug(NaviString.Altitude.toLatin1().data()); |
||
1238 | */ |
||
1239 | } |
||
1240 | |||
248 | Brean | 1241 | void MKTool::slot_ac_SendWaypoint() |
1242 | { |
||
1243 | if (Navi.Current.Longitude == 0 && |
||
1244 | Navi.Current.Latitude == 0) { |
||
1245 | QMessageBox msgB; |
||
1246 | QString msg; |
||
1247 | msgB.setText("Fehler: Es konnten keine GPS-Daten vom Mikrokopter empfangen werden"); |
||
1248 | msgB.exec(); |
||
1249 | return; |
||
1250 | } |
||
1251 | //erstelle einen Wegpunkt, den die NaviCtrl auswerten kann |
||
1252 | Waypoint_t desired_pos; |
||
1253 | bool ok_lat, ok_lon; |
||
1254 | |||
1255 | //eingegebene Daten holen |
||
1256 | double desired_long, desired_lat; |
||
1257 | desired_long = le_LonValue->text().toDouble(&ok_lon); |
||
1258 | desired_lat = le_LatValue->text().toDouble(&ok_lat); |
||
1259 | if (ok_lon && desired_long < 100) |
||
1260 | desired_long *= 10000000+0.5; |
||
1261 | if (ok_lat && desired_lat < 100) |
||
1262 | desired_lat *= 10000000+0.5; |
||
1263 | |||
1264 | //fülle Wegpunkt-Daten |
||
1265 | desired_pos.Position.Altitude= 0; |
||
1266 | desired_pos.Position.Longitude= int32_t(desired_long); |
||
1267 | desired_pos.Position.Latitude= int32_t(desired_lat); |
||
1268 | desired_pos.Position.Status = NEWDATA; |
||
1269 | desired_pos.Heading = -1; |
||
1270 | desired_pos.ToleranceRadius = 1; |
||
1271 | desired_pos.HoldTime = 60; |
||
1272 | desired_pos.Event_Flag = 0; |
||
1273 | desired_pos.reserve[0] = 0; // reserve |
||
1274 | desired_pos.reserve[1] = 0; // reserve |
||
1275 | desired_pos.reserve[2] = 0; // reserve |
||
1276 | desired_pos.reserve[3] = 0; // reserve |
||
1277 | |||
1278 | //...und sende ihn an die NaviCtrl |
||
1279 | int max_radius = 10000; |
||
1280 | if (ok_lat && ok_lon && |
||
1281 | abs(Navi.Current.Longitude - desired_pos.Position.Longitude) < max_radius && |
||
1282 | abs(Navi.Current.Latitude - desired_pos.Position.Latitude) < max_radius) { |
||
1283 | send_Data('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false); |
||
1284 | } else { |
||
1285 | QMessageBox msgB; |
||
1286 | QString msg; |
||
1287 | msg += "Bitte die Eingabe ueberpruefen!\n"; |
||
1288 | msg += "Die Werte muessen sich in der Naehe der aktuellen Koordinaten befinden\n"; |
||
1289 | msg += "(Lon: "; |
||
1290 | msg += ToolBox::get_Float(Navi.Current.Longitude,10000000); |
||
1291 | msg += ", "; |
||
1292 | msg += "Lat: "; |
||
1293 | msg += ToolBox::get_Float(Navi.Current.Latitude,10000000); |
||
1294 | msg += ")"; |
||
1295 | msgB.setText(msg); |
||
1296 | msgB.exec(); |
||
1297 | } |
||
1298 | } |
||
1299 | |||
158 | KeyOz | 1300 | // Seriel-Port Bereich, Befehle senden und Daten empfangen |
1301 | ////////////////////////////////////////////////////////// |
||
1302 | |||
1303 | // Neues Datenpacket empfangen -> Verarbeiten |
||
159 | KeyOz | 1304 | void MKTool::new_RXData(sRxData RX) // DONE 0.71g |
158 | KeyOz | 1305 | { |
1306 | |||
1307 | if (LastSend.length() > 2) |
||
1308 | { |
||
1309 | } |
||
1310 | |||
162 | KeyOz | 1311 | int HardwareID = RX.Input[1] - 'a'; |
1312 | |||
167 | KeyOz | 1313 | switch(HardwareID) |
158 | KeyOz | 1314 | { |
167 | KeyOz | 1315 | case ADDRESS_FC : |
1316 | switch(RX.Input[2]) |
||
1317 | { |
||
1318 | // Stick-Belegung der Fernsteuerung |
||
1319 | case 'P' : // DONE 0.71g |
||
1320 | if (ToolBox::Decode64(RX)) |
||
158 | KeyOz | 1321 | { |
167 | KeyOz | 1322 | f_Settings->pb_K1->setValue(ToolBox::Data2Int(RX.Decode, 2,true)); |
1323 | f_Settings->pb_K2->setValue(ToolBox::Data2Int(RX.Decode, 4,true)); |
||
1324 | f_Settings->pb_K3->setValue(ToolBox::Data2Int(RX.Decode, 6,true)); |
||
1325 | f_Settings->pb_K4->setValue(ToolBox::Data2Int(RX.Decode, 8,true)); |
||
1326 | f_Settings->pb_K5->setValue(ToolBox::Data2Int(RX.Decode, 10 ,true)); |
||
1327 | f_Settings->pb_K6->setValue(ToolBox::Data2Int(RX.Decode, 12,true)); |
||
1328 | f_Settings->pb_K7->setValue(ToolBox::Data2Int(RX.Decode, 14,true)); |
||
1329 | f_Settings->pb_K8->setValue(ToolBox::Data2Int(RX.Decode, 16,true)); |
||
1330 | } |
||
1331 | break; |
||
1332 | // Settings lesen |
||
1333 | case 'Q' : // DONE 0.71g |
||
1334 | if (ToolBox::Decode64(RX)) |
||
1335 | { |
||
1336 | TickerEvent[0] = false; |
||
1337 | |||
1338 | if (RX.Decode[1] == VERSION_SETTINGS) |
||
1339 | { |
||
1340 | int Settings_ID = RX.Decode[0]; |
||
1341 | for (int a = 0; a < MaxParameter; a++) |
||
1342 | { |
||
199 | KeyOz | 1343 | FCSettings[a] = RX.Decode[a + 2]; |
167 | KeyOz | 1344 | } |
1345 | //show_ParameterSet(Settings_ID); |
||
199 | KeyOz | 1346 | f_Settings->show_FCSettings(Settings_ID, FCSettings); |
1347 | f_Settings->pb_Read->setEnabled(true); |
||
1348 | f_Settings->pb_Write->setEnabled(true); |
||
167 | KeyOz | 1349 | } |
1350 | else |
||
1351 | { |
||
1352 | f_Settings->pb_Read->setDisabled(true); |
||
1353 | f_Settings->pb_Write->setDisabled(true); |
||
1354 | |||
1355 | QMessageBox::warning(this, QA_NAME, |
||
1356 | "Versionen inkompatibel. \nParameterbearbeitung nicht moeglich.", QMessageBox::Ok); |
||
1357 | } |
||
1358 | } |
||
1359 | break; |
||
1360 | // Settings geschrieben |
||
1361 | case 'S' : // DONE 0.71g |
||
1362 | TickerEvent[0] = false; |
||
1363 | break; |
||
1364 | } |
||
1365 | |||
1366 | case ADDRESS_NC : |
||
1367 | switch(RX.Input[2]) |
||
1368 | { |
||
1369 | // Navigationsdaten |
||
1370 | case 'O' : // NOT DONE 0.12h |
||
1371 | if (ToolBox::Decode64(RX)) |
||
1372 | { |
||
199 | KeyOz | 1373 | new_NaviData(RX); |
167 | KeyOz | 1374 | } |
1375 | break; |
||
1376 | } |
||
1377 | // case ADDRESS_MK3MAG : |
||
1378 | |||
1379 | default : |
||
1380 | switch(RX.Input[2]) |
||
1381 | { |
||
1382 | // LCD-Anzeige |
||
1383 | case 'L' : // DONE 0.71g |
||
1384 | if (ToolBox::Decode64(RX)) |
||
1385 | { |
||
159 | KeyOz | 1386 | int LCD[150]; |
1387 | memcpy(LCD,RX.Decode, sizeof(RX.Decode)); |
||
1388 | |||
227 | KeyOz | 1389 | f_LCD->show_Data(LCD); |
1390 | |||
159 | KeyOz | 1391 | LCD_Page = RX.Decode[0]; |
1392 | LCD_MAX_Page = RX.Decode[1]; |
||
1393 | |||
1394 | TickerEvent[0] = false; |
||
158 | KeyOz | 1395 | } |
1396 | break; |
||
167 | KeyOz | 1397 | // Analoglabels |
1398 | case 'A' : // DONE 0.71g |
||
1399 | if (ToolBox::Decode64(RX)) |
||
158 | KeyOz | 1400 | { |
159 | KeyOz | 1401 | int Position = RX.Decode[0]; |
163 | KeyOz | 1402 | if (Position != 31) |
158 | KeyOz | 1403 | { |
162 | KeyOz | 1404 | Settings->Analog1.Label[Position] = ToolBox::Data2QString(RX.Decode,1,17).trimmed(); |
167 | KeyOz | 1405 | if (Settings->Analog1.Label[Position] == "") |
1406 | { |
||
1407 | Settings->Analog1.Label[Position] = "A-" + QString("%1").arg(Position); |
||
1408 | } |
||
158 | KeyOz | 1409 | Position ++; |
1410 | TX_Data[0] = Position; |
||
167 | KeyOz | 1411 | send_Data('a', ADDRESS_ALL, TX_Data, 1, true); |
158 | KeyOz | 1412 | } |
166 | KeyOz | 1413 | if (Position == 31) |
158 | KeyOz | 1414 | { |
1415 | for (int a = 0; a < MaxAnalog; a++) |
||
1416 | { |
||
162 | KeyOz | 1417 | lb_Analog[a]->setText(Settings->Analog1.Label[a]); |
158 | KeyOz | 1418 | } |
163 | KeyOz | 1419 | Settings->Analog1.Version = Mode.Version; |
162 | KeyOz | 1420 | Settings->write_Settings_AnalogLabels(HardwareID); |
158 | KeyOz | 1421 | config_Plot(); |
1422 | } |
||
1423 | } |
||
1424 | break; |
||
167 | KeyOz | 1425 | // Debug-Daten |
1426 | case 'D' : // DONE 0.71g |
||
1427 | if (ToolBox::Decode64(RX)) |
||
158 | KeyOz | 1428 | { |
1429 | for (int i = 0; i < MaxAnalog; i++) |
||
1430 | { |
||
1431 | AnalogData[i] = ToolBox::Data2Int(RX.Decode, (i * 2) + 2); |
||
1432 | } |
||
1433 | show_DebugData(); |
||
1434 | } |
||
1435 | break; |
||
167 | KeyOz | 1436 | // Version |
1437 | case 'V' : // DONE 0.71h |
||
1438 | if (ToolBox::Decode64(RX)) |
||
159 | KeyOz | 1439 | { |
167 | KeyOz | 1440 | TickerEvent[0] = false; |
159 | KeyOz | 1441 | |
167 | KeyOz | 1442 | Mode.ID = HardwareID; |
1443 | Mode.VERSION_MAJOR = RX.Decode[0]; |
||
1444 | Mode.VERSION_MINOR = RX.Decode[1]; |
||
1445 | Mode.VERSION_PATCH = RX.Decode[4]; |
||
1446 | Mode.VERSION_SERIAL_MAJOR = RX.Decode[2]; |
||
1447 | Mode.VERSION_SERIAL_MINOR = RX.Decode[3]; |
||
159 | KeyOz | 1448 | |
167 | KeyOz | 1449 | Mode.Hardware = HardwareType[Mode.ID]; |
1450 | Mode.Version = QString("%1").arg(RX.Decode[0]) + "." + QString("%1").arg(RX.Decode[1]) + QString(RX.Decode[4] + 'a'); |
||
158 | KeyOz | 1451 | |
167 | KeyOz | 1452 | setWindowTitle(QA_NAME + " v" + QA_VERSION + " - " + Mode.Hardware + " " + Mode.Version); |
158 | KeyOz | 1453 | |
167 | KeyOz | 1454 | if (Mode.VERSION_SERIAL_MAJOR != VERSION_SERIAL_MAJOR) |
1455 | { |
||
1456 | AllowSend = false; |
||
1457 | QMessageBox::warning(this, QA_NAME, |
||
1458 | "Serielles Protokoll Inkompatibel. \nBitte neue Programmversion installieren,", QMessageBox::Ok); |
||
1459 | } |
||
159 | KeyOz | 1460 | |
199 | KeyOz | 1461 | if (ac_NoDebug->isChecked()) |
1462 | { |
||
1463 | TX_Data[0] = 0; |
||
1464 | } |
||
1465 | else |
||
1466 | if (ac_FastDebug->isChecked()) |
||
1467 | { |
||
1468 | TX_Data[0] = Settings->Data.Debug_Fast / 10; |
||
1469 | } |
||
1470 | else |
||
1471 | { |
||
1472 | TX_Data[0] = Settings->Data.Debug_Slow / 10; |
||
1473 | } |
||
1474 | |||
1475 | send_Data('d', ADDRESS_ALL, TX_Data, 1, false); |
||
1476 | |||
167 | KeyOz | 1477 | // Wenn MK3MAG dann andauernd Daten neu anfragen. |
1478 | if (Mode.ID == ADDRESS_MK3MAG) |
||
1479 | { |
||
1480 | TickerEvent[3] = true; |
||
199 | KeyOz | 1481 | rb_SelMag->setChecked(true); |
167 | KeyOz | 1482 | } |
158 | KeyOz | 1483 | |
199 | KeyOz | 1484 | // Wenn NaviCtrl dann hier. |
1485 | if (Mode.ID == ADDRESS_NC) |
||
1486 | { |
||
1487 | rb_SelNC->setChecked(true); |
||
158 | KeyOz | 1488 | |
199 | KeyOz | 1489 | if (ac_NoNavi->isChecked()) |
1490 | { |
||
1491 | TX_Data[0] = 0; |
||
1492 | } |
||
1493 | else |
||
1494 | if (ac_FastNavi->isChecked()) |
||
1495 | { |
||
1496 | TX_Data[0] = Settings->Data.Navi_Fast / 10; |
||
1497 | } |
||
1498 | else |
||
1499 | { |
||
1500 | TX_Data[0] = Settings->Data.Navi_Slow / 10; |
||
1501 | } |
||
1502 | |||
1503 | send_Data('o', ADDRESS_NC, TX_Data, 1, false); |
||
1504 | } |
||
1505 | |||
1506 | |||
167 | KeyOz | 1507 | // Wenn FlightCtrl dann Settings abfragen. |
1508 | if (Mode.ID == ADDRESS_FC) |
||
1509 | { |
||
199 | KeyOz | 1510 | rb_SelFC->setChecked(true); |
167 | KeyOz | 1511 | { |
1512 | TX_Data[0] = 0xff; |
||
1513 | TX_Data[1] = 0; |
||
1514 | send_Data('q', ADDRESS_FC, TX_Data, 1); |
||
1515 | } |
||
1516 | } |
||
1517 | // Wenn nicht Lesen und Schreiben der Settings deaktivieren. |
||
1518 | else |
||
1519 | { |
||
1520 | f_Settings->pb_Read->setDisabled(true); |
||
1521 | f_Settings->pb_Write->setDisabled(true); |
||
1522 | } |
||
158 | KeyOz | 1523 | |
167 | KeyOz | 1524 | Settings->read_Settings_Analog(HardwareID); |
1525 | Settings->read_Settings_AnalogLabels(HardwareID); |
||
159 | KeyOz | 1526 | |
167 | KeyOz | 1527 | if (Settings->Analog1.Version != Mode.Version) |
158 | KeyOz | 1528 | { |
167 | KeyOz | 1529 | lb_Status->setText("Analoglabel-Version unterschiedlich. Lese Analoglabels neu aus."); |
1530 | slot_ac_GetLabels(); |
||
158 | KeyOz | 1531 | } |
167 | KeyOz | 1532 | else |
1533 | for (int a = 0; a < MaxAnalog; a++) |
||
1534 | { |
||
1535 | lb_Analog[a]->setText(Settings->Analog1.Label[a]); |
||
1536 | } |
||
1537 | config_Plot(); |
||
158 | KeyOz | 1538 | } |
1539 | break; |
||
167 | KeyOz | 1540 | } |
158 | KeyOz | 1541 | } |
1542 | } |
||
1543 | |||
1544 | // Neue Daten an der Schnittstelle |
||
159 | KeyOz | 1545 | void MKTool::slot_newDataReceived(const QByteArray &dataReceived) // DONE 0.71g |
158 | KeyOz | 1546 | { |
1547 | const char *RXt; |
||
1548 | RXt = dataReceived.data(); |
||
1549 | int a = 0; |
||
1550 | |||
1551 | while (RXt[a] != '\0') |
||
1552 | { |
||
1553 | if (RXt[a] == '\r') |
||
1554 | { |
||
1555 | while ((RxData.String.length() > 1) && (RxData.String.at(1) == '#')) |
||
1556 | { |
||
1557 | RxData.String.remove(0,1); |
||
1558 | } |
||
1559 | |||
1560 | if (ToolBox::check_CRC(RxData.String)) |
||
1561 | { |
||
1562 | RxData.Input = RxData.String.toLatin1().data(); |
||
1563 | new_RXData(RxData); |
||
1564 | |||
162 | KeyOz | 1565 | if ((cb_ShowData->isChecked()) && ((tab_Main->currentWidget()->objectName() == QString("Tab_3")) || (cb_ShowAlways->isChecked()))) |
158 | KeyOz | 1566 | { |
1567 | te_RX->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); |
||
166 | KeyOz | 1568 | // te_RX->insertPlainText(" > " + RxData.String + '\r'); |
1569 | te_RX->insertHtml("<span style=\"color:#00008b;\">" + RxData.String + "<br /></span>"); |
||
158 | KeyOz | 1570 | } |
1571 | } |
||
1572 | else |
||
1573 | { |
||
162 | KeyOz | 1574 | if ((cb_ShowMSG->isChecked()) && ((tab_Main->currentWidget()->objectName() == QString("Tab_3")) || (cb_ShowAlways->isChecked()))) |
158 | KeyOz | 1575 | { |
1576 | te_RX->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); |
||
166 | KeyOz | 1577 | // te_RX->insertPlainText(" > " + RxData.String + '\r'); |
1578 | te_RX->insertHtml("<span style=\"color:#008b00;\">" + RxData.String + "<br /></span>"); |
||
158 | KeyOz | 1579 | } |
1580 | } |
||
1581 | RxData.String = QString(""); |
||
1582 | } |
||
1583 | else |
||
1584 | { |
||
1585 | { |
||
1586 | RxData.String = RxData.String + QString(RXt[a]); |
||
1587 | } |
||
1588 | } |
||
1589 | a++; |
||
1590 | } |
||
1591 | } |
||
1592 | |||
1593 | // Seriellen Port öffnen |
||
1594 | void MKTool::slot_OpenPort() |
||
1595 | { |
||
1596 | if (serialPort->isOpen()) |
||
227 | KeyOz | 1597 | { |
199 | KeyOz | 1598 | TX_Data[0] = Settings->Data.Debug_Off / 10; |
1599 | send_Data('d', ADDRESS_ALL, TX_Data, 1, false); |
||
227 | KeyOz | 1600 | ToolBox::Wait(SLEEP); |
158 | KeyOz | 1601 | |
199 | KeyOz | 1602 | if (Mode.ID == ADDRESS_NC) |
1603 | { |
||
1604 | TX_Data[0] = Settings->Data.Navi_Off / 10; |
||
1605 | send_Data('o', ADDRESS_NC, TX_Data, 1, false); |
||
227 | KeyOz | 1606 | ToolBox::Wait(SLEEP); |
199 | KeyOz | 1607 | } |
1608 | |||
1609 | if (Mode.ID == ADDRESS_NC) |
||
1610 | { |
||
1611 | TX_Data[0] = 0; |
||
1612 | TX_Data[1] = 0; |
||
1613 | TX_Data[2] = 0; |
||
1614 | TX_Data[3] = 0; |
||
1615 | send_Data('t', ADDRESS_FC, TX_Data, 4, false); |
||
227 | KeyOz | 1616 | ToolBox::Wait(SLEEP); |
199 | KeyOz | 1617 | } |
158 | KeyOz | 1618 | serialPort->close(); |
227 | KeyOz | 1619 | // pb_Open->setText("Seriell Verbinden"); |
1620 | ac_ConnectTTY->setText("Seriell Verbinden"); |
||
1621 | // pb_Open->setIcon(ToolBox::Icon(9)); |
||
1622 | // ac_ConnectTTY->setIcon(ToolBox::Icon(9)); |
||
167 | KeyOz | 1623 | |
199 | KeyOz | 1624 | le_Port->setEnabled(true); |
1625 | |||
167 | KeyOz | 1626 | Ticker->stop(); |
158 | KeyOz | 1627 | } |
1628 | else |
||
1629 | { |
||
1630 | serialPort->setPort(le_Port->text()); //Port |
||
1631 | |||
1632 | serialPort->setBaudRate(BAUD57600); //BaudRate |
||
1633 | serialPort->setDataBits(DATA_8); //DataBits |
||
1634 | serialPort->setParity(PAR_NONE); //Parity |
||
1635 | serialPort->setStopBits(STOP_1); //StopBits |
||
1636 | serialPort->setFlowControl(FLOW_OFF); //FlowControl |
||
1637 | |||
1638 | serialPort->setTimeout(0, 10); |
||
1639 | serialPort->enableSending(); |
||
1640 | serialPort->enableReceiving(); |
||
1641 | |||
1642 | serialPort->open(); |
||
1643 | if (serialPort->isOpen()) |
||
1644 | { |
||
199 | KeyOz | 1645 | le_Port->setEnabled(false); |
158 | KeyOz | 1646 | serialPort->receiveData(); |
1647 | |||
159 | KeyOz | 1648 | send_Data('v', ADDRESS_ALL, TX_Data, 0, true); |
1649 | |||
227 | KeyOz | 1650 | // pb_Open->setText("Seriell Trennen"); |
1651 | ac_ConnectTTY->setText("Seriell Trennen"); |
||
1652 | // pb_Open->setIcon(ToolBox::Icon(8)); |
||
1653 | // ac_ConnectTTY->setIcon(ToolBox::Icon(8)); |
||
167 | KeyOz | 1654 | |
1655 | Ticker->start(2000); |
||
158 | KeyOz | 1656 | } |
1657 | } |
||
1658 | } |
||
1659 | |||
1660 | // Daten senden |
||
159 | KeyOz | 1661 | void MKTool::send_Data(char CMD, int Address, char Data[150],unsigned int Length, bool Resend) // DONE 0.71g |
158 | KeyOz | 1662 | { |
159 | KeyOz | 1663 | if (serialPort->isOpen() && AllowSend) |
158 | KeyOz | 1664 | { |
199 | KeyOz | 1665 | QByteArray Temp; |
1666 | QString TX_Data; |
||
158 | KeyOz | 1667 | |
199 | KeyOz | 1668 | if (CMD != '#') |
1669 | { |
||
1670 | // qDebug("Send data.."); |
||
1671 | TX_Data = ToolBox::Encode64(Data, Length); |
||
158 | KeyOz | 1672 | |
199 | KeyOz | 1673 | TX_Data = QString("#") + (QString('a' + Address)) + QString(CMD) + TX_Data; |
1674 | |||
158 | KeyOz | 1675 | // qDebug(TX_Data.toLatin1().data()); |
1676 | |||
199 | KeyOz | 1677 | TX_Data = ToolBox::add_CRC(TX_Data) + '\r'; |
158 | KeyOz | 1678 | |
1679 | // qDebug(TX_Data.toLatin1().data()); |
||
1680 | |||
199 | KeyOz | 1681 | if (Resend) |
1682 | { |
||
1683 | LastSend = TX_Data; |
||
1684 | TickerEvent[0] = true; |
||
1685 | } |
||
1686 | Temp = QByteArray(TX_Data.toUtf8()); |
||
1687 | } |
||
1688 | else |
||
158 | KeyOz | 1689 | { |
199 | KeyOz | 1690 | // qDebug("Send Raw.."); |
1691 | for (unsigned int a = 0; a < Length; a++) |
||
1692 | { |
||
1693 | Temp[a] = Data[a]; |
||
1694 | // qDebug(QString("%1").arg(Temp[a]).toLatin1().data()); |
||
1695 | } |
||
158 | KeyOz | 1696 | } |
1697 | |||
1698 | serialPort->sendData(Temp); |
||
166 | KeyOz | 1699 | |
199 | KeyOz | 1700 | if (cb_ShowSend->isChecked() && (CMD != '#')) |
166 | KeyOz | 1701 | { |
1702 | te_RX->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); |
||
1703 | te_RX->insertHtml("<span style='color:#8b0000;'>" + TX_Data + "<br /></span>"); |
||
1704 | } |
||
158 | KeyOz | 1705 | } |
1706 | } |
||
1707 | |||
1708 | |||
1709 | // Programm beenden |
||
1710 | /////////////////// |
||
162 | KeyOz | 1711 | |
1712 | MKTool::~MKTool() |
||
158 | KeyOz | 1713 | { |
166 | KeyOz | 1714 | // qDebug(" Programm Ende ..!! "); |
158 | KeyOz | 1715 | if (serialPort->isOpen()) |
1716 | { |
||
1717 | serialPort->close(); |
||
1718 | } |
||
1719 | |||
167 | KeyOz | 1720 | set_Preferences(); |
162 | KeyOz | 1721 | Settings->write_Settings(); |
158 | KeyOz | 1722 | |
239 | Brean | 1723 | logger->close(); |
158 | KeyOz | 1724 | } |