diff options
author | Thales Lima Oliveira <thaleslima.ufu@gmail.com> | 2017-11-07 21:59:43 -0200 |
---|---|---|
committer | Thales Lima Oliveira <thaleslima.ufu@gmail.com> | 2017-11-07 21:59:43 -0200 |
commit | b23a673fbe5cfd322956cdff8ef3472da8e0dbff (patch) | |
tree | 8a29fd584941228fd894050f37db876dfe0d02df /Project/SimulationsSettingsForm.cpp | |
parent | 24808d2de827f219b683ad46744a179ae25bc859 (diff) | |
download | PSP.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/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()); +} |