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