Subversion Repositories Projects

Rev

Rev 397 | Rev 440 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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