19#include "../elements/powerElement/Bus.h"
21BusForm::BusForm(wxWindow* parent,
Bus* bus) : BusFormBase(parent)
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"));
28 SetSize(GetBestSize());
33 m_textCtrlName->SetValue(bus->GetElectricalData().name);
34 m_textCtrlNomVoltage->SetValue(bus->
StringFromDouble(bus->GetElectricalData().nominalVoltage));
37 m_choiceNomVoltage->SetSelection(0);
39 m_choiceNomVoltage->SetSelection(1);
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);
46 m_checkBoxFault->SetValue(bus->GetElectricalData().hasFault);
47 switch(bus->GetElectricalData().faultType) {
49 m_choiceFaultType->SetSelection(0);
52 m_choiceFaultType->SetSelection(1);
55 m_choiceFaultType->SetSelection(2);
58 m_choiceFaultType->SetSelection(3);
63 switch(bus->GetElectricalData().faultLocation) {
65 m_choiceFaultPlace->SetSelection(0);
68 m_choiceFaultPlace->SetSelection(1);
71 m_choiceFaultPlace->SetSelection(2);
76 m_textCtrlFaultResistance->SetValue(bus->
StringFromDouble(bus->GetElectricalData().faultResistance));
77 m_textCtrlFaultReactance->SetValue(bus->
StringFromDouble(bus->GetElectricalData().faultReactance));
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));
86 EnableCtrlVoltageFields(bus->GetElectricalData().isVoltageControlled);
87 EnableFaultFields(bus->GetElectricalData().hasFault);
88 EnableStabFaultFields(bus->GetElectricalData().stabHasFault);
90 m_checkBoxPlotPQData->SetValue(bus->GetElectricalData().plotPQData);
94void BusForm::OnButtonCancelClick(wxCommandEvent& event) { EndModal(wxID_CANCEL); }
95void BusForm::OnButtonOKClick(wxCommandEvent& event)
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\".")))
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\".")))
108 data.controlledVoltageUnitChoice = m_choiceCtrlVoltage->GetSelection();
110 data.slackBus = m_checkBoxSlackBus->GetValue();
112 data.hasFault = m_checkBoxFault->GetValue();
113 switch(m_choiceFaultType->GetSelection()) {
128 switch(m_choiceFaultPlace->GetSelection()) {
140 if(!m_bus->
DoubleFromString(m_parent, m_textCtrlFaultResistance->GetValue(), data.faultResistance,
141 _(
"Value entered incorrectly in the field \"Fault resistance\".")))
144 if(!m_bus->
DoubleFromString(m_parent, m_textCtrlFaultReactance->GetValue(), data.faultReactance,
145 _(
"Value entered incorrectly in the field \"Fault reactance\".")))
148 data.plotBus = m_checkBoxPlotData->GetValue();
149 data.stabHasFault = m_checkBoxStabFault->GetValue();
151 if(!m_bus->
DoubleFromString(m_parent, m_textCtrlStabFaultTime->GetValue(), data.stabFaultTime,
152 _(
"Value entered incorrectly in the field \"Time\".")))
155 if(!m_bus->
DoubleFromString(m_parent, m_textCtrlStabFaultLength->GetValue(), data.stabFaultLength,
156 _(
"Value entered incorrectly in the field \"Fault lenght\".")))
159 if(!m_bus->
DoubleFromString(m_parent, m_textCtrlStabFaultResistance->GetValue(), data.stabFaultResistance,
160 _(
"Value entered incorrectly in the field \"Fault resistence (stability)\".")))
163 if(!m_bus->
DoubleFromString(m_parent, m_textCtrlStabFaultReactance->GetValue(), data.stabFaultReactance,
164 _(
"Value entered incorrectly in the field \"Fault reactance (stability)\".")))
167 data.plotPQData = m_checkBoxPlotPQData->GetValue();
169 m_bus->SetElectricalData(data);
171 if(data.stabHasFault)
179void BusForm::OnNominalVoltageChoice(wxCommandEvent& event) { UpdateChoiceBoxes(); }
180void BusForm::OnFaultTypeChoice(wxCommandEvent& event) { UpdateChoiceBoxes(); }
181void BusForm::OnControlledVoltageClick(wxCommandEvent& event)
183 EnableCtrlVoltageFields(m_checkBoxCtrlVoltage->GetValue());
185void BusForm::OnInsertFaultClick(wxCommandEvent& event) { EnableFaultFields(m_checkBoxFault->GetValue()); }
186void BusForm::OnInsertStabFaultClick(wxCommandEvent& event) { EnableStabFaultFields(m_checkBoxStabFault->GetValue()); }
187void BusForm::EnableCtrlVoltageFields(
bool enable)
189 m_textCtrlCtrlVoltage->Enable(enable);
190 m_choiceCtrlVoltage->Enable(enable);
195void BusForm::EnableFaultFields(
bool enable)
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);
207void BusForm::EnableStabFaultFields(
bool enable)
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);
219void BusForm::UpdateChoiceBoxes()
221 switch(m_choiceFaultType->GetSelection()) {
224 m_choiceFaultPlace->Enable(
false);
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"));
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"));
244 switch(m_choiceNomVoltage->GetSelection()) {
246 m_choiceCtrlVoltage->SetString(1, _(
"V"));
249 m_choiceCtrlVoltage->SetString(1, _(
"kV"));
Node for power elements. All others power elements are connected through this.
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.
virtual void SetDynamicEvent(bool dynEvent=true)
Set if the power element have dynamic event.