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