20#include "../elements/powerElement/Transformer.h"
22TransformerForm::TransformerForm(wxWindow* parent,
Transformer* transformer) : TransformerFormBase(parent)
24 m_choiceResistance->SetString(1, L
'\u03A9');
25 m_choiceReactance->SetString(1, L
'\u03A9');
28 m_choiceConnection->SetString(0, _(
"Grounded Wye - Grounded Wye"));
29 m_choiceConnection->SetString(1, _(
"Wye - Grounded Wye"));
30 m_choiceConnection->SetString(2, _(
"Grounded Wye - Wye"));
31 m_choiceConnection->SetString(3, _(
"Wye - Wye"));
32 m_choiceConnection->SetString(4, _(
"Delta - Grounded Wye"));
33 m_choiceConnection->SetString(5, _(
"Delta - Wye"));
34 m_choiceConnection->SetString(6, _(
"Grounded Wye - Delta"));
35 m_choiceConnection->SetString(7, _(
"Wye - Delta"));
36 m_choiceConnection->SetString(8, _(
"Delta - Delta"));
38 SetSize(GetBestSize());
42 m_transformer = transformer;
46 m_textCtrlName->SetValue(data.name);
49 switch(data.primaryNominalVoltageUnit) {
60 switch(data.secondaryNominalVoltageUnit) {
70 m_staticTextNominalVoltageValue->SetLabel(wxString::Format(
"%s / %s", primVoltStr, secVoltStr));
72 m_choiceBaseVoltage->SetString(0, primVoltStr);
73 m_choiceBaseVoltage->SetString(1, secVoltStr);
74 m_choiceBaseVoltage->SetSelection(data.baseVoltage);
77 switch(data.nominalPowerUnit) {
79 m_choiceNominalPower->SetSelection(0);
82 m_choiceNominalPower->SetSelection(1);
85 m_choiceNominalPower->SetSelection(2);
92 switch(data.resistanceUnit) {
94 m_choiceResistance->SetSelection(0);
97 m_choiceResistance->SetSelection(1);
104 switch(data.indReactanceUnit) {
106 m_choiceReactance->SetSelection(0);
109 m_choiceReactance->SetSelection(1);
115 m_choiceConnection->SetSelection(data.connection);
120 m_checkUseTransformerPower->SetValue(data.useTransformerPower);
130TransformerForm::~TransformerForm() {}
131void TransformerForm::OnCancelButtonClick(wxCommandEvent& event) { EndModal(wxID_CANCEL); }
132void TransformerForm::OnOKButtonClick(wxCommandEvent& event)
134 if(ValidateData()) EndModal(wxID_OK);
136void TransformerForm::OnStabilityButtonClick(wxCommandEvent& event)
140 swForm.SetTitle(_(
"Transfomer: Switching"));
146bool TransformerForm::ValidateData()
150 data.name = m_textCtrlName->GetValue();
151 data.baseVoltage = m_choiceBaseVoltage->GetSelection();
153 if(!m_transformer->
DoubleFromString(m_parent, m_textCtrlNominalPower->GetValue(), data.nominalPower,
154 _(
"Value entered incorrectly in the field \"Nominal power\".")))
156 switch(m_choiceNominalPower->GetSelection()) {
168 if(!m_transformer->
DoubleFromString(m_parent, m_textCtrlResistance->GetValue(), data.resistance,
169 _(
"Value entered incorrectly in the field \"Resistance\".")))
171 switch(m_choiceResistance->GetSelection()) {
180 if(!m_transformer->
DoubleFromString(m_parent, m_textCtrlReactance->GetValue(), data.indReactance,
181 _(
"Value entered incorrectly in the field \"Indutive reactance\".")))
183 switch(m_choiceReactance->GetSelection()) {
192 switch(m_choiceConnection->GetSelection()) {
194 data.connection = GWYE_GWYE;
197 data.connection = WYE_GWYE;
200 data.connection = GWYE_WYE;
203 data.connection = WYE_WYE;
206 data.connection = DELTA_GWYE;
209 data.connection = DELTA_WYE;
212 data.connection = GWYE_DELTA;
215 data.connection = WYE_DELTA;
218 data.connection = DELTA_DELTA;
222 if(!m_transformer->
DoubleFromString(m_parent, m_textCtrlTurnRatio->GetValue(), data.turnsRatio,
223 _(
"Value entered incorrectly in the field \"Turns ratio\".")))
226 if(!m_transformer->
DoubleFromString(m_parent, m_textCtrlPhaseShift->GetValue(), data.phaseShift,
227 _(
"Value entered incorrectly in the field \"Phase shift\".")))
230 data.useTransformerPower = m_checkUseTransformerPower->GetValue();
232 if(!m_transformer->
DoubleFromString(m_parent, m_textCtrlZeroResistance->GetValue(), data.zeroResistance,
233 _(
"Value entered incorrectly in the field \"Zero sequence resistance\".")))
237 m_parent, m_textCtrlZeroReactance->GetValue(), data.zeroIndReactance,
238 _(
"Value entered incorrectly in the field \"Zero sequence indutive reactance\".")))
241 if(!m_transformer->
DoubleFromString(m_parent, m_textCtrlPrimResistance->GetValue(), data.primaryGrndResistance,
242 _(
"Value entered incorrectly in the field \"Primary ground resistance\".")))
245 if(!m_transformer->
DoubleFromString(m_parent, m_textCtrlPrimReactance->GetValue(), data.primaryGrndReactance,
246 _(
"Value entered incorrectly in the field \"Primary ground reactance\".")))
249 if(!m_transformer->
DoubleFromString(m_parent, m_textCtrlSecResistance->GetValue(), data.secondaryGrndResistance,
250 _(
"Value entered incorrectly in the field \"Secondary ground resistance\".")))
253 if(!m_transformer->
DoubleFromString(m_parent, m_textCtrlSecReactance->GetValue(), data.secondaryGrndReactance,
254 _(
"Value entered incorrectly in the field \"Secondary ground reactance\".")))
257 m_transformer->SetElectricaData(data);
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.