18#include "../elements/powerElement/IndMotor.h"
22IndMotorForm::IndMotorForm(wxWindow* parent,
IndMotor* indMotor) : IndMotorFormBase(parent)
24 SetSize(GetBestSize());
25 m_staticTextw->SetLabel(
static_cast<wxString
>(L
'\u03C9') + wxT(
" +"));
26 m_staticTextw2->SetLabel(
static_cast<wxString
>(L
'\u03C9') +
static_cast<wxString
>(L
'\u00B2'));
29 m_textCtrlName->SetValue(data.name);
32 switch(data.activePowerUnit) {
34 m_choiceNominalPower->SetSelection(0);
37 m_choiceNominalPower->SetSelection(1);
40 m_choiceNominalPower->SetSelection(2);
47 switch(data.activePowerUnit) {
49 m_choiceActivePower->SetSelection(0);
52 m_choiceActivePower->SetSelection(1);
55 m_choiceActivePower->SetSelection(2);
58 m_choiceActivePower->SetSelection(3);
65 switch(data.reactivePowerUnit) {
67 m_choiceReactivePower->SetSelection(0);
70 m_choiceReactivePower->SetSelection(1);
73 m_choiceReactivePower->SetSelection(2);
76 m_choiceReactivePower->SetSelection(3);
82 m_checkBoxComputeQ->SetValue(data.calcQInPowerFlow);
83 m_checkBoxUseMachinePower->SetValue(data.useMachinePowerAsBase);
86 m_checkBoxPlotIndMachine->SetValue(data.plotIndMachine);
93 m_checkBoxUseKf->SetValue(data.useKf);
95 m_textCtrlKf->Enable(data.useKf);
102 m_indMotor = indMotor;
107IndMotorForm::~IndMotorForm() {}
108void IndMotorForm::OnOKButtonClick(wxCommandEvent& event)
110 if(ValidateData()) EndModal(wxID_OK);
112void IndMotorForm::OnStabilityButtonClick(wxCommandEvent& event)
116 swForm.SetTitle(_(
"Induction motor: Switching"));
122bool IndMotorForm::ValidateData()
126 data.name = m_textCtrlName->GetValue();
128 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlnominalPower->GetValue(), data.ratedPower,
129 _(
"Value entered incorrectly in the field \"Rated power\".")))
131 switch(m_choiceNominalPower->GetSelection()) {
143 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlActivePower->GetValue(), data.activePower,
144 _(
"Value entered incorrectly in the field \"Active power\".")))
146 switch(m_choiceActivePower->GetSelection()) {
161 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlReactivePower->GetValue(), data.reactivePower,
162 _(
"Value entered incorrectly in the field \"Reactive power\".")))
164 switch(m_choiceReactivePower->GetSelection()) {
179 data.calcQInPowerFlow = m_checkBoxComputeQ->GetValue();
180 data.useMachinePowerAsBase = m_checkBoxUseMachinePower->GetValue();
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\".")))
187 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlStatorResistence->GetValue(), data.r1,
188 _(
"Value entered incorrectly in the field \"Stator resistence\".")))
190 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlStatorReactance->GetValue(), data.x1,
191 _(
"Value entered incorrectly in the field \"Stator reactance\".")))
193 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlRotorResistence->GetValue(), data.r2,
194 _(
"Value entered incorrectly in the field \"Rotor resistence\".")))
196 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlRotorReactance->GetValue(), data.x2,
197 _(
"Value entered incorrectly in the field \"Rotor reactance\".")))
199 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlMagnetizingReactance->GetValue(), data.xm,
200 _(
"Value entered incorrectly in the field \"Magnetizing reactance\".")))
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\".")))
207 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlA->GetValue(), data.aw,
208 _(
"Value entered incorrectly in the field \"Constant torque\".")))
210 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlB->GetValue(), data.bw,
211 _(
"Value entered incorrectly in the field \"Linear torque\".")))
213 if(!m_indMotor->
DoubleFromString(m_parent, m_textCtrlC->GetValue(), data.cw,
214 _(
"Value entered incorrectly in the field \"Quadratic torque\".")))
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();
227 m_indMotor->SetElectricalData(data);
230void IndMotorForm::OnCheckboxUseCageFactorClick(wxCommandEvent& event) { UpdateFields(); }
231void IndMotorForm::OnCalcQInPFClick(wxCommandEvent& event) { UpdateFields(); }
233void IndMotorForm::UpdateFields()
235 m_textCtrlKf->Enable(m_checkBoxUseKf->GetValue());
236 m_textCtrlReactivePower->Enable(!m_checkBoxComputeQ->GetValue());
237 m_choiceReactivePower->Enable(!m_checkBoxComputeQ->GetValue());
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.
static wxString StringFromDouble(double value, int minDecimal=1, int maxDecimals=13)
Convert a double value to string.
Induction motor power element.