Rev 399 | Rev 441 | 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); |
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 | { |
||
440 | Brean | 200 | //new KopterData object that contains all data from MK |
201 | data = new KopterData(); |
||
202 | |||
396 | Brean | 203 | //new QT-Communication object |
204 | com = new QTCommunication(); |
||
205 | |||
206 | //create handler that handles incomming data |
||
440 | Brean | 207 | handler = new Handler(com, data); |
396 | Brean | 208 | |
158 | KeyOz | 209 | // QTimer-Instanzen |
199 | KeyOz | 210 | Ticker = new QTimer(this); |
158 | KeyOz | 211 | |
306 | KeyOz | 212 | // Verbindungsobject |
396 | Brean | 213 | //o_Connection = new cConnection(); |
250 | KeyOz | 214 | |
396 | Brean | 215 | // Logger |
440 | Brean | 216 | logger = new Logger(Settings, data); |
159 | KeyOz | 217 | |
227 | KeyOz | 218 | // LCD-Dialog |
219 | f_LCD = new dlg_LCD(this); |
||
220 | |||
305 | KeyOz | 221 | // LCD-Dialog |
307 | KeyOz | 222 | f_MotorMixer = new dlg_MotorMixer(this); |
223 | |||
224 | // LCD-Dialog |
||
305 | KeyOz | 225 | f_Map = new dlg_Map(this); |
306 | KeyOz | 226 | f_Map->create_Map(Settings); |
305 | KeyOz | 227 | |
306 | KeyOz | 228 | KML_Server = new cKML_Server(); |
199 | KeyOz | 229 | |
272 | KeyOz | 230 | QMK_Server = new cQMK_Server(); |
231 | QMK_Server->setProperty("Connect", false); |
||
199 | KeyOz | 232 | |
233 | if (Settings->Server.StartServer) |
||
234 | { |
||
235 | ac_StartServer->setChecked(true); |
||
306 | KeyOz | 236 | KML_Server->start_Server(Settings->Server.Port.toInt(), Settings); |
199 | KeyOz | 237 | } |
158 | KeyOz | 238 | } |
239 | |||
240 | void MKTool::init_Connections() |
||
241 | { |
||
250 | KeyOz | 242 | connect(Dec, SIGNAL(clicked()), this, SLOT(slot_Test())); |
199 | KeyOz | 243 | |
306 | KeyOz | 244 | // Waypoints übergeben |
245 | connect(f_Map, SIGNAL(set_Target(sWayPoint)), this , SLOT(slot_MAP_SetTarget(sWayPoint))); |
||
358 | KeyOz | 246 | connect(f_Map, SIGNAL(set_WayPoints(QList<sWayPoint>)), this , SLOT(slot_MAP_SetWayPoints(QList<sWayPoint>))); |
306 | KeyOz | 247 | |
250 | KeyOz | 248 | // Daten Senden / Empfangen |
396 | Brean | 249 | //FIXME: put this in QTCommunication.cpp |
250 | // connect(o_Connection, SIGNAL(newData(sRxData)), this, SLOT(slot_newData(sRxData))); |
||
251 | // connect(o_Connection, SIGNAL(showTerminal(int, QString)), this, SLOT(slot_showTerminal(int, QString))); |
||
158 | KeyOz | 252 | |
199 | KeyOz | 253 | // Serielle Verbundung öffnen / schließen |
254 | connect(ac_ConnectTTY, SIGNAL(triggered()), this, SLOT(slot_OpenPort())); |
||
255 | |||
396 | Brean | 256 | // TCP-Connection for other QMK-Groundstations |
227 | KeyOz | 257 | connect(ac_QMKServer, SIGNAL(triggered()), this, SLOT(slot_QMKS_Connect())); |
258 | |||
167 | KeyOz | 259 | // Buttons Settings lesen / schreiben |
199 | KeyOz | 260 | connect(f_Settings->pb_Read, SIGNAL(clicked()), this, SLOT(slot_GetFCSettings())); |
261 | connect(f_Settings->pb_Write, SIGNAL(clicked()), this, SLOT(slot_SetFCSettings())); |
||
158 | KeyOz | 262 | |
263 | // Actions |
||
264 | connect(ac_Config, SIGNAL(triggered()), this, SLOT(slot_ac_Config())); |
||
159 | KeyOz | 265 | connect(ac_Preferences, SIGNAL(triggered()), this, SLOT(slot_ac_Preferences())); |
158 | KeyOz | 266 | connect(ac_Motortest, SIGNAL(triggered()), this, SLOT(slot_ac_Motortest())); |
307 | KeyOz | 267 | connect(ac_MotorMixer, SIGNAL(triggered()), this, SLOT(slot_ac_MotorMixer())); |
227 | KeyOz | 268 | connect(ac_LCD, SIGNAL(triggered()), this, SLOT(slot_ac_LCD())); |
305 | KeyOz | 269 | connect(ac_Map, SIGNAL(triggered()), this, SLOT(slot_ac_Map())); |
199 | KeyOz | 270 | connect(ac_FastDebug, SIGNAL(triggered()), this, SLOT(slot_ac_FastDebug())); |
271 | connect(ac_NoDebug, SIGNAL(triggered()), this, SLOT(slot_ac_NoDebug())); |
||
272 | connect(ac_FastNavi, SIGNAL(triggered()), this, SLOT(slot_ac_FastNavi())); |
||
273 | connect(ac_NoNavi, SIGNAL(triggered()), this, SLOT(slot_ac_NoNavi())); |
||
158 | KeyOz | 274 | connect(ac_GetLabels, SIGNAL(triggered()), this, SLOT(slot_ac_GetLabels())); |
275 | |||
167 | KeyOz | 276 | // Plotter starten / scrollen |
277 | connect(scroll_plot, SIGNAL(valueChanged(int)), this, SLOT(slot_ScrollPlot(int))); |
||
278 | connect(ac_StartPlotter, SIGNAL(triggered()), this, SLOT(slot_ac_StartPlotter())); |
||
199 | KeyOz | 279 | connect(ac_StartServer, SIGNAL(triggered()), this, SLOT(slot_ac_StartServer())); |
167 | KeyOz | 280 | |
158 | KeyOz | 281 | // Tabs ein & ausblenden |
282 | connect(ac_View0, SIGNAL(triggered()), this, SLOT(slot_ac_View())); |
||
283 | connect(ac_View1, SIGNAL(triggered()), this, SLOT(slot_ac_View())); |
||
284 | connect(ac_View2, SIGNAL(triggered()), this, SLOT(slot_ac_View())); |
||
285 | connect(ac_View3, SIGNAL(triggered()), this, SLOT(slot_ac_View())); |
||
286 | connect(ac_View4, SIGNAL(triggered()), this, SLOT(slot_ac_View())); |
||
287 | connect(ac_View5, SIGNAL(triggered()), this, SLOT(slot_ac_View())); |
||
227 | KeyOz | 288 | connect(ac_View6, SIGNAL(triggered()), this, SLOT(slot_ac_View())); |
158 | KeyOz | 289 | |
199 | KeyOz | 290 | connect(ac_SelNC, SIGNAL(triggered()), this, SLOT(slot_ac_Hardware())); |
291 | connect(ac_SelFC, SIGNAL(triggered()), this, SLOT(slot_ac_Hardware())); |
||
292 | connect(ac_SelMag, SIGNAL(triggered()), this, SLOT(slot_ac_Hardware())); |
||
293 | |||
294 | connect(rb_SelNC, SIGNAL(clicked()), this, SLOT(slot_rb_Hardware())); |
||
295 | connect(rb_SelFC, SIGNAL(clicked()), this, SLOT(slot_rb_Hardware())); |
||
296 | connect(rb_SelMag, SIGNAL(clicked()), this, SLOT(slot_rb_Hardware())); |
||
297 | |||
167 | KeyOz | 298 | // firmeware Updateen / flashen |
199 | KeyOz | 299 | connect(pb_Update, SIGNAL(clicked()), this, SLOT(slot_pb_Update())); |
166 | KeyOz | 300 | connect(pb_HexFile, SIGNAL(clicked()), this, SLOT(slot_pb_HexFile())); |
158 | KeyOz | 301 | |
250 | KeyOz | 302 | // Wegpunkt-Befehl |
358 | KeyOz | 303 | connect(pb_FlyTo, SIGNAL(clicked()), this, SLOT(slot_pb_SendTarget())); |
250 | KeyOz | 304 | |
167 | KeyOz | 305 | // CVS-Record starten / stoppen |
239 | Brean | 306 | connect(ac_RecordCSV, SIGNAL(triggered()), this, SLOT(slot_RecordLog())); |
158 | KeyOz | 307 | |
308 | // Timer-Events |
||
309 | connect(Ticker, SIGNAL(timeout()), SLOT(slot_Ticker())); |
||
310 | |||
167 | KeyOz | 311 | // Seitenwechsel |
199 | KeyOz | 312 | connect(tab_Main, SIGNAL(currentChanged(int)), this, SLOT(slot_TabChanged(int))); |
306 | KeyOz | 313 | // connect(f_Settings->tab_Par, SIGNAL(currentChanged(int)), this, SLOT(slot_TabChanged(int))); |
314 | connect(f_Settings->listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(slot_TabChanged(int))); |
||
158 | KeyOz | 315 | |
167 | KeyOz | 316 | // About QMK & About-QT Dialog einfügen |
317 | connect(ac_About, SIGNAL(triggered()), this, SLOT(slot_ac_About())); |
||
158 | KeyOz | 318 | menu_Help->addAction(trUtf8("Über &Qt"), qApp, SLOT(aboutQt())); |
319 | } |
||
320 | |||
321 | void MKTool::init_Arrays() |
||
322 | { |
||
323 | lb_Analog[0] = lb_A_0; |
||
324 | lb_Analog[1] = lb_A_1; |
||
325 | lb_Analog[2] = lb_A_2; |
||
326 | lb_Analog[3] = lb_A_3; |
||
327 | lb_Analog[4] = lb_A_4; |
||
328 | lb_Analog[5] = lb_A_5; |
||
329 | lb_Analog[6] = lb_A_6; |
||
330 | lb_Analog[7] = lb_A_7; |
||
331 | lb_Analog[8] = lb_A_8; |
||
332 | lb_Analog[9] = lb_A_9; |
||
333 | lb_Analog[10] = lb_A_10; |
||
334 | lb_Analog[11] = lb_A_11; |
||
335 | lb_Analog[12] = lb_A_12; |
||
336 | lb_Analog[13] = lb_A_13; |
||
337 | lb_Analog[14] = lb_A_14; |
||
338 | lb_Analog[15] = lb_A_15; |
||
339 | lb_Analog[16] = lb_A_16; |
||
340 | lb_Analog[17] = lb_A_17; |
||
341 | lb_Analog[18] = lb_A_18; |
||
342 | lb_Analog[19] = lb_A_19; |
||
343 | lb_Analog[20] = lb_A_20; |
||
344 | lb_Analog[21] = lb_A_21; |
||
345 | lb_Analog[22] = lb_A_22; |
||
346 | lb_Analog[23] = lb_A_23; |
||
347 | lb_Analog[24] = lb_A_24; |
||
348 | lb_Analog[25] = lb_A_25; |
||
349 | lb_Analog[26] = lb_A_26; |
||
350 | lb_Analog[27] = lb_A_27; |
||
351 | lb_Analog[28] = lb_A_28; |
||
352 | lb_Analog[29] = lb_A_29; |
||
353 | lb_Analog[30] = lb_A_30; |
||
354 | lb_Analog[31] = lb_A_31; |
||
355 | } |
||
356 | |||
357 | void MKTool::init_Plot() |
||
358 | { |
||
359 | NextPlot = 0; |
||
360 | |||
361 | qwtPlot->setCanvasBackground(QColor(QRgb(0x00000000))); |
||
362 | |||
363 | qwtPlot->insertLegend(new QwtLegend(), QwtPlot::RightLegend); |
||
364 | |||
365 | QwtPlotGrid *Grid = new QwtPlotGrid(); |
||
366 | Grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine)); |
||
367 | |||
368 | Grid->attach(qwtPlot); |
||
369 | |||
166 | KeyOz | 370 | qwtPlot->setAxisScale(QwtPlot::xBottom,0,Settings->Data.Plotter_Count,0); |
158 | KeyOz | 371 | |
372 | for (int a = 0; a < MaxAnalog; a++) |
||
373 | { |
||
162 | KeyOz | 374 | Plot[a] = new QwtPlotCurve(Settings->Analog1.Label[a]); |
375 | Plot[a]->setPen(QPen(QColor(Def_Colors[a]))); |
||
250 | KeyOz | 376 | // Plot[a]->setRenderHint(QwtPlotItem::RenderAntialiased); |
158 | KeyOz | 377 | |
162 | KeyOz | 378 | if (Settings->Analog1.PlotView[a]) |
158 | KeyOz | 379 | Plot[a]->attach(qwtPlot); |
380 | } |
||
381 | qwtPlot->replot(); |
||
382 | } |
||
383 | |||
306 | KeyOz | 384 | void MKTool::slot_set_Settings(cSettings *t_Settings) |
385 | { |
||
386 | Settings = t_Settings; |
||
387 | } |
||
388 | |||
199 | KeyOz | 389 | void MKTool::slot_Test() |
158 | KeyOz | 390 | { |
272 | KeyOz | 391 | sRxData RX; |
392 | |||
391 | Brean | 393 | RX.str = IN->text().toLatin1().data(); |
272 | KeyOz | 394 | |
391 | Brean | 395 | RX.input = (char *)RX.str.c_str(); |
272 | KeyOz | 396 | |
358 | KeyOz | 397 | slot_newData(RX); |
250 | KeyOz | 398 | } |
158 | KeyOz | 399 | |
272 | KeyOz | 400 | // KML-Datei nach Wegpunkt parsen |
401 | // TODO: Richtigen KML-Parser bauen |
||
250 | KeyOz | 402 | void MKTool::parse_TargetKML() |
403 | { |
||
404 | QString Tmp = te_KML->toPlainText().simplified(); |
||
397 | Brean | 405 | QStringList list; |
158 | KeyOz | 406 | |
250 | KeyOz | 407 | if ((Tmp.contains("<kml xmlns=\"http://earth.google.com/kml/2.2\">")) && (Tmp.contains("<coordinates>"))) |
408 | { |
||
397 | Brean | 409 | list = Tmp.split("<coordinates>"); |
410 | list = list[1].split(","); |
||
250 | KeyOz | 411 | |
397 | Brean | 412 | le_TarLong->setText( QString::number( list[0].toDouble() ) ); |
413 | le_TarLat->setText( QString::number( list[1].toDouble() ) ); |
||
414 | //le_TarLong->setText(ToolBox::get_Float((List[0].toDouble() * 10000000), 7)); |
||
415 | //le_TarLat->setText(ToolBox::get_Float((List[1].toDouble() * 10000000), 7)); |
||
250 | KeyOz | 416 | } |
158 | KeyOz | 417 | } |
418 | |||
272 | KeyOz | 419 | // Waypoint zur NC Senden. |
399 | Brean | 420 | //FIXME: put this in cpp/NaviCtrl.cpp? |
358 | KeyOz | 421 | void MKTool::slot_pb_SendTarget() |
250 | KeyOz | 422 | { |
440 | Brean | 423 | sNaviData navi = data->navi; |
424 | if ((navi.Current.Longitude == 0) && (navi.Current.Latitude == 0)) |
||
250 | KeyOz | 425 | { |
426 | QMessageBox msgB; |
||
427 | QString msg; |
||
358 | KeyOz | 428 | msgB.setText(tr("Fehler: Es konnten keine GPS-Daten vom Mikrokopter empfangen werden")); |
250 | KeyOz | 429 | msgB.exec(); |
430 | return; |
||
431 | } |
||
272 | KeyOz | 432 | |
250 | KeyOz | 433 | //erstelle einen Wegpunkt, den die NaviCtrl auswerten kann |
434 | Waypoint_t desired_pos; |
||
435 | bool ok_lat, ok_lon; |
||
436 | |||
437 | //eingegebene Daten holen |
||
438 | double desired_long, desired_lat; |
||
439 | |||
440 | desired_long = le_TarLong->text().toDouble(&ok_lon); |
||
441 | desired_lat = le_TarLat->text().toDouble(&ok_lat); |
||
442 | |||
443 | if (ok_lon && desired_long < 100) |
||
444 | desired_long *= 10000000+0.5; |
||
445 | |||
446 | if (ok_lat && desired_lat < 100) |
||
447 | desired_lat *= 10000000+0.5; |
||
448 | |||
449 | //fülle Wegpunkt-Daten |
||
450 | desired_pos.Position.Altitude = 0; |
||
451 | desired_pos.Position.Longitude = int32_t(desired_long); |
||
452 | desired_pos.Position.Latitude = int32_t(desired_lat); |
||
453 | desired_pos.Position.Status = NEWDATA; |
||
454 | desired_pos.Heading = -1; |
||
334 | KeyOz | 455 | desired_pos.ToleranceRadius = 5; |
358 | KeyOz | 456 | desired_pos.HoldTime = sb_TarTime->value(); |
250 | KeyOz | 457 | desired_pos.Event_Flag = 0; |
458 | desired_pos.reserve[0] = 0; // reserve |
||
459 | desired_pos.reserve[1] = 0; // reserve |
||
460 | desired_pos.reserve[2] = 0; // reserve |
||
461 | desired_pos.reserve[3] = 0; // reserve |
||
462 | |||
463 | //...und sende ihn an die NaviCtrl |
||
464 | int max_radius = 10000; |
||
465 | if (ok_lat && ok_lon && |
||
440 | Brean | 466 | abs((double)(navi.Current.Longitude - desired_pos.Position.Longitude)) < max_radius && |
467 | abs((double)(navi.Current.Latitude - desired_pos.Position.Latitude)) < max_radius) |
||
250 | KeyOz | 468 | { |
399 | Brean | 469 | handler->send_waypoint(desired_pos); |
250 | KeyOz | 470 | } |
471 | else |
||
472 | { |
||
473 | QMessageBox msgB; |
||
474 | QString msg; |
||
358 | KeyOz | 475 | msg += tr("Bitte die Eingabe ueberpruefen!\n"); |
476 | msg += tr("Die Werte muessen sich in der Naehe der aktuellen Koordinaten befinden\n"); |
||
250 | KeyOz | 477 | msg += "(Lon: "; |
440 | Brean | 478 | msg += QString::number(navi.Current.Longitude); |
250 | KeyOz | 479 | msg += ", "; |
480 | msg += "Lat: "; |
||
440 | Brean | 481 | msg += QString::number(navi.Current.Latitude); |
250 | KeyOz | 482 | msg += ")"; |
483 | msgB.setText(msg); |
||
484 | msgB.exec(); |
||
485 | } |
||
486 | } |
||
487 | |||
337 | KeyOz | 488 | // Hardware-Auswahl im Menp |
199 | KeyOz | 489 | void MKTool::slot_ac_Hardware() |
490 | { |
||
491 | QAction *Action = (QAction*)sender(); |
||
158 | KeyOz | 492 | |
199 | KeyOz | 493 | if (Action->isChecked() == false) |
494 | { |
||
495 | Action->setChecked(true); |
||
496 | } |
||
497 | |||
498 | slot_rb_Hardware(); |
||
499 | } |
||
500 | |||
337 | KeyOz | 501 | // Hardware Auswahl und umschalten |
199 | KeyOz | 502 | void MKTool::slot_rb_Hardware() |
503 | { |
||
440 | Brean | 504 | if ((rb_SelNC->isChecked() == false) && (data->mode.ID != ADDRESS_NC)) |
199 | KeyOz | 505 | { |
506 | lb_Status->setText(tr("Schalte um auf NaviCtrl.")); |
||
399 | Brean | 507 | handler->switch_navictrl(); |
508 | //FIXME: remove wait? |
||
509 | ToolBox::wait(SLEEP); |
||
199 | KeyOz | 510 | } |
511 | |||
512 | if (rb_SelFC->isChecked()) |
||
513 | { |
||
514 | lb_Status->setText(tr("Schalte um auf FlightCtrl.")); |
||
399 | Brean | 515 | handler->switch_flightctrl(); |
199 | KeyOz | 516 | } |
517 | else |
||
518 | if (rb_SelMag->isChecked()) |
||
519 | { |
||
520 | lb_Status->setText(tr("Schalte um auf MK3MAG.")); |
||
399 | Brean | 521 | handler->switch_mk3mag(); |
199 | KeyOz | 522 | } |
523 | else |
||
524 | if (rb_SelNC->isChecked()) |
||
525 | { |
||
526 | lb_Status->setText(tr("Schalte um auf NaviCtrl.")); |
||
399 | Brean | 527 | handler->switch_navictrl(); |
199 | KeyOz | 528 | } |
391 | Brean | 529 | ToolBox::wait(SLEEP); |
199 | KeyOz | 530 | |
531 | // qDebug("Select RB Hardware"); |
||
399 | Brean | 532 | handler->get_version(); |
199 | KeyOz | 533 | } |
534 | |||
158 | KeyOz | 535 | // Ticker-Event |
536 | /////////////// |
||
537 | void MKTool::slot_Ticker() |
||
538 | { |
||
440 | Brean | 539 | //FIXME: Put this somewhere in libMK/QTCommunication.cpp |
396 | Brean | 540 | /* |
158 | KeyOz | 541 | if (TickerDiv) |
542 | TickerDiv = false; |
||
543 | else |
||
544 | TickerDiv = true; |
||
396 | Brean | 545 | |
158 | KeyOz | 546 | for (int a = 0; a < MaxTickerEvents; a++) |
547 | { |
||
548 | if (TickerEvent[a] == true) |
||
549 | { |
||
550 | switch(a) |
||
551 | { |
||
552 | case 0 : |
||
553 | { |
||
554 | } |
||
555 | break; |
||
556 | case 1 : |
||
159 | KeyOz | 557 | TX_Data[0] = 0; |
306 | KeyOz | 558 | o_Connection->send_Cmd('p', ADDRESS_FC, TX_Data, 0, false); |
158 | KeyOz | 559 | break; |
159 | KeyOz | 560 | case 2 : |
227 | KeyOz | 561 | if (f_LCD->cb_LCD->isChecked()) |
167 | KeyOz | 562 | { |
227 | KeyOz | 563 | if (!f_LCD->isVisible()) |
564 | { |
||
565 | Ticker->setInterval(2000); |
||
566 | TickerEvent[2] = false; |
||
567 | } |
||
167 | KeyOz | 568 | TX_Data[0] = LCD_Page; |
569 | TX_Data[1] = 0; |
||
306 | KeyOz | 570 | o_Connection->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true); |
167 | KeyOz | 571 | } |
159 | KeyOz | 572 | break; |
167 | KeyOz | 573 | case 3 : |
199 | KeyOz | 574 | if (ac_FastDebug->isChecked()) |
167 | KeyOz | 575 | { |
576 | TX_Data[0] = Settings->Data.Debug_Fast / 10; |
||
306 | KeyOz | 577 | o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
167 | KeyOz | 578 | } |
579 | else |
||
580 | { |
||
581 | TX_Data[0] = Settings->Data.Debug_Slow / 10; |
||
306 | KeyOz | 582 | o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
167 | KeyOz | 583 | } |
584 | break; |
||
337 | KeyOz | 585 | case 4 : |
586 | { |
||
587 | for (int z = 0; z<12; z++) |
||
588 | { |
||
589 | TX_Data[z] = Motor.Speed[z]; |
||
590 | } |
||
591 | o_Connection->send_Cmd('t', ADDRESS_FC, TX_Data, 12, false); |
||
592 | } |
||
593 | |||
158 | KeyOz | 594 | } |
595 | } |
||
596 | } |
||
396 | Brean | 597 | */ |
158 | KeyOz | 598 | } |
599 | |||
337 | KeyOz | 600 | // Zum QMK-Datenserver verbinden |
227 | KeyOz | 601 | void MKTool::slot_QMKS_Connect() |
602 | { |
||
603 | if (ac_QMKServer->isChecked()) |
||
604 | { |
||
605 | lb_Status->setText(tr("Verbinde zum QMK-Datenserver.")); |
||
158 | KeyOz | 606 | |
272 | KeyOz | 607 | QMK_Server->Connect(Settings->Server.QMKS_Host, Settings->Server.QMKS_Port.toInt(), Settings->Server.QMKS_Login, Settings->Server.QMKS_Password); |
227 | KeyOz | 608 | |
272 | KeyOz | 609 | connect(QMK_Server, SIGNAL(sig_Connected()), this, SLOT(slot_QMKS_Connected())); |
610 | connect(QMK_Server, SIGNAL(sig_Disconnected(int)), this, SLOT(slot_QMKS_Disconnected(int))); |
||
227 | KeyOz | 611 | } |
612 | else |
||
613 | { |
||
272 | KeyOz | 614 | if ((QMK_Server->property("Connect")) == true) |
227 | KeyOz | 615 | { |
272 | KeyOz | 616 | disconnect(QMK_Server, SIGNAL(sig_Disconnected(int)), 0, 0); |
227 | KeyOz | 617 | lb_Status->setText(tr("Trenne vom QMK-Datenserver.")); |
618 | |||
272 | KeyOz | 619 | QMK_Server->Disconnect(); |
620 | QMK_Server->setProperty("Connect", false); |
||
358 | KeyOz | 621 | ac_QMKServer->setText(tr("QMK-Server Verbinden")); |
227 | KeyOz | 622 | } |
623 | } |
||
624 | } |
||
625 | |||
337 | KeyOz | 626 | // Verbindung zum QMK-Server hergestellt. |
227 | KeyOz | 627 | void MKTool::slot_QMKS_Connected() |
628 | { |
||
272 | KeyOz | 629 | QMK_Server->setProperty("Connect", true); |
358 | KeyOz | 630 | ac_QMKServer->setText(tr("QMK-Server Trennnen")); |
227 | KeyOz | 631 | lb_Status->setText(tr("Verbunden mit QMK-Datenserver.")); |
632 | } |
||
633 | |||
337 | KeyOz | 634 | // QMK-Serververbindung getrennt |
227 | KeyOz | 635 | void MKTool::slot_QMKS_Disconnected(int Error) |
636 | { |
||
272 | KeyOz | 637 | QMK_Server->setProperty("Connect", false); |
358 | KeyOz | 638 | ac_QMKServer->setText(tr("QMK-Server Verbinden")); |
227 | KeyOz | 639 | ac_QMKServer->setChecked(false); |
640 | |||
272 | KeyOz | 641 | disconnect(QMK_Server, SIGNAL(sig_Disconnected(int)), 0, 0); |
227 | KeyOz | 642 | |
643 | switch (Error) |
||
644 | { |
||
645 | case 1 : |
||
646 | { |
||
647 | lb_Status->setText(tr("Verbindung vom Server beendet.")); |
||
358 | KeyOz | 648 | QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Verbindung wurde vom Server beendet."), QMessageBox::Ok); |
227 | KeyOz | 649 | } |
650 | break; |
||
651 | case 2 : |
||
652 | { |
||
653 | lb_Status->setText(tr("Server nicht gefunden.")); |
||
358 | KeyOz | 654 | QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Kann nicht zum Server verbinden."), QMessageBox::Ok); |
227 | KeyOz | 655 | } |
656 | break; |
||
657 | case 3 : |
||
658 | { |
||
659 | lb_Status->setText(tr("Serververbindung getrennt. Logindaten falsch.")); |
||
358 | KeyOz | 660 | QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Loginname oder Password falsch."), QMessageBox::Ok); |
227 | KeyOz | 661 | } |
662 | break; |
||
663 | default : |
||
664 | { |
||
665 | lb_Status->setText(tr("Getrennt vom QMK-Datenserver.")); |
||
666 | } |
||
667 | break; |
||
668 | } |
||
669 | } |
||
670 | |||
158 | KeyOz | 671 | // Slots der Actions (Menüpunkte, Buttons) |
672 | ////////////////////////////////////////// |
||
673 | void MKTool::slot_ac_Motortest() |
||
674 | { |
||
675 | dlg_Motortest *f_Motortest = new dlg_Motortest(this); |
||
676 | |||
337 | KeyOz | 677 | // connect(f_Motortest, SIGNAL(updateMotor(int, int, int, int)), this, SLOT(slot_Motortest(int, int, int, int))); |
678 | connect(f_Motortest, SIGNAL(updateMotor(sMotor)), this, SLOT(slot_Motortest(sMotor))); |
||
158 | KeyOz | 679 | |
337 | KeyOz | 680 | |
681 | Ticker->setInterval(500); |
||
682 | TickerEvent[4] = true; |
||
683 | |||
158 | KeyOz | 684 | if (f_Motortest->exec()==QDialog::Accepted) |
685 | { |
||
686 | } |
||
687 | |||
688 | disconnect(f_Motortest, 0,0,0); |
||
337 | KeyOz | 689 | |
440 | Brean | 690 | handler->reset_motor(); |
337 | KeyOz | 691 | |
692 | Ticker->setInterval(2000); |
||
693 | TickerEvent[4] = false; |
||
158 | KeyOz | 694 | } |
695 | |||
337 | KeyOz | 696 | void MKTool::slot_Motortest(sMotor p_Motor) |
697 | { |
||
399 | Brean | 698 | handler->motor_test(p_Motor); |
337 | KeyOz | 699 | } |
700 | |||
701 | // Motormixer-Einstellungen anzeigen |
||
307 | KeyOz | 702 | void MKTool::slot_ac_MotorMixer() |
703 | { |
||
396 | Brean | 704 | f_MotorMixer->set_Objects(handler, Settings); |
440 | Brean | 705 | handler->read_motor_mixer(); |
307 | KeyOz | 706 | |
707 | if (f_MotorMixer->exec()==QDialog::Accepted) |
||
708 | { |
||
709 | } |
||
710 | } |
||
711 | |||
337 | KeyOz | 712 | // LCD Anzeigen |
227 | KeyOz | 713 | void MKTool::slot_ac_LCD() |
714 | { |
||
715 | if (!f_LCD->isVisible()) |
||
716 | { |
||
306 | KeyOz | 717 | delete f_LCD; |
227 | KeyOz | 718 | f_LCD = new dlg_LCD(this); |
719 | |||
720 | // LCD auf / ab |
||
721 | connect(f_LCD->pb_LCDup, SIGNAL(clicked()), this, SLOT(slot_LCD_UP())); |
||
722 | connect(f_LCD->pb_LCDdown, SIGNAL(clicked()), this, SLOT(slot_LCD_DOWN())); |
||
440 | Brean | 723 | //FIXME: put this in libMK/Handler.cpp |
227 | KeyOz | 724 | f_LCD->show(); |
399 | Brean | 725 | handler->show_lcd(); |
440 | Brean | 726 | //FIXME: replace ticker with something else??? |
227 | KeyOz | 727 | Ticker->setInterval(500); |
728 | TickerEvent[2] = true; |
||
729 | } |
||
730 | } |
||
731 | |||
337 | KeyOz | 732 | // Map-Fenster anzeigen |
305 | KeyOz | 733 | void MKTool::slot_ac_Map() |
734 | { |
||
735 | if (!f_Map->isVisible()) |
||
736 | { |
||
737 | f_Map->show(); |
||
738 | } |
||
739 | } |
||
740 | |||
358 | KeyOz | 741 | void MKTool::slot_MAP_SetWayPoints(QList<sWayPoint> l_WayPoints) |
742 | { |
||
440 | Brean | 743 | //FIXME: Put this in libMK/Handler.cpp or libMK/NaviCtrl.cpp |
399 | Brean | 744 | |
358 | KeyOz | 745 | double Longitude, Latitude; |
746 | |||
399 | Brean | 747 | // delete waypoint-list |
748 | handler->delete_waypoints(); |
||
391 | Brean | 749 | ToolBox::wait(SLEEP); |
358 | KeyOz | 750 | |
751 | for (int z = 0; z < l_WayPoints.count(); z++) |
||
752 | { |
||
753 | Longitude = l_WayPoints[z].Longitude; |
||
754 | Latitude = l_WayPoints[z].Latitude; |
||
755 | |||
756 | if (Longitude < 100) |
||
757 | Longitude *= 10000000+0.5; |
||
758 | |||
759 | if (Latitude < 100) |
||
760 | Latitude *= 10000000+0.5; |
||
761 | |||
399 | Brean | 762 | Waypoint_t WayPoint; |
358 | KeyOz | 763 | //fülle Wegpunkt-Daten |
764 | WayPoint.Position.Altitude = 0; |
||
765 | WayPoint.Position.Longitude = int32_t(Longitude); |
||
766 | WayPoint.Position.Latitude = int32_t(Latitude); |
||
767 | WayPoint.Position.Status = NEWDATA; |
||
768 | WayPoint.Heading = -1; |
||
769 | WayPoint.ToleranceRadius = 5; |
||
770 | WayPoint.HoldTime = l_WayPoints[z].Time; |
||
771 | WayPoint.Event_Flag = 0; |
||
772 | WayPoint.reserve[0] = 0; // reserve |
||
773 | WayPoint.reserve[1] = 0; // reserve |
||
774 | WayPoint.reserve[2] = 0; // reserve |
||
775 | WayPoint.reserve[3] = 0; // reserve |
||
776 | |||
399 | Brean | 777 | handler->add_waypoint(WayPoint); |
358 | KeyOz | 778 | // ToolBox::Wait(SLEEP); |
779 | } |
||
780 | } |
||
781 | |||
306 | KeyOz | 782 | void MKTool::slot_MAP_SetTarget(sWayPoint Target) |
783 | { |
||
315 | KeyOz | 784 | |
785 | QString s_Lon, s_Lat; |
||
786 | QTextStream t_Lon(&s_Lon); |
||
787 | QTextStream t_Lat(&s_Lat); |
||
788 | |||
789 | t_Lon.setRealNumberPrecision(9); |
||
790 | t_Lat.setRealNumberPrecision(9); |
||
791 | t_Lon << Target.Longitude; |
||
792 | t_Lat << Target.Latitude; |
||
793 | |||
794 | le_TarLong->setText(s_Lon); |
||
795 | le_TarLat->setText(s_Lat); |
||
306 | KeyOz | 796 | sb_TarTime->setValue(Target.Time); |
305 | KeyOz | 797 | |
358 | KeyOz | 798 | slot_pb_SendTarget(); |
306 | KeyOz | 799 | } |
800 | |||
158 | KeyOz | 801 | void MKTool::slot_ac_Config() |
802 | { |
||
162 | KeyOz | 803 | set_Analog Old_Analog1; |
158 | KeyOz | 804 | |
162 | KeyOz | 805 | Old_Analog1 = Settings->Analog1; |
806 | |||
158 | KeyOz | 807 | dlg_Config *f_Config = new dlg_Config(this); |
440 | Brean | 808 | f_Config->set_Settings(Settings, data->mode.ID); |
158 | KeyOz | 809 | |
810 | if (f_Config->exec()==QDialog::Accepted) |
||
811 | { |
||
812 | Settings = f_Config->get_Settings(); |
||
440 | Brean | 813 | Settings->write_Settings_Analog(data->mode.ID); |
158 | KeyOz | 814 | |
163 | KeyOz | 815 | // Plotter neu einrichten |
816 | if (Old_Analog1.PlotView != Settings->Analog1.PlotView) |
||
158 | KeyOz | 817 | { |
163 | KeyOz | 818 | config_Plot(); |
158 | KeyOz | 819 | } |
820 | |||
163 | KeyOz | 821 | // CVS-Datei neu anlegen. |
241 | KeyOz | 822 | if ((logger->is_active()) && (Old_Analog1.LogView != Settings->Analog1.LogView)) |
158 | KeyOz | 823 | { |
239 | Brean | 824 | logger->close(); |
240 | Brean | 825 | logger->start_Log(); |
158 | KeyOz | 826 | } |
827 | |||
828 | } |
||
829 | } |
||
830 | |||
239 | Brean | 831 | //aktualisiere Logging-Status |
241 | KeyOz | 832 | void MKTool::update_Log() |
833 | { |
||
239 | Brean | 834 | if (logger->is_active()) |
835 | { |
||
272 | KeyOz | 836 | |
358 | KeyOz | 837 | ac_RecordCSV->setText(tr("Log Stop")); |
239 | Brean | 838 | lb_Status->setText(tr("Log-Record gestartet.")); |
839 | } |
||
840 | else |
||
841 | { |
||
358 | KeyOz | 842 | ac_RecordCSV->setText(tr("Log Aufzeichnen")); |
239 | Brean | 843 | lb_Status->setText(tr("Log-Record gestopt.")); |
844 | } |
||
845 | } |
||
846 | |||
847 | //starte/stoppe Logging, wenn auf den entsprechenden Button gedrückt wurde |
||
848 | void MKTool::slot_RecordLog() |
||
849 | { |
||
850 | if (!logger->is_active()) |
||
851 | logger->start_Log(); |
||
852 | else |
||
853 | logger->close(); |
||
241 | KeyOz | 854 | |
239 | Brean | 855 | update_Log(); |
856 | } |
||
857 | |||
159 | KeyOz | 858 | void MKTool::slot_ac_Preferences() |
859 | { |
||
860 | dlg_Preferences *f_Preferences = new dlg_Preferences(this); |
||
861 | |||
166 | KeyOz | 862 | Settings->TTY.Port = le_Port->text(); |
163 | KeyOz | 863 | f_Preferences->set_Settings(Settings); |
864 | |||
159 | KeyOz | 865 | if (f_Preferences->exec()==QDialog::Accepted) |
866 | { |
||
163 | KeyOz | 867 | Settings = f_Preferences->get_Settings(); |
868 | Settings->write_Settings(); |
||
166 | KeyOz | 869 | le_Port->setText(Settings->TTY.Port); |
870 | config_Plot(); |
||
159 | KeyOz | 871 | } |
872 | } |
||
873 | |||
158 | KeyOz | 874 | void MKTool::slot_ac_StartPlotter() |
875 | { |
||
876 | if (ac_StartPlotter->isChecked()) |
||
877 | { |
||
199 | KeyOz | 878 | lb_Status->setText(tr("Datenplotter gestartet.")); |
358 | KeyOz | 879 | ac_StartPlotter->setText(tr("Stop Plotter")); |
880 | pb_StartPlotter->setText(tr("Stop Plotter")); |
||
158 | KeyOz | 881 | } |
882 | else |
||
883 | { |
||
199 | KeyOz | 884 | lb_Status->setText(tr("Datenplotter gestopt.")); |
358 | KeyOz | 885 | ac_StartPlotter->setText(tr("Start Plotter")); |
886 | pb_StartPlotter->setText(tr("Start Plotter")); |
||
158 | KeyOz | 887 | } |
888 | } |
||
889 | |||
890 | void MKTool::slot_ac_View() |
||
891 | { |
||
227 | KeyOz | 892 | int Aktive = -1; |
158 | KeyOz | 893 | |
894 | QAction *Action = (QAction*)sender(); |
||
895 | |||
896 | if (Action->objectName() == QString("ac_View0")) |
||
897 | Aktive = 0; |
||
898 | if (Action->objectName() == QString("ac_View1")) |
||
899 | Aktive = 1; |
||
900 | if (Action->objectName() == QString("ac_View2")) |
||
901 | Aktive = 2; |
||
902 | if (Action->objectName() == QString("ac_View3")) |
||
903 | Aktive = 3; |
||
904 | if (Action->objectName() == QString("ac_View4")) |
||
905 | Aktive = 4; |
||
906 | if (Action->objectName() == QString("ac_View5")) |
||
907 | Aktive = 5; |
||
272 | KeyOz | 908 | if (Action->objectName() == QString("ac_View6")) |
909 | Aktive = 6; |
||
158 | KeyOz | 910 | |
911 | QString TabName = QString("Tab_%1").arg(Aktive); |
||
912 | |||
913 | if (!Action->isChecked()) |
||
914 | { |
||
915 | for (int a = 0; a < tab_Main->count(); a++) |
||
916 | { |
||
917 | if (tab_Main->widget(a)->objectName() == TabName) |
||
918 | { |
||
919 | tab_Main->removeTab(a); |
||
920 | } |
||
921 | } |
||
922 | } |
||
923 | else |
||
924 | { |
||
227 | KeyOz | 925 | tab_Main->insertTab(Aktive, TabWidgets[Aktive], Action->icon(), Action->text()); |
158 | KeyOz | 926 | } |
927 | } |
||
928 | |||
199 | KeyOz | 929 | void MKTool::slot_ac_FastNavi() // DONE NC 0.12i |
158 | KeyOz | 930 | { |
199 | KeyOz | 931 | if (!ac_NoNavi->isChecked()) |
158 | KeyOz | 932 | { |
199 | KeyOz | 933 | if (ac_FastNavi->isChecked()) |
166 | KeyOz | 934 | { |
199 | KeyOz | 935 | lb_Status->setText(tr("Fordere schnelle NaviDaten an.")); |
399 | Brean | 936 | handler->set_navictrl_debug(Settings->Data.Navi_Fast / 10); |
199 | KeyOz | 937 | } |
938 | else |
||
939 | { |
||
940 | lb_Status->setText(tr("Fordere langsame NaviDaten an.")); |
||
399 | Brean | 941 | handler->set_navictrl_debug(Settings->Data.Navi_Slow / 10); |
199 | KeyOz | 942 | } |
943 | } |
||
944 | } |
||
945 | |||
946 | void MKTool::slot_ac_NoNavi() // DONE NC 0.12i |
||
947 | { |
||
948 | if (ac_NoNavi->isChecked()) |
||
949 | { |
||
950 | lb_Status->setText(tr("NaviDaten abstellen.")); |
||
399 | Brean | 951 | handler->stop_navictrl_debug(); |
199 | KeyOz | 952 | } |
953 | else |
||
954 | { |
||
955 | if (ac_FastNavi->isChecked()) |
||
956 | { |
||
957 | lb_Status->setText(tr("Fordere schnelle NaviDaten an.")); |
||
399 | Brean | 958 | handler->set_navictrl_debug(Settings->Data.Navi_Fast / 10); |
199 | KeyOz | 959 | } |
960 | else |
||
961 | { |
||
962 | lb_Status->setText(tr("Fordere langsame NaviDaten an.")); |
||
399 | Brean | 963 | handler->set_navictrl_debug(Settings->Data.Navi_Slow / 10); |
199 | KeyOz | 964 | } |
965 | } |
||
966 | } |
||
967 | |||
968 | void MKTool::slot_ac_FastDebug() // DONE 0.71g |
||
969 | { |
||
970 | if (!ac_NoDebug->isChecked()) |
||
971 | { |
||
972 | if (ac_FastDebug->isChecked()) |
||
973 | { |
||
974 | lb_Status->setText(tr("Fordere schnelle DebugDaten an.")); |
||
399 | Brean | 975 | handler->set_all_debug(Settings->Data.Debug_Fast / 10); |
166 | KeyOz | 976 | } |
977 | else |
||
978 | { |
||
199 | KeyOz | 979 | lb_Status->setText(tr("Fordere langsame DebugDaten an.")); |
399 | Brean | 980 | handler->set_all_debug(Settings->Data.Debug_Slow / 10); |
166 | KeyOz | 981 | } |
982 | } |
||
983 | } |
||
984 | |||
199 | KeyOz | 985 | void MKTool::slot_ac_NoDebug() // DONE 0.71g |
166 | KeyOz | 986 | { |
199 | KeyOz | 987 | if (ac_NoDebug->isChecked()) |
166 | KeyOz | 988 | { |
199 | KeyOz | 989 | lb_Status->setText(tr("DebugDaten abstellen.")); |
167 | KeyOz | 990 | TickerEvent[3] = false; |
399 | Brean | 991 | handler->stop_all_debug(); |
166 | KeyOz | 992 | } |
158 | KeyOz | 993 | else |
994 | { |
||
167 | KeyOz | 995 | // Wenn MK3MAG dann andauernd Daten neu anfragen. |
440 | Brean | 996 | //FIXME: TickerEvent in Communication oder so |
997 | /* if (Mode.ID == ADDRESS_MK3MAG) |
||
998 | TickerEvent[3] = true;*/ |
||
167 | KeyOz | 999 | |
199 | KeyOz | 1000 | if (ac_FastDebug->isChecked()) |
166 | KeyOz | 1001 | { |
199 | KeyOz | 1002 | lb_Status->setText(tr("Fordere schnelle DebugDaten an.")); |
399 | Brean | 1003 | handler->set_all_debug(Settings->Data.Debug_Fast / 10); |
166 | KeyOz | 1004 | } |
1005 | else |
||
1006 | { |
||
199 | KeyOz | 1007 | lb_Status->setText(tr("Fordere langsame DebugDaten an.")); |
399 | Brean | 1008 | handler->set_all_debug(Settings->Data.Debug_Slow / 10); |
166 | KeyOz | 1009 | } |
1010 | } |
||
158 | KeyOz | 1011 | } |
1012 | |||
1013 | void MKTool::slot_ac_About() |
||
1014 | { |
||
1015 | QMessageBox::about(this, trUtf8(("Über ")) + QA_NAME, QA_ABOUT); |
||
1016 | } |
||
1017 | |||
159 | KeyOz | 1018 | void MKTool::slot_ac_GetLabels() // DONE 0.71g |
158 | KeyOz | 1019 | { |
199 | KeyOz | 1020 | lb_Status->setText(tr("Analoglabels auslesen.")); |
399 | Brean | 1021 | handler->get_analog(); |
158 | KeyOz | 1022 | } |
1023 | |||
199 | KeyOz | 1024 | void MKTool::slot_ac_StartServer() |
1025 | { |
||
1026 | if (ac_StartServer->isChecked()) |
||
1027 | { |
||
306 | KeyOz | 1028 | lb_Status->setText(tr("KML-Server gestartet.")); |
1029 | KML_Server->start_Server(Settings->Server.Port.toInt(), Settings); |
||
199 | KeyOz | 1030 | } |
1031 | else |
||
1032 | { |
||
306 | KeyOz | 1033 | lb_Status->setText(tr("KML-Server gestopt.")); |
1034 | KML_Server->stop_Server(); |
||
199 | KeyOz | 1035 | } |
1036 | } |
||
159 | KeyOz | 1037 | |
227 | KeyOz | 1038 | |
158 | KeyOz | 1039 | // Daten-Plotter |
1040 | ///////////////// |
||
1041 | void MKTool::update_Plot() |
||
1042 | { |
||
1043 | for (int a = 0; a < MaxAnalog; a++) |
||
1044 | { |
||
1045 | Plot[a]->setData(aID,aData[a],NextPlot - 1); |
||
1046 | } |
||
1047 | |||
166 | KeyOz | 1048 | if ((NextPlot > Settings->Data.Plotter_Count)) |
158 | KeyOz | 1049 | { |
166 | KeyOz | 1050 | scroll_plot->setMaximum(NextPlot - Settings->Data.Plotter_Count); |
158 | KeyOz | 1051 | } |
1052 | |||
166 | KeyOz | 1053 | if ((scroll_plot->value() == NextPlot - (Settings->Data.Plotter_Count + 1))) |
158 | KeyOz | 1054 | { |
166 | KeyOz | 1055 | qwtPlot->setAxisScale(QwtPlot::xBottom,NextPlot - Settings->Data.Plotter_Count,NextPlot,0); |
1056 | scroll_plot->setValue(NextPlot - Settings->Data.Plotter_Count); |
||
158 | KeyOz | 1057 | } |
1058 | |||
1059 | qwtPlot->replot(); |
||
1060 | } |
||
1061 | |||
1062 | void MKTool::config_Plot() |
||
1063 | { |
||
166 | KeyOz | 1064 | // qDebug("Plotter rekonfiguriert..!!"); |
1065 | qwtPlot->setAxisScale(QwtPlot::xBottom,0,Settings->Data.Plotter_Count,0); |
||
1066 | |||
158 | KeyOz | 1067 | for (int a = 0; a < MaxAnalog; a++) |
1068 | { |
||
1069 | Plot[a]->detach(); |
||
162 | KeyOz | 1070 | Plot[a]->setPen(QPen(QColor(Def_Colors[a]))); |
158 | KeyOz | 1071 | |
162 | KeyOz | 1072 | if (Settings->Analog1.PlotView[a]) |
1073 | { |
||
1074 | Plot[a]->setTitle(Settings->Analog1.Label[a]); |
||
158 | KeyOz | 1075 | Plot[a]->attach(qwtPlot); |
162 | KeyOz | 1076 | } |
158 | KeyOz | 1077 | } |
166 | KeyOz | 1078 | qwtPlot->replot(); |
158 | KeyOz | 1079 | } |
1080 | |||
1081 | void MKTool::slot_ScrollPlot(int Pos) |
||
1082 | { |
||
166 | KeyOz | 1083 | qwtPlot->setAxisScale(QwtPlot::xBottom,Pos,Pos + Settings->Data.Plotter_Count,0); |
158 | KeyOz | 1084 | qwtPlot->replot(); |
1085 | } |
||
1086 | |||
1087 | |||
1088 | // Firmeware-Update |
||
1089 | /////////////////// |
||
1090 | void MKTool::slot_pb_Update() |
||
1091 | { |
||
167 | KeyOz | 1092 | QString Device; |
1093 | QString Hardware; |
||
158 | KeyOz | 1094 | |
167 | KeyOz | 1095 | if (rb_FC->isChecked()) |
1096 | { |
||
1097 | Device = "m644"; |
||
1098 | Hardware = "FlightCtrl"; |
||
1099 | } |
||
1100 | else if (rb_MK3MAG->isChecked()) |
||
1101 | { |
||
1102 | Device = "m168"; |
||
1103 | Hardware = "MK3MAG"; |
||
1104 | } |
||
1105 | else if (rb_BL->isChecked()) |
||
1106 | { |
||
1107 | Device = "m8"; |
||
1108 | Hardware = "BL-Ctrl"; |
||
1109 | } |
||
166 | KeyOz | 1110 | |
358 | KeyOz | 1111 | QString Message = trUtf8("Firmeware-Datei \n\n"); |
166 | KeyOz | 1112 | Message = Message + le_HexFile->text() + "\n\n"; |
358 | KeyOz | 1113 | Message = Message + trUtf8("an ") + Hardware + trUtf8(" mit AVRDUDE - Seriel & Bootloader über ") + le_Port->text() + trUtf8(" übertragen?\n"); |
166 | KeyOz | 1114 | |
1115 | if (le_HexFile->text() == "") |
||
162 | KeyOz | 1116 | { |
166 | KeyOz | 1117 | QMessageBox::warning(this, QA_NAME, trUtf8("Bitte Firmeware-Datei wählen."), QMessageBox::Ok); |
162 | KeyOz | 1118 | } |
166 | KeyOz | 1119 | else if (QMessageBox::warning(this, QA_NAME, Message, QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) |
1120 | { |
||
306 | KeyOz | 1121 | QString Programm = Settings->DIR.AVRDUDE; |
162 | KeyOz | 1122 | |
166 | KeyOz | 1123 | QStringList Argumente; |
162 | KeyOz | 1124 | |
166 | KeyOz | 1125 | Update = new QProcess(); |
162 | KeyOz | 1126 | |
396 | Brean | 1127 | //FIXME: put this in QTCommunication.cpp |
1128 | /* if (o_Connection->isOpen()) |
||
166 | KeyOz | 1129 | { |
1130 | slot_OpenPort(); |
||
1131 | } |
||
396 | Brean | 1132 | */ |
166 | KeyOz | 1133 | Argumente << "-P"; |
1134 | Argumente << le_Port->text(); |
||
1135 | Argumente << "-p"; |
||
1136 | Argumente << Device; |
||
1137 | Argumente << "-c"; |
||
1138 | Argumente << "butterfly"; |
||
1139 | Argumente << "-b"; |
||
1140 | Argumente << "57600"; |
||
1141 | Argumente << "-U"; |
||
1142 | Argumente << "flash:w:" + le_HexFile->text(); |
||
1143 | |||
1144 | // 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"; |
||
1145 | |||
1146 | te_Shell->setText(""); // Ausgabefenster säubern |
||
1147 | |||
1148 | connect(Update, SIGNAL(readyReadStandardOutput()), this, SLOT(slot_UpdateShell()) ); |
||
1149 | connect(Update, SIGNAL(readyReadStandardError()), this, SLOT(slot_UpdateShell()) ); |
||
1150 | |||
1151 | Update->start(Programm, Argumente); // Programmaufruf |
||
1152 | } |
||
158 | KeyOz | 1153 | } |
1154 | |||
1155 | void MKTool::slot_UpdateShell() |
||
1156 | { |
||
162 | KeyOz | 1157 | QByteArray Output; |
158 | KeyOz | 1158 | |
166 | KeyOz | 1159 | Output = Update->readAllStandardError(); // Shellausgabe an Variable |
162 | KeyOz | 1160 | te_Shell->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); |
1161 | te_Shell->insertPlainText(QString::fromUtf8(Output)); |
||
158 | KeyOz | 1162 | |
166 | KeyOz | 1163 | Output = Update->readAll(); |
1164 | te_Shell->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); |
||
1165 | te_Shell->insertPlainText(QString::fromUtf8(Output)); |
||
158 | KeyOz | 1166 | } |
1167 | |||
166 | KeyOz | 1168 | void MKTool::slot_pb_HexFile() |
1169 | { |
||
1170 | QString FileName = QFileDialog::getOpenFileName(this,trUtf8(("Firmeware-Datei wählen")),"", |
||
1171 | tr("Intel Hex(*.hex);;Alle Dateien (*)")); |
||
1172 | if (!FileName.isEmpty()) |
||
1173 | { |
||
1174 | le_HexFile->setText(FileName); |
||
1175 | } |
||
1176 | } |
||
158 | KeyOz | 1177 | |
1178 | |||
167 | KeyOz | 1179 | // Wechsel der Tabs erkennen |
159 | KeyOz | 1180 | void MKTool::slot_TabChanged(int Tab) // DONE 0.71g |
158 | KeyOz | 1181 | { |
1182 | Tab = Tab; |
||
162 | KeyOz | 1183 | if (tab_Main->count() != 0) |
158 | KeyOz | 1184 | { |
306 | KeyOz | 1185 | if ((tab_Main->currentWidget()->objectName() == QString("Tab_2")) && (f_Settings->listWidget->currentRow() == 1)) |
162 | KeyOz | 1186 | { |
399 | Brean | 1187 | //FIXME: Do we really need the ppm-channels if we change the page? |
1188 | // maybe this is a bug or the description on |
||
1189 | // http://www.mikrokopter.com/ucwiki/en/SerialCommands |
||
1190 | // is WRONG! |
||
1191 | handler->get_ppm_channels(); |
||
159 | KeyOz | 1192 | |
162 | KeyOz | 1193 | Ticker->setInterval(500); |
1194 | TickerEvent[1] = true; |
||
1195 | } |
||
1196 | else |
||
1197 | { |
||
1198 | Ticker->setInterval(2000); |
||
1199 | TickerEvent[1] = false; |
||
1200 | } |
||
159 | KeyOz | 1201 | } |
158 | KeyOz | 1202 | } |
1203 | |||
167 | KeyOz | 1204 | // LCD-Seiten weiterschalten |
159 | KeyOz | 1205 | void MKTool::slot_LCD_UP() // DONE 0.71g |
158 | KeyOz | 1206 | { |
399 | Brean | 1207 | handler->lcd_up(); |
159 | KeyOz | 1208 | } |
1209 | |||
1210 | void MKTool::slot_LCD_DOWN() // DONE 0.71g |
||
1211 | { |
||
399 | Brean | 1212 | handler->lcd_down(); |
159 | KeyOz | 1213 | } |
1214 | |||
167 | KeyOz | 1215 | // Settings aus MK lesen / in MK schreiben |
199 | KeyOz | 1216 | void MKTool::slot_GetFCSettings() // DONE 0.71g |
159 | KeyOz | 1217 | { |
199 | KeyOz | 1218 | lb_Status->setText(tr("Lese FlightCtrl-Settings aus.")); |
399 | Brean | 1219 | handler->get_flightctrl_settings(f_Settings->sb_Set->value()); |
158 | KeyOz | 1220 | } |
1221 | |||
199 | KeyOz | 1222 | void MKTool::slot_SetFCSettings() // DONE 0.71g |
158 | KeyOz | 1223 | { |
399 | Brean | 1224 | handler->set_flightctrl_settings(f_Settings->GetFCSettings()); |
199 | KeyOz | 1225 | lb_Status->setText(tr("Schreibe FlightCtrl-Settings.")); |
158 | KeyOz | 1226 | } |
1227 | |||
159 | KeyOz | 1228 | |
167 | KeyOz | 1229 | // Save GUI-Preferences |
1230 | /////////////////////// |
||
1231 | void MKTool::set_Preferences() |
||
158 | KeyOz | 1232 | { |
163 | KeyOz | 1233 | Settings->GUI.TabViews.setBit(0, ac_View0->isChecked()); |
1234 | Settings->GUI.TabViews.setBit(1, ac_View1->isChecked()); |
||
1235 | Settings->GUI.TabViews.setBit(2, ac_View2->isChecked()); |
||
1236 | Settings->GUI.TabViews.setBit(3, ac_View3->isChecked()); |
||
1237 | Settings->GUI.TabViews.setBit(4, ac_View4->isChecked()); |
||
1238 | Settings->GUI.TabViews.setBit(5, ac_View5->isChecked()); |
||
227 | KeyOz | 1239 | Settings->GUI.TabViews.setBit(6, ac_View6->isChecked()); |
158 | KeyOz | 1240 | |
227 | KeyOz | 1241 | Settings->GUI.ToolViews.setBit(0, tb_Allgemein->isVisibleTo(this)); |
1242 | Settings->GUI.ToolViews.setBit(1, tb_Werkzeuge->isVisibleTo(this)); |
||
1243 | Settings->GUI.ToolViews.setBit(2, tb_Debug->isVisibleTo(this)); |
||
1244 | Settings->GUI.ToolViews.setBit(3, tb_TTY->isVisibleTo(this)); |
||
1245 | Settings->GUI.ToolViews.setBit(4, tb_Hardware->isVisibleTo(this)); |
||
1246 | |||
162 | KeyOz | 1247 | Settings->GUI.Term_Info = cb_ShowMSG->isChecked(); |
1248 | Settings->GUI.Term_Data = cb_ShowData->isChecked(); |
||
1249 | Settings->GUI.Term_Always = cb_ShowAlways->isChecked(); |
||
166 | KeyOz | 1250 | Settings->GUI.Term_Send = cb_ShowSend->isChecked(); |
167 | KeyOz | 1251 | Settings->GUI.isMax = isMaximized(); |
1252 | Settings->GUI.Size = size(); |
||
1253 | Settings->GUI.Point = pos(); |
||
162 | KeyOz | 1254 | |
163 | KeyOz | 1255 | Settings->TTY.Port = le_Port->text(); |
158 | KeyOz | 1256 | } |
1257 | |||
1258 | void MKTool::show_DebugData() |
||
1259 | { |
||
440 | Brean | 1260 | //FIXME: log analogdata in Communication |
1261 | /* if (logger->is_active()) |
||
1262 | logger->write(AnalogData);*/ |
||
158 | KeyOz | 1263 | |
1264 | if (ac_StartPlotter->isChecked()) |
||
1265 | { |
||
1266 | aID[NextPlot] = NextPlot; |
||
440 | Brean | 1267 | //FIXME: get analogData from handler |
1268 | /* |
||
158 | KeyOz | 1269 | for (int a = 0; a < MaxAnalog; a++) |
1270 | { |
||
1271 | aData[a][NextPlot] = AnalogData[a]; |
||
440 | Brean | 1272 | }*/ |
158 | KeyOz | 1273 | NextPlot++; |
1274 | |||
1275 | if ((tab_Main->currentWidget()->objectName() == QString("Tab_1"))) |
||
1276 | update_Plot(); |
||
1277 | } |
||
1278 | |||
440 | Brean | 1279 | //FIXME: get analogdata from handler |
1280 | /* |
||
158 | KeyOz | 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 | } |
||
440 | Brean | 1333 | */ |
158 | KeyOz | 1334 | } |
1335 | |||
199 | KeyOz | 1336 | void MKTool::new_NaviData(sRxData RX) |
1337 | { |
||
306 | KeyOz | 1338 | // qDebug("Navi-Data"); |
440 | Brean | 1339 | sNaviData navi = data->navi; |
391 | Brean | 1340 | switch(RX.decode[N_NC_FLAGS]) |
306 | KeyOz | 1341 | { |
358 | KeyOz | 1342 | case 0x01 : lb_Mode->setText(tr("Free")); break; |
1343 | case 0x02 : lb_Mode->setText(tr("Position Hold")); break; |
||
1344 | case 0x04 : lb_Mode->setText(tr("Coming Home")); break; |
||
1345 | case 0x08 : lb_Mode->setText(tr("Range Limit")); break; |
||
1346 | case 0x10 : lb_Mode->setText(tr("Serial Error")); break; |
||
1347 | case 0x20 : lb_Mode->setText(tr("Target reached")); break; |
||
1348 | case 0x40 : lb_Mode->setText(tr("Manual Control")); break; |
||
306 | KeyOz | 1349 | } |
1350 | |||
440 | Brean | 1351 | navi.Current.Longitude = Parser::dataToLong(RX.decode, N_CUR_LONGITUDE, true); |
1352 | navi.Current.Latitude = Parser::dataToLong(RX.decode, N_CUR_LATITUDE, true); |
||
1353 | navi.Current.Altitude = Parser::dataToLong(RX.decode, N_CUR_ALTITUDE, true); |
||
1354 | navi.Target.Longitude = Parser::dataToLong(RX.decode, N_TAR_LONGITUDE, true); |
||
1355 | navi.Target.Latitude = Parser::dataToLong(RX.decode, N_TAR_LATITUDE, true); |
||
1356 | navi.Target.Altitude = Parser::dataToLong(RX.decode, N_TAR_ALTITUDE, true); |
||
199 | KeyOz | 1357 | |
391 | Brean | 1358 | le_CDistance->setText(QString("%1 cm").arg(Parser::dataToInt(RX.decode, N_HOME_DISTANCE))); |
1359 | le_CWPA->setText(QString("%1").arg(RX.decode[N_WP_INDEX])); |
||
1360 | le_CWPT->setText(QString("%1").arg(RX.decode[N_WP_NUMBER])); |
||
1361 | le_CSats->setText(QString("%1").arg(RX.decode[N_SATS_IN_USER])); |
||
227 | KeyOz | 1362 | |
391 | Brean | 1363 | qwt_Rate->setValue(double(Parser::dataToInt(RX.decode, N_VARIOMETER, true))); |
227 | KeyOz | 1364 | |
391 | Brean | 1365 | le_CTime->setText(QString("%1 sec.").arg(Parser::dataToInt(RX.decode, N_FLYING_TIME))); |
227 | KeyOz | 1366 | |
391 | Brean | 1367 | bar_UBAT->setValue(RX.decode[N_UBAT]); |
227 | KeyOz | 1368 | |
391 | Brean | 1369 | double Speed = double((Parser::dataToLong(RX.decode, N_GROUND_SPEED)) / 10.0); |
227 | KeyOz | 1370 | |
1371 | if ((Speed > 4.5) && SpeedMeter->property("END") == 5) |
||
1372 | { |
||
1373 | SpeedMeter->setRange(0.0, 10.0); |
||
1374 | SpeedMeter->setScale(1, 2, 1); |
||
1375 | SpeedMeter->setProperty("END", 10); |
||
1376 | } |
||
1377 | |||
1378 | if ((Speed > 9) && SpeedMeter->property("END") == 10) |
||
1379 | { |
||
1380 | SpeedMeter->setRange(0.0, 20.0); |
||
1381 | SpeedMeter->setScale(1, 2, 2); |
||
1382 | SpeedMeter->setProperty("END", 20); |
||
1383 | } |
||
1384 | |||
1385 | SpeedMeter->setValue(Speed); |
||
1386 | |||
391 | Brean | 1387 | Compass->setValue(Parser::dataToInt(RX.decode, N_COMAPSS_HEADING)); //(68) |
227 | KeyOz | 1388 | |
391 | Brean | 1389 | bar_RX->setValue(RX.decode[N_RC_QUALITY]); |
227 | KeyOz | 1390 | |
391 | Brean | 1391 | int Nick = RX.decode[N_ANGLE_NICK]; |
1392 | int Roll = RX.decode[N_ANGLE_ROLL]; |
||
227 | KeyOz | 1393 | |
1394 | if (Roll > 128) |
||
1395 | Roll = Roll - 255; |
||
1396 | |||
1397 | if (Nick > 128) |
||
1398 | Nick = Nick - 255; |
||
1399 | |||
1400 | Attitude->setAngle(Roll); |
||
234 | KeyOz | 1401 | Attitude->setGradient(double(0.0 - (double(Nick) / 100.0))); |
227 | KeyOz | 1402 | |
440 | Brean | 1403 | sNaviData naviData; |
1404 | |||
1405 | naviData.Longitude = Parser::getFloat(navi.Current.Longitude,7); |
||
1406 | naviData.Latitude = Parser::getFloat(navi.Current.Latitude,7); |
||
1407 | naviData.Altitude = Parser::getFloat(navi.Current.Altitude,3); |
||
199 | KeyOz | 1408 | |
440 | Brean | 1409 | le_CurLong->setText(QString::number(naviData.Longitude)); |
1410 | le_CurLat->setText(QString::number(naviData.Latitude)); |
||
199 | KeyOz | 1411 | |
440 | Brean | 1412 | KML_Server->store_NaviString(naviData); |
199 | KeyOz | 1413 | |
440 | Brean | 1414 | f_Map->add_Position(naviData.Longitude, naviData.Latitude); |
306 | KeyOz | 1415 | |
272 | KeyOz | 1416 | if ((QMK_Server->property("Connect")) == true) |
227 | KeyOz | 1417 | { |
440 | Brean | 1418 | // qDebug("Send Data to Server..."); |
1419 | QMK_Server->NewPosition(naviData); |
||
227 | KeyOz | 1420 | } |
199 | KeyOz | 1421 | } |
1422 | |||
272 | KeyOz | 1423 | // Kopter-Kommunikations-Bereich, Befehle senden und Daten empfangen |
1424 | //////////////////////////////////////////////////////////////////// |
||
158 | KeyOz | 1425 | |
1426 | // Neues Datenpacket empfangen -> Verarbeiten |
||
250 | KeyOz | 1427 | void MKTool::slot_newData(sRxData RX) // DONE 0.71g |
158 | KeyOz | 1428 | { |
393 | Brean | 1429 | //handler->receiveData(RX) |
162 | KeyOz | 1430 | |
272 | KeyOz | 1431 | // TODO: Roh-Daten senden zum QMK-Server dazu Sendebuffer bauen. |
1432 | if ((QMK_Server->property("Connect")) == true) |
||
1433 | { |
||
1434 | // QMK_Server->send_RawData(RX.String); |
||
1435 | } |
||
1436 | |||
393 | Brean | 1437 | slot_showTerminal(1, QString(RX.str.c_str())); |
158 | KeyOz | 1438 | } |
1439 | |||
250 | KeyOz | 1440 | void MKTool::slot_showTerminal(int Typ, QString Text) |
158 | KeyOz | 1441 | { |
250 | KeyOz | 1442 | switch(Typ) |
158 | KeyOz | 1443 | { |
250 | KeyOz | 1444 | case 1 : |
158 | KeyOz | 1445 | { |
250 | KeyOz | 1446 | if ((cb_ShowData->isChecked()) && ((tab_Main->currentWidget()->objectName() == QString("Tab_3")) || (cb_ShowAlways->isChecked()))) |
158 | KeyOz | 1447 | { |
250 | KeyOz | 1448 | te_RX->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); |
1449 | te_RX->insertHtml("<span style=\"color:#00008b;\">" + Text + "<br /></span>"); |
||
158 | KeyOz | 1450 | } |
250 | KeyOz | 1451 | } |
1452 | break; |
||
1453 | case 2 : |
||
1454 | { |
||
1455 | if ((cb_ShowMSG->isChecked()) && ((tab_Main->currentWidget()->objectName() == QString("Tab_3")) || (cb_ShowAlways->isChecked()))) |
||
158 | KeyOz | 1456 | { |
307 | KeyOz | 1457 | if (Text.length() > 0) |
1458 | { |
||
1459 | te_RX->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); |
||
1460 | te_RX->insertHtml("<span style=\"color:#008b00;\">" + Text + "</span><br />"); |
||
1461 | } |
||
158 | KeyOz | 1462 | } |
1463 | } |
||
250 | KeyOz | 1464 | break; |
1465 | case 3 : |
||
158 | KeyOz | 1466 | { |
250 | KeyOz | 1467 | if (cb_ShowSend->isChecked()) |
158 | KeyOz | 1468 | { |
250 | KeyOz | 1469 | te_RX->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); |
1470 | te_RX->insertHtml("<span style='color:#8b0000;'>" + Text + "<br /></span>"); |
||
158 | KeyOz | 1471 | } |
1472 | } |
||
250 | KeyOz | 1473 | break; |
158 | KeyOz | 1474 | } |
1475 | } |
||
1476 | |||
272 | KeyOz | 1477 | // Verbindung zum Kopter herstellen / Trennen |
158 | KeyOz | 1478 | void MKTool::slot_OpenPort() |
1479 | { |
||
440 | Brean | 1480 | //FIXME: Put this in libMK/QTCommunication.cpp |
396 | Brean | 1481 | /* |
306 | KeyOz | 1482 | if (o_Connection->isOpen()) |
250 | KeyOz | 1483 | { |
199 | KeyOz | 1484 | TX_Data[0] = Settings->Data.Debug_Off / 10; |
306 | KeyOz | 1485 | o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
391 | Brean | 1486 | ToolBox::wait(SLEEP); |
158 | KeyOz | 1487 | |
199 | KeyOz | 1488 | if (Mode.ID == ADDRESS_NC) |
1489 | { |
||
1490 | TX_Data[0] = Settings->Data.Navi_Off / 10; |
||
306 | KeyOz | 1491 | o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
391 | Brean | 1492 | ToolBox::wait(SLEEP); |
199 | KeyOz | 1493 | } |
1494 | |||
272 | KeyOz | 1495 | if (Mode.ID == ADDRESS_FC) |
199 | KeyOz | 1496 | { |
1497 | TX_Data[0] = 0; |
||
1498 | TX_Data[1] = 0; |
||
1499 | TX_Data[2] = 0; |
||
1500 | TX_Data[3] = 0; |
||
306 | KeyOz | 1501 | o_Connection->send_Cmd('t', ADDRESS_FC, TX_Data, 4, false); |
391 | Brean | 1502 | ToolBox::wait(SLEEP); |
199 | KeyOz | 1503 | } |
250 | KeyOz | 1504 | |
306 | KeyOz | 1505 | o_Connection->Close(); |
250 | KeyOz | 1506 | |
358 | KeyOz | 1507 | ac_ConnectTTY->setText(tr("Kopter Verbinden")); |
199 | KeyOz | 1508 | le_Port->setEnabled(true); |
1509 | |||
167 | KeyOz | 1510 | Ticker->stop(); |
158 | KeyOz | 1511 | } |
1512 | else |
||
1513 | { |
||
263 | KeyOz | 1514 | int i_Type; |
1515 | if (le_Port->text().contains(QString("IP:"))) |
||
158 | KeyOz | 1516 | { |
263 | KeyOz | 1517 | i_Type = C_IP; |
1518 | } |
||
1519 | else |
||
1520 | { |
||
1521 | i_Type = C_TTY; |
||
1522 | } |
||
1523 | |||
306 | KeyOz | 1524 | if (o_Connection->Open(i_Type, le_Port->text())) |
263 | KeyOz | 1525 | { |
358 | KeyOz | 1526 | ac_ConnectTTY->setText(tr("Kopter Trennen")); |
199 | KeyOz | 1527 | le_Port->setEnabled(false); |
158 | KeyOz | 1528 | |
306 | KeyOz | 1529 | o_Connection->send_Cmd('v', ADDRESS_ALL, TX_Data, 0, true); |
159 | KeyOz | 1530 | |
167 | KeyOz | 1531 | Ticker->start(2000); |
158 | KeyOz | 1532 | } |
1533 | } |
||
396 | Brean | 1534 | */ |
158 | KeyOz | 1535 | } |
1536 | |||
1537 | // Programm beenden |
||
1538 | /////////////////// |
||
162 | KeyOz | 1539 | |
1540 | MKTool::~MKTool() |
||
158 | KeyOz | 1541 | { |
440 | Brean | 1542 | //FIXME: Put this in libMK/QTCommunication.cpp |
396 | Brean | 1543 | /* |
306 | KeyOz | 1544 | if (o_Connection->isOpen()) |
158 | KeyOz | 1545 | { |
306 | KeyOz | 1546 | o_Connection->Close(); |
158 | KeyOz | 1547 | } |
396 | Brean | 1548 | */ |
167 | KeyOz | 1549 | set_Preferences(); |
162 | KeyOz | 1550 | Settings->write_Settings(); |
158 | KeyOz | 1551 | |
239 | Brean | 1552 | logger->close(); |
158 | KeyOz | 1553 | } |