123{
125
126 data.name = m_textCtrlName->GetValue();
127
128 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlnominalPower->GetValue(), data.ratedPower,
129 _("Value entered incorrectly in the field \"Rated power\".")))
130 return false;
131 switch(m_choiceNominalPower->GetSelection()) {
132 case 0: {
134 } break;
135 case 1: {
137 } break;
138 case 2: {
140 } break;
141 }
142
143 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlActivePower->GetValue(), data.activePower,
144 _("Value entered incorrectly in the field \"Active power\".")))
145 return false;
146 switch(m_choiceActivePower->GetSelection()) {
147 case 0: {
149 } break;
150 case 1: {
152 } break;
153 case 2: {
155 } break;
156 case 3: {
158 } break;
159 }
160
161 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlReactivePower->GetValue(), data.reactivePower,
162 _("Value entered incorrectly in the field \"Reactive power\".")))
163 return false;
164 switch(m_choiceReactivePower->GetSelection()) {
165 case 0: {
167 } break;
168 case 1: {
170 } break;
171 case 2: {
173 } break;
174 case 3: {
176 } break;
177 }
178
179 data.calcQInPowerFlow = m_checkBoxComputeQ->GetValue();
180 data.useMachinePowerAsBase = m_checkBoxUseMachinePower->GetValue();
181
182
183 data.plotIndMachine = m_checkBoxPlotIndMachine->GetValue();
184 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlInertia->GetValue(), data.inertia,
185 _("Value entered incorrectly in the field \"Inertia\".")))
186 return false;
187 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlStatorResistence->GetValue(), data.r1,
188 _("Value entered incorrectly in the field \"Stator resistence\".")))
189 return false;
190 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlStatorReactance->GetValue(), data.x1,
191 _("Value entered incorrectly in the field \"Stator reactance\".")))
192 return false;
193 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlRotorResistence->GetValue(), data.r2,
194 _("Value entered incorrectly in the field \"Rotor resistence\".")))
195 return false;
196 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlRotorReactance->GetValue(), data.x2,
197 _("Value entered incorrectly in the field \"Rotor reactance\".")))
198 return false;
199 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlMagnetizingReactance->GetValue(), data.xm,
200 _("Value entered incorrectly in the field \"Magnetizing reactance\".")))
201 return false;
202 data.useKf = m_checkBoxUseKf->GetValue();
203 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlKf->GetValue(), data.kf,
204 _("Value entered incorrectly in the field \"Cage factor\".")))
205 return false;
206
207 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlA->GetValue(), data.aw,
208 _("Value entered incorrectly in the field \"Constant torque\".")))
209 return false;
210 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlB->GetValue(), data.bw,
211 _("Value entered incorrectly in the field \"Linear torque\".")))
212 return false;
213 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlC->GetValue(), data.cw,
214 _("Value entered incorrectly in the field \"Quadratic torque\".")))
215 return false;
216
217 double sum = data.aw + data.bw + data.cw;
218 double tolerance = 1e-4;
219 if(sum > (1.0 + tolerance) || sum < (1.0 - tolerance)) {
220 wxString errorMsg = _("The sum of the torque portions must be unitary.\nThe current value is ") +
222 wxMessageDialog msgDialog(m_parent, errorMsg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR);
223 msgDialog.ShowModal();
224 return false;
225 }
226
227 m_indMotor->SetElectricalData(data);
228 return true;
229}
static bool DoubleFromString(wxWindow *parent, wxString strValue, double &value, wxString errorMsg)
Get a double value from a string. Show a error message if the conversion fail.