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