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

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

#include <BusForm.h>

Inheritance diagram for BusForm:
Collaboration diagram for BusForm:

Public Member Functions

 BusForm (wxWindow *parent, Bus *bus)
 

Protected Member Functions

virtual void OnFaultTypeChoice (wxCommandEvent &event)
 
virtual void OnControlledVoltageClick (wxCommandEvent &event)
 
virtual void OnInsertFaultClick (wxCommandEvent &event)
 
virtual void OnInsertStabFaultClick (wxCommandEvent &event)
 
virtual void OnNominalVoltageChoice (wxCommandEvent &event)
 
virtual void OnButtonCancelClick (wxCommandEvent &event)
 
virtual void OnButtonOKClick (wxCommandEvent &event)
 
virtual void EnableCtrlVoltageFields (bool enable=true)
 
virtual void EnableFaultFields (bool enable=true)
 
virtual void EnableStabFaultFields (bool enable=true)
 
virtual void UpdateChoiceBoxes ()
 

Protected Attributes

Busm_bus = nullptr
 
wxWindow * m_parent = nullptr
 

Detailed Description

Form to edit the bus power data.

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

Definition at line 31 of file BusForm.h.

Constructor & Destructor Documentation

◆ BusForm()

BusForm::BusForm ( wxWindow *  parent,
Bus bus 
)

Definition at line 21 of file BusForm.cpp.

21 : BusFormBase(parent)
22{
23 m_choiceFaultType->SetString(0, _("Three-phase"));
24 m_choiceFaultType->SetString(1, _("Line-to-line"));
25 m_choiceFaultType->SetString(2, _("Double line-to-ground"));
26 m_choiceFaultType->SetString(3, _("Line-to-ground"));
27
28 SetSize(GetBestSize());
29
30 m_parent = parent;
31 m_bus = bus;
32
33 m_textCtrlName->SetValue(bus->GetElectricalData().name);
34 m_textCtrlNomVoltage->SetValue(bus->StringFromDouble(bus->GetElectricalData().nominalVoltage));
35
36 if(bus->GetElectricalData().nominalVoltageUnit == ElectricalUnit::UNIT_V)
37 m_choiceNomVoltage->SetSelection(0);
38 else
39 m_choiceNomVoltage->SetSelection(1);
40
41 m_checkBoxCtrlVoltage->SetValue(bus->GetElectricalData().isVoltageControlled);
42 m_textCtrlCtrlVoltage->SetValue(bus->StringFromDouble(bus->GetElectricalData().controlledVoltage));
43 m_choiceCtrlVoltage->SetSelection(bus->GetElectricalData().controlledVoltageUnitChoice);
44 m_checkBoxSlackBus->SetValue(bus->GetElectricalData().slackBus);
45
46 m_checkBoxFault->SetValue(bus->GetElectricalData().hasFault);
47 switch(bus->GetElectricalData().faultType) {
49 m_choiceFaultType->SetSelection(0);
50 } break;
52 m_choiceFaultType->SetSelection(1);
53 } break;
55 m_choiceFaultType->SetSelection(2);
56 } break;
58 m_choiceFaultType->SetSelection(3);
59 } break;
60 default:
61 break;
62 }
63 switch(bus->GetElectricalData().faultLocation) {
65 m_choiceFaultPlace->SetSelection(0);
66 } break;
68 m_choiceFaultPlace->SetSelection(1);
69 } break;
71 m_choiceFaultPlace->SetSelection(2);
72 } break;
73 default:
74 break;
75 }
76 m_textCtrlFaultResistance->SetValue(bus->StringFromDouble(bus->GetElectricalData().faultResistance));
77 m_textCtrlFaultReactance->SetValue(bus->StringFromDouble(bus->GetElectricalData().faultReactance));
78
79 m_checkBoxPlotData->SetValue(bus->GetElectricalData().plotBus);
80 m_checkBoxStabFault->SetValue(bus->GetElectricalData().stabHasFault);
81 m_textCtrlStabFaultTime->SetValue(bus->StringFromDouble(bus->GetElectricalData().stabFaultTime));
82 m_textCtrlStabFaultLength->SetValue(bus->StringFromDouble(bus->GetElectricalData().stabFaultLength));
83 m_textCtrlStabFaultResistance->SetValue(bus->StringFromDouble(bus->GetElectricalData().stabFaultResistance));
84 m_textCtrlStabFaultReactance->SetValue(bus->StringFromDouble(bus->GetElectricalData().stabFaultReactance));
85
86 EnableCtrlVoltageFields(bus->GetElectricalData().isVoltageControlled);
87 EnableFaultFields(bus->GetElectricalData().hasFault);
88 EnableStabFaultFields(bus->GetElectricalData().stabHasFault);
89
90 m_checkBoxPlotPQData->SetValue(bus->GetElectricalData().plotPQData);
91}
@ FAULT_LINE_GROUND
@ FAULT_2LINE_GROUND
@ FAULT_THREEPHASE
static wxString StringFromDouble(double value, int minDecimal=1, int maxDecimals=13)
Convert a double value to string.
Definition Element.cpp:533

◆ ~BusForm()

BusForm::~BusForm ( )
virtual

Definition at line 93 of file BusForm.cpp.

93{}

Member Function Documentation

◆ EnableCtrlVoltageFields()

void BusForm::EnableCtrlVoltageFields ( bool  enable = true)
protectedvirtual

Definition at line 187 of file BusForm.cpp.

188{
189 m_textCtrlCtrlVoltage->Enable(enable);
190 m_choiceCtrlVoltage->Enable(enable);
191
192 UpdateChoiceBoxes();
193}

◆ EnableFaultFields()

void BusForm::EnableFaultFields ( bool  enable = true)
protectedvirtual

Definition at line 195 of file BusForm.cpp.

196{
197 m_choiceFaultType->Enable(enable);
198 m_choiceFaultPlace->Enable(enable);
199 m_textCtrlFaultReactance->Enable(enable);
200 m_textCtrlFaultResistance->Enable(enable);
201 m_staticTextPU_1->Enable(enable);
202 m_staticTextPU_2->Enable(enable);
203
204 UpdateChoiceBoxes();
205}

◆ EnableStabFaultFields()

void BusForm::EnableStabFaultFields ( bool  enable = true)
protectedvirtual

Definition at line 207 of file BusForm.cpp.

208{
209 m_textCtrlStabFaultTime->Enable(enable);
210 m_textCtrlStabFaultLength->Enable(enable);
211 m_staticTextS_1->Enable(enable);
212 m_staticTextS_2->Enable(enable);
213 m_textCtrlStabFaultReactance->Enable(enable);
214 m_textCtrlStabFaultResistance->Enable(enable);
215 m_staticTextPU_3->Enable(enable);
216 m_staticTextPU_4->Enable(enable);
217}

◆ OnButtonCancelClick()

void BusForm::OnButtonCancelClick ( wxCommandEvent &  event)
protectedvirtual

Definition at line 94 of file BusForm.cpp.

94{ EndModal(wxID_CANCEL); }

◆ OnButtonOKClick()

void BusForm::OnButtonOKClick ( wxCommandEvent &  event)
protectedvirtual

Definition at line 95 of file BusForm.cpp.

96{
97 BusElectricalData data = m_bus->GetElectricalData();
98 data.name = m_textCtrlName->GetValue();
99 if(!m_bus->DoubleFromString(m_parent, m_textCtrlNomVoltage->GetValue(), data.nominalVoltage,
100 _("Value entered incorrectly in the field \"Rated voltage\".")))
101 return;
102 data.nominalVoltageUnit = m_choiceNomVoltage->GetSelection() == 0 ? ElectricalUnit::UNIT_V : ElectricalUnit::UNIT_kV;
103 data.isVoltageControlled = m_checkBoxCtrlVoltage->GetValue();
104 if(data.isVoltageControlled) {
105 if(!m_bus->DoubleFromString(m_parent, m_textCtrlCtrlVoltage->GetValue(), data.controlledVoltage,
106 _("Value entered incorrectly in the field \"Controlled voltage\".")))
107 return;
108 data.controlledVoltageUnitChoice = m_choiceCtrlVoltage->GetSelection();
109 }
110 data.slackBus = m_checkBoxSlackBus->GetValue();
111
112 data.hasFault = m_checkBoxFault->GetValue();
113 switch(m_choiceFaultType->GetSelection()) {
114 case 0: {
115 data.faultType = FaultData::FAULT_THREEPHASE;
116 } break;
117 case 1: {
118 data.faultType = FaultData::FAULT_2LINE;
119 } break;
120 case 2: {
121 data.faultType = FaultData::FAULT_2LINE_GROUND;
122 } break;
123 case 3: {
124 data.faultType = FaultData::FAULT_LINE_GROUND;
125 } break;
126 }
127
128 switch(m_choiceFaultPlace->GetSelection()) {
129 case 0: {
130 data.faultLocation = FaultData::FAULT_LINE_A;
131 } break;
132 case 1: {
133 data.faultLocation = FaultData::FAULT_LINE_B;
134 } break;
135 case 2: {
136 data.faultLocation = FaultData::FAULT_LINE_C;
137 } break;
138 }
139
140 if(!m_bus->DoubleFromString(m_parent, m_textCtrlFaultResistance->GetValue(), data.faultResistance,
141 _("Value entered incorrectly in the field \"Fault resistance\".")))
142 return;
143
144 if(!m_bus->DoubleFromString(m_parent, m_textCtrlFaultReactance->GetValue(), data.faultReactance,
145 _("Value entered incorrectly in the field \"Fault reactance\".")))
146 return;
147
148 data.plotBus = m_checkBoxPlotData->GetValue();
149 data.stabHasFault = m_checkBoxStabFault->GetValue();
150
151 if(!m_bus->DoubleFromString(m_parent, m_textCtrlStabFaultTime->GetValue(), data.stabFaultTime,
152 _("Value entered incorrectly in the field \"Time\".")))
153 return;
154
155 if(!m_bus->DoubleFromString(m_parent, m_textCtrlStabFaultLength->GetValue(), data.stabFaultLength,
156 _("Value entered incorrectly in the field \"Fault lenght\".")))
157 return;
158
159 if(!m_bus->DoubleFromString(m_parent, m_textCtrlStabFaultResistance->GetValue(), data.stabFaultResistance,
160 _("Value entered incorrectly in the field \"Fault resistence (stability)\".")))
161 return;
162
163 if(!m_bus->DoubleFromString(m_parent, m_textCtrlStabFaultReactance->GetValue(), data.stabFaultReactance,
164 _("Value entered incorrectly in the field \"Fault reactance (stability)\".")))
165 return;
166
167 data.plotPQData = m_checkBoxPlotPQData->GetValue();
168
169 m_bus->SetElectricalData(data);
170
171 if(data.stabHasFault)
172 m_bus->SetDynamicEvent(true);
173 else
174 m_bus->SetDynamicEvent(false);
175
176 EndModal(wxID_OK);
177}
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
virtual void SetDynamicEvent(bool dynEvent=true)
Set if the power element have dynamic event.

◆ OnControlledVoltageClick()

void BusForm::OnControlledVoltageClick ( wxCommandEvent &  event)
protectedvirtual

Definition at line 181 of file BusForm.cpp.

182{
183 EnableCtrlVoltageFields(m_checkBoxCtrlVoltage->GetValue());
184}

◆ OnFaultTypeChoice()

void BusForm::OnFaultTypeChoice ( wxCommandEvent &  event)
protectedvirtual

Definition at line 180 of file BusForm.cpp.

180{ UpdateChoiceBoxes(); }

◆ OnInsertFaultClick()

void BusForm::OnInsertFaultClick ( wxCommandEvent &  event)
protectedvirtual

Definition at line 185 of file BusForm.cpp.

185{ EnableFaultFields(m_checkBoxFault->GetValue()); }

◆ OnInsertStabFaultClick()

void BusForm::OnInsertStabFaultClick ( wxCommandEvent &  event)
protectedvirtual

Definition at line 186 of file BusForm.cpp.

186{ EnableStabFaultFields(m_checkBoxStabFault->GetValue()); }

◆ OnNominalVoltageChoice()

void BusForm::OnNominalVoltageChoice ( wxCommandEvent &  event)
protectedvirtual

Definition at line 179 of file BusForm.cpp.

179{ UpdateChoiceBoxes(); }

◆ UpdateChoiceBoxes()

void BusForm::UpdateChoiceBoxes ( )
protectedvirtual

Definition at line 219 of file BusForm.cpp.

220{
221 switch(m_choiceFaultType->GetSelection()) {
222 case 0: // three-phase
223 {
224 m_choiceFaultPlace->Enable(false);
225 } break;
226 case 1: // line-to-line
227 case 2: // double line-to-line
228 {
229 if(m_checkBoxFault->GetValue()) m_choiceFaultPlace->Enable(true);
230 m_choiceFaultPlace->SetString(0, _("Lines AB"));
231 m_choiceFaultPlace->SetString(1, _("Lines BC"));
232 m_choiceFaultPlace->SetString(2, _("Lines CA"));
233 } break;
234 case 3: // line-to-ground
235 {
236 if(m_checkBoxFault->GetValue()) m_choiceFaultPlace->Enable(true);
237 m_choiceFaultPlace->SetString(0, _("Line A"));
238 m_choiceFaultPlace->SetString(1, _("Line B"));
239 m_choiceFaultPlace->SetString(2, _("Line C"));
240 } break;
241 default:
242 break;
243 }
244 switch(m_choiceNomVoltage->GetSelection()) {
245 case 0: {
246 m_choiceCtrlVoltage->SetString(1, _("V"));
247 } break;
248 case 1: {
249 m_choiceCtrlVoltage->SetString(1, _("kV"));
250 } break;
251 default:
252 break;
253 }
254}

Member Data Documentation

◆ m_bus

Bus* BusForm::m_bus = nullptr
protected

Definition at line 50 of file BusForm.h.

◆ m_parent

wxWindow* BusForm::m_parent = nullptr
protected

Definition at line 51 of file BusForm.h.


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