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