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