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