Rev 440 | Rev 449 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 440 | Rev 442 | ||
---|---|---|---|
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 | this->data = handler->data; |
|
74 | o_Settings = t_Settings; |
75 | o_Settings = t_Settings; |
75 | } |
76 | } |
76 | 77 | ||
77 | // Motordaten übernehmen. |
78 | // Motordaten übernehmen. |
78 | void dlg_MotorMixer::set_MotorConfig(sRxData RX) |
79 | void dlg_MotorMixer::set_MotorConfig(sRxData RX) |
79 | { |
80 | { |
80 | //FIXME: put this in libMK/Handler.cpp and fill motor values in KopterData |
81 | //FIXME: put this in libMK/Handler.cpp and fill motor values in KopterData |
81 | /* |
82 | /* |
82 | int Pos = 0; |
83 | int Pos = 0; |
83 | 84 | ||
84 | MixerName = ToolBox::dataToQString(RX.decode, 1, 12); |
85 | MixerName = ToolBox::dataToQString(RX.decode, 1, 12); |
85 | 86 | ||
86 | Pos = 13; |
87 | Pos = 13; |
87 | 88 | ||
88 | for (int z = 0; z < 16; z++) |
89 | for (int z = 0; z < 16; z++) |
89 | { |
90 | { |
90 | for (int y = 0; y < 4; y++) |
91 | for (int y = 0; y < 4; y++) |
91 | { |
92 | { |
92 | Motor[z][y] = Parser::dataToChar(RX.decode,Pos); |
93 | Motor[z][y] = Parser::dataToChar(RX.decode,Pos); |
93 | Pos++; |
94 | Pos++; |
94 | } |
95 | } |
95 | } |
96 | } |
96 | 97 | ||
97 | set_MotorData(); |
98 | set_MotorData(); |
98 | */ |
99 | */ |
99 | } |
100 | } |
100 | 101 | ||
101 | // Motordaten aus GUI übernehmen |
102 | // Motordaten aus GUI übernehmen |
102 | void dlg_MotorMixer::get_MotorData() |
103 | void dlg_MotorMixer::get_MotorData() |
103 | { |
104 | { |
104 | //FIXME: add Function in handler to send data |
105 | sMotorData motorData; |
- | 106 | ||
105 | char * mixerName = le_NAME->text().toAscii().data(); |
107 | char * mixerName = le_NAME->text().toAscii().data(); |
- | 108 | motorData.mixer_name = string(mixerName); |
|
106 | - | ||
107 | //TODO: use an array in Form |
109 | |
108 | int motor[16][4] = { |
110 | int gas[MAX_MOTORS] = { |
109 | sb_GAS_1->value(), sb_NICK_1->value(), sb_ROLL_1->value(), sb_GIER_1->value(), |
111 | sb_GAS_1->value(), sb_GAS_2->value(), sb_GAS_3->value(), sb_GAS_4->value(), |
110 | sb_GAS_2->value(), sb_NICK_2->value(), sb_ROLL_2->value(), sb_GIER_2->value(), |
112 | sb_GAS_5->value(), sb_GAS_6->value(), sb_GAS_7->value(), sb_GAS_8->value(), |
- | 113 | sb_GAS_9->value(), sb_GAS_10->value(), sb_GAS_11->value(), sb_GAS_12->value() |
|
- | 114 | }; |
|
111 | sb_GAS_3->value(), sb_NICK_3->value(), sb_ROLL_3->value(), sb_GIER_3->value(), |
115 | int nick[MAX_MOTORS] = { |
112 | sb_GAS_4->value(), sb_NICK_4->value(), sb_ROLL_4->value(), sb_GIER_4->value(), |
116 | sb_NICK_1->value(), sb_NICK_2->value(), sb_NICK_3->value(), sb_NICK_4->value(), |
113 | sb_GAS_5->value(), sb_NICK_5->value(), sb_ROLL_5->value(), sb_GIER_5->value(), |
117 | sb_NICK_5->value(), sb_NICK_6->value(), sb_NICK_7->value(), sb_NICK_8->value(), |
- | 118 | sb_NICK_9->value(), sb_NICK_10->value(), sb_NICK_11->value(), sb_NICK_12->value() |
|
- | 119 | }; |
|
114 | sb_GAS_6->value(), sb_NICK_6->value(), sb_ROLL_6->value(), sb_GIER_6->value(), |
120 | int roll[MAX_MOTORS] = { |
115 | sb_GAS_7->value(), sb_NICK_7->value(), sb_ROLL_7->value(), sb_GIER_7->value(), |
121 | sb_ROLL_1->value(), sb_ROLL_2->value(), sb_ROLL_3->value(), sb_ROLL_4->value(), |
116 | sb_GAS_8->value(), sb_NICK_8->value(), sb_ROLL_8->value(), sb_GIER_8->value(), |
122 | sb_ROLL_5->value(), sb_ROLL_6->value(), sb_ROLL_7->value(), sb_ROLL_8->value(), |
- | 123 | sb_ROLL_9->value(), sb_ROLL_10->value(), sb_ROLL_11->value(), sb_ROLL_12->value() |
|
- | 124 | }; |
|
117 | sb_GAS_9->value(), sb_NICK_9->value(), sb_ROLL_9->value(), sb_GIER_9->value(), |
125 | int yaw[MAX_MOTORS] = { |
118 | sb_GAS_10->value(), sb_NICK_10->value(), sb_ROLL_10->value(), sb_GIER_10->value(), |
126 | sb_GIER_1->value(), sb_GIER_2->value(), sb_GIER_3->value(), sb_GIER_4->value(), |
119 | sb_GAS_11->value(), sb_NICK_11->value(), sb_ROLL_11->value(), sb_GIER_11->value(), |
127 | sb_GIER_5->value(), sb_GIER_6->value(), sb_GIER_7->value(), sb_GIER_8->value(), |
120 | sb_GAS_12->value(), sb_NICK_12->value(), sb_ROLL_12->value(), sb_GIER_12->value() |
128 | sb_GIER_9->value(), sb_GIER_10->value(), sb_GIER_11->value(), sb_GIER_12->value() |
- | 129 | }; |
|
- | 130 | for (int i = 0; i < MAX_MOTORS; i++) { |
|
- | 131 | motorData.mixer_gas[i] = gas[i]; |
|
- | 132 | motorData.mixer_nick[i] = nick[i]; |
|
- | 133 | motorData.mixer_roll[i] = roll[i]; |
|
- | 134 | motorData.mixer_yaw[i] = yaw[i]; |
|
- | 135 | } |
|
121 | }; |
136 | //FIXME: add Function in handler to send data |
122 | } |
137 | } |
123 | 138 | ||
124 | // Motordaten anzeigen |
139 | // Motordaten anzeigen |
125 | void dlg_MotorMixer::set_MotorData() |
140 | void dlg_MotorMixer::set_MotorData() |
126 | { |
141 | { |
127 | //FIXME: create special struct for mixer - KopterData |
142 | sMotorData motorData = handler->data->motor; |
128 | /* |
- | |
129 | le_NAME->setText(MixerName); |
143 | le_NAME->setText(motorData.mixer_name.c_str()); |
130 | 144 | ||
131 | sb_GAS_1->setValue(Motor[0][0]); |
145 | sb_GAS_1->setValue(motorData.mixer_gas[0]); |
132 | sb_GAS_2->setValue(Motor[1][0]); |
146 | sb_GAS_2->setValue(motorData.mixer_gas[1]); |
133 | sb_GAS_3->setValue(Motor[2][0]); |
147 | sb_GAS_3->setValue(motorData.mixer_gas[2]); |
134 | sb_GAS_4->setValue(Motor[3][0]); |
148 | sb_GAS_4->setValue(motorData.mixer_gas[3]); |
135 | sb_GAS_5->setValue(Motor[4][0]); |
149 | sb_GAS_5->setValue(motorData.mixer_gas[4]); |
136 | sb_GAS_6->setValue(Motor[5][0]); |
150 | sb_GAS_6->setValue(motorData.mixer_gas[5]); |
137 | sb_GAS_7->setValue(Motor[6][0]); |
151 | sb_GAS_7->setValue(motorData.mixer_gas[6]); |
138 | sb_GAS_8->setValue(Motor[7][0]); |
152 | sb_GAS_8->setValue(motorData.mixer_gas[7]); |
139 | sb_GAS_9->setValue(Motor[8][0]); |
153 | sb_GAS_9->setValue(motorData.mixer_gas[8]); |
140 | sb_GAS_10->setValue(Motor[9][0]); |
154 | sb_GAS_10->setValue(motorData.mixer_gas[9]); |
141 | sb_GAS_11->setValue(Motor[10][0]); |
155 | sb_GAS_11->setValue(motorData.mixer_gas[10]); |
142 | sb_GAS_12->setValue(Motor[11][0]); |
156 | sb_GAS_12->setValue(motorData.mixer_gas[11]); |
143 | 157 | ||
144 | sb_NICK_1->setValue(Motor[0][1]); |
158 | sb_NICK_1->setValue(motorData.mixer_nick[0]); |
145 | sb_NICK_2->setValue(Motor[1][1]); |
159 | sb_NICK_2->setValue(motorData.mixer_nick[1]); |
146 | sb_NICK_3->setValue(Motor[2][1]); |
160 | sb_NICK_3->setValue(motorData.mixer_nick[2]); |
147 | sb_NICK_4->setValue(Motor[3][1]); |
161 | sb_NICK_4->setValue(motorData.mixer_nick[3]); |
148 | sb_NICK_5->setValue(Motor[4][1]); |
162 | sb_NICK_5->setValue(motorData.mixer_nick[4]); |
149 | sb_NICK_6->setValue(Motor[5][1]); |
163 | sb_NICK_6->setValue(motorData.mixer_nick[5]); |
150 | sb_NICK_7->setValue(Motor[6][1]); |
164 | sb_NICK_7->setValue(motorData.mixer_nick[6]); |
151 | sb_NICK_8->setValue(Motor[7][1]); |
165 | sb_NICK_8->setValue(motorData.mixer_nick[7]); |
152 | sb_NICK_9->setValue(Motor[8][1]); |
166 | sb_NICK_9->setValue(motorData.mixer_nick[8]); |
153 | sb_NICK_10->setValue(Motor[9][1]); |
167 | sb_NICK_10->setValue(motorData.mixer_nick[9]); |
154 | sb_NICK_11->setValue(Motor[10][1]); |
168 | sb_NICK_11->setValue(motorData.mixer_nick[10]); |
155 | sb_NICK_12->setValue(Motor[11][1]); |
169 | sb_NICK_12->setValue(motorData.mixer_nick[11]); |
156 | 170 | ||
157 | sb_ROLL_1->setValue(Motor[0][2]); |
171 | sb_ROLL_1->setValue(motorData.mixer_roll[0]); |
158 | sb_ROLL_2->setValue(Motor[1][2]); |
172 | sb_ROLL_2->setValue(motorData.mixer_roll[1]); |
159 | sb_ROLL_3->setValue(Motor[2][2]); |
173 | sb_ROLL_3->setValue(motorData.mixer_roll[2]); |
160 | sb_ROLL_4->setValue(Motor[3][2]); |
174 | sb_ROLL_4->setValue(motorData.mixer_roll[3]); |
161 | sb_ROLL_5->setValue(Motor[4][2]); |
175 | sb_ROLL_5->setValue(motorData.mixer_roll[4]); |
162 | sb_ROLL_6->setValue(Motor[5][2]); |
176 | sb_ROLL_6->setValue(motorData.mixer_roll[5]); |
163 | sb_ROLL_7->setValue(Motor[6][2]); |
177 | sb_ROLL_7->setValue(motorData.mixer_roll[6]); |
164 | sb_ROLL_8->setValue(Motor[7][2]); |
178 | sb_ROLL_8->setValue(motorData.mixer_roll[7]); |
165 | sb_ROLL_9->setValue(Motor[8][2]); |
179 | sb_ROLL_9->setValue(motorData.mixer_roll[8]); |
166 | sb_ROLL_10->setValue(Motor[9][2]); |
180 | sb_ROLL_10->setValue(motorData.mixer_roll[9]); |
167 | sb_ROLL_11->setValue(Motor[10][2]); |
181 | sb_ROLL_11->setValue(motorData.mixer_roll[10]); |
168 | sb_ROLL_12->setValue(Motor[11][2]); |
182 | sb_ROLL_12->setValue(motorData.mixer_roll[11]); |
169 | 183 | ||
170 | sb_GIER_1->setValue(Motor[0][3]); |
184 | sb_GIER_1->setValue(motorData.mixer_yaw[0]); |
171 | sb_GIER_2->setValue(Motor[1][3]); |
185 | sb_GIER_2->setValue(motorData.mixer_yaw[1]); |
172 | sb_GIER_3->setValue(Motor[2][3]); |
186 | sb_GIER_3->setValue(motorData.mixer_yaw[2]); |
173 | sb_GIER_4->setValue(Motor[3][3]); |
187 | sb_GIER_4->setValue(motorData.mixer_yaw[3]); |
174 | sb_GIER_5->setValue(Motor[4][3]); |
188 | sb_GIER_5->setValue(motorData.mixer_yaw[4]); |
175 | sb_GIER_6->setValue(Motor[5][3]); |
189 | sb_GIER_6->setValue(motorData.mixer_yaw[5]); |
176 | sb_GIER_7->setValue(Motor[6][3]); |
190 | sb_GIER_7->setValue(motorData.mixer_yaw[6]); |
177 | sb_GIER_8->setValue(Motor[7][3]); |
191 | sb_GIER_8->setValue(motorData.mixer_yaw[7]); |
178 | sb_GIER_9->setValue(Motor[8][3]); |
192 | sb_GIER_9->setValue(motorData.mixer_yaw[8]); |
179 | sb_GIER_10->setValue(Motor[9][3]); |
193 | sb_GIER_10->setValue(motorData.mixer_yaw[9]); |
180 | sb_GIER_11->setValue(Motor[10][3]); |
194 | sb_GIER_11->setValue(motorData.mixer_yaw[10]); |
181 | sb_GIER_12->setValue(Motor[11][3]); |
- | |
182 | */ |
195 | sb_GIER_12->setValue(motorData.mixer_yaw[11]); |
183 | } |
196 | } |
184 | 197 | ||
185 | // Prüfen auf vollstaändigkeit |
198 | // Prüfen auf vollstaändigkeit |
186 | void dlg_MotorMixer::slot_CheckValue(int Wert) |
199 | void dlg_MotorMixer::slot_CheckValue(int Wert) |
187 | { |
200 | { |
188 | Wert = Wert; |
201 | Wert = Wert; |
189 | 202 | ||
- | 203 | int NICK = sb_NICK_1->value() + sb_NICK_2->value() + sb_NICK_3->value() + |
|
- | 204 | 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() + |
205 | sb_NICK_7->value() + sb_NICK_8->value() + sb_NICK_9->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(); |
206 | sb_NICK_10->value() + sb_NICK_11->value() + sb_NICK_12->value(); |
192 | 207 | ||
- | 208 | int ROLL = sb_ROLL_1->value() + sb_ROLL_2->value() + sb_ROLL_3->value() + |
|
- | 209 | 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() + |
210 | sb_ROLL_7->value() + sb_ROLL_8->value() + sb_ROLL_9->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(); |
211 | sb_ROLL_10->value() + sb_ROLL_11->value() + sb_ROLL_12->value(); |
195 | 212 | ||
- | 213 | int GIER = sb_GIER_1->value() + sb_GIER_2->value() + sb_GIER_3->value() + |
|
- | 214 | 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() + |
215 | sb_GIER_7->value() + sb_GIER_8->value() + sb_GIER_9->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(); |
216 | sb_GIER_10->value() + sb_GIER_11->value() + sb_GIER_12->value(); |
198 | 217 | ||
199 | if (NICK == 0) |
218 | if (NICK == 0) |
200 | { |
219 | { |
201 | lb_NICK->setEnabled(true); |
220 | lb_NICK->setEnabled(true); |
202 | } |
221 | } |
203 | else |
222 | else |
204 | { |
223 | { |
205 | lb_NICK->setEnabled(false); |
224 | lb_NICK->setEnabled(false); |
206 | } |
225 | } |
207 | 226 | ||
208 | if (ROLL == 0) |
227 | if (ROLL == 0) |
209 | { |
228 | { |
210 | lb_ROLL->setEnabled(true); |
229 | lb_ROLL->setEnabled(true); |
211 | } |
230 | } |
212 | else |
231 | else |
213 | { |
232 | { |
214 | lb_ROLL->setEnabled(false); |
233 | lb_ROLL->setEnabled(false); |
215 | } |
234 | } |
216 | 235 | ||
217 | if (GIER == 0) |
236 | if (GIER == 0) |
218 | { |
237 | { |
219 | lb_GIER->setEnabled(true); |
238 | lb_GIER->setEnabled(true); |
220 | } |
239 | } |
221 | else |
240 | else |
222 | { |
241 | { |
223 | lb_GIER->setEnabled(false); |
242 | lb_GIER->setEnabled(false); |
224 | } |
243 | } |
225 | } |
244 | } |
226 | 245 | ||
227 | //FIXME: put this in libMK/Handler.cpp |
246 | //FIXME: put this in libMK/Handler.cpp |
228 | /* |
247 | /* |
229 | int dlg_MotorMixer::get_MotorConfig() |
248 | int dlg_MotorMixer::get_MotorConfig() |
230 | { |
249 | { |
231 | get_MotorData(); |
250 | get_MotorData(); |
232 | 251 | ||
233 | TX_Data[0] = VERSION_MIXER; |
252 | TX_Data[0] = VERSION_MIXER; |
234 | 253 | ||
235 | char *Name = MixerName.toLatin1().data(); |
254 | char *Name = MixerName.toLatin1().data(); |
236 | 255 | ||
237 | int a; |
256 | int a; |
238 | 257 | ||
239 | for (a = 0; a < MixerName.length(); a++) |
258 | for (a = 0; a < MixerName.length(); a++) |
240 | { |
259 | { |
241 | TX_Data[1+a] = Name[a]; |
260 | TX_Data[1+a] = Name[a]; |
242 | } |
261 | } |
243 | 262 | ||
244 | while(a < 12) |
263 | while(a < 12) |
245 | { |
264 | { |
246 | TX_Data[1+a] = 0; |
265 | TX_Data[1+a] = 0; |
247 | a++; |
266 | a++; |
248 | } |
267 | } |
249 | 268 | ||
250 | int Pos = 13; |
269 | int Pos = 13; |
251 | 270 | ||
252 | for (int z = 0; z < 16; z++) |
271 | for (int z = 0; z < 16; z++) |
253 | { |
272 | { |
254 | for (int y = 0; y < 4; y++) |
273 | for (int y = 0; y < 4; y++) |
255 | { |
274 | { |
256 | TX_Data[Pos] = Parser::charToData(Motor[z][y]); |
275 | TX_Data[Pos] = Parser::charToData(Motor[z][y]); |
257 | Pos++; |
276 | Pos++; |
258 | } |
277 | } |
259 | } |
278 | } |
260 | 279 | ||
261 | return Pos - 1; |
280 | return Pos - 1; |
262 | } |
281 | } |
263 | */ |
282 | */ |
264 | 283 | ||
265 | // read motor values |
284 | // read motor values |
266 | void dlg_MotorMixer::slot_pb_READ() |
285 | void dlg_MotorMixer::slot_pb_READ() |
267 | { |
286 | { |
268 | //send command to get mixer values |
287 | //send command to get mixer values |
269 | handler->read_motor_mixer(); |
288 | handler->read_motor_mixer(); |
270 | } |
289 | } |
271 | 290 | ||
272 | //write motor values |
291 | //write motor values |
273 | //FIXME: put this in libMK/Handler.cpp |
292 | //FIXME: put this in libMK/Handler.cpp |
274 | void dlg_MotorMixer::slot_pb_WRITE() |
293 | void dlg_MotorMixer::slot_pb_WRITE() |
275 | { |
294 | { |
276 | char tx_data[150]; |
295 | char tx_data[150]; |
277 | int length = handler->get_motor_config(tx_data); |
296 | int length = handler->get_motor_config(tx_data); |
278 | handler->write_motor_mixer(tx_data, length); |
297 | handler->write_motor_mixer(tx_data, length); |
279 | } |
298 | } |
280 | 299 | ||
281 | void dlg_MotorMixer::slot_pb_LOAD() |
300 | void dlg_MotorMixer::slot_pb_LOAD() |
282 | { |
301 | { |
283 | QString Filename = QFileDialog::getOpenFileName(this, tr("Mikrokopter MotorMixer laden"), o_Settings->DIR.Parameter + "", tr("MK MotorMixer(*.mkm);;Alle Dateien (*)")); |
302 | QString Filename = QFileDialog::getOpenFileName(this, tr("Mikrokopter MotorMixer laden"), o_Settings->DIR.Parameter + "", tr("MK MotorMixer(*.mkm);;Alle Dateien (*)")); |
284 | 303 | ||
285 | if (!Filename.isEmpty()) |
304 | if (!Filename.isEmpty()) |
286 | { |
305 | { |
287 | QSettings Setting(Filename, QSettings::IniFormat); |
306 | QSettings Setting(Filename, QSettings::IniFormat); |
288 | 307 | ||
289 | Setting.beginGroup("Info"); |
308 | Setting.beginGroup("Info"); |
290 | //FIXME: Add mixer-struct in kopter.h for kopterdata |
- | |
291 | // MixerName = Setting.value("Name", QString("--noname--")).toString(); |
309 | data->motor.mixer_name = Setting.value("Name", QString("--noname--")).toString().toAscii().data(); |
292 | // MixerVersion = Setting.value("Version", 0).toInt(); |
310 | data->motor.mixer_version = Setting.value("Version", 0).toInt(); |
293 | Setting.endGroup(); |
311 | Setting.endGroup(); |
294 | - | ||
295 | //FIXME: Add mixer-struct in kopter.h for kopterdata |
- | |
296 | /* |
312 | |
297 | Setting.beginGroup("Gas"); |
313 | Setting.beginGroup("Gas"); |
298 | for (int z = 0; z < MAXMOTOR; z++) |
314 | for (int z = 0; z < MAXMOTOR; z++) |
299 | { |
315 | { |
300 | Motor[z][0] = Setting.value(QString("Motor%1").arg(z+1), 0).toInt(); |
316 | data->motor.mixer_gas[z] = Setting.value(QString("Motor%1").arg(z+1), 0).toInt(); |
301 | } |
317 | } |
302 | Setting.endGroup(); |
318 | Setting.endGroup(); |
303 | 319 | ||
304 | Setting.beginGroup("Nick"); |
320 | Setting.beginGroup("Nick"); |
305 | for (int z = 0; z < MAXMOTOR; z++) |
321 | for (int z = 0; z < MAXMOTOR; z++) |
306 | { |
322 | { |
307 | Motor[z][1] = Setting.value(QString("Motor%1").arg(z+1), 0).toInt(); |
323 | data->motor.mixer_nick[z] = Setting.value(QString("Motor%1").arg(z+1), 0).toInt(); |
308 | } |
324 | } |
309 | Setting.endGroup(); |
325 | Setting.endGroup(); |
310 | 326 | ||
311 | Setting.beginGroup("Roll"); |
327 | Setting.beginGroup("Roll"); |
312 | for (int z = 0; z < MAXMOTOR; z++) |
328 | for (int z = 0; z < MAXMOTOR; z++) |
313 | { |
329 | { |
314 | Motor[z][2] = Setting.value(QString("Motor%1").arg(z+1), 0).toInt(); |
330 | data->motor.mixer_roll[z] = Setting.value(QString("Motor%1").arg(z+1), 0).toInt(); |
315 | } |
331 | } |
316 | Setting.endGroup(); |
332 | Setting.endGroup(); |
317 | 333 | ||
318 | Setting.beginGroup("Yaw"); |
334 | Setting.beginGroup("Yaw"); |
319 | for (int z = 0; z < MAXMOTOR; z++) |
335 | for (int z = 0; z < MAXMOTOR; z++) |
320 | { |
336 | { |
321 | Motor[z][3] = Setting.value(QString("Motor%1").arg(z+1), 0).toInt(); |
337 | data->motor.mixer_yaw[z] = Setting.value(QString("Motor%1").arg(z+1), 0).toInt(); |
322 | } |
338 | } |
323 | Setting.endGroup(); |
339 | Setting.endGroup(); |
- | 340 | ||
324 | if (MixerVersion == VERSION_MIXER) |
341 | if (data->motor.mixer_version == VERSION_MIXER) |
325 | { |
342 | { |
326 | set_MotorData(); |
343 | set_MotorData(); |
327 | } |
344 | } |
328 | */ |
- | |
329 | } |
345 | } |
330 | } |
346 | } |
331 | 347 | ||
332 | void dlg_MotorMixer::slot_pb_SAVE() |
348 | void dlg_MotorMixer::slot_pb_SAVE() |
333 | { |
349 | { |
334 | QString Filename = QFileDialog::getSaveFileName(this, tr("Mikrokopter MotorMixer speichern"), o_Settings->DIR.Parameter + "/" + le_NAME->text(), tr("MK MotorMixer(*.mkm);;Alle Dateien (*)")); |
350 | QString Filename = QFileDialog::getSaveFileName(this, tr("Mikrokopter MotorMixer speichern"), o_Settings->DIR.Parameter + "/" + le_NAME->text(), tr("MK MotorMixer(*.mkm);;Alle Dateien (*)")); |
335 | 351 | ||
336 | if (!Filename.isEmpty()) |
352 | if (!Filename.isEmpty()) |
337 | { |
353 | { |
338 | if (!(Filename.endsWith(".mkm", Qt::CaseInsensitive))) |
354 | if (!(Filename.endsWith(".mkm", Qt::CaseInsensitive))) |
339 | { |
355 | { |
340 | Filename = Filename + QString(".mkm"); |
356 | Filename = Filename + QString(".mkm"); |
341 | } |
357 | } |
342 | 358 | ||
343 | get_MotorData(); |
359 | get_MotorData(); |
344 | 360 | ||
345 | QSettings Setting(Filename, QSettings::IniFormat); |
361 | QSettings Setting(Filename, QSettings::IniFormat); |
346 | 362 | ||
347 | Setting.beginGroup("Info"); |
363 | Setting.beginGroup("Info"); |
348 | //FIXME: Add mixer-struct in kopter.h for kopterdata - doppelter Code!!! |
- | |
349 | /* |
- | |
350 | Setting.setValue("Name", MixerName); |
364 | Setting.setValue("Name", data->motor.mixer_name.c_str()); |
351 | Setting.setValue("Version", VERSION_MIXER); |
365 | Setting.setValue("Version", data->motor.mixer_version); |
352 | Setting.endGroup(); |
366 | Setting.endGroup(); |
353 | 367 | ||
354 | Setting.beginGroup("Gas"); |
368 | Setting.beginGroup("Gas"); |
355 | for (int z = 0; z < MAXMOTOR; z++) |
369 | for (int z = 0; z < MAXMOTOR; z++) |
356 | { |
370 | { |
357 | Setting.setValue(QString("Motor%1").arg(z+1), Motor[z][0]); |
371 | Setting.setValue(QString("Motor%1").arg(z+1), data->motor.mixer_gas[z]); |
358 | } |
372 | } |
359 | Setting.endGroup(); |
373 | Setting.endGroup(); |
360 | 374 | ||
361 | Setting.beginGroup("Nick"); |
375 | Setting.beginGroup("Nick"); |
362 | for (int z = 0; z < MAXMOTOR; z++) |
376 | for (int z = 0; z < MAXMOTOR; z++) |
363 | { |
377 | { |
364 | Setting.setValue(QString("Motor%1").arg(z+1), Motor[z][1]); |
378 | Setting.setValue(QString("Motor%1").arg(z+1), data->motor.mixer_nick[z]); |
365 | } |
379 | } |
366 | Setting.endGroup(); |
380 | Setting.endGroup(); |
367 | 381 | ||
368 | Setting.beginGroup("Roll"); |
382 | Setting.beginGroup("Roll"); |
369 | for (int z = 0; z < MAXMOTOR; z++) |
383 | for (int z = 0; z < MAXMOTOR; z++) |
370 | { |
384 | { |
371 | Setting.setValue(QString("Motor%1").arg(z+1), Motor[z][2]); |
385 | Setting.setValue(QString("Motor%1").arg(z+1), data->motor.mixer_roll[z]); |
372 | } |
386 | } |
373 | Setting.endGroup(); |
387 | Setting.endGroup(); |
374 | 388 | ||
375 | Setting.beginGroup("Yaw"); |
389 | Setting.beginGroup("Yaw"); |
376 | for (int z = 0; z < MAXMOTOR; z++) |
390 | for (int z = 0; z < MAXMOTOR; z++) |
377 | { |
391 | { |
378 | Setting.setValue(QString("Motor%1").arg(z+1), Motor[z][3]); |
392 | Setting.setValue(QString("Motor%1").arg(z+1), data->motor.mixer_yaw[z]); |
379 | } |
393 | } |
380 | Setting.endGroup(); |
394 | Setting.endGroup(); |
381 | */ |
- | |
382 | } |
395 | } |
383 | } |
396 | } |
384 | 397 |