Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
IndMotorForm Class Reference

Form to edit the induction motor power data. More...

#include <IndMotorForm.h>

Inheritance diagram for IndMotorForm:
Collaboration diagram for IndMotorForm:

Public Member Functions

 IndMotorForm (wxWindow *parent, IndMotor *indMotor)
 
virtual bool ValidateData ()
 

Protected Member Functions

virtual void OnCalcQInPFClick (wxCommandEvent &event)
 
virtual void OnCheckboxUseCageFactorClick (wxCommandEvent &event)
 
virtual void OnCancelButtonClick (wxCommandEvent &event)
 
virtual void OnOKButtonClick (wxCommandEvent &event)
 
virtual void OnStabilityButtonClick (wxCommandEvent &event)
 
void UpdateFields ()
 

Protected Attributes

wxWindow * m_parent = nullptr
 
IndMotorm_indMotor = nullptr
 

Detailed Description

Form to edit the induction motor power data.

Author
Thales Lima Oliveira thale.nosp@m.s@uf.nosp@m.u.br
Date
05/10/2017

Definition at line 31 of file IndMotorForm.h.

Constructor & Destructor Documentation

◆ IndMotorForm()

IndMotorForm::IndMotorForm ( wxWindow *  parent,
IndMotor indMotor 
)

Definition at line 22 of file IndMotorForm.cpp.

22 : IndMotorFormBase(parent)
23{
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'));
27 IndMotorElectricalData data = indMotor->GetElectricalData();
28
29 m_textCtrlName->SetValue(data.name);
30
31 m_textCtrlnominalPower->SetValue(IndMotor::StringFromDouble(data.ratedPower));
32 switch(data.activePowerUnit) {
34 m_choiceNominalPower->SetSelection(0);
35 } break;
37 m_choiceNominalPower->SetSelection(1);
38 } break;
40 m_choiceNominalPower->SetSelection(2);
41 } break;
42 default:
43 break;
44 }
45
46 m_textCtrlActivePower->SetValue(IndMotor::StringFromDouble(data.activePower));
47 switch(data.activePowerUnit) {
49 m_choiceActivePower->SetSelection(0);
50 } break;
52 m_choiceActivePower->SetSelection(1);
53 } break;
55 m_choiceActivePower->SetSelection(2);
56 } break;
58 m_choiceActivePower->SetSelection(3);
59 } break;
60 default:
61 break;
62 }
63
64 m_textCtrlReactivePower->SetValue(IndMotor::StringFromDouble(data.reactivePower));
65 switch(data.reactivePowerUnit) {
67 m_choiceReactivePower->SetSelection(0);
68 } break;
70 m_choiceReactivePower->SetSelection(1);
71 } break;
73 m_choiceReactivePower->SetSelection(2);
74 } break;
76 m_choiceReactivePower->SetSelection(3);
77 } break;
78 default:
79 break;
80 }
81
82 m_checkBoxComputeQ->SetValue(data.calcQInPowerFlow);
83 m_checkBoxUseMachinePower->SetValue(data.useMachinePowerAsBase);
84
85 // Stability
86 m_checkBoxPlotIndMachine->SetValue(data.plotIndMachine);
87 m_textCtrlInertia->SetValue(IndMotor::StringFromDouble(data.inertia));
88 m_textCtrlStatorResistence->SetValue(IndMotor::StringFromDouble(data.r1));
89 m_textCtrlStatorReactance->SetValue(IndMotor::StringFromDouble(data.x1));
90 m_textCtrlRotorResistence->SetValue(IndMotor::StringFromDouble(data.r2));
91 m_textCtrlRotorReactance->SetValue(IndMotor::StringFromDouble(data.x2));
92 m_textCtrlMagnetizingReactance->SetValue(IndMotor::StringFromDouble(data.xm));
93 m_checkBoxUseKf->SetValue(data.useKf);
94 m_textCtrlKf->SetValue(IndMotor::StringFromDouble(data.kf));
95 m_textCtrlKf->Enable(data.useKf);
96
97 m_textCtrlA->SetValue(IndMotor::StringFromDouble(data.aw));
98 m_textCtrlB->SetValue(IndMotor::StringFromDouble(data.bw));
99 m_textCtrlC->SetValue(IndMotor::StringFromDouble(data.cw));
100
101 m_parent = parent;
102 m_indMotor = indMotor;
103
104 UpdateFields();
105}
static wxString StringFromDouble(double value, int minDecimal=1, int maxDecimals=13)
Convert a double value to string.
Definition Element.cpp:533

◆ ~IndMotorForm()

IndMotorForm::~IndMotorForm ( )
virtual

Definition at line 107 of file IndMotorForm.cpp.

107{}

Member Function Documentation

◆ OnCalcQInPFClick()

void IndMotorForm::OnCalcQInPFClick ( wxCommandEvent &  event)
protectedvirtual

Definition at line 231 of file IndMotorForm.cpp.

231{ UpdateFields(); }

◆ OnCancelButtonClick()

virtual void IndMotorForm::OnCancelButtonClick ( wxCommandEvent &  event)
inlineprotectedvirtual

Definition at line 41 of file IndMotorForm.h.

41{ EndModal(wxID_CANCEL); };

◆ OnCheckboxUseCageFactorClick()

void IndMotorForm::OnCheckboxUseCageFactorClick ( wxCommandEvent &  event)
protectedvirtual

Definition at line 230 of file IndMotorForm.cpp.

230{ UpdateFields(); }

◆ OnOKButtonClick()

void IndMotorForm::OnOKButtonClick ( wxCommandEvent &  event)
protectedvirtual

Definition at line 108 of file IndMotorForm.cpp.

109{
110 if(ValidateData()) EndModal(wxID_OK);
111}

◆ OnStabilityButtonClick()

void IndMotorForm::OnStabilityButtonClick ( wxCommandEvent &  event)
protectedvirtual

Definition at line 112 of file IndMotorForm.cpp.

113{
114 if(ValidateData()) {
115 SwitchingForm swForm(m_parent, m_indMotor);
116 swForm.SetTitle(_("Induction motor: Switching"));
117 swForm.ShowModal();
118 EndModal(wxID_OK);
119 }
120}
Form to edit the switching data of power elements for electromechanical transient studies.

◆ UpdateFields()

void IndMotorForm::UpdateFields ( )
protected

Definition at line 233 of file IndMotorForm.cpp.

234{
235 m_textCtrlKf->Enable(m_checkBoxUseKf->GetValue());
236 m_textCtrlReactivePower->Enable(!m_checkBoxComputeQ->GetValue());
237 m_choiceReactivePower->Enable(!m_checkBoxComputeQ->GetValue());
238}

◆ ValidateData()

bool IndMotorForm::ValidateData ( )
virtual

Definition at line 122 of file IndMotorForm.cpp.

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: {
133 data.activePowerUnit = ElectricalUnit::UNIT_VA;
134 } break;
135 case 1: {
136 data.activePowerUnit = ElectricalUnit::UNIT_kVA;
137 } break;
138 case 2: {
139 data.activePowerUnit = ElectricalUnit::UNIT_MVA;
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: {
148 data.activePowerUnit = ElectricalUnit::UNIT_PU;
149 } break;
150 case 1: {
151 data.activePowerUnit = ElectricalUnit::UNIT_W;
152 } break;
153 case 2: {
154 data.activePowerUnit = ElectricalUnit::UNIT_kW;
155 } break;
156 case 3: {
157 data.activePowerUnit = ElectricalUnit::UNIT_MW;
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: {
166 data.reactivePowerUnit = ElectricalUnit::UNIT_PU;
167 } break;
168 case 1: {
169 data.reactivePowerUnit = ElectricalUnit::UNIT_var;
170 } break;
171 case 2: {
172 data.reactivePowerUnit = ElectricalUnit::UNIT_kvar;
173 } break;
174 case 3: {
175 data.reactivePowerUnit = ElectricalUnit::UNIT_Mvar;
176 } break;
177 }
178
179 data.calcQInPowerFlow = m_checkBoxComputeQ->GetValue();
180 data.useMachinePowerAsBase = m_checkBoxUseMachinePower->GetValue();
181
182 // Stability
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 ") +
221 m_indMotor->StringFromDouble(sum);
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.
Definition Element.cpp:505

Member Data Documentation

◆ m_indMotor

IndMotor* IndMotorForm::m_indMotor = nullptr
protected

Definition at line 48 of file IndMotorForm.h.

◆ m_parent

wxWindow* IndMotorForm::m_parent = nullptr
protected

Definition at line 47 of file IndMotorForm.h.


The documentation for this class was generated from the following files: