20#include "../editors/ControlEditor.h"
24#include "../elements/controlElement/ControlElementContainer.h"
25#include "../elements/powerElement/SyncGenerator.h"
27GeneratorStabForm::GeneratorStabForm(wxWindow* parent,
SyncGenerator* syncGenerator,
int plotLib)
28 : GeneratorStabFormBase(parent), m_parent(parent), m_syncGenerator(syncGenerator), m_plotLib(plotLib)
30 SetSize(GetBestSize());
37 m_checkBoxPlotSyncMachine->SetValue(data.plotSyncMachine);
42 m_checkBoxUseAVR->SetValue(data.useAVR);
43 m_buttonEditAVR->Enable(data.useAVR);
45 m_checkBoxUseSG->SetValue(data.useSpeedGovernor);
46 m_buttonEditSG->Enable(data.useSpeedGovernor);
67GeneratorStabForm::~GeneratorStabForm()
70void GeneratorStabForm::OnCancelButtonClick(wxCommandEvent& event)
72 EndModal(wxID_CANCEL);
74void GeneratorStabForm::OnEditAVRButtonClick(wxCommandEvent& event)
80 m_syncGenerator->SetElectricalData(data);
97 cEditor =
new ControlEditor(
nullptr, IOControl::IN_TERMINAL_VOLTAGE | IOControl::IN_ACTIVE_POWER |
98 IOControl::IN_REACTIVE_POWER | IOControl::IN_INITIAL_TERMINAL_VOLTAGE | IOControl::IN_VELOCITY |
99 IOControl::IN_INITIAL_VELOCITY | IOControl::IN_DELTA_VELOCITY | IOControl::IN_DELTA_ACTIVE_POWER |
100 IOControl::OUT_FIELD_VOLTAGE);
102 cEditor->SetElementsList(data.avr->GetControlElementsList());
103 cEditor->SetConnectionsList(data.avr->GetConnectionLineList());
104 cEditor->SetControlContainer(data.avr);
105 cEditor->SetPlotLib(m_plotLib);
107 cEditor->SetJustOpened(
true);
114void GeneratorStabForm::OnOKButtonClick(wxCommandEvent& event)
120void GeneratorStabForm::OnSpeedGovernorButtonClick(wxCommandEvent& event)
122 if (ValidateData()) {
124 if (!data.speedGov) {
126 m_syncGenerator->SetElectricalData(data);
138 cEditor =
new ControlEditor(
nullptr, IOControl::IN_VELOCITY | IOControl::IN_ACTIVE_POWER | IOControl::IN_REACTIVE_POWER |
139 IOControl::IN_INITIAL_VELOCITY | IOControl::IN_INITIAL_MEC_POWER | IOControl::OUT_MEC_POWER);
141 cEditor->SetElementsList(data.speedGov->GetControlElementsList());
142 cEditor->SetConnectionsList(data.speedGov->GetConnectionLineList());
143 cEditor->SetControlContainer(data.speedGov);
144 cEditor->SetPlotLib(m_plotLib);
146 cEditor->SetJustOpened(
true);
153void GeneratorStabForm::OnSwitchingButtonClick(wxCommandEvent& event)
155 if (ValidateData()) {
157 swForm.SetTitle(_(
"Synchronous generator: Switching"));
163bool GeneratorStabForm::ValidateData()
167 data.plotSyncMachine = m_checkBoxPlotSyncMachine->GetValue();
169 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlInertia->GetValue(), data.inertia,
170 _(
"Value entered incorrectly in the field \"Inertia\".")))
173 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlDamping->GetValue(), data.damping,
174 _(
"Value entered incorrectly in the field \"Damping factor\".")))
177 data.useAVR = m_checkBoxUseAVR->GetValue();
178 data.useSpeedGovernor = m_checkBoxUseSG->GetValue();
180 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlRa->GetValue(), data.armResistance,
181 _(
"Value entered incorrectly in the field \"Armature resistance\".")))
184 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlXp->GetValue(), data.potierReactance,
185 _(
"Value entered incorrectly in the field \"Potier reactance\".")))
188 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlSat->GetValue(), data.satFactor,
189 _(
"Value entered incorrectly in the field \"Saturation factor\".")))
192 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlOCFreq->GetValue(), data.ocFrequency,
193 _(
"Value entered incorrectly in the field \"Open-circuit frequency\".")))
196 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlSyncXd->GetValue(), data.syncXd,
197 _(
"Value entered incorrectly in the field \"Synchronous direct-axis reactance\".")))
200 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlSyncXq->GetValue(), data.syncXq,
201 _(
"Value entered incorrectly in the field \"Synchronous quadrature-axis reactance\".")))
204 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlTranXd->GetValue(), data.transXd,
205 _(
"Value entered incorrectly in the field \"Transitory direct-axis reactance\".")))
208 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlTranXq->GetValue(), data.transXq,
209 _(
"Value entered incorrectly in the field \"Transitory quadrature-axis reactance\".")))
212 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlTranTd0->GetValue(), data.transTd0,
213 _(
"Value entered incorrectly in the field \"Transitory direct-axis time constant\".")))
216 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlTranTq0->GetValue(), data.transTq0,
217 _(
"Value entered incorrectly in the field \"Transitory quadrature-axis time constant\".")))
220 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlSubXd->GetValue(), data.subXd,
221 _(
"Value entered incorrectly in the field \"Subtransitory direct-axis reactance\".")))
224 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlSubXq->GetValue(), data.subXq,
225 _(
"Value entered incorrectly in the field \"Subtransitory quadrature-axis reactance\".")))
228 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlSubTd0->GetValue(), data.subTd0,
229 _(
"Value entered incorrectly in the field \"Subtransitory direct-axis time constant\".")))
232 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlSubTq0->GetValue(), data.subTq0,
233 _(
"Value entered incorrectly in the field \"Subtransitory quadrature-axis time constant\".")))
236 m_syncGenerator->SetElectricalData(data);
240void GeneratorStabForm::UseAVRClick(wxCommandEvent& event)
242 m_buttonEditAVR->Enable(m_checkBoxUseAVR->GetValue());
244void GeneratorStabForm::UseSGClick(wxCommandEvent& event)
246 m_buttonEditSG->Enable(m_checkBoxUseSG->GetValue());
Class that can contain all control elements. Can identify (using RTTI) the elements from a generic li...
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.
Synchronous generator power element.