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