20#include "../elements/powerElement/Load.h"
22LoadForm::LoadForm(wxWindow* parent,
Load* load) : LoadFormBase(parent)
24 SetSize(GetBestSize());
27 m_textCtrlName->SetValue(data.name);
30 switch(data.activePowerUnit) {
32 m_choiceActivePower->SetSelection(0);
35 m_choiceActivePower->SetSelection(1);
38 m_choiceActivePower->SetSelection(2);
41 m_choiceActivePower->SetSelection(3);
48 switch(data.reactivePowerUnit) {
50 m_choiceReactivePower->SetSelection(0);
53 m_choiceReactivePower->SetSelection(1);
56 m_choiceReactivePower->SetSelection(2);
59 m_choiceReactivePower->SetSelection(3);
65 switch(data.loadType) {
67 m_choiceType->SetSelection(0);
69 case CONST_IMPEDANCE: {
70 m_choiceType->SetSelection(1);
74 m_checkBoxPlotData->SetValue(data.plotLoad);
76 m_checkBoxUseCompLoad->SetValue(data.useCompLoad);
88 UpdateZIPLoadFieldStatus();
91LoadForm::~LoadForm() {}
92void LoadForm::OnOnButtonClick(wxCommandEvent& event)
94 if(ValidateData()) EndModal(wxID_OK);
97void LoadForm::OnStabilityButtonClick(wxCommandEvent& event)
101 swForm.SetTitle(_(
"Load: Switching"));
107bool LoadForm::ValidateData()
111 data.name = m_textCtrlName->GetValue();
113 if(!m_load->
DoubleFromString(m_parent, m_textCtrlActivePower->GetValue(), data.activePower,
114 _(
"Value entered incorrectly in the field \"Active power\".")))
116 switch(m_choiceActivePower->GetSelection()) {
131 if(!m_load->
DoubleFromString(m_parent, m_textCtrlReactivePower->GetValue(), data.reactivePower,
132 _(
"Value entered incorrectly in the field \"Reactive power\".")))
134 switch(m_choiceReactivePower->GetSelection()) {
149 switch(m_choiceType->GetSelection()) {
151 data.loadType = CONST_POWER;
154 data.loadType = CONST_IMPEDANCE;
158 data.plotLoad = m_checkBoxPlotData->GetValue();
160 data.useCompLoad = m_checkBoxUseCompLoad->GetValue();
163 this, m_textCtrlActivePowerImp->GetValue(), data.constImpedanceActive,
164 _(
"Value entered incorrectly in the field \"Constant impedance portion of active power\".")))
167 this, m_textCtrlActivePowerCur->GetValue(), data.constCurrentActive,
168 _(
"Value entered incorrectly in the field \"Constant current portion of active power\".")))
171 this, m_textCtrlActivePowerPow->GetValue(), data.constPowerActive,
172 _(
"Value entered incorrectly in the field \"Constant power portion of active power\".")))
175 this, m_textCtrlReactivePowerImp->GetValue(), data.constImpedanceReactive,
176 _(
"Value entered incorrectly in the field \"Constant impedance portion of reactive power\".")))
179 this, m_textCtrlReactivePowerCur->GetValue(), data.constCurrentReactive,
180 _(
"Value entered incorrectly in the field \"Constant current portion of reactive power\".")))
183 this, m_textCtrlReactivePowerPow->GetValue(), data.constPowerReactive,
184 _(
"Value entered incorrectly in the field \"Constant power portion of reactive power\".")))
187 double sum = data.constImpedanceActive + data.constCurrentActive + data.constPowerActive;
188 if(sum > 100.01 || sum < 99.99) {
189 wxMessageDialog msgDialog(
this, _(
"The sum of active power load composition must be 100%."), _(
"Error"),
190 wxOK | wxCENTRE | wxICON_ERROR);
191 msgDialog.ShowModal();
194 sum = data.constImpedanceReactive + data.constCurrentReactive + data.constPowerReactive;
195 if(sum > 100.01 || sum < 99.99) {
196 wxMessageDialog msgDialog(
this, _(
"The sum of reactive power load composition must be 100%."), _(
"Error"),
197 wxOK | wxCENTRE | wxICON_ERROR);
198 msgDialog.ShowModal();
202 m_load->SetElectricalData(data);
206void LoadForm::UpdateZIPLoadFieldStatus()
208 m_textCtrlActivePowerImp->Enable(m_checkBoxUseCompLoad->GetValue());
209 m_textCtrlActivePowerCur->Enable(m_checkBoxUseCompLoad->GetValue());
210 m_textCtrlActivePowerPow->Enable(m_checkBoxUseCompLoad->GetValue());
211 m_textCtrlReactivePowerImp->Enable(m_checkBoxUseCompLoad->GetValue());
212 m_textCtrlReactivePowerCur->Enable(m_checkBoxUseCompLoad->GetValue());
213 m_textCtrlReactivePowerPow->Enable(m_checkBoxUseCompLoad->GetValue());
static bool DoubleFromString(wxWindow *parent, wxString strValue, double &value, wxString errorMsg)
Get a double value from a string. Show a error message if the conversion fail.
static wxString StringFromDouble(double value, int minDecimal=1, int maxDecimals=13)
Convert a double value to string.
Loas shunt power element.