43 : BusFormBase(parent), m_bus(bus), m_parent(parent), m_workspace(workspace)
44{
45 m_choiceFaultType->SetString(0, _("Three-phase"));
46 m_choiceFaultType->SetString(1, _("Line-to-line"));
47 m_choiceFaultType->SetString(2, _("Double line-to-ground"));
48 m_choiceFaultType->SetString(3, _("Line-to-ground"));
49
50
51 struct ElectrodeConfiguration
52 {
53 wxString code;
54 wxString image;
55 };
56
57 const std::vector<ElectrodeConfiguration> configurations = {
58 {.code = _("VCB - Vertical, Metal Box"), .image = "VCB.png"},
59 {.code = _("VCBB - Vertical, Insulating Barrier"), .image = "VCBB.png"},
60 {.code = _("HCB - Horizontal, Metal Box"), .image = "HCB.png"},
61 {.code = _("VOA - Vertical, Open Air"), .image = "VOA.png"},
62 {.code = _("HOA - Horizontal, Open Air"), .image = "HOA.png"}
63 };
64
65 const wxSize size = FromDIP(wxSize(32, 32));
66 const wxString imgPath = Paths::GetDataPath() + "/images/arcflash/";
67
68 for (const auto& config : configurations)
69 {
70 wxImage image(imgPath + config.image, wxBITMAP_TYPE_PNG);
71 if (!image.IsOk()) {
72 wxMessageBox(_("Could not load the electrode configuration image:\n") + imgPath + config.image, _("Arc Flash"), wxOK | wxICON_ERROR, this);
73 continue;
74 }
75
76 image.Rescale(size.x, size.y, wxIMAGE_QUALITY_HIGH);
77 m_bmpComboBoxConfig->Append(config.code, wxBitmap(image));
78 }
79
80 m_electrodePreview = new BitmapPopup(this);
81 m_electrodePreview->Hide();
82
83 m_textCtrlName->SetValue(bus->GetElectricalData().name);
84 m_textCtrlNomVoltage->SetValue(bus->
StringFromDouble(bus->GetElectricalData().nominalVoltage));
85
86 if (bus->GetElectricalData().nominalVoltageUnit == ElectricalUnit::UNIT_V)
87 m_choiceNomVoltage->SetSelection(0);
88 else
89 m_choiceNomVoltage->SetSelection(1);
90
91 m_checkBoxCtrlVoltage->SetValue(bus->GetElectricalData().isVoltageControlled);
92 m_textCtrlCtrlVoltage->SetValue(bus->
StringFromDouble(bus->GetElectricalData().controlledVoltage));
93 m_choiceCtrlVoltage->SetSelection(bus->GetElectricalData().controlledVoltageUnitChoice);
94 m_checkBoxSlackBus->SetValue(bus->GetElectricalData().slackBus);
95
96 m_checkBoxFault->SetValue(bus->GetElectricalData().hasFault);
97 switch (bus->GetElectricalData().faultType) {
99 m_choiceFaultType->SetSelection(0);
100 } break;
102 m_choiceFaultType->SetSelection(1);
103 } break;
105 m_choiceFaultType->SetSelection(2);
106 } break;
108 m_choiceFaultType->SetSelection(3);
109 } break;
110 default:
111 break;
112 }
113 switch (bus->GetElectricalData().faultLocation) {
115 m_choiceFaultPlace->SetSelection(0);
116 } break;
118 m_choiceFaultPlace->SetSelection(1);
119 } break;
121 m_choiceFaultPlace->SetSelection(2);
122 } break;
123 default:
124 break;
125 }
126 m_textCtrlFaultResistance->SetValue(bus->
StringFromDouble(bus->GetElectricalData().faultResistance));
127 m_textCtrlFaultReactance->SetValue(bus->
StringFromDouble(bus->GetElectricalData().faultReactance));
128
129 m_checkBoxPlotData->SetValue(bus->GetElectricalData().plotBus);
130 m_checkBoxStabFault->SetValue(bus->GetElectricalData().stabHasFault);
131 m_textCtrlStabFaultTime->SetValue(bus->
StringFromDouble(bus->GetElectricalData().stabFaultTime));
132 m_textCtrlStabFaultLength->SetValue(bus->
StringFromDouble(bus->GetElectricalData().stabFaultLength));
133 m_textCtrlStabFaultResistance->SetValue(bus->
StringFromDouble(bus->GetElectricalData().stabFaultResistance));
134 m_textCtrlStabFaultReactance->SetValue(bus->
StringFromDouble(bus->GetElectricalData().stabFaultReactance));
135
136 EnableCtrlVoltageFields(bus->GetElectricalData().isVoltageControlled);
137 EnableFaultFields(bus->GetElectricalData().hasFault);
138 EnableStabFaultFields(bus->GetElectricalData().stabHasFault);
139
140 m_checkBoxPlotPQData->SetValue(bus->GetElectricalData().plotPQData);
141
142 LoadArcFlashData(m_bus->GetElectricalDataRef().arcFlash);
143
144 m_staticBitmapWarning->Hide();
145
146 GetSizer()->Layout();
147 GetSizer()->Fit(this);
148 SetSize(GetBestSize());
149}
static wxString StringFromDouble(double value, int minDecimal=1, int maxDecimals=13)
Convert a double value to string.