Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
LoadForm Class Reference

Form to edit the load power data. More...

#include <LoadForm.h>

Inheritance diagram for LoadForm:
Collaboration diagram for LoadForm:

Public Member Functions

 LoadForm (wxWindow *parent, Load *load)
 
virtual bool ValidateData ()
 

Protected Member Functions

virtual void OnCheckBoxCompLoadClick (wxCommandEvent &event)
 
virtual void OnCancelButtonClick (wxCommandEvent &event)
 
virtual void OnOnButtonClick (wxCommandEvent &event)
 
virtual void OnStabilityButtonClick (wxCommandEvent &event)
 
virtual void UpdateZIPLoadFieldStatus ()
 

Protected Attributes

wxWindow * m_parent = nullptr
 
Loadm_load = nullptr
 

Detailed Description

Form to edit the load power data.

Author
Thales Lima Oliveira thale.nosp@m.s@uf.nosp@m.u.br
Date
05/10/2017

Definition at line 32 of file LoadForm.h.

Constructor & Destructor Documentation

◆ LoadForm()

LoadForm::LoadForm ( wxWindow *  parent,
Load load 
)

Definition at line 22 of file LoadForm.cpp.

22 : LoadFormBase(parent)
23{
24 SetSize(GetBestSize());
25 LoadElectricalData data = load->GetElectricalData();
26
27 m_textCtrlName->SetValue(data.name);
28
29 m_textCtrlActivePower->SetValue(Load::StringFromDouble(data.activePower));
30 switch(data.activePowerUnit) {
32 m_choiceActivePower->SetSelection(0);
33 } break;
35 m_choiceActivePower->SetSelection(1);
36 } break;
38 m_choiceActivePower->SetSelection(2);
39 } break;
41 m_choiceActivePower->SetSelection(3);
42 } break;
43 default:
44 break;
45 }
46
47 m_textCtrlReactivePower->SetValue(Load::StringFromDouble(data.reactivePower));
48 switch(data.reactivePowerUnit) {
50 m_choiceReactivePower->SetSelection(0);
51 } break;
53 m_choiceReactivePower->SetSelection(1);
54 } break;
56 m_choiceReactivePower->SetSelection(2);
57 } break;
59 m_choiceReactivePower->SetSelection(3);
60 } break;
61 default:
62 break;
63 }
64
65 switch(data.loadType) {
66 case CONST_POWER: {
67 m_choiceType->SetSelection(0);
68 } break;
69 case CONST_IMPEDANCE: {
70 m_choiceType->SetSelection(1);
71 } break;
72 }
73
74 m_checkBoxPlotData->SetValue(data.plotLoad);
75
76 m_checkBoxUseCompLoad->SetValue(data.useCompLoad);
77
78 m_textCtrlActivePowerImp->SetValue(Element::StringFromDouble(data.constImpedanceActive));
79 m_textCtrlActivePowerCur->SetValue(Element::StringFromDouble(data.constCurrentActive));
80 m_textCtrlActivePowerPow->SetValue(Element::StringFromDouble(data.constPowerActive));
81 m_textCtrlReactivePowerImp->SetValue(Element::StringFromDouble(data.constImpedanceReactive));
82 m_textCtrlReactivePowerCur->SetValue(Element::StringFromDouble(data.constCurrentReactive));
83 m_textCtrlReactivePowerPow->SetValue(Element::StringFromDouble(data.constPowerReactive));
84
85 m_parent = parent;
86 m_load = load;
87
88 UpdateZIPLoadFieldStatus();
89}
static wxString StringFromDouble(double value, int minDecimal=1, int maxDecimals=13)
Convert a double value to string.
Definition Element.cpp:533

◆ ~LoadForm()

LoadForm::~LoadForm ( )
virtual

Definition at line 91 of file LoadForm.cpp.

91{}

Member Function Documentation

◆ OnCancelButtonClick()

virtual void LoadForm::OnCancelButtonClick ( wxCommandEvent &  event)
inlineprotectedvirtual

Definition at line 42 of file LoadForm.h.

42{ EndModal(wxID_CANCEL); };

◆ OnCheckBoxCompLoadClick()

virtual void LoadForm::OnCheckBoxCompLoadClick ( wxCommandEvent &  event)
inlineprotectedvirtual

Definition at line 41 of file LoadForm.h.

41{ UpdateZIPLoadFieldStatus(); }

◆ OnOnButtonClick()

void LoadForm::OnOnButtonClick ( wxCommandEvent &  event)
protectedvirtual

Definition at line 92 of file LoadForm.cpp.

93{
94 if(ValidateData()) EndModal(wxID_OK);
95}

◆ OnStabilityButtonClick()

void LoadForm::OnStabilityButtonClick ( wxCommandEvent &  event)
protectedvirtual

Definition at line 97 of file LoadForm.cpp.

98{
99 if(ValidateData()) {
100 SwitchingForm swForm(m_parent, m_load);
101 swForm.SetTitle(_("Load: Switching"));
102 swForm.ShowModal();
103 EndModal(wxID_OK);
104 }
105}
Form to edit the switching data of power elements for electromechanical transient studies.

◆ UpdateZIPLoadFieldStatus()

void LoadForm::UpdateZIPLoadFieldStatus ( )
protectedvirtual

Definition at line 206 of file LoadForm.cpp.

207{
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());
214}

◆ ValidateData()

bool LoadForm::ValidateData ( )
virtual

Definition at line 107 of file LoadForm.cpp.

108{
110
111 data.name = m_textCtrlName->GetValue();
112
113 if(!m_load->DoubleFromString(m_parent, m_textCtrlActivePower->GetValue(), data.activePower,
114 _("Value entered incorrectly in the field \"Active power\".")))
115 return false;
116 switch(m_choiceActivePower->GetSelection()) {
117 case 0: {
118 data.activePowerUnit = ElectricalUnit::UNIT_PU;
119 } break;
120 case 1: {
121 data.activePowerUnit = ElectricalUnit::UNIT_W;
122 } break;
123 case 2: {
124 data.activePowerUnit = ElectricalUnit::UNIT_kW;
125 } break;
126 case 3: {
127 data.activePowerUnit = ElectricalUnit::UNIT_MW;
128 } break;
129 }
130
131 if(!m_load->DoubleFromString(m_parent, m_textCtrlReactivePower->GetValue(), data.reactivePower,
132 _("Value entered incorrectly in the field \"Reactive power\".")))
133 return false;
134 switch(m_choiceReactivePower->GetSelection()) {
135 case 0: {
136 data.reactivePowerUnit = ElectricalUnit::UNIT_PU;
137 } break;
138 case 1: {
139 data.reactivePowerUnit = ElectricalUnit::UNIT_var;
140 } break;
141 case 2: {
142 data.reactivePowerUnit = ElectricalUnit::UNIT_kvar;
143 } break;
144 case 3: {
145 data.reactivePowerUnit = ElectricalUnit::UNIT_Mvar;
146 } break;
147 }
148
149 switch(m_choiceType->GetSelection()) {
150 case 0: {
151 data.loadType = CONST_POWER;
152 } break;
153 case 1: {
154 data.loadType = CONST_IMPEDANCE;
155 } break;
156 }
157
158 data.plotLoad = m_checkBoxPlotData->GetValue();
159
160 data.useCompLoad = m_checkBoxUseCompLoad->GetValue();
161
163 this, m_textCtrlActivePowerImp->GetValue(), data.constImpedanceActive,
164 _("Value entered incorrectly in the field \"Constant impedance portion of active power\".")))
165 return false;
167 this, m_textCtrlActivePowerCur->GetValue(), data.constCurrentActive,
168 _("Value entered incorrectly in the field \"Constant current portion of active power\".")))
169 return false;
171 this, m_textCtrlActivePowerPow->GetValue(), data.constPowerActive,
172 _("Value entered incorrectly in the field \"Constant power portion of active power\".")))
173 return false;
175 this, m_textCtrlReactivePowerImp->GetValue(), data.constImpedanceReactive,
176 _("Value entered incorrectly in the field \"Constant impedance portion of reactive power\".")))
177 return false;
179 this, m_textCtrlReactivePowerCur->GetValue(), data.constCurrentReactive,
180 _("Value entered incorrectly in the field \"Constant current portion of reactive power\".")))
181 return false;
183 this, m_textCtrlReactivePowerPow->GetValue(), data.constPowerReactive,
184 _("Value entered incorrectly in the field \"Constant power portion of reactive power\".")))
185 return false;
186
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();
192 return false;
193 }
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();
199 return false;
200 }
201
202 m_load->SetElectricalData(data);
203 return true;
204}
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.
Definition Element.cpp:505

Member Data Documentation

◆ m_load

Load* LoadForm::m_load = nullptr
protected

Definition at line 48 of file LoadForm.h.

◆ m_parent

wxWindow* LoadForm::m_parent = nullptr
protected

Definition at line 47 of file LoadForm.h.


The documentation for this class was generated from the following files: