Subversion Repositories Projects

Rev

Rev 449 | Rev 500 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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