Power System Platform  2026w23a-beta
Loading...
Searching...
No Matches
SimulationsSettingsForm Class Reference

Form to edit the simulation data. More...

#include <SimulationsSettingsForm.h>

Inheritance diagram for SimulationsSettingsForm:
Collaboration diagram for SimulationsSettingsForm:

Public Member Functions

 SimulationsSettingsForm (wxWindow *parent, PropertiesData *properties, wxLocale *locale)
 

Protected Member Functions

virtual void OnBusFreqEstimationSelect (wxCommandEvent &event)
 
virtual void OnCheckboxUseCompLoadClick (wxCommandEvent &event)
 
virtual void OnPFMethodChoiceSelected (wxCommandEvent &event)
 
virtual void OnButtonCancelClick (wxCommandEvent &event)
 
virtual void OnButtonOKClick (wxCommandEvent &event)
 
virtual bool ValidateData ()
 
virtual void UpdateZIPLoadFieldStatus ()
 
virtual void UpdatePFFieldStatus ()
 
virtual void UpdateBusFreqFieldStatus ()
 

Protected Attributes

PropertiesDatam_properties
 

Detailed Description

Form to edit the simulation data.

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

Definition at line 32 of file SimulationsSettingsForm.h.

Constructor & Destructor Documentation

◆ SimulationsSettingsForm()

SimulationsSettingsForm::SimulationsSettingsForm ( wxWindow *  parent,
PropertiesData properties,
wxLocale *  locale 
)

Definition at line 23 of file SimulationsSettingsForm.cpp.

24 : SimulationsSettingsFormBase(parent)
25{
26 m_properties = properties;
27 auto data = m_properties->GetSimulationPropertiesData();
28
29 m_textCtrlbasePower->SetValue(Element::StringFromDouble(data.basePower));
30 switch (data.basePowerUnit) {
31 case ElectricalUnit::UNIT_VA: {
32 m_choiceBasePower->SetSelection(0);
33 } break;
34 case ElectricalUnit::UNIT_kVA: {
35 m_choiceBasePower->SetSelection(1);
36 } break;
37 case ElectricalUnit::UNIT_MVA: {
38 m_choiceBasePower->SetSelection(2);
39 } break;
40 default: {
41 m_choiceBasePower->SetSelection(wxNOT_FOUND);
42 } break;
43 }
44 m_checkBoxFaultAfterPF->SetValue(data.faultAfterPowerFlow);
45 m_checkBoxSCPowerAfterPF->SetValue(data.scPowerAfterPowerFlow);
46 m_checkBoxTHDAfterPF->SetValue(data.harmDistortionAfterPowerFlow);
47 switch (data.powerFlowMethod) {
48 case NEWTON_RAPHSON : {
49 m_choicePFMethod->SetSelection(0);
50 } break;
51 case GAUSS_SEIDEL: {
52 m_choicePFMethod->SetSelection(1);
53 } break;
54 case GAUSS_NEWTON: {
55 m_choicePFMethod->SetSelection(2);
56 } break;
57 default: {
58 m_choicePFMethod->SetSelection(wxNOT_FOUND);
59 } break;
60 }
61 m_textCtrlAccFactor->SetValue(Element::StringFromDouble(data.accFator));
62 m_textCtrlPFTolerance->SetValue(wxString::Format("%g", data.powerFlowTolerance));
63 m_textCtrlPFMaxIterations->SetValue(wxString::Format("%d", data.powerFlowMaxIterations));
64 m_textCtrlPFSlackBusAngle->SetValue(Element::StringFromDouble(data.initAngle));
65 m_textCtrlPFNewtonInertia->SetValue(Element::StringFromDouble(data.newtonInertia));
66 m_textCtrlPFGaussTolerance->SetValue(wxString::Format("%g", data.gaussTolerance));
67 m_textCtrlTimeStep->SetValue(wxString::Format("%g", data.timeStep));
68 m_textCtrlSimTime->SetValue(Element::StringFromDouble(data.stabilitySimulationTime));
69 m_textCtrlFreq->SetValue(Element::StringFromDouble(data.stabilityFrequency));
70 m_textCtrlStabTolerance->SetValue(wxString::Format("%g", data.stabilityTolerance));
71 m_textCtrlStabMaxIterations->SetValue(wxString::Format("%d", data.stabilityMaxIterations));
72 m_textCtrlCtrlStepRatio->SetValue(wxString::Format("%d", data.controlTimeStepRatio));
73 m_textCtrlPrintTime->SetValue(wxString::Format("%g", data.plotTime));
74
75 m_checkBoxUseCOI->SetValue(data.useCOI);
76
77 m_checkBoxUseCompLoads->SetValue(data.useCompLoads);
78
79 m_textCtrlActivePowerImp->SetValue(Element::StringFromDouble(data.constImpedanceActive));
80 m_textCtrlActivePowerCur->SetValue(Element::StringFromDouble(data.constCurrentActive));
81 m_textCtrlActivePowerPow->SetValue(Element::StringFromDouble(data.constPowerActive));
82 m_textCtrlReactivePowerImp->SetValue(Element::StringFromDouble(data.constImpedanceReactive));
83 m_textCtrlReactivePowerCur->SetValue(Element::StringFromDouble(data.constCurrentReactive));
84 m_textCtrlReactivePowerPow->SetValue(Element::StringFromDouble(data.constPowerReactive));
85
86 m_textCtrlUVCur->SetValue(Element::StringFromDouble(data.underVoltageConstCurrent));
87 m_textCtrlUVPow->SetValue(Element::StringFromDouble(data.underVoltageConstPower));
88
89 m_radioBoxBusFreqEstimation->SetSelection(static_cast<int>(data.busFreqEstimation));
90 m_checkBoxBusFreqIgnoreEvent->SetValue(data.ignoreBusFreqEventStep);
91 m_textCtrlTf->SetValue(Element::StringFromDouble(data.tf));
92 m_textCtrlTw->SetValue(Element::StringFromDouble(data.tw));
93
94 m_choiceHarmLoadConn->SetSelection(static_cast<int>(data.harmLoadConnection));
95
96 if (locale->GetCanonicalName() == wxT("pt_BR")) {
97 wxBitmap wfDiagram;
98 wfDiagram.LoadFile(Paths::GetDataPath() + "/images/WF-pt.png", wxBITMAP_TYPE_PNG);
99 m_staticBitmapDiagram->SetBitmap(wfDiagram);
100 }
101
102 UpdateZIPLoadFieldStatus();
103 UpdatePFFieldStatus();
104 UpdateBusFreqFieldStatus();
105}
static wxString StringFromDouble(double value, int minDecimal=1, int maxDecimals=13)
Convert a double value to string.
Definition Element.cpp:466

◆ ~SimulationsSettingsForm()

SimulationsSettingsForm::~SimulationsSettingsForm ( )
virtual

Definition at line 107 of file SimulationsSettingsForm.cpp.

107{}

Member Function Documentation

◆ OnBusFreqEstimationSelect()

void SimulationsSettingsForm::OnBusFreqEstimationSelect ( wxCommandEvent &  event)
protectedvirtual

Definition at line 301 of file SimulationsSettingsForm.cpp.

302{
303 UpdateBusFreqFieldStatus();
304}

◆ OnButtonCancelClick()

virtual void SimulationsSettingsForm::OnButtonCancelClick ( wxCommandEvent &  event)
inlineprotectedvirtual

Definition at line 42 of file SimulationsSettingsForm.h.

42{ EndModal(wxID_CANCEL); }

◆ OnButtonOKClick()

void SimulationsSettingsForm::OnButtonOKClick ( wxCommandEvent &  event)
protectedvirtual

Definition at line 108 of file SimulationsSettingsForm.cpp.

109{
110 if (ValidateData()) EndModal(wxID_OK);
111}

◆ OnCheckboxUseCompLoadClick()

virtual void SimulationsSettingsForm::OnCheckboxUseCompLoadClick ( wxCommandEvent &  event)
inlineprotectedvirtual

Definition at line 40 of file SimulationsSettingsForm.h.

40{ UpdateZIPLoadFieldStatus(); }

◆ OnPFMethodChoiceSelected()

void SimulationsSettingsForm::OnPFMethodChoiceSelected ( wxCommandEvent &  event)
protectedvirtual

Definition at line 262 of file SimulationsSettingsForm.cpp.

262{ UpdatePFFieldStatus(); }

◆ UpdateBusFreqFieldStatus()

void SimulationsSettingsForm::UpdateBusFreqFieldStatus ( )
protectedvirtual

Definition at line 289 of file SimulationsSettingsForm.cpp.

290{
291 bool visible = true;
292 if (m_radioBoxBusFreqEstimation->GetSelection() == 0) visible = false;
293 m_checkBoxBusFreqIgnoreEvent->Show(!visible);
294 m_staticTextTf->Show(visible);
295 m_textCtrlTf->Show(visible);
296 m_staticTextTw->Show(visible);
297 m_textCtrlTw->Show(visible);
298 m_staticBitmapDiagram->Show(visible);
299}

◆ UpdatePFFieldStatus()

void SimulationsSettingsForm::UpdatePFFieldStatus ( )
protectedvirtual

Definition at line 274 of file SimulationsSettingsForm.cpp.

275{
276 if (m_choicePFMethod->GetSelection() == 1 || m_choicePFMethod->GetSelection() == 2)
277 m_textCtrlAccFactor->Enable();
278 else
279 m_textCtrlAccFactor->Enable(false);
280 if (m_choicePFMethod->GetSelection() == 2)
281 m_textCtrlPFGaussTolerance->Enable();
282 else
283 m_textCtrlPFGaussTolerance->Enable(false);
284 if (m_choicePFMethod->GetSelection() == 0 || m_choicePFMethod->GetSelection() == 2)
285 m_textCtrlPFNewtonInertia->Enable();
286 else
287 m_textCtrlPFNewtonInertia->Enable(false);
288}

◆ UpdateZIPLoadFieldStatus()

void SimulationsSettingsForm::UpdateZIPLoadFieldStatus ( )
protectedvirtual

Definition at line 264 of file SimulationsSettingsForm.cpp.

265{
266 m_textCtrlActivePowerImp->Enable(m_checkBoxUseCompLoads->GetValue());
267 m_textCtrlActivePowerCur->Enable(m_checkBoxUseCompLoads->GetValue());
268 m_textCtrlActivePowerPow->Enable(m_checkBoxUseCompLoads->GetValue());
269 m_textCtrlReactivePowerImp->Enable(m_checkBoxUseCompLoads->GetValue());
270 m_textCtrlReactivePowerCur->Enable(m_checkBoxUseCompLoads->GetValue());
271 m_textCtrlReactivePowerPow->Enable(m_checkBoxUseCompLoads->GetValue());
272}

◆ ValidateData()

bool SimulationsSettingsForm::ValidateData ( )
protectedvirtual

Definition at line 113 of file SimulationsSettingsForm.cpp.

114{
115 auto data = m_properties->GetSimulationPropertiesData();
116 if (!Element::DoubleFromString(this, m_textCtrlbasePower->GetValue(), data.basePower,
117 _("Value entered incorrectly in the field \"Base power\".")))
118 return false;
119 switch (m_choiceBasePower->GetSelection()) {
120 case 0: {
121 data.basePowerUnit = ElectricalUnit::UNIT_VA;
122 } break;
123 case 1: {
124 data.basePowerUnit = ElectricalUnit::UNIT_kVA;
125 } break;
126 default: {
127 data.basePowerUnit = ElectricalUnit::UNIT_MVA;
128 } break;
129 }
130 data.faultAfterPowerFlow = m_checkBoxFaultAfterPF->GetValue();
131 data.scPowerAfterPowerFlow = m_checkBoxSCPowerAfterPF->GetValue();
132 data.harmDistortionAfterPowerFlow = m_checkBoxTHDAfterPF->GetValue();
133 switch (m_choicePFMethod->GetSelection()) {
134 case 0: {
135 data.powerFlowMethod = NEWTON_RAPHSON;
136 } break;
137 case 1: {
138 data.powerFlowMethod = GAUSS_SEIDEL;
139 } break;
140 case 2: {
141 data.powerFlowMethod = GAUSS_NEWTON;
142 } break;
143 }
144 if (!Element::DoubleFromString(this, m_textCtrlAccFactor->GetValue(), data.accFator,
145 _("Value entered incorrectly in the field \"Acceleration factor\".")))
146 return false;
147 if (!Element::DoubleFromString(this, m_textCtrlPFTolerance->GetValue(), data.powerFlowTolerance,
148 _("Value entered incorrectly in the field \"Tolerance (Power flow)\".")))
149 return false;
150 if (!Element::IntFromString(this, m_textCtrlPFMaxIterations->GetValue(), data.powerFlowMaxIterations,
151 _("Value entered incorrectly in the field \"Max. iterations (Power flow)\".")))
152 return false;
153 if (!Element::DoubleFromString(this, m_textCtrlPFSlackBusAngle->GetValue(), data.initAngle,
154 _("Value entered incorrectly in the field \"Slack bus angle\".")))
155 return false;
156 if (!Element::DoubleFromString(this, m_textCtrlPFNewtonInertia->GetValue(), data.newtonInertia,
157 _("Value entered incorrectly in the field \"Newton inertia (Power flow)\".")))
158 return false;
159 if (!Element::DoubleFromString(this, m_textCtrlPFGaussTolerance->GetValue(), data.gaussTolerance,
160 _("Value entered incorrectly in the field \"Gauss tolerance (Power flow)\".")))
161 return false;
162 if (!Element::DoubleFromString(this, m_textCtrlTimeStep->GetValue(), data.timeStep,
163 _("Value entered incorrectly in the field \"Time step\".")))
164 return false;
165 if (!Element::DoubleFromString(this, m_textCtrlSimTime->GetValue(), data.stabilitySimulationTime,
166 _("Value entered incorrectly in the field \"Simulation time\".")))
167 return false;
168 if (!Element::DoubleFromString(this, m_textCtrlFreq->GetValue(), data.stabilityFrequency,
169 _("Value entered incorrectly in the field \"System frequency\".")))
170 return false;
171 if (!Element::DoubleFromString(this, m_textCtrlStabTolerance->GetValue(), data.stabilityTolerance,
172 _("Value entered incorrectly in the field \"Tolerance (stability)\".")))
173 return false;
174 if (!Element::IntFromString(this, m_textCtrlStabMaxIterations->GetValue(), data.stabilityMaxIterations,
175 _("Value entered incorrectly in the field \"Max. iterations (stability)\".")))
176 return false;
177 if (!Element::IntFromString(this, m_textCtrlCtrlStepRatio->GetValue(), data.controlTimeStepRatio,
178 _("Value entered incorrectly in the field \"Controls step ratio\".")))
179 return false;
180 if (!Element::DoubleFromString(this, m_textCtrlPrintTime->GetValue(), data.plotTime,
181 _("Value entered incorrectly in the field \"Plot time\".")))
182 return false;
183 data.useCOI = m_checkBoxUseCOI->GetValue();
184
185 data.useCompLoads = m_checkBoxUseCompLoads->GetValue();
186
188 this, m_textCtrlActivePowerImp->GetValue(), data.constImpedanceActive,
189 _("Value entered incorrectly in the field \"Constant impedance portion of active power (ZIP load)\".")))
190 return false;
192 this, m_textCtrlActivePowerCur->GetValue(), data.constCurrentActive,
193 _("Value entered incorrectly in the field \"Constant current portion of active power (ZIP load)\".")))
194 return false;
196 this, m_textCtrlActivePowerPow->GetValue(), data.constPowerActive,
197 _("Value entered incorrectly in the field \"Constant power portion of active power (ZIP load)\".")))
198 return false;
200 this, m_textCtrlReactivePowerImp->GetValue(), data.constImpedanceReactive,
201 _("Value entered incorrectly in the field \"Constant impedance portion of reactive power (ZIP load)\".")))
202 return false;
204 this, m_textCtrlReactivePowerCur->GetValue(), data.constCurrentReactive,
205 _("Value entered incorrectly in the field \"Constant current portion of reactive power (ZIP load)\".")))
206 return false;
208 this, m_textCtrlReactivePowerPow->GetValue(), data.constPowerReactive,
209 _("Value entered incorrectly in the field \"Constant power portion of reactive power (ZIP load)\".")))
210 return false;
211
213 this, m_textCtrlUVCur->GetValue(), data.underVoltageConstCurrent,
214 _("Value entered incorrectly in the field \"Constant current undervoltage limit (ZIP load)\".")))
215 return false;
216
218 this, m_textCtrlUVPow->GetValue(), data.underVoltageConstPower,
219 _("Value entered incorrectly in the field \"Constant power undervoltage limit (ZIP load)\".")))
220 return false;
221
222 double sum = data.constImpedanceActive + data.constCurrentActive + data.constPowerActive;
223 if (sum > 100.01 || sum < 99.99) {
224 wxMessageDialog msgDialog(this, _("The sum of active power load composition must be 100%."), _("Error"),
225 wxOK | wxCENTRE | wxICON_ERROR);
226 msgDialog.ShowModal();
227 return false;
228 }
229 sum = data.constImpedanceReactive + data.constCurrentReactive + data.constPowerReactive;
230 if (sum > 100.01 || sum < 99.99) {
231 wxMessageDialog msgDialog(this, _("The sum of reactive power load composition must be 100%."), _("Error"),
232 wxOK | wxCENTRE | wxICON_ERROR);
233 msgDialog.ShowModal();
234 return false;
235 }
236
237 data.busFreqEstimation = static_cast<BusFreqEstimation>(m_radioBoxBusFreqEstimation->GetSelection());
238
239 if (m_checkBoxBusFreqIgnoreEvent->IsShown()) {
240 data.ignoreBusFreqEventStep = m_checkBoxBusFreqIgnoreEvent->GetValue();
241 }
242
243 if (m_textCtrlTf->IsShown()) {
245 this, m_textCtrlTf->GetValue(), data.tf,
246 _("Value entered incorrectly in the field \"Time constant Tf (Bus Frequency)\".")))
247 return false;
248 }
249 if (m_textCtrlTw->IsShown()) {
251 this, m_textCtrlTw->GetValue(), data.tw,
252 _("Value entered incorrectly in the field \"Time constant Tw (Bus Frequency)\".")))
253 return false;
254 }
255
256 data.harmLoadConnection = static_cast<HarmLoadConnection>(m_choiceHarmLoadConn->GetSelection());
257
258 m_properties->SetSimulationPropertiesData(data);
259 return true;
260}
static bool IntFromString(wxWindow *parent, wxString strValue, int &value, wxString errorMsg)
Convert a string to int. Show a error message if the conversion fail.
Definition Element.cpp:452
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:438

Member Data Documentation

◆ m_properties

PropertiesData* SimulationsSettingsForm::m_properties
protected

Definition at line 49 of file SimulationsSettingsForm.h.


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