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

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

#include <LineForm.h>

Inheritance diagram for LineForm:
Collaboration diagram for LineForm:

Public Member Functions

 LineForm (wxWindow *parent, Line *line)
 

Protected Member Functions

virtual void OnCancelButtonClick (wxCommandEvent &event)
 
virtual void OnOKButtonClick (wxCommandEvent &event)
 
virtual void OnStabilityButtonClick (wxCommandEvent &event)
 
virtual void ReplaceStaticTextLabelChar (wxStaticText *staticText, wchar_t newChar)
 
virtual bool ValidateData ()
 

Protected Attributes

wxWindow * m_parent = nullptr
 
Linem_line = nullptr
 

Detailed Description

Form to edit the line power data.

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

Definition at line 32 of file LineForm.h.

Constructor & Destructor Documentation

◆ LineForm()

LineForm::LineForm ( wxWindow *  parent,
Line line 
)

Definition at line 22 of file LineForm.cpp.

22 : LineFormBase(parent)
23{
24 SetSize(GetBestSize());
25 m_choiceResistance->SetString(1, L'\u03A9');
26 m_choiceResistance->SetString(2, (wxString)L'\u03A9' + "/km");
27 m_choiceResistance->SetInitialSize();
28 m_textCtrlResistance->SetInitialSize();
29
30 m_choiceReactance->SetString(1, L'\u03A9');
31 m_choiceReactance->SetString(2, (wxString)L'\u03A9' + "/km");
32 m_choiceReactance->SetInitialSize();
33 m_textCtrlReactance->SetInitialSize();
34
35 ReplaceStaticTextLabelChar(m_staticTextZeroResistance, L'\u2080');
36 ReplaceStaticTextLabelChar(m_staticTextZeroReactance, L'\u2080');
37 ReplaceStaticTextLabelChar(m_staticTextZeroSusceptance, L'\u2080');
38
39 SetSize(GetBestSize());
40 Layout();
41 m_parent = parent;
42 m_line = line;
43
44 LineElectricalData data = line->GetElectricalData();
45
46 m_textCtrlName->SetValue(data.name);
47
48 wxString nominalVoltageStr = Line::StringFromDouble(data.nominalVoltage);
49 switch(data.nominalVoltageUnit) {
51 nominalVoltageStr += " V";
52 } break;
54 nominalVoltageStr += " kV";
55 } break;
56 default:
57 break;
58 }
59 m_staticTextNominalVoltageValue->SetLabel(nominalVoltageStr);
60
61 m_textCtrlNominalPower->SetValue(Line::StringFromDouble(data.nominalPower));
62 switch(data.nominalPowerUnit) {
64 m_choiceNominalPower->SetSelection(0);
65 } break;
67 m_choiceNominalPower->SetSelection(1);
68 } break;
70 m_choiceNominalPower->SetSelection(2);
71 } break;
72 default:
73 break;
74 }
75
76 m_textCtrlResistance->SetValue(Line::StringFromDouble(data.resistance));
77 switch(data.resistanceUnit) {
79 m_choiceResistance->SetSelection(0);
80 } break;
82 m_choiceResistance->SetSelection(1);
83 } break;
85 m_choiceResistance->SetSelection(2);
86 } break;
87 default:
88 break;
89 }
90
91 m_textCtrlReactance->SetValue(Line::StringFromDouble(data.indReactance));
92 switch(data.indReactanceUnit) {
94 m_choiceReactance->SetSelection(0);
95 } break;
97 m_choiceReactance->SetSelection(1);
98 } break;
100 m_choiceReactance->SetSelection(2);
101 } break;
102 default:
103 break;
104 }
105
106 m_textCtrlSusceptance->SetValue(Line::StringFromDouble(data.capSusceptance));
107 switch(data.capSusceptanceUnit) {
109 m_choiceSusceptance->SetSelection(0);
110 } break;
112 m_choiceSusceptance->SetSelection(1);
113 } break;
115 m_choiceSusceptance->SetSelection(2);
116 } break;
117 default:
118 break;
119 }
120
121 m_textCtrlLineSize->SetValue(Line::StringFromDouble(data.lineSize));
122 m_checkUseLinePower->SetValue(data.useLinePower);
123
124 m_textCtrlZeroResistance->SetValue(Line::StringFromDouble(data.zeroResistance));
125 m_textCtrlZeroReactance->SetValue(Line::StringFromDouble(data.zeroIndReactance));
126 m_textCtrlZeroSusceptance->SetValue(Line::StringFromDouble(data.zeroCapSusceptance));
127}
static wxString StringFromDouble(double value, int minDecimal=1, int maxDecimals=13)
Convert a double value to string.
Definition Element.cpp:533

◆ ~LineForm()

LineForm::~LineForm ( )
virtual

Definition at line 129 of file LineForm.cpp.

129{}

Member Function Documentation

◆ OnCancelButtonClick()

void LineForm::OnCancelButtonClick ( wxCommandEvent &  event)
protectedvirtual

Definition at line 130 of file LineForm.cpp.

130{ EndModal(wxID_CANCEL); }

◆ OnOKButtonClick()

void LineForm::OnOKButtonClick ( wxCommandEvent &  event)
protectedvirtual

Definition at line 131 of file LineForm.cpp.

132{
133 if(ValidateData()) EndModal(wxID_OK);
134}

◆ OnStabilityButtonClick()

void LineForm::OnStabilityButtonClick ( wxCommandEvent &  event)
protectedvirtual

Definition at line 136 of file LineForm.cpp.

137{
138 if(ValidateData()) {
139 SwitchingForm swForm(m_parent, m_line);
140 swForm.SetTitle(_("Line: Switching"));
141 swForm.ShowModal();
142 EndModal(wxID_OK);
143 }
144}
Form to edit the switching data of power elements for electromechanical transient studies.

◆ ReplaceStaticTextLabelChar()

void LineForm::ReplaceStaticTextLabelChar ( wxStaticText *  staticText,
wchar_t  newChar 
)
protectedvirtual

Definition at line 146 of file LineForm.cpp.

147{
148 wxString label = staticText->GetLabel();
149 label[label.length() - 2] = newChar;
150 staticText->SetLabel(label);
151}

◆ ValidateData()

bool LineForm::ValidateData ( )
protectedvirtual

Definition at line 153 of file LineForm.cpp.

154{
155 LineElectricalData data = m_line->GetElectricalData();
156
157 data.name = m_textCtrlName->GetValue();
158
159 if(!m_line->DoubleFromString(m_parent, m_textCtrlNominalPower->GetValue(), data.nominalPower,
160 _("Value entered incorrectly in the field \"Nominal power\".")))
161 return false;
162 switch(m_choiceNominalPower->GetSelection()) {
163 case 0: {
164 data.nominalPowerUnit = ElectricalUnit::UNIT_VA;
165 } break;
166 case 1: {
167 data.nominalPowerUnit = ElectricalUnit::UNIT_kVA;
168 } break;
169 case 2: {
170 data.nominalPowerUnit = ElectricalUnit::UNIT_MVA;
171 } break;
172 }
173
174 if(!m_line->DoubleFromString(m_parent, m_textCtrlResistance->GetValue(), data.resistance,
175 _("Value entered incorrectly in the field \"Resistance\".")))
176 return false;
177 switch(m_choiceResistance->GetSelection()) {
178 case 0: {
179 data.resistanceUnit = ElectricalUnit::UNIT_PU;
180 } break;
181 case 1: {
182 data.resistanceUnit = ElectricalUnit::UNIT_OHM;
183 } break;
184 case 2: {
185 data.resistanceUnit = ElectricalUnit::UNIT_OHM_km;
186 } break;
187 }
188
189 if(!m_line->DoubleFromString(m_parent, m_textCtrlReactance->GetValue(), data.indReactance,
190 _("Value entered incorrectly in the field \"Indutive Reactance\".")))
191 return false;
192 switch(m_choiceReactance->GetSelection()) {
193 case 0: {
194 data.indReactanceUnit = ElectricalUnit::UNIT_PU;
195 } break;
196 case 1: {
197 data.indReactanceUnit = ElectricalUnit::UNIT_OHM;
198 } break;
199 case 2: {
200 data.indReactanceUnit = ElectricalUnit::UNIT_OHM_km;
201 } break;
202 }
203
204 if(!m_line->DoubleFromString(m_parent, m_textCtrlSusceptance->GetValue(), data.capSusceptance,
205 _("Value entered incorrectly in the field \"Capacitive Susceptance\".")))
206 return false;
207 switch(m_choiceSusceptance->GetSelection()) {
208 case 0: {
209 data.capSusceptanceUnit = ElectricalUnit::UNIT_PU;
210 } break;
211 case 1: {
212 data.capSusceptanceUnit = ElectricalUnit::UNIT_S;
213 } break;
214 case 2: {
215 data.capSusceptanceUnit = ElectricalUnit::UNIT_S_km;
216 } break;
217 }
218
219 if(!m_line->DoubleFromString(m_parent, m_textCtrlLineSize->GetValue(), data.lineSize,
220 _("Value entered incorrectly in the field \"Line size\".")))
221 return false;
222
223 data.useLinePower = m_checkUseLinePower->GetValue();
224
225 if(!m_line->DoubleFromString(m_parent, m_textCtrlZeroResistance->GetValue(), data.zeroResistance,
226 _("Value entered incorrectly in the field \"Zero-sequence resistance\".")))
227 return false;
228 if(!m_line->DoubleFromString(m_parent, m_textCtrlZeroReactance->GetValue(), data.zeroIndReactance,
229 _("Value entered incorrectly in the field \"Zero-sequence indutive reactance\".")))
230 return false;
231 if(!m_line->DoubleFromString(m_parent, m_textCtrlZeroSusceptance->GetValue(), data.zeroCapSusceptance,
232 _("Value entered incorrectly in the field \"Zero-sequence capacitive susceptance\".")))
233 return false;
234
235 m_line->SetElectricalData(data);
236
237 return true;
238}
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_line

Line* LineForm::m_line = nullptr
protected

Definition at line 46 of file LineForm.h.

◆ m_parent

wxWindow* LineForm::m_parent = nullptr
protected

Definition at line 45 of file LineForm.h.


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