summaryrefslogtreecommitdiffstats
path: root/Project/LoadForm.cpp
diff options
context:
space:
mode:
authorThales Lima Oliveira <thaleslima.ufu@gmail.com>2017-11-07 21:59:43 -0200
committerThales Lima Oliveira <thaleslima.ufu@gmail.com>2017-11-07 21:59:43 -0200
commitb23a673fbe5cfd322956cdff8ef3472da8e0dbff (patch)
tree8a29fd584941228fd894050f37db876dfe0d02df /Project/LoadForm.cpp
parent24808d2de827f219b683ad46744a179ae25bc859 (diff)
downloadPSP.git-b23a673fbe5cfd322956cdff8ef3472da8e0dbff.tar.gz
PSP.git-b23a673fbe5cfd322956cdff8ef3472da8e0dbff.tar.xz
PSP.git-b23a673fbe5cfd322956cdff8ef3472da8e0dbff.zip
ZIP load fully implemented
Need to save the new data
Diffstat (limited to 'Project/LoadForm.cpp')
-rw-r--r--Project/LoadForm.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/Project/LoadForm.cpp b/Project/LoadForm.cpp
index 67fd356..ca73ba5 100644
--- a/Project/LoadForm.cpp
+++ b/Project/LoadForm.cpp
@@ -71,8 +71,21 @@ LoadForm::LoadForm(wxWindow* parent, Load* load) : LoadFormBase(parent)
} break;
}
+ m_checkBoxPlotData->SetValue(data.plotLoad);
+
+ m_checkBoxUseCompLoad->SetValue(data.useCompLoad);
+
+ m_textCtrlActivePowerImp->SetValue(Element::StringFromDouble(data.constImpedanceActive));
+ m_textCtrlActivePowerCur->SetValue(Element::StringFromDouble(data.constCurrentActive));
+ m_textCtrlActivePowerPow->SetValue(Element::StringFromDouble(data.constPowerActive));
+ m_textCtrlReactivePowerImp->SetValue(Element::StringFromDouble(data.constImpedanceReactive));
+ m_textCtrlReactivePowerCur->SetValue(Element::StringFromDouble(data.constCurrentReactive));
+ m_textCtrlReactivePowerPow->SetValue(Element::StringFromDouble(data.constPowerReactive));
+
m_parent = parent;
m_load = load;
+
+ UpdateZIPLoadFieldStatus();
}
LoadForm::~LoadForm() {}
@@ -142,6 +155,60 @@ bool LoadForm::ValidateData()
} break;
}
+ data.plotLoad = m_checkBoxPlotData->GetValue();
+
+ data.useCompLoad = m_checkBoxUseCompLoad->GetValue();
+
+ if(!Element::DoubleFromString(
+ this, m_textCtrlActivePowerImp->GetValue(), data.constImpedanceActive,
+ _("Value entered incorrectly in the field \"Constant impedance portion of active power\".")))
+ return false;
+ if(!Element::DoubleFromString(
+ this, m_textCtrlActivePowerCur->GetValue(), data.constCurrentActive,
+ _("Value entered incorrectly in the field \"Constant current portion of active power\".")))
+ return false;
+ if(!Element::DoubleFromString(
+ this, m_textCtrlActivePowerPow->GetValue(), data.constPowerActive,
+ _("Value entered incorrectly in the field \"Constant power portion of active power\".")))
+ return false;
+ if(!Element::DoubleFromString(
+ this, m_textCtrlReactivePowerImp->GetValue(), data.constImpedanceReactive,
+ _("Value entered incorrectly in the field \"Constant impedance portion of reactive power\".")))
+ return false;
+ if(!Element::DoubleFromString(
+ this, m_textCtrlReactivePowerCur->GetValue(), data.constCurrentReactive,
+ _("Value entered incorrectly in the field \"Constant current portion of reactive power\".")))
+ return false;
+ if(!Element::DoubleFromString(
+ this, m_textCtrlReactivePowerPow->GetValue(), data.constPowerReactive,
+ _("Value entered incorrectly in the field \"Constant power portion of reactive power\".")))
+ return false;
+
+ double sum = data.constImpedanceActive + data.constCurrentActive + data.constPowerActive;
+ if(sum > 100.01 || sum < 99.99) {
+ wxMessageDialog msgDialog(this, _("The sum of active power load composition must be 100%."), _("Error"),
+ wxOK | wxCENTRE | wxICON_ERROR);
+ msgDialog.ShowModal();
+ return false;
+ }
+ sum = data.constImpedanceReactive + data.constCurrentReactive + data.constPowerReactive;
+ if(sum > 100.01 || sum < 99.99) {
+ wxMessageDialog msgDialog(this, _("The sum of reactive power load composition must be 100%."), _("Error"),
+ wxOK | wxCENTRE | wxICON_ERROR);
+ msgDialog.ShowModal();
+ return false;
+ }
+
m_load->SetElectricalData(data);
return true;
}
+
+void LoadForm::UpdateZIPLoadFieldStatus()
+{
+ m_textCtrlActivePowerImp->Enable(m_checkBoxUseCompLoad->GetValue());
+ m_textCtrlActivePowerCur->Enable(m_checkBoxUseCompLoad->GetValue());
+ m_textCtrlActivePowerPow->Enable(m_checkBoxUseCompLoad->GetValue());
+ m_textCtrlReactivePowerImp->Enable(m_checkBoxUseCompLoad->GetValue());
+ m_textCtrlReactivePowerCur->Enable(m_checkBoxUseCompLoad->GetValue());
+ m_textCtrlReactivePowerPow->Enable(m_checkBoxUseCompLoad->GetValue());
+}