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