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