Rev 399 | Rev 442 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 399 | Rev 440 | ||
---|---|---|---|
1 | #include<Handler.h> |
1 | #include<Handler.h> |
2 | 2 | ||
3 | /** |
3 | /** |
4 | * Constructor that gets a communication instance |
4 | * Constructor that gets a communication instance |
5 | */ |
5 | */ |
6 | Handler::Handler(Communication * com) { |
6 | Handler::Handler(Communication * com, KopterData * data) { |
7 | this->com = com; |
7 | this->com = com; |
- | 8 | this->data = data; |
|
8 | } |
9 | } |
9 | 10 | ||
10 | //-------------FlightCtrl commands-------------------- |
11 | //-------------FlightCtrl commands-------------------- |
11 | /** |
12 | /** |
12 | * read settings from FlightCtrl (settings index 0x00-0x05) |
13 | * read settings from FlightCtrl (settings index 0x00-0x05) |
13 | */ |
14 | */ |
14 | void Handler::get_flightctrl_settings(int index) { |
15 | void Handler::get_flightctrl_settings(int index) { |
15 | char tx_data[2] = {index, 0}; |
16 | char tx_data[2] = {index, 0}; |
16 | com->send_cmd('q', ADDRESS_FC, tx_data, 1, true); |
17 | com->send_cmd('q', ADDRESS_FC, tx_data, 1, true); |
17 | } |
18 | } |
18 | 19 | ||
19 | /** |
20 | /** |
20 | * write settings to FlightCtrl |
21 | * write settings to FlightCtrl |
21 | */ |
22 | */ |
22 | void Handler::set_flightctrl_settings(char * tx_data) { |
23 | void Handler::set_flightctrl_settings(char * tx_data) { |
23 | com->send_cmd('s', ADDRESS_FC, tx_data, MaxParameter+2, true); |
24 | com->send_cmd('s', ADDRESS_FC, tx_data, MaxParameter+2, true); |
24 | } |
25 | } |
25 | 26 | ||
26 | /** |
27 | /** |
27 | * test one or more motors |
28 | * test one or more motors |
28 | */ |
29 | */ |
29 | void Handler::motor_test(sMotor motor) { |
30 | void Handler::motor_test(sMotor motor) { |
30 | char tx_data[12]; |
31 | char tx_data[12]; |
31 | for (int z = 0; z<12; z++) |
32 | for (int z = 0; z<12; z++) |
32 | { |
33 | { |
33 | tx_data[z] = motor.Speed[z]; |
34 | tx_data[z] = motor.Speed[z]; |
34 | } |
35 | } |
35 | com->send_cmd('t', ADDRESS_FC, tx_data, 12, false); |
36 | com->send_cmd('t', ADDRESS_FC, tx_data, 12, false); |
36 | } |
37 | } |
- | 38 | ||
- | 39 | void Handler::reset_motor() { |
|
- | 40 | sMotor motor; |
|
- | 41 | for (int z = 0; z<12; z++) |
|
- | 42 | { |
|
- | 43 | motor.Speed[z] = 0; |
|
- | 44 | } |
|
- | 45 | ||
- | 46 | motor_test(motor); |
|
- | 47 | } |
|
37 | 48 | ||
38 | /** |
49 | /** |
39 | * read mixer values from FlightCtrl |
50 | * read mixer values from FlightCtrl |
40 | */ |
51 | */ |
41 | void Handler::read_mixer() { |
52 | void Handler::read_motor_mixer() { |
42 | char tx_data[1] = {0}; |
53 | char tx_data[1] = {0}; |
43 | //com->log("read motor mixer"); |
54 | //com->log("read motor mixer"); |
44 | com->send_cmd('n', ADDRESS_FC, tx_data, 1, true); |
55 | com->send_cmd('n', ADDRESS_FC, tx_data, 1, true); |
45 | } |
56 | } |
46 | 57 | ||
47 | /** |
58 | /** |
48 | * write motor mixer values to FlightCtrl |
59 | * write motor mixer values to FlightCtrl |
49 | */ |
60 | */ |
50 | void Handler::write_mixer(char * tx_data, int length) { |
61 | void Handler::write_motor_mixer(char * tx_data, int length) { |
51 | com->send_cmd('m', ADDRESS_FC, tx_data, length, true); |
62 | com->send_cmd('m', ADDRESS_FC, tx_data, length, true); |
52 | } |
63 | } |
53 | 64 | ||
- | 65 | int Handler::get_motor_config(char * tx_data) { |
|
54 | void Handler::get_motor_config() { |
66 | return -1; |
55 | } |
67 | } |
56 | 68 | ||
57 | //-------------NaviCtrl commands-------------------- |
69 | //-------------NaviCtrl commands-------------------- |
58 | /** |
70 | /** |
59 | * set debug values for NaviCtrl |
71 | * set debug values for NaviCtrl |
60 | */ |
72 | */ |
61 | void Handler::set_navictrl_debug(int speed) { |
73 | void Handler::set_navictrl_debug(int speed) { |
62 | char tx_data[1] = { speed }; |
74 | char tx_data[1] = { speed }; |
63 | com->send_cmd('o', ADDRESS_NC, tx_data, 1, false); |
75 | com->send_cmd('o', ADDRESS_NC, tx_data, 1, false); |
64 | } |
76 | } |
65 | 77 | ||
66 | /** |
78 | /** |
67 | * stop debug for NaviCtrl |
79 | * stop debug for NaviCtrl |
68 | */ |
80 | */ |
69 | void Handler::stop_navictrl_debug() { |
81 | void Handler::stop_navictrl_debug() { |
70 | set_navictrl_debug(0); |
82 | set_navictrl_debug(0); |
71 | } |
83 | } |
72 | 84 | ||
73 | /** |
85 | /** |
74 | * send a waypoint to the NaviCtrl (the copter will fly to the position emidiately) |
86 | * send a waypoint to the NaviCtrl (the copter will fly to the position emidiately) |
75 | */ |
87 | */ |
76 | void Handler::send_waypoint(Waypoint_t desired_pos) { |
88 | void Handler::send_waypoint(Waypoint_t desired_pos) { |
77 | com->send_cmd('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false); |
89 | com->send_cmd('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false); |
78 | } |
90 | } |
79 | 91 | ||
80 | /** |
92 | /** |
81 | * add waypoint to waypoint list |
93 | * add waypoint to waypoint list |
82 | */ |
94 | */ |
83 | void Handler::add_waypoint(Waypoint_t wp) { |
95 | void Handler::add_waypoint(Waypoint_t wp) { |
84 | com->send_cmd('w', ADDRESS_NC, (char *)&wp, sizeof(wp), false); |
96 | com->send_cmd('w', ADDRESS_NC, (char *)&wp, sizeof(wp), false); |
85 | } |
97 | } |
86 | 98 | ||
87 | /** |
99 | /** |
88 | * clear waypoint list on MK |
100 | * clear waypoint list on MK |
89 | */ |
101 | */ |
90 | void Handler::delete_waypoints() { |
102 | void Handler::delete_waypoints() { |
91 | Waypoint_t wp; |
103 | Waypoint_t wp; |
92 | wp.Position.Status = INVALID; |
104 | wp.Position.Status = INVALID; |
93 | send_waypoint(wp); |
105 | send_waypoint(wp); |
94 | } |
106 | } |
95 | //-------------switch between Hardware-------------------- |
107 | //-------------switch between Hardware-------------------- |
96 | void Handler::switch_navictrl() { |
108 | void Handler::switch_navictrl() { |
97 | char tx_data[6] = { 0x1B, 0x1B, 0x55, 0xAA, 0x00, '\r'}; |
109 | char tx_data[6] = { 0x1B, 0x1B, 0x55, 0xAA, 0x00, '\r'}; |
98 | com->send_cmd('#', ADDRESS_NC, tx_data, 6, false); |
110 | com->send_cmd('#', ADDRESS_NC, tx_data, 6, false); |
99 | } |
111 | } |
100 | 112 | ||
101 | void Handler::switch_flightctrl() { |
113 | void Handler::switch_flightctrl() { |
102 | char tx_data[1] = { 0 }; |
114 | char tx_data[1] = { 0 }; |
103 | com->send_cmd('u', ADDRESS_NC, tx_data, 1, false); |
115 | com->send_cmd('u', ADDRESS_NC, tx_data, 1, false); |
104 | } |
116 | } |
105 | 117 | ||
106 | void Handler::switch_mk3mag() { |
118 | void Handler::switch_mk3mag() { |
107 | char tx_data[1] = { 1 }; |
119 | char tx_data[1] = { 1 }; |
108 | com->send_cmd('u', ADDRESS_NC, tx_data, 1, false); |
120 | com->send_cmd('u', ADDRESS_NC, tx_data, 1, false); |
109 | } |
121 | } |
110 | 122 | ||
111 | //-------------commands for MK3MAG----------------- |
123 | //-------------commands for MK3MAG----------------- |
112 | 124 | ||
113 | 125 | ||
114 | //-------------commands for all-------------------- |
126 | //-------------commands for all-------------------- |
115 | 127 | ||
116 | /** |
128 | /** |
117 | * set debug values for all components |
129 | * set debug values for all components |
118 | */ |
130 | */ |
119 | void Handler::set_all_debug(int speed) { |
131 | void Handler::set_all_debug(int speed) { |
120 | char tx_data[1] = { speed }; |
132 | char tx_data[1] = { speed }; |
121 | com->send_cmd('d', ADDRESS_ALL, tx_data, 1, false); |
133 | com->send_cmd('d', ADDRESS_ALL, tx_data, 1, false); |
122 | } |
134 | } |
123 | 135 | ||
124 | /** |
136 | /** |
125 | * stop debug for all components |
137 | * stop debug for all components |
126 | */ |
138 | */ |
127 | void Handler::stop_all_debug() { |
139 | void Handler::stop_all_debug() { |
128 | set_all_debug(0); |
140 | set_all_debug(0); |
129 | } |
141 | } |
130 | 142 | ||
131 | /** |
143 | /** |
132 | * get all analog labels |
144 | * get all analog labels |
133 | */ |
145 | */ |
134 | void Handler::get_analog() { |
146 | void Handler::get_analog() { |
135 | char tx_data[1] = { 0 }; |
147 | char tx_data[1] = { 0 }; |
136 | com->send_cmd('a', ADDRESS_ALL, tx_data, 1, true); |
148 | com->send_cmd('a', ADDRESS_ALL, tx_data, 1, true); |
137 | } |
149 | } |
138 | 150 | ||
139 | /** |
151 | /** |
140 | * get values from LCD / show LCD |
152 | * get values from LCD / show LCD |
141 | */ |
153 | */ |
142 | void Handler::show_lcd() { |
154 | void Handler::show_lcd() { |
143 | char tx_data[1] = {0}; |
155 | char tx_data[1] = {0}; |
144 | com->send_cmd('l', ADDRESS_ALL, tx_data, 1, true); |
156 | com->send_cmd('l', ADDRESS_ALL, tx_data, 1, true); |
145 | } |
157 | } |
146 | 158 | ||
147 | /** |
159 | /** |
148 | * got to next LCD Page |
160 | * got to next LCD Page |
149 | */ |
161 | */ |
150 | void Handler::lcd_up() { |
162 | void Handler::lcd_up() { |
151 | char tx_data[2] = { 0, 0 }; |
163 | char tx_data[2] = { 0, 0 }; |
152 | if (lcd_cur != lcd_max) |
164 | if (data->lcd_cur != data->lcd_max) |
153 | tx_data[0] = lcd_cur+1; |
165 | tx_data[0] = data->lcd_cur+1; |
154 | com->send_cmd('l', ADDRESS_ALL, tx_data, 1, true); |
166 | com->send_cmd('l', ADDRESS_ALL, tx_data, 1, true); |
155 | } |
167 | } |
156 | 168 | ||
157 | /** |
169 | /** |
158 | * got to previous LCD Page |
170 | * got to previous LCD Page |
159 | */ |
171 | */ |
160 | void Handler::lcd_down() { |
172 | void Handler::lcd_down() { |
161 | char tx_data[2] = { 0, 0 }; |
173 | char tx_data[2] = { 0, 0 }; |
162 | if (lcd_cur != 0) |
174 | if (data->lcd_cur != 0) |
163 | tx_data[0] = lcd_cur-1; |
175 | tx_data[0] = data->lcd_cur-1; |
164 | com->send_cmd('l', ADDRESS_ALL, tx_data, 1, true); |
176 | com->send_cmd('l', ADDRESS_ALL, tx_data, 1, true); |
165 | } |
177 | } |
166 | 178 | ||
167 | void Handler::get_version() { |
179 | void Handler::get_version() { |
168 | //TODO: Check if is this correct or do we need data from switch_... |
180 | //TODO: Check if is this correct or do we need data from switch_... |
169 | char tx_data[1] = { 0 }; |
181 | char tx_data[1] = { 0 }; |
170 | com->send_cmd('v', ADDRESS_ALL, tx_data, 0, true); |
182 | com->send_cmd('v', ADDRESS_ALL, tx_data, 0, true); |
171 | } |
183 | } |
172 | 184 | ||
173 | void Handler::get_ppm_channels() { |
185 | void Handler::get_ppm_channels() { |
174 | char tx_data[1] = { 0 }; |
186 | char tx_data[1] = { 0 }; |
175 | com->send_cmd('p', ADDRESS_ALL, tx_data, 0, false); |
187 | com->send_cmd('p', ADDRESS_ALL, tx_data, 0, false); |
176 | } |
188 | } |
177 | 189 | ||
178 | /** |
190 | /** |
179 | * receive data |
191 | * receive data |
180 | */ |
192 | */ |
181 | void Handler::receive_data(sRxData RX) { |
193 | void Handler::receive_data(sRxData RX) { |
182 | //extract hardware ID from received Data |
194 | //extract hardware ID from received Data |
183 | int hardwareID = RX.input[1] - 'a'; |
195 | int hardwareID = RX.input[1] - 'a'; |
184 | switch(hardwareID) |
196 | switch(hardwareID) |
185 | { |
197 | { |
186 | case ADDRESS_FC : |
198 | case ADDRESS_FC : |
187 | switch(RX.input[2]) |
199 | switch(RX.input[2]) |
188 | { |
200 | { |
189 | // Motor-Mixer |
201 | // Motor-Mixer |
190 | case 'N' : |
202 | case 'N' : |
191 | if (Parser::decode64(RX)) |
203 | if (Parser::decode64(RX)) |
192 | { |
204 | { |
193 | com->stop_resend(); |
205 | com->stop_resend(); |
194 | 206 | ||
195 | if (RX.decode[0] == VERSION_MIXER) |
207 | if (RX.decode[0] == VERSION_MIXER) |
196 | { |
208 | { |
197 | //f_MotorMixer->set_MotorConfig(RX); |
209 | //f_MotorMixer->set_MotorConfig(RX); |
198 | } |
210 | } |
199 | } |
211 | } |
200 | break; |
212 | break; |
201 | // Motor-Mixer Schreib-Bestätigung |
213 | // Motor-Mixer Schreib-Bestätigung |
202 | case 'M' : |
214 | case 'M' : |
203 | if (Parser::decode64(RX)) |
215 | if (Parser::decode64(RX)) |
204 | { |
216 | { |
205 | com->stop_resend(); |
217 | com->stop_resend(); |
206 | 218 | ||
207 | if (RX.decode[0] == 1) |
219 | if (RX.decode[0] == 1) |
208 | { |
220 | { |
209 | //lb_Status->setText(tr("MotorMixer-Daten in FC geschrieben.")); |
221 | //lb_Status->setText(tr("MotorMixer-Daten in FC geschrieben.")); |
210 | } |
222 | } |
211 | } |
223 | } |
212 | break; |
224 | break; |
213 | 225 | ||
214 | // Stick-Belegung der Fernsteuerung |
226 | // Stick-Belegung der Fernsteuerung |
215 | case 'P' : // DONE 0.71g |
227 | case 'P' : // DONE 0.71g |
216 | if (Parser::decode64(RX)) |
228 | if (Parser::decode64(RX)) |
217 | { |
229 | { |
218 | /*f_Settings->pb_K1->setValue(Parser::dataToInt(RX.decode, 2,true)); |
230 | /*f_Settings->pb_K1->setValue(Parser::dataToInt(RX.decode, 2,true)); |
219 | f_Settings->pb_K2->setValue(Parser::dataToInt(RX.decode, 4,true)); |
231 | f_Settings->pb_K2->setValue(Parser::dataToInt(RX.decode, 4,true)); |
220 | f_Settings->pb_K3->setValue(Parser::dataToInt(RX.decode, 6,true)); |
232 | f_Settings->pb_K3->setValue(Parser::dataToInt(RX.decode, 6,true)); |
221 | f_Settings->pb_K4->setValue(Parser::dataToInt(RX.decode, 8,true)); |
233 | f_Settings->pb_K4->setValue(Parser::dataToInt(RX.decode, 8,true)); |
222 | f_Settings->pb_K5->setValue(Parser::dataToInt(RX.decode, 10 ,true)); |
234 | f_Settings->pb_K5->setValue(Parser::dataToInt(RX.decode, 10 ,true)); |
223 | f_Settings->pb_K6->setValue(Parser::dataToInt(RX.decode, 12,true)); |
235 | f_Settings->pb_K6->setValue(Parser::dataToInt(RX.decode, 12,true)); |
224 | f_Settings->pb_K7->setValue(Parser::dataToInt(RX.decode, 14,true)); |
236 | f_Settings->pb_K7->setValue(Parser::dataToInt(RX.decode, 14,true)); |
225 | f_Settings->pb_K8->setValue(Parser::dataToInt(RX.decode, 16,true));*/ |
237 | f_Settings->pb_K8->setValue(Parser::dataToInt(RX.decode, 16,true));*/ |
226 | } |
238 | } |
227 | break; |
239 | break; |
228 | // Settings lesen |
240 | // Settings lesen |
229 | case 'Q' : // DONE 0.71g |
241 | case 'Q' : // DONE 0.71g |
230 | if (Parser::decode64(RX)) |
242 | if (Parser::decode64(RX)) |
231 | { |
243 | { |
232 | com->stop_resend(); |
244 | com->stop_resend(); |
233 | 245 | ||
234 | if (RX.decode[1] == VERSION_SETTINGS) |
246 | if (RX.decode[1] == VERSION_SETTINGS) |
235 | { |
247 | { |
236 | int Settings_ID = RX.decode[0]; |
248 | int Settings_ID = RX.decode[0]; |
237 | /*for (int a = 0; a < MaxParameter; a++) |
249 | /*for (int a = 0; a < MaxParameter; a++) |
238 | { |
250 | { |
239 | FCSettings[a] = RX.decode[a + 2]; |
251 | FCSettings[a] = RX.decode[a + 2]; |
240 | } |
252 | } |
241 | f_Settings->show_FCSettings(Settings_ID, FCSettings); |
253 | f_Settings->show_FCSettings(Settings_ID, FCSettings); |
242 | f_Settings->pb_Read->setEnabled(true); |
254 | f_Settings->pb_Read->setEnabled(true); |
243 | f_Settings->pb_Write->setEnabled(true);*/ |
255 | f_Settings->pb_Write->setEnabled(true);*/ |
244 | } |
256 | } |
245 | else |
257 | else |
246 | { |
258 | { |
247 | /*f_Settings->pb_Read->setDisabled(true); |
259 | /*f_Settings->pb_Read->setDisabled(true); |
248 | f_Settings->pb_Write->setDisabled(true); |
260 | f_Settings->pb_Write->setDisabled(true); |
249 | 261 | ||
250 | QString name = QString("Versionen inkompatibel.\n") + |
262 | QString name = QString("Versionen inkompatibel.\n") + |
251 | QString("Version von GroundStation benoetigt: ") + |
263 | QString("Version von GroundStation benoetigt: ") + |
252 | QString(VERSION_SETTINGS) + |
264 | QString(VERSION_SETTINGS) + |
253 | QString("\nVersion auf der FlightCtrl: ") + |
265 | QString("\nVersion auf der FlightCtrl: ") + |
254 | QString(RX.decode[1]) + |
266 | QString(RX.decode[1]) + |
255 | QString("\nParameterbearbeitung nicht moeglich."); |
267 | QString("\nParameterbearbeitung nicht moeglich."); |
256 | QMessageBox::warning(this, QA_NAME, |
268 | QMessageBox::warning(this, QA_NAME, |
257 | name, QMessageBox::Ok);*/ |
269 | name, QMessageBox::Ok);*/ |
258 | } |
270 | } |
259 | } |
271 | } |
260 | break; |
272 | break; |
261 | // Settings written |
273 | // Settings written |
262 | case 'S' : // DONE 0.71g |
274 | case 'S' : // DONE 0.71g |
263 | com->stop_resend(); |
275 | com->stop_resend(); |
264 | //TODO: QMessagebox("settings written successful") ? |
276 | //TODO: QMessagebox("settings written successful") ? |
265 | break; |
277 | break; |
266 | } |
278 | } |
267 | 279 | ||
268 | case ADDRESS_NC : |
280 | case ADDRESS_NC : |
269 | switch(RX.input[2]) |
281 | switch(RX.input[2]) |
270 | { |
282 | { |
271 | // Navigationsdaten |
283 | // Navigationsdaten |
272 | case 'O' : // NOT DONE 0.12h |
284 | case 'O' : // NOT DONE 0.12h |
273 | if (Parser::decode64(RX)) |
285 | if (Parser::decode64(RX)) |
274 | { |
286 | { |
275 | //new_NaviData(RX); |
287 | //new_NaviData(RX); |
276 | } |
288 | } |
277 | break; |
289 | break; |
278 | } |
290 | } |
279 | // case ADDRESS_MK3MAG : |
291 | // case ADDRESS_MK3MAG : |
280 | 292 | ||
281 | default : |
293 | default : |
282 | switch(RX.input[2]) |
294 | switch(RX.input[2]) |
283 | { |
295 | { |
284 | // LCD-Anzeige |
296 | // LCD-Anzeige |
285 | case 'L' : // DONE 0.71g |
297 | case 'L' : // DONE 0.71g |
286 | if (Parser::decode64(RX)) |
298 | if (Parser::decode64(RX)) |
287 | { |
299 | { |
288 | com->stop_resend(); |
300 | com->stop_resend(); |
289 | 301 | ||
290 | /*int LCD[150]; |
302 | /*int LCD[150]; |
291 | memcpy(LCD,RX.decode, sizeof(RX.decode)); |
303 | memcpy(LCD,RX.decode, sizeof(RX.decode)); |
292 | 304 | ||
293 | f_LCD->show_Data(LCD); |
305 | f_LCD->show_Data(LCD); |
294 | 306 | ||
295 | LCD_Page = RX.decode[0]; |
307 | LCD_Page = RX.decode[0]; |
296 | LCD_MAX_Page = RX.decode[1]; |
308 | LCD_MAX_Page = RX.decode[1]; |
297 | */ |
309 | */ |
298 | } |
310 | } |
299 | break; |
311 | break; |
300 | // Analoglabels |
312 | // Analoglabels |
301 | case 'A' : // DONE 0.71g |
313 | case 'A' : // DONE 0.71g |
302 | if (Parser::decode64(RX)) |
314 | if (Parser::decode64(RX)) |
303 | { |
315 | { |
304 | com->stop_resend(); |
316 | com->stop_resend(); |
305 | 317 | ||
306 | int Position = RX.decode[0]; |
318 | int Position = RX.decode[0]; |
307 | if (Position != 31) |
319 | if (Position != 31) |
308 | { |
320 | { |
309 | /* |
321 | /* |
310 | Settings->Analog1.Label[Position] = ToolBox::dataToQString(RX.decode,1,17).trimmed(); |
322 | Settings->Analog1.Label[Position] = ToolBox::dataToQString(RX.decode,1,17).trimmed(); |
311 | if (Settings->Analog1.Label[Position] == "") |
323 | if (Settings->Analog1.Label[Position] == "") |
312 | { |
324 | { |
313 | Settings->Analog1.Label[Position] = "A-" + QString("%1").arg(Position); |
325 | Settings->Analog1.Label[Position] = "A-" + QString("%1").arg(Position); |
314 | } |
326 | } |
315 | Position ++; |
327 | Position ++; |
316 | TX_Data[0] = Position; |
328 | TX_Data[0] = Position; |
317 | o_Connection->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true);*/ |
329 | o_Connection->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true);*/ |
318 | } |
330 | } |
319 | if (Position == 31) |
331 | if (Position == 31) |
320 | { |
332 | { |
321 | /* |
333 | /* |
322 | for (int a = 0; a < MaxAnalog; a++) |
334 | for (int a = 0; a < MaxAnalog; a++) |
323 | { |
335 | { |
324 | lb_Analog[a]->setText(Settings->Analog1.Label[a]); |
336 | lb_Analog[a]->setText(Settings->Analog1.Label[a]); |
325 | } |
337 | } |
326 | Settings->Analog1.Version = QString(Mode.Version); |
338 | Settings->Analog1.Version = QString(Mode.Version); |
327 | Settings->write_Settings_AnalogLabels(HardwareID); |
339 | Settings->write_Settings_AnalogLabels(HardwareID); |
328 | config_Plot();*/ |
340 | config_Plot();*/ |
329 | } |
341 | } |
330 | } |
342 | } |
331 | break; |
343 | break; |
332 | // Debug-Daten |
344 | // Debug-Daten |
333 | case 'D' : // DONE 0.71g |
345 | case 'D' : // DONE 0.71g |
334 | if (Parser::decode64(RX)) |
346 | if (Parser::decode64(RX)) |
335 | { |
347 | { |
336 | for (int i = 0; i < MaxAnalog; i++) |
348 | for (int i = 0; i < MaxAnalog; i++) |
337 | { |
349 | { |
338 | //AnalogData[i] = Parser::dataToInt(RX.decode, (i * 2) + 2); |
350 | //AnalogData[i] = Parser::dataToInt(RX.decode, (i * 2) + 2); |
339 | } |
351 | } |
340 | //show_DebugData(); |
352 | //show_DebugData(); |
341 | } |
353 | } |
342 | break; |
354 | break; |
343 | // Version |
355 | // Version |
344 | case 'V' : // DONE 0.71h |
356 | case 'V' : // DONE 0.71h |
345 | if (Parser::decode64(RX)) |
357 | if (Parser::decode64(RX)) |
346 | { |
358 | { |
347 | com->stop_resend(); |
359 | com->stop_resend(); |
348 | /* |
360 | /* |
349 | Mode.ID = HardwareID; |
361 | Mode.ID = HardwareID; |
350 | Mode.VERSION_MAJOR = RX.decode[0]; |
362 | Mode.VERSION_MAJOR = RX.decode[0]; |
351 | Mode.VERSION_MINOR = RX.decode[1]; |
363 | Mode.VERSION_MINOR = RX.decode[1]; |
352 | Mode.VERSION_PATCH = RX.decode[4]; |
364 | Mode.VERSION_PATCH = RX.decode[4]; |
353 | Mode.VERSION_SERIAL_MAJOR = RX.decode[2]; |
365 | Mode.VERSION_SERIAL_MAJOR = RX.decode[2]; |
354 | Mode.VERSION_SERIAL_MINOR = RX.decode[3]; |
366 | Mode.VERSION_SERIAL_MINOR = RX.decode[3]; |
355 | 367 | ||
356 | Mode.Hardware = HardwareType[Mode.ID]; |
368 | Mode.Hardware = HardwareType[Mode.ID]; |
357 | //TODO: Funktion im Handler get_version() oder sowas |
369 | //TODO: Funktion im Handler get_version() oder sowas |
358 | QString version = QString("%1").arg(RX.decode[0]) + "." + |
370 | QString version = QString("%1").arg(RX.decode[0]) + "." + |
359 | QString("%1").arg(RX.decode[1]) + |
371 | QString("%1").arg(RX.decode[1]) + |
360 | QString(RX.decode[4] + 'a'); |
372 | QString(RX.decode[4] + 'a'); |
361 | Mode.Version = version.toLatin1().data; |
373 | Mode.Version = version.toLatin1().data; |
362 | setWindowTitle(QA_NAME + " v" + QA_VERSION + " - " + |
374 | setWindowTitle(QA_NAME + " v" + QA_VERSION + " - " + |
363 | Mode.Hardware + " " + |
375 | Mode.Hardware + " " + |
364 | Mode.Version); |
376 | Mode.Version); |
365 | 377 | ||
366 | if (Mode.VERSION_SERIAL_MAJOR != VERSION_SERIAL_MAJOR) |
378 | if (Mode.VERSION_SERIAL_MAJOR != VERSION_SERIAL_MAJOR) |
367 | { |
379 | { |
368 | // AllowSend = false; |
380 | // AllowSend = false; |
369 | QMessageBox::warning(this, QA_NAME, |
381 | QMessageBox::warning(this, QA_NAME, |
370 | tr("Serielles Protokoll Inkompatibel. \nBitte neue Programmversion installieren,"), QMessageBox::Ok); |
382 | tr("Serielles Protokoll Inkompatibel. \nBitte neue Programmversion installieren,"), QMessageBox::Ok); |
371 | } |
383 | } |
372 | 384 | ||
373 | if (ac_NoDebug->isChecked()) |
385 | if (ac_NoDebug->isChecked()) |
374 | { |
386 | { |
375 | TX_Data[0] = 0; |
387 | TX_Data[0] = 0; |
376 | } |
388 | } |
377 | else |
389 | else |
378 | if (ac_FastDebug->isChecked()) |
390 | if (ac_FastDebug->isChecked()) |
379 | { |
391 | { |
380 | TX_Data[0] = Settings->Data.Debug_Fast / 10; |
392 | TX_Data[0] = Settings->Data.Debug_Fast / 10; |
381 | } |
393 | } |
382 | else |
394 | else |
383 | { |
395 | { |
384 | TX_Data[0] = Settings->Data.Debug_Slow / 10; |
396 | TX_Data[0] = Settings->Data.Debug_Slow / 10; |
385 | } |
397 | } |
386 | 398 | ||
387 | o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
399 | o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
388 | 400 | ||
389 | // Wenn MK3MAG dann andauernd Daten neu anfragen. |
401 | // Wenn MK3MAG dann andauernd Daten neu anfragen. |
390 | if (Mode.ID == ADDRESS_MK3MAG) |
402 | if (Mode.ID == ADDRESS_MK3MAG) |
391 | { |
403 | { |
392 | TickerEvent[3] = true; |
404 | TickerEvent[3] = true; |
393 | rb_SelMag->setChecked(true); |
405 | rb_SelMag->setChecked(true); |
394 | } |
406 | } |
395 | 407 | ||
396 | // Wenn NaviCtrl dann hier. |
408 | // Wenn NaviCtrl dann hier. |
397 | if (Mode.ID == ADDRESS_NC) |
409 | if (Mode.ID == ADDRESS_NC) |
398 | { |
410 | { |
399 | rb_SelNC->setChecked(true); |
411 | rb_SelNC->setChecked(true); |
400 | 412 | ||
401 | if (ac_NoNavi->isChecked()) |
413 | if (ac_NoNavi->isChecked()) |
402 | { |
414 | { |
403 | TX_Data[0] = 0; |
415 | TX_Data[0] = 0; |
404 | } |
416 | } |
405 | else |
417 | else |
406 | if (ac_FastNavi->isChecked()) |
418 | if (ac_FastNavi->isChecked()) |
407 | { |
419 | { |
408 | TX_Data[0] = Settings->Data.Navi_Fast / 10; |
420 | TX_Data[0] = Settings->Data.Navi_Fast / 10; |
409 | } |
421 | } |
410 | else |
422 | else |
411 | { |
423 | { |
412 | TX_Data[0] = Settings->Data.Navi_Slow / 10; |
424 | TX_Data[0] = Settings->Data.Navi_Slow / 10; |
413 | } |
425 | } |
414 | 426 | ||
415 | o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
427 | o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
416 | } |
428 | } |
417 | 429 | ||
418 | 430 | ||
419 | // Wenn FlightCtrl dann Settings abfragen. |
431 | // Wenn FlightCtrl dann Settings abfragen. |
420 | if (Mode.ID == ADDRESS_FC) |
432 | if (Mode.ID == ADDRESS_FC) |
421 | { |
433 | { |
422 | rb_SelFC->setChecked(true); |
434 | rb_SelFC->setChecked(true); |
423 | { |
435 | { |
424 | TX_Data[0] = 0xff; |
436 | TX_Data[0] = 0xff; |
425 | TX_Data[1] = 0; |
437 | TX_Data[1] = 0; |
426 | 438 | ||
427 | // DEP: Raus wenn Resend implementiert. |
439 | // DEP: Raus wenn Resend implementiert. |
428 | // ToolBox::Wait(SLEEP); |
440 | // ToolBox::Wait(SLEEP); |
429 | o_Connection->send_Cmd('q', ADDRESS_FC, TX_Data, 1, true); |
441 | o_Connection->send_Cmd('q', ADDRESS_FC, TX_Data, 1, true); |
430 | qDebug("FC - Get Settings"); |
442 | qDebug("FC - Get Settings"); |
431 | } |
443 | } |
432 | } |
444 | } |
433 | // Wenn nicht Lesen und Schreiben der Settings deaktivieren. |
445 | // Wenn nicht Lesen und Schreiben der Settings deaktivieren. |
434 | else |
446 | else |
435 | { |
447 | { |
436 | f_Settings->pb_Read->setDisabled(true); |
448 | f_Settings->pb_Read->setDisabled(true); |
437 | f_Settings->pb_Write->setDisabled(true); |
449 | f_Settings->pb_Write->setDisabled(true); |
438 | } |
450 | } |
439 | 451 | ||
440 | Settings->read_Settings_Analog(HardwareID); |
452 | Settings->read_Settings_Analog(HardwareID); |
441 | Settings->read_Settings_AnalogLabels(HardwareID); |
453 | Settings->read_Settings_AnalogLabels(HardwareID); |
442 | 454 | ||
443 | if (Settings->Analog1.Version != QString(Mode.Version)) |
455 | if (Settings->Analog1.Version != QString(Mode.Version)) |
444 | { |
456 | { |
445 | lb_Status->setText(tr("Analoglabel-Version unterschiedlich. Lese Analoglabels neu aus.")); |
457 | lb_Status->setText(tr("Analoglabel-Version unterschiedlich. Lese Analoglabels neu aus.")); |
446 | slot_ac_GetLabels(); |
458 | slot_ac_GetLabels(); |
447 | } |
459 | } |
448 | else |
460 | else |
449 | for (int a = 0; a < MaxAnalog; a++) |
461 | for (int a = 0; a < MaxAnalog; a++) |
450 | { |
462 | { |
451 | lb_Analog[a]->setText(Settings->Analog1.Label[a]); |
463 | lb_Analog[a]->setText(Settings->Analog1.Label[a]); |
452 | } |
464 | } |
453 | config_Plot();*/ |
465 | config_Plot();*/ |
454 | } |
466 | } |
455 | break; |
467 | break; |
456 | } |
468 | } |
457 | } |
469 | } |
458 | } |
470 | } |