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