diff options
author | Thales Lima Oliveira <thaleslima.ufu@gmail.com> | 2019-07-18 09:22:27 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-18 09:22:27 -0300 |
commit | 8357c081eb75147bb8f94d8b6e367d88ea3898ed (patch) | |
tree | 9d9726fdcefb917475d6b33344d2b832d4e78ef8 /Project/IndMotorForm.cpp | |
parent | 295b775ad53eb1e128b705e6028f9690dc6fa640 (diff) | |
parent | 7f46d390b8cc1d5f37560f52b222198dbc5e1225 (diff) | |
download | PSP.git-8357c081eb75147bb8f94d8b6e367d88ea3898ed.tar.gz PSP.git-8357c081eb75147bb8f94d8b6e367d88ea3898ed.tar.xz PSP.git-8357c081eb75147bb8f94d8b6e367d88ea3898ed.zip |
Merge pull request #50 from Thales1330/wip/induction-motor
Wip/induction motor
Diffstat (limited to 'Project/IndMotorForm.cpp')
-rw-r--r-- | Project/IndMotorForm.cpp | 112 |
1 files changed, 109 insertions, 3 deletions
diff --git a/Project/IndMotorForm.cpp b/Project/IndMotorForm.cpp index d758c18..6df1684 100644 --- a/Project/IndMotorForm.cpp +++ b/Project/IndMotorForm.cpp @@ -15,17 +15,34 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -#include "IndMotorForm.h" #include "IndMotor.h" +#include "IndMotorForm.h" +#include "SwitchingForm.h" IndMotorForm::IndMotorForm(wxWindow* parent, IndMotor* indMotor) : IndMotorFormBase(parent) { SetSize(GetBestSize()); - m_buttonStabButton->Enable(false); + m_staticTextw->SetLabel(static_cast<wxString>(L'\u03C9') + wxT(" +")); + m_staticTextw2->SetLabel(static_cast<wxString>(L'\u03C9') + static_cast<wxString>(L'\u00B2')); IndMotorElectricalData data = indMotor->GetElectricalData(); m_textCtrlName->SetValue(data.name); + m_textCtrlnominalPower->SetValue(IndMotor::StringFromDouble(data.ratedPower)); + switch(data.activePowerUnit) { + case UNIT_VA: { + m_choiceNominalPower->SetSelection(0); + } break; + case UNIT_kVA: { + m_choiceNominalPower->SetSelection(1); + } break; + case UNIT_MVA: { + m_choiceNominalPower->SetSelection(2); + } break; + default: + break; + } + m_textCtrlActivePower->SetValue(IndMotor::StringFromDouble(data.activePower)); switch(data.activePowerUnit) { case UNIT_PU: { @@ -62,6 +79,24 @@ IndMotorForm::IndMotorForm(wxWindow* parent, IndMotor* indMotor) : IndMotorFormB break; } + m_checkBoxUseMachinePower->SetValue(data.useMachinePowerAsBase); + + // Stability + m_checkBoxPlotIndMachine->SetValue(data.plotIndMachine); + m_textCtrlInertia->SetValue(IndMotor::StringFromDouble(data.inertia)); + m_textCtrlStatorResistence->SetValue(IndMotor::StringFromDouble(data.r1)); + m_textCtrlStatorReactance->SetValue(IndMotor::StringFromDouble(data.x1)); + m_textCtrlRotorResistence->SetValue(IndMotor::StringFromDouble(data.r2)); + m_textCtrlRotorReactance->SetValue(IndMotor::StringFromDouble(data.x2)); + m_textCtrlMagnetizingReactance->SetValue(IndMotor::StringFromDouble(data.xm)); + m_checkBoxUseKf->SetValue(data.useKf); + m_textCtrlKf->SetValue(IndMotor::StringFromDouble(data.kf)); + m_textCtrlKf->Enable(data.useKf); + + m_textCtrlA->SetValue(IndMotor::StringFromDouble(data.aw)); + m_textCtrlB->SetValue(IndMotor::StringFromDouble(data.bw)); + m_textCtrlC->SetValue(IndMotor::StringFromDouble(data.cw)); + m_parent = parent; m_indMotor = indMotor; } @@ -73,7 +108,12 @@ void IndMotorForm::OnOKButtonClick(wxCommandEvent& event) } void IndMotorForm::OnStabilityButtonClick(wxCommandEvent& event) { - // TODO: Induction motor stability form + if(ValidateData()) { + SwitchingForm swForm(m_parent, m_indMotor); + swForm.SetTitle(_("Induction motor: Switching")); + swForm.ShowModal(); + EndModal(wxID_OK); + } } bool IndMotorForm::ValidateData() @@ -82,6 +122,21 @@ bool IndMotorForm::ValidateData() data.name = m_textCtrlName->GetValue(); + if(!m_indMotor->DoubleFromString(m_parent, m_textCtrlnominalPower->GetValue(), data.ratedPower, + _("Value entered incorrectly in the field \"Rated power\"."))) + return false; + switch(m_choiceNominalPower->GetSelection()) { + case 0: { + data.activePowerUnit = UNIT_VA; + } break; + case 1: { + data.activePowerUnit = UNIT_kVA; + } break; + case 2: { + data.activePowerUnit = UNIT_MVA; + } break; + } + if(!m_indMotor->DoubleFromString(m_parent, m_textCtrlActivePower->GetValue(), data.activePower, _("Value entered incorrectly in the field \"Active power\"."))) return false; @@ -118,6 +173,57 @@ bool IndMotorForm::ValidateData() } break; } + data.useMachinePowerAsBase = m_checkBoxUseMachinePower->GetValue(); + + // Stability + data.plotIndMachine = m_checkBoxPlotIndMachine->GetValue(); + if(!m_indMotor->DoubleFromString(m_parent, m_textCtrlInertia->GetValue(), data.inertia, + _("Value entered incorrectly in the field \"Inertia\"."))) + return false; + if(!m_indMotor->DoubleFromString(m_parent, m_textCtrlStatorResistence->GetValue(), data.r1, + _("Value entered incorrectly in the field \"Stator resistence\"."))) + return false; + if(!m_indMotor->DoubleFromString(m_parent, m_textCtrlStatorReactance->GetValue(), data.x1, + _("Value entered incorrectly in the field \"Stator reactance\"."))) + return false; + if(!m_indMotor->DoubleFromString(m_parent, m_textCtrlRotorResistence->GetValue(), data.r2, + _("Value entered incorrectly in the field \"Rotor resistence\"."))) + return false; + if(!m_indMotor->DoubleFromString(m_parent, m_textCtrlRotorReactance->GetValue(), data.x2, + _("Value entered incorrectly in the field \"Rotor reactance\"."))) + return false; + if(!m_indMotor->DoubleFromString(m_parent, m_textCtrlMagnetizingReactance->GetValue(), data.xm, + _("Value entered incorrectly in the field \"Magnetizing reactance\"."))) + return false; + data.useKf = m_checkBoxUseKf->GetValue(); + if(!m_indMotor->DoubleFromString(m_parent, m_textCtrlKf->GetValue(), data.kf, + _("Value entered incorrectly in the field \"Cage factor\"."))) + return false; + + if(!m_indMotor->DoubleFromString(m_parent, m_textCtrlA->GetValue(), data.aw, + _("Value entered incorrectly in the field \"Constant torque\"."))) + return false; + if(!m_indMotor->DoubleFromString(m_parent, m_textCtrlB->GetValue(), data.bw, + _("Value entered incorrectly in the field \"Linear torque\"."))) + return false; + if(!m_indMotor->DoubleFromString(m_parent, m_textCtrlC->GetValue(), data.cw, + _("Value entered incorrectly in the field \"Quadratic torque\"."))) + return false; + + double sum = data.aw + data.bw + data.cw; + double tolerance = 1e-4; + if(sum > (1.0 + tolerance) || sum < (1.0 - tolerance)) { + wxString errorMsg = _("The sum of the torque portions must be unitary.\nThe current value is ") + + m_indMotor->StringFromDouble(sum); + wxMessageDialog msgDialog(m_parent, errorMsg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); + msgDialog.ShowModal(); + return false; + } + m_indMotor->SetElectricalData(data); return true; } +void IndMotorForm::OnCheckboxUseCageFactorClick(wxCommandEvent& event) +{ + m_textCtrlKf->Enable(m_checkBoxUseKf->GetValue()); +} |