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