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