diff options
author | Thales Lima Oliveira <thaleslima.ufu@gmail.com> | 2017-11-08 19:24:39 -0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-08 19:24:39 -0200 |
commit | 879830d81c4d01084990e655028b60fd01bcc244 (patch) | |
tree | 5497752183130eeb282506ae2dda7ad196ea2509 /Project/SimulationsSettingsForm.cpp | |
parent | 24808d2de827f219b683ad46744a179ae25bc859 (diff) | |
parent | 3f2f03cc1aac38ad880c0859707b30654a3c935c (diff) | |
download | PSP.git-879830d81c4d01084990e655028b60fd01bcc244.tar.gz PSP.git-879830d81c4d01084990e655028b60fd01bcc244.tar.xz PSP.git-879830d81c4d01084990e655028b60fd01bcc244.zip |
Merge pull request #41 from Thales1330/wip/zip-load
Wip zip load
Diffstat (limited to 'Project/SimulationsSettingsForm.cpp')
-rw-r--r-- | Project/SimulationsSettingsForm.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/Project/SimulationsSettingsForm.cpp b/Project/SimulationsSettingsForm.cpp index a203662..174b614 100644 --- a/Project/SimulationsSettingsForm.cpp +++ b/Project/SimulationsSettingsForm.cpp @@ -65,6 +65,20 @@ SimulationsSettingsForm::SimulationsSettingsForm(wxWindow* parent, PropertiesDat m_textCtrlPrintTime->SetValue(wxString::Format("%g", data.plotTime)); m_checkBoxUseCOI->SetValue(data.useCOI); + + m_checkBoxUseCompLoads->SetValue(data.useCompLoads); + + 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_textCtrlUVCur->SetValue(Element::StringFromDouble(data.underVoltageConstCurrent)); + m_textCtrlUVPow->SetValue(Element::StringFromDouble(data.underVoltageConstPower)); + + UpdateZIPLoadFieldStatus(); } SimulationsSettingsForm::~SimulationsSettingsForm() {} @@ -132,9 +146,62 @@ bool SimulationsSettingsForm::ValidateData() return false; data.useCOI = m_checkBoxUseCOI->GetValue(); + data.useCompLoads = m_checkBoxUseCompLoads->GetValue(); + + if(!Element::DoubleFromString( + this, m_textCtrlActivePowerImp->GetValue(), data.constImpedanceActive, + _("Value entered incorrectly in the field \"Constant impedance portion of active power (ZIP load)\"."))) + return false; + if(!Element::DoubleFromString( + this, m_textCtrlActivePowerCur->GetValue(), data.constCurrentActive, + _("Value entered incorrectly in the field \"Constant current portion of active power (ZIP load)\"."))) + return false; + if(!Element::DoubleFromString( + this, m_textCtrlActivePowerPow->GetValue(), data.constPowerActive, + _("Value entered incorrectly in the field \"Constant power portion of active power (ZIP load)\"."))) + return false; + if(!Element::DoubleFromString( + this, m_textCtrlReactivePowerImp->GetValue(), data.constImpedanceReactive, + _("Value entered incorrectly in the field \"Constant impedance portion of reactive power (ZIP load)\"."))) + return false; + if(!Element::DoubleFromString( + this, m_textCtrlReactivePowerCur->GetValue(), data.constCurrentReactive, + _("Value entered incorrectly in the field \"Constant current portion of reactive power (ZIP load)\"."))) + return false; + if(!Element::DoubleFromString( + this, m_textCtrlReactivePowerPow->GetValue(), data.constPowerReactive, + _("Value entered incorrectly in the field \"Constant power portion of reactive power (ZIP load)\"."))) + return false; + + if(!Element::DoubleFromString( + this, m_textCtrlUVCur->GetValue(), data.underVoltageConstCurrent, + _("Value entered incorrectly in the field \"Constant current undervoltage limit (ZIP load)\"."))) + return false; + + if(!Element::DoubleFromString( + this, m_textCtrlUVPow->GetValue(), data.underVoltageConstPower, + _("Value entered incorrectly in the field \"Constant power undervoltage limit (ZIP load)\"."))) + 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_properties->SetSimulationPropertiesData(data); return true; } + void SimulationsSettingsForm::OnPFMethodChoiceSelected(wxCommandEvent& event) { if(m_choicePFMethod->GetSelection() == 0) @@ -142,3 +209,13 @@ void SimulationsSettingsForm::OnPFMethodChoiceSelected(wxCommandEvent& event) else m_textCtrlAccFactor->Enable(false); } + +void SimulationsSettingsForm::UpdateZIPLoadFieldStatus() +{ + m_textCtrlActivePowerImp->Enable(m_checkBoxUseCompLoads->GetValue()); + m_textCtrlActivePowerCur->Enable(m_checkBoxUseCompLoads->GetValue()); + m_textCtrlActivePowerPow->Enable(m_checkBoxUseCompLoads->GetValue()); + m_textCtrlReactivePowerImp->Enable(m_checkBoxUseCompLoads->GetValue()); + m_textCtrlReactivePowerCur->Enable(m_checkBoxUseCompLoads->GetValue()); + m_textCtrlReactivePowerPow->Enable(m_checkBoxUseCompLoads->GetValue()); +} |