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