Power System Platform  2026w10a-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 21 of file SimulationsSettingsForm.cpp.

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

◆ ~SimulationsSettingsForm()

SimulationsSettingsForm::~SimulationsSettingsForm ( )
virtual

Definition at line 105 of file SimulationsSettingsForm.cpp.

105{}

Member Function Documentation

◆ OnBusFreqEstimationSelect()

void SimulationsSettingsForm::OnBusFreqEstimationSelect ( wxCommandEvent &  event)
protectedvirtual

Definition at line 299 of file SimulationsSettingsForm.cpp.

300{
301 UpdateBusFreqFieldStatus();
302}

◆ 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 106 of file SimulationsSettingsForm.cpp.

107{
108 if (ValidateData()) EndModal(wxID_OK);
109}

◆ 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 260 of file SimulationsSettingsForm.cpp.

260{ UpdatePFFieldStatus(); }

◆ UpdateBusFreqFieldStatus()

void SimulationsSettingsForm::UpdateBusFreqFieldStatus ( )
protectedvirtual

Definition at line 287 of file SimulationsSettingsForm.cpp.

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

◆ UpdatePFFieldStatus()

void SimulationsSettingsForm::UpdatePFFieldStatus ( )
protectedvirtual

Definition at line 272 of file SimulationsSettingsForm.cpp.

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

◆ UpdateZIPLoadFieldStatus()

void SimulationsSettingsForm::UpdateZIPLoadFieldStatus ( )
protectedvirtual

Definition at line 262 of file SimulationsSettingsForm.cpp.

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

◆ ValidateData()

bool SimulationsSettingsForm::ValidateData ( )
protectedvirtual

Definition at line 111 of file SimulationsSettingsForm.cpp.

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