summaryrefslogtreecommitdiffstats
path: root/Project/IndMotorForm.cpp
diff options
context:
space:
mode:
authorThales Lima Oliveira <thaleslima.ufu@gmail.com>2019-07-10 14:14:30 -0300
committerThales Lima Oliveira <thaleslima.ufu@gmail.com>2019-07-10 14:14:30 -0300
commitf54297e08079fe1954920ca2742b0bed19f86181 (patch)
tree2022c968210fa803eb09c6e1faa3f3e6985af895 /Project/IndMotorForm.cpp
parent2b02ef22cc5f2025b09b700f1cb6e1cec94d80f6 (diff)
downloadPSP.git-f54297e08079fe1954920ca2742b0bed19f86181.tar.gz
PSP.git-f54297e08079fe1954920ca2742b0bed19f86181.tar.xz
PSP.git-f54297e08079fe1954920ca2742b0bed19f86181.zip
Induction motor implementation start
Machine initialization implemented. It seems that it's working. Check a OMIB with the motor.
Diffstat (limited to 'Project/IndMotorForm.cpp')
-rw-r--r--Project/IndMotorForm.cpp97
1 files changed, 94 insertions, 3 deletions
diff --git a/Project/IndMotorForm.cpp b/Project/IndMotorForm.cpp
index d758c18..5b91f0a 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,20 @@ IndMotorForm::IndMotorForm(wxWindow* parent, IndMotor* indMotor) : IndMotorFormB
break;
}
+ m_checkBoxUseMachinePower->SetValue(data.useMachinePowerAsBase);
+
+ // Stability
+ 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_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 +104,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 +118,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 +169,46 @@ bool IndMotorForm::ValidateData()
} break;
}
+ data.useMachinePowerAsBase = m_checkBoxUseMachinePower->GetValue();
+
+ // Stability
+ 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;
+
+ 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;
+ if(sum > 1.01 || sum < 0.99) {
+ wxString errorMsg = _("The sum of the portions of the torque must be unitary");
+ wxMessageDialog msgDialog(m_parent, errorMsg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR);
+ msgDialog.ShowModal();
+ return false;
+ }*/
+
m_indMotor->SetElectricalData(data);
return true;
}