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