Subversion Repositories Projects

Rev

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
/***************************************************************************
1
/***************************************************************************
2
 *   Copyright (C) 2009 by Manuel Schrape                                  *
2
 *   Copyright (C) 2009 by Manuel Schrape                                  *
3
 *   manuel.schrape@gmx.de                                                 *
3
 *   manuel.schrape@gmx.de                                                 *
4
 *                                                                         *
4
 *                                                                         *
5
 *   This program is free software; you can redistribute it and/or modify  *
5
 *   This program is free software; you can redistribute it and/or modify  *
6
 *   it under the terms of the GNU General Public License as published by  *
6
 *   it under the terms of the GNU General Public License as published by  *
7
 *   the Free Software Foundation; either version 2 of the License.        *
7
 *   the Free Software Foundation; either version 2 of the License.        *
8
 *                                                                         *
8
 *                                                                         *
9
 *   This program is distributed in the hope that it will be useful,       *
9
 *   This program is distributed in the hope that it will be useful,       *
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12
 *   GNU General Public License for more details.                          *
12
 *   GNU General Public License for more details.                          *
13
 *                                                                         *
13
 *                                                                         *
14
 *   You should have received a copy of the GNU General Public License     *
14
 *   You should have received a copy of the GNU General Public License     *
15
 *   along with this program; if not, write to the                         *
15
 *   along with this program; if not, write to the                         *
16
 *   Free Software Foundation, Inc.,                                       *
16
 *   Free Software Foundation, Inc.,                                       *
17
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
17
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
18
 ***************************************************************************/
18
 ***************************************************************************/
19
#include "dlg_MotorMixer.h"
19
#include "dlg_MotorMixer.h"
20
 
20
 
21
dlg_MotorMixer::dlg_MotorMixer(QWidget *parent) : QDialog(parent)
21
dlg_MotorMixer::dlg_MotorMixer(QWidget *parent) : QDialog(parent)
22
{
22
{
23
    setupUi(this);
23
    setupUi(this);
24
    connect(pb_READ, SIGNAL(clicked()), this, SLOT(slot_pb_READ()));
24
    connect(pb_READ, SIGNAL(clicked()), this, SLOT(slot_pb_READ()));
25
    connect(pb_LOAD, SIGNAL(clicked()), this, SLOT(slot_pb_LOAD()));
25
    connect(pb_LOAD, SIGNAL(clicked()), this, SLOT(slot_pb_LOAD()));
26
    connect(pb_SAVE, SIGNAL(clicked()), this, SLOT(slot_pb_SAVE()));
26
    connect(pb_SAVE, SIGNAL(clicked()), this, SLOT(slot_pb_SAVE()));
27
    connect(pb_WRITE, SIGNAL(clicked()), this, SLOT(slot_pb_WRITE()));
27
    connect(pb_WRITE, SIGNAL(clicked()), this, SLOT(slot_pb_WRITE()));
28
 
28
 
29
    connect(sb_NICK_1, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
29
    connect(sb_NICK_1, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
30
    connect(sb_NICK_2, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
30
    connect(sb_NICK_2, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
31
    connect(sb_NICK_3, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
31
    connect(sb_NICK_3, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
32
    connect(sb_NICK_4, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
32
    connect(sb_NICK_4, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
33
    connect(sb_NICK_5, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
33
    connect(sb_NICK_5, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
34
    connect(sb_NICK_6, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
34
    connect(sb_NICK_6, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
35
    connect(sb_NICK_7, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
35
    connect(sb_NICK_7, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
36
    connect(sb_NICK_8, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
36
    connect(sb_NICK_8, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
37
    connect(sb_NICK_9, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
37
    connect(sb_NICK_9, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
38
    connect(sb_NICK_10, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
38
    connect(sb_NICK_10, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
39
    connect(sb_NICK_11, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
39
    connect(sb_NICK_11, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
40
    connect(sb_NICK_12, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
40
    connect(sb_NICK_12, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
41
 
41
 
42
    connect(sb_ROLL_1, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
42
    connect(sb_ROLL_1, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
43
    connect(sb_ROLL_2, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
43
    connect(sb_ROLL_2, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
44
    connect(sb_ROLL_3, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
44
    connect(sb_ROLL_3, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
45
    connect(sb_ROLL_4, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
45
    connect(sb_ROLL_4, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
46
    connect(sb_ROLL_5, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
46
    connect(sb_ROLL_5, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
47
    connect(sb_ROLL_6, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
47
    connect(sb_ROLL_6, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
48
    connect(sb_ROLL_7, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
48
    connect(sb_ROLL_7, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
49
    connect(sb_ROLL_8, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
49
    connect(sb_ROLL_8, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
50
    connect(sb_ROLL_9, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
50
    connect(sb_ROLL_9, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
51
    connect(sb_ROLL_10, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
51
    connect(sb_ROLL_10, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
52
    connect(sb_ROLL_11, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
52
    connect(sb_ROLL_11, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
53
    connect(sb_ROLL_12, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
53
    connect(sb_ROLL_12, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
54
 
54
 
55
    connect(sb_GIER_1, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
55
    connect(sb_GIER_1, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
56
    connect(sb_GIER_2, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
56
    connect(sb_GIER_2, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
57
    connect(sb_GIER_3, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
57
    connect(sb_GIER_3, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
58
    connect(sb_GIER_4, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
58
    connect(sb_GIER_4, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
59
    connect(sb_GIER_5, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
59
    connect(sb_GIER_5, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
60
    connect(sb_GIER_6, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
60
    connect(sb_GIER_6, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
61
    connect(sb_GIER_7, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
61
    connect(sb_GIER_7, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
62
    connect(sb_GIER_8, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
62
    connect(sb_GIER_8, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
63
    connect(sb_GIER_9, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
63
    connect(sb_GIER_9, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
64
    connect(sb_GIER_10, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
64
    connect(sb_GIER_10, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
65
    connect(sb_GIER_11, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
65
    connect(sb_GIER_11, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
66
    connect(sb_GIER_12, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
66
    connect(sb_GIER_12, SIGNAL(valueChanged(int)), this, SLOT(slot_CheckValue(int)));
67
 
67
 
68
}
68
}
69
 
69
 
70
// Connection-Object übergeben.
70
// Connection-Object übergeben.
71
void dlg_MotorMixer::set_Objects(Handler *handler, cSettings *t_Settings)
71
void dlg_MotorMixer::set_Objects(Handler *handler, cSettings *t_Settings)
72
{
72
{
73
    this->handler = handler;
73
    this->handler = handler;
74
    o_Settings   = t_Settings;
74
    o_Settings   = t_Settings;
75
}
75
}
76
 
76
 
77
// Motordaten übernehmen.
77
// Motordaten übernehmen.
78
void dlg_MotorMixer::set_MotorConfig(sRxData RX)
78
void dlg_MotorMixer::set_MotorConfig(sRxData RX)
79
{
79
{
-
 
80
//FIXME: put this in libMK/Handler.cpp and fill motor values in KopterData
-
 
81
/*
80
    int Pos = 0;
82
    int Pos = 0;
81
 
83
 
82
    MixerName = ToolBox::dataToQString(RX.decode, 1, 12);
84
    MixerName = ToolBox::dataToQString(RX.decode, 1, 12);
83
 
85
 
84
    Pos = 13;
86
    Pos = 13;
85
 
87
 
86
    for (int z = 0; z < 16; z++)
88
    for (int z = 0; z < 16; z++)
87
    {
89
    {
88
        for (int y = 0; y < 4; y++)
90
        for (int y = 0; y < 4; y++)
89
        {
91
        {
90
            Motor[z][y] = Parser::dataToChar(RX.decode,Pos);
92
            Motor[z][y] = Parser::dataToChar(RX.decode,Pos);
91
            Pos++;
93
            Pos++;
92
        }
94
        }
93
    }
95
    }
94
 
96
 
95
    set_MotorData();
97
    set_MotorData();
-
 
98
*/
96
}
99
}
97
 
100
 
98
// Motordaten aus GUI übernehmen
101
// Motordaten aus GUI übernehmen
99
void dlg_MotorMixer::get_MotorData()
102
void dlg_MotorMixer::get_MotorData()
100
{
103
{
-
 
104
//FIXME: add Function in handler to send data
101
    MixerName = le_NAME->text();
105
    char * mixerName = le_NAME->text().toAscii().data();
102
 
-
 
103
    Motor[0][0]  = sb_GAS_1->value();
-
 
104
    Motor[1][0]  = sb_GAS_2->value();
-
 
105
    Motor[2][0]  = sb_GAS_3->value();
-
 
106
    Motor[3][0]  = sb_GAS_4->value();
-
 
107
    Motor[4][0]  = sb_GAS_5->value();
-
 
108
    Motor[5][0]  = sb_GAS_6->value();
-
 
109
    Motor[6][0]  = sb_GAS_7->value();
106
 
110
    Motor[7][0]  = sb_GAS_8->value();
-
 
111
    Motor[8][0]  = sb_GAS_9->value();
-
 
112
    Motor[9][0]  = sb_GAS_10->value();
-
 
113
    Motor[10][0] = sb_GAS_11->value();
107
    //TODO: use an array in Form
114
    Motor[11][0] = sb_GAS_12->value();
-
 
115
 
-
 
116
    Motor[0][1]  = sb_NICK_1->value();
-
 
117
    Motor[1][1]  = sb_NICK_2->value();
-
 
118
    Motor[2][1]  = sb_NICK_3->value();
-
 
119
    Motor[3][1]  = sb_NICK_4->value();
-
 
120
    Motor[4][1]  = sb_NICK_5->value();
-
 
121
    Motor[5][1]  = sb_NICK_6->value();
-
 
122
    Motor[6][1]  = sb_NICK_7->value();
-
 
123
    Motor[7][1]  = sb_NICK_8->value();
-
 
124
    Motor[8][1]  = sb_NICK_9->value();
-
 
125
    Motor[9][1]  = sb_NICK_10->value();
108
    int motor[16][4] = {
126
    Motor[10][1] = sb_NICK_11->value();
-
 
127
    Motor[11][1] = sb_NICK_12->value();
-
 
128
 
-
 
129
    Motor[0][2]  = sb_ROLL_1->value();
109
        sb_GAS_1->value(),  sb_NICK_1->value(),  sb_ROLL_1->value(),  sb_GIER_1->value(),
130
    Motor[1][2]  = sb_ROLL_2->value();
110
        sb_GAS_2->value(),  sb_NICK_2->value(),  sb_ROLL_2->value(),  sb_GIER_2->value(),
131
    Motor[2][2]  = sb_ROLL_3->value();
111
        sb_GAS_3->value(),  sb_NICK_3->value(),  sb_ROLL_3->value(),  sb_GIER_3->value(),
132
    Motor[3][2]  = sb_ROLL_4->value();
112
        sb_GAS_4->value(),  sb_NICK_4->value(),  sb_ROLL_4->value(),  sb_GIER_4->value(),
133
    Motor[4][2]  = sb_ROLL_5->value();
113
        sb_GAS_5->value(),  sb_NICK_5->value(),  sb_ROLL_5->value(),  sb_GIER_5->value(),
134
    Motor[5][2]  = sb_ROLL_6->value();
114
        sb_GAS_6->value(),  sb_NICK_6->value(),  sb_ROLL_6->value(),  sb_GIER_6->value(),
135
    Motor[6][2]  = sb_ROLL_7->value();
115
        sb_GAS_7->value(),  sb_NICK_7->value(),  sb_ROLL_7->value(),  sb_GIER_7->value(),
136
    Motor[7][2]  = sb_ROLL_8->value();
116
        sb_GAS_8->value(),  sb_NICK_8->value(),  sb_ROLL_8->value(),  sb_GIER_8->value(),
137
    Motor[8][2]  = sb_ROLL_9->value();
117
        sb_GAS_9->value(),  sb_NICK_9->value(),  sb_ROLL_9->value(),  sb_GIER_9->value(),
138
    Motor[9][2]  = sb_ROLL_10->value();
118
        sb_GAS_10->value(), sb_NICK_10->value(), sb_ROLL_10->value(), sb_GIER_10->value(),
139
    Motor[10][2] = sb_ROLL_11->value();
119
        sb_GAS_11->value(), sb_NICK_11->value(), sb_ROLL_11->value(), sb_GIER_11->value(),
140
    Motor[11][2] = sb_ROLL_12->value();
120
        sb_GAS_12->value(), sb_NICK_12->value(), sb_ROLL_12->value(), sb_GIER_12->value()
141
 
-
 
142
    Motor[0][3]  = sb_GIER_1->value();
-
 
143
    Motor[1][3]  = sb_GIER_2->value();
-
 
144
    Motor[2][3]  = sb_GIER_3->value();
-
 
145
    Motor[3][3]  = sb_GIER_4->value();
-
 
146
    Motor[4][3]  = sb_GIER_5->value();
-
 
147
    Motor[5][3]  = sb_GIER_6->value();
-
 
148
    Motor[6][3]  = sb_GIER_7->value();
-
 
149
    Motor[7][3]  = sb_GIER_8->value();
-
 
150
    Motor[8][3]  = sb_GIER_9->value();
-
 
151
    Motor[9][3]  = sb_GIER_10->value();
-
 
152
    Motor[10][3] = sb_GIER_11->value();
-
 
153
    Motor[11][3] = sb_GIER_12->value();
121
    };
154
}
122
}
155
 
123
 
156
// Motordaten anzeigen
124
// Motordaten anzeigen
157
void dlg_MotorMixer::set_MotorData()
125
void dlg_MotorMixer::set_MotorData()
158
{
126
{
-
 
127
//FIXME: create special struct for mixer - KopterData
-
 
128
/*
159
    le_NAME->setText(MixerName);
129
    le_NAME->setText(MixerName);
160
 
130
 
161
    sb_GAS_1->setValue(Motor[0][0]);
131
    sb_GAS_1->setValue(Motor[0][0]);
162
    sb_GAS_2->setValue(Motor[1][0]);
132
    sb_GAS_2->setValue(Motor[1][0]);
163
    sb_GAS_3->setValue(Motor[2][0]);
133
    sb_GAS_3->setValue(Motor[2][0]);
164
    sb_GAS_4->setValue(Motor[3][0]);
134
    sb_GAS_4->setValue(Motor[3][0]);
165
    sb_GAS_5->setValue(Motor[4][0]);
135
    sb_GAS_5->setValue(Motor[4][0]);
166
    sb_GAS_6->setValue(Motor[5][0]);
136
    sb_GAS_6->setValue(Motor[5][0]);
167
    sb_GAS_7->setValue(Motor[6][0]);
137
    sb_GAS_7->setValue(Motor[6][0]);
168
    sb_GAS_8->setValue(Motor[7][0]);
138
    sb_GAS_8->setValue(Motor[7][0]);
169
    sb_GAS_9->setValue(Motor[8][0]);
139
    sb_GAS_9->setValue(Motor[8][0]);
170
    sb_GAS_10->setValue(Motor[9][0]);
140
    sb_GAS_10->setValue(Motor[9][0]);
171
    sb_GAS_11->setValue(Motor[10][0]);
141
    sb_GAS_11->setValue(Motor[10][0]);
172
    sb_GAS_12->setValue(Motor[11][0]);
142
    sb_GAS_12->setValue(Motor[11][0]);
173
 
143
 
174
    sb_NICK_1->setValue(Motor[0][1]);
144
    sb_NICK_1->setValue(Motor[0][1]);
175
    sb_NICK_2->setValue(Motor[1][1]);
145
    sb_NICK_2->setValue(Motor[1][1]);
176
    sb_NICK_3->setValue(Motor[2][1]);
146
    sb_NICK_3->setValue(Motor[2][1]);
177
    sb_NICK_4->setValue(Motor[3][1]);
147
    sb_NICK_4->setValue(Motor[3][1]);
178
    sb_NICK_5->setValue(Motor[4][1]);
148
    sb_NICK_5->setValue(Motor[4][1]);
179
    sb_NICK_6->setValue(Motor[5][1]);
149
    sb_NICK_6->setValue(Motor[5][1]);
180
    sb_NICK_7->setValue(Motor[6][1]);
150
    sb_NICK_7->setValue(Motor[6][1]);
181
    sb_NICK_8->setValue(Motor[7][1]);
151
    sb_NICK_8->setValue(Motor[7][1]);
182
    sb_NICK_9->setValue(Motor[8][1]);
152
    sb_NICK_9->setValue(Motor[8][1]);
183
    sb_NICK_10->setValue(Motor[9][1]);
153
    sb_NICK_10->setValue(Motor[9][1]);
184
    sb_NICK_11->setValue(Motor[10][1]);
154
    sb_NICK_11->setValue(Motor[10][1]);
185
    sb_NICK_12->setValue(Motor[11][1]);
155
    sb_NICK_12->setValue(Motor[11][1]);
186
 
156
 
187
    sb_ROLL_1->setValue(Motor[0][2]);
157
    sb_ROLL_1->setValue(Motor[0][2]);
188
    sb_ROLL_2->setValue(Motor[1][2]);
158
    sb_ROLL_2->setValue(Motor[1][2]);
189
    sb_ROLL_3->setValue(Motor[2][2]);
159
    sb_ROLL_3->setValue(Motor[2][2]);
190
    sb_ROLL_4->setValue(Motor[3][2]);
160
    sb_ROLL_4->setValue(Motor[3][2]);
191
    sb_ROLL_5->setValue(Motor[4][2]);
161
    sb_ROLL_5->setValue(Motor[4][2]);
192
    sb_ROLL_6->setValue(Motor[5][2]);
162
    sb_ROLL_6->setValue(Motor[5][2]);
193
    sb_ROLL_7->setValue(Motor[6][2]);
163
    sb_ROLL_7->setValue(Motor[6][2]);
194
    sb_ROLL_8->setValue(Motor[7][2]);
164
    sb_ROLL_8->setValue(Motor[7][2]);
195
    sb_ROLL_9->setValue(Motor[8][2]);
165
    sb_ROLL_9->setValue(Motor[8][2]);
196
    sb_ROLL_10->setValue(Motor[9][2]);
166
    sb_ROLL_10->setValue(Motor[9][2]);
197
    sb_ROLL_11->setValue(Motor[10][2]);
167
    sb_ROLL_11->setValue(Motor[10][2]);
198
    sb_ROLL_12->setValue(Motor[11][2]);
168
    sb_ROLL_12->setValue(Motor[11][2]);
199
 
169
 
200
    sb_GIER_1->setValue(Motor[0][3]);
170
    sb_GIER_1->setValue(Motor[0][3]);
201
    sb_GIER_2->setValue(Motor[1][3]);
171
    sb_GIER_2->setValue(Motor[1][3]);
202
    sb_GIER_3->setValue(Motor[2][3]);
172
    sb_GIER_3->setValue(Motor[2][3]);
203
    sb_GIER_4->setValue(Motor[3][3]);
173
    sb_GIER_4->setValue(Motor[3][3]);
204
    sb_GIER_5->setValue(Motor[4][3]);
174
    sb_GIER_5->setValue(Motor[4][3]);
205
    sb_GIER_6->setValue(Motor[5][3]);
175
    sb_GIER_6->setValue(Motor[5][3]);
206
    sb_GIER_7->setValue(Motor[6][3]);
176
    sb_GIER_7->setValue(Motor[6][3]);
207
    sb_GIER_8->setValue(Motor[7][3]);
177
    sb_GIER_8->setValue(Motor[7][3]);
208
    sb_GIER_9->setValue(Motor[8][3]);
178
    sb_GIER_9->setValue(Motor[8][3]);
209
    sb_GIER_10->setValue(Motor[9][3]);
179
    sb_GIER_10->setValue(Motor[9][3]);
210
    sb_GIER_11->setValue(Motor[10][3]);
180
    sb_GIER_11->setValue(Motor[10][3]);
211
    sb_GIER_12->setValue(Motor[11][3]);
181
    sb_GIER_12->setValue(Motor[11][3]);
-
 
182
*/
212
}
183
}
213
 
184
 
214
// Prüfen auf vollstaändigkeit
185
// Prüfen auf vollstaändigkeit
215
void dlg_MotorMixer::slot_CheckValue(int Wert)
186
void dlg_MotorMixer::slot_CheckValue(int Wert)
216
{
187
{
217
    Wert = Wert;
188
    Wert = Wert;
218
 
189
 
219
    int NICK = sb_NICK_1->value() + sb_NICK_2->value() + sb_NICK_3->value() + sb_NICK_4->value() + sb_NICK_5->value() + sb_NICK_6->value() +
190
    int NICK = sb_NICK_1->value() + sb_NICK_2->value() + sb_NICK_3->value() + sb_NICK_4->value() + sb_NICK_5->value() + sb_NICK_6->value() +
220
               sb_NICK_7->value() + sb_NICK_8->value() + sb_NICK_9->value() + sb_NICK_10->value() + sb_NICK_11->value() + sb_NICK_12->value();
191
               sb_NICK_7->value() + sb_NICK_8->value() + sb_NICK_9->value() + sb_NICK_10->value() + sb_NICK_11->value() + sb_NICK_12->value();
221
 
192
 
222
    int ROLL = sb_ROLL_1->value() + sb_ROLL_2->value() + sb_ROLL_3->value() + sb_ROLL_4->value() + sb_ROLL_5->value() + sb_ROLL_6->value() +
193
    int ROLL = sb_ROLL_1->value() + sb_ROLL_2->value() + sb_ROLL_3->value() + sb_ROLL_4->value() + sb_ROLL_5->value() + sb_ROLL_6->value() +
223
               sb_ROLL_7->value() + sb_ROLL_8->value() + sb_ROLL_9->value() + sb_ROLL_10->value() + sb_ROLL_11->value() + sb_ROLL_12->value();
194
               sb_ROLL_7->value() + sb_ROLL_8->value() + sb_ROLL_9->value() + sb_ROLL_10->value() + sb_ROLL_11->value() + sb_ROLL_12->value();
224
 
195
 
225
    int GIER = sb_GIER_1->value() + sb_GIER_2->value() + sb_GIER_3->value() + sb_GIER_4->value() + sb_GIER_5->value() + sb_GIER_6->value() +
196
    int GIER = sb_GIER_1->value() + sb_GIER_2->value() + sb_GIER_3->value() + sb_GIER_4->value() + sb_GIER_5->value() + sb_GIER_6->value() +
226
               sb_GIER_7->value() + sb_GIER_8->value() + sb_GIER_9->value() + sb_GIER_10->value() + sb_GIER_11->value() + sb_GIER_12->value();
197
               sb_GIER_7->value() + sb_GIER_8->value() + sb_GIER_9->value() + sb_GIER_10->value() + sb_GIER_11->value() + sb_GIER_12->value();
227
 
198
 
228
    if (NICK == 0)
199
    if (NICK == 0)
229
    {
200
    {
230
        lb_NICK->setEnabled(true);
201
        lb_NICK->setEnabled(true);
231
    }
202
    }
232
    else
203
    else
233
    {
204
    {
234
        lb_NICK->setEnabled(false);
205
        lb_NICK->setEnabled(false);
235
    }
206
    }
236
 
207
 
237
    if (ROLL == 0)
208
    if (ROLL == 0)
238
    {
209
    {
239
        lb_ROLL->setEnabled(true);
210
        lb_ROLL->setEnabled(true);
240
    }
211
    }
241
    else
212
    else
242
    {
213
    {
243
        lb_ROLL->setEnabled(false);
214
        lb_ROLL->setEnabled(false);
244
    }
215
    }
245
 
216
 
246
    if (GIER == 0)
217
    if (GIER == 0)
247
    {
218
    {
248
        lb_GIER->setEnabled(true);
219
        lb_GIER->setEnabled(true);
249
    }
220
    }
250
    else
221
    else
251
    {
222
    {
252
        lb_GIER->setEnabled(false);
223
        lb_GIER->setEnabled(false);
253
    }
224
    }
254
}
225
}
255
 
226
 
256
//FIXME: put this in com/Handler.cpp
227
//FIXME: put this in libMK/Handler.cpp
257
/*
228
/*
258
int dlg_MotorMixer::get_MotorConfig()
229
int dlg_MotorMixer::get_MotorConfig()
259
{
230
{
260
    get_MotorData();
231
    get_MotorData();
261
 
232
 
262
    TX_Data[0] = VERSION_MIXER;
233
    TX_Data[0] = VERSION_MIXER;
263
 
234
 
264
    char *Name = MixerName.toLatin1().data();
235
    char *Name = MixerName.toLatin1().data();
265
 
236
 
266
    int a;
237
    int a;
267
 
238
 
268
    for (a = 0; a < MixerName.length(); a++)
239
    for (a = 0; a < MixerName.length(); a++)
269
    {
240
    {
270
        TX_Data[1+a] = Name[a];
241
        TX_Data[1+a] = Name[a];
271
    }
242
    }
272
 
243
 
273
    while(a < 12)
244
    while(a < 12)
274
    {
245
    {
275
        TX_Data[1+a] = 0;
246
        TX_Data[1+a] = 0;
276
        a++;
247
        a++;
277
    }
248
    }
278
 
249
 
279
    int Pos = 13;
250
    int Pos = 13;
280
 
251
 
281
    for (int z = 0; z < 16; z++)
252
    for (int z = 0; z < 16; z++)
282
    {
253
    {
283
        for (int y = 0; y < 4; y++)
254
        for (int y = 0; y < 4; y++)
284
        {
255
        {
285
            TX_Data[Pos] = Parser::charToData(Motor[z][y]);
256
            TX_Data[Pos] = Parser::charToData(Motor[z][y]);
286
            Pos++;
257
            Pos++;
287
        }
258
        }
288
    }
259
    }
289
 
260
 
290
    return Pos - 1;
261
    return Pos - 1;
291
}
262
}
292
 
-
 
293
void dlg_MotorMixer::read_Mixer()
-
 
294
{
-
 
295
//See Handler::read_mixer in com/Handler.cpp
-
 
296
}*/
263
*/
297
 
264
 
298
// read motor values
265
// read motor values
299
void dlg_MotorMixer::slot_pb_READ()
266
void dlg_MotorMixer::slot_pb_READ()
300
{
267
{
301
    //send command to get mixer values
268
    //send command to get mixer values
302
    handler->read_mixer();
269
    handler->read_motor_mixer();
303
}
270
}
304
 
271
 
305
//write motor values
272
//write motor values
306
//FIXME: put this in com/Handler.cpp
273
//FIXME: put this in libMK/Handler.cpp
307
 
-
 
308
void dlg_MotorMixer::slot_pb_WRITE()
274
void dlg_MotorMixer::slot_pb_WRITE()
309
{
275
{
-
 
276
    char tx_data[150];
310
/*    int Length = handler->get_motor_config();
277
    int length = handler->get_motor_config(tx_data);
311
    handler->write_mixer(TX_Data, Length);*/
278
    handler->write_motor_mixer(tx_data, length);
312
}
279
}
313
 
280
 
314
void dlg_MotorMixer::slot_pb_LOAD()
281
void dlg_MotorMixer::slot_pb_LOAD()
315
{
282
{
316
    QString Filename = QFileDialog::getOpenFileName(this, tr("Mikrokopter MotorMixer laden"),  o_Settings->DIR.Parameter + "", tr("MK MotorMixer(*.mkm);;Alle Dateien (*)"));
283
    QString Filename = QFileDialog::getOpenFileName(this, tr("Mikrokopter MotorMixer laden"),  o_Settings->DIR.Parameter + "", tr("MK MotorMixer(*.mkm);;Alle Dateien (*)"));
317
 
284
 
318
    if (!Filename.isEmpty())
285
    if (!Filename.isEmpty())
319
    {
286
    {
320
        QSettings Setting(Filename, QSettings::IniFormat);
287
        QSettings Setting(Filename, QSettings::IniFormat);
321
 
288
 
322
        Setting.beginGroup("Info");
289
        Setting.beginGroup("Info");
-
 
290
//FIXME: Add mixer-struct in kopter.h for kopterdata
323
            MixerName    = Setting.value("Name", QString("--noname--")).toString();
291
//            MixerName    = Setting.value("Name", QString("--noname--")).toString();
324
            MixerVersion = Setting.value("Version", 0).toInt();
292
//            MixerVersion = Setting.value("Version", 0).toInt();
325
        Setting.endGroup();
293
        Setting.endGroup();
-
 
294
 
-
 
295
//FIXME: Add mixer-struct in kopter.h for kopterdata
326
 
296
/*
327
        Setting.beginGroup("Gas");
297
        Setting.beginGroup("Gas");
328
            for (int z = 0; z < MAXMOTOR; z++)
298
            for (int z = 0; z < MAXMOTOR; z++)
329
            {
299
            {
330
                Motor[z][0] = Setting.value(QString("Motor%1").arg(z+1), 0).toInt();
300
                Motor[z][0] = Setting.value(QString("Motor%1").arg(z+1), 0).toInt();
331
            }
301
            }
332
        Setting.endGroup();
302
        Setting.endGroup();
333
 
303
 
334
        Setting.beginGroup("Nick");
304
        Setting.beginGroup("Nick");
335
            for (int z = 0; z < MAXMOTOR; z++)
305
            for (int z = 0; z < MAXMOTOR; z++)
336
            {
306
            {
337
                Motor[z][1] = Setting.value(QString("Motor%1").arg(z+1), 0).toInt();
307
                Motor[z][1] = Setting.value(QString("Motor%1").arg(z+1), 0).toInt();
338
            }
308
            }
339
        Setting.endGroup();
309
        Setting.endGroup();
340
 
310
 
341
        Setting.beginGroup("Roll");
311
        Setting.beginGroup("Roll");
342
            for (int z = 0; z < MAXMOTOR; z++)
312
            for (int z = 0; z < MAXMOTOR; z++)
343
            {
313
            {
344
                Motor[z][2] = Setting.value(QString("Motor%1").arg(z+1), 0).toInt();
314
                Motor[z][2] = Setting.value(QString("Motor%1").arg(z+1), 0).toInt();
345
            }
315
            }
346
        Setting.endGroup();
316
        Setting.endGroup();
347
 
317
 
348
        Setting.beginGroup("Yaw");
318
        Setting.beginGroup("Yaw");
349
            for (int z = 0; z < MAXMOTOR; z++)
319
            for (int z = 0; z < MAXMOTOR; z++)
350
            {
320
            {
351
                Motor[z][3] = Setting.value(QString("Motor%1").arg(z+1), 0).toInt();
321
                Motor[z][3] = Setting.value(QString("Motor%1").arg(z+1), 0).toInt();
352
            }
322
            }
353
        Setting.endGroup();
323
        Setting.endGroup();
354
 
-
 
355
        if (MixerVersion == VERSION_MIXER)
324
        if (MixerVersion == VERSION_MIXER)
356
        {
325
        {
357
            set_MotorData();
326
            set_MotorData();
358
        }
327
        }
-
 
328
*/
359
    }
329
    }
360
}
330
}
361
 
331
 
362
void dlg_MotorMixer::slot_pb_SAVE()
332
void dlg_MotorMixer::slot_pb_SAVE()
363
{
333
{
364
    QString Filename = QFileDialog::getSaveFileName(this, tr("Mikrokopter MotorMixer speichern"), o_Settings->DIR.Parameter + "/" + le_NAME->text(), tr("MK MotorMixer(*.mkm);;Alle Dateien (*)"));
334
    QString Filename = QFileDialog::getSaveFileName(this, tr("Mikrokopter MotorMixer speichern"), o_Settings->DIR.Parameter + "/" + le_NAME->text(), tr("MK MotorMixer(*.mkm);;Alle Dateien (*)"));
365
 
335
 
366
    if (!Filename.isEmpty())
336
    if (!Filename.isEmpty())
367
    {
337
    {
368
        if (!(Filename.endsWith(".mkm", Qt::CaseInsensitive)))
338
        if (!(Filename.endsWith(".mkm", Qt::CaseInsensitive)))
369
        {
339
        {
370
            Filename = Filename + QString(".mkm");
340
            Filename = Filename + QString(".mkm");
371
        }
341
        }
372
 
342
 
373
        get_MotorData();
343
        get_MotorData();
374
 
344
 
375
        QSettings Setting(Filename, QSettings::IniFormat);
345
        QSettings Setting(Filename, QSettings::IniFormat);
376
 
346
 
377
        Setting.beginGroup("Info");
347
        Setting.beginGroup("Info");
-
 
348
//FIXME: Add mixer-struct in kopter.h for kopterdata - doppelter Code!!!
-
 
349
/*
378
            Setting.setValue("Name",         MixerName);
350
            Setting.setValue("Name",         MixerName);
379
            Setting.setValue("Version",      VERSION_MIXER);
351
            Setting.setValue("Version",      VERSION_MIXER);
380
        Setting.endGroup();
352
        Setting.endGroup();
381
 
353
 
382
        Setting.beginGroup("Gas");
354
        Setting.beginGroup("Gas");
383
            for (int z = 0; z < MAXMOTOR; z++)
355
            for (int z = 0; z < MAXMOTOR; z++)
384
            {
356
            {
385
                Setting.setValue(QString("Motor%1").arg(z+1), Motor[z][0]);
357
                Setting.setValue(QString("Motor%1").arg(z+1), Motor[z][0]);
386
            }
358
            }
387
        Setting.endGroup();
359
        Setting.endGroup();
388
 
360
 
389
        Setting.beginGroup("Nick");
361
        Setting.beginGroup("Nick");
390
            for (int z = 0; z < MAXMOTOR; z++)
362
            for (int z = 0; z < MAXMOTOR; z++)
391
            {
363
            {
392
                 Setting.setValue(QString("Motor%1").arg(z+1), Motor[z][1]);
364
                 Setting.setValue(QString("Motor%1").arg(z+1), Motor[z][1]);
393
            }
365
            }
394
        Setting.endGroup();
366
        Setting.endGroup();
395
 
367
 
396
        Setting.beginGroup("Roll");
368
        Setting.beginGroup("Roll");
397
            for (int z = 0; z < MAXMOTOR; z++)
369
            for (int z = 0; z < MAXMOTOR; z++)
398
            {
370
            {
399
                Setting.setValue(QString("Motor%1").arg(z+1), Motor[z][2]);
371
                Setting.setValue(QString("Motor%1").arg(z+1), Motor[z][2]);
400
            }
372
            }
401
        Setting.endGroup();
373
        Setting.endGroup();
402
 
374
 
403
        Setting.beginGroup("Yaw");
375
        Setting.beginGroup("Yaw");
404
            for (int z = 0; z < MAXMOTOR; z++)
376
            for (int z = 0; z < MAXMOTOR; z++)
405
            {
377
            {
406
                Setting.setValue(QString("Motor%1").arg(z+1), Motor[z][3]);
378
                Setting.setValue(QString("Motor%1").arg(z+1), Motor[z][3]);
407
            }
379
            }
408
        Setting.endGroup();
380
        Setting.endGroup();
-
 
381
*/
409
    }
382
    }
410
}
383
}
411
 
384