20#include "../editors/Workspace.h"
21#include "../editors/ControlEditor.h"
22#include "../editors/ControlEditorManager.h"
26#include "../elements/controlElement/ControlElementContainer.h"
27#include "../elements/powerElement/SyncGenerator.h"
28#include "../utils/PropertiesData.h"
31 : GeneratorStabFormBase(parent), m_parent(parent), m_syncGenerator(syncGenerator), m_workspace(workspace)
33 SetSize(GetBestSize());
40 m_checkBoxPlotSyncMachine->SetValue(data.plotSyncMachine);
45 m_checkBoxUseAVR->SetValue(data.useAVR);
46 m_buttonEditAVR->Enable(data.useAVR);
48 m_checkBoxUseSG->SetValue(data.useSpeedGovernor);
49 m_buttonEditSG->Enable(data.useSpeedGovernor);
70GeneratorStabForm::~GeneratorStabForm()
73void GeneratorStabForm::OnCancelButtonClick(wxCommandEvent& event)
75 EndModal(wxID_CANCEL);
77void GeneratorStabForm::OnEditAVRButtonClick(wxCommandEvent& event)
83 m_syncGenerator->SetElectricalData(data);
86 int ioFlags = IOControl::IN_TERMINAL_VOLTAGE | IOControl::IN_ACTIVE_POWER |
87 IOControl::IN_REACTIVE_POWER | IOControl::IN_INITIAL_TERMINAL_VOLTAGE | IOControl::IN_VELOCITY |
88 IOControl::IN_INITIAL_VELOCITY | IOControl::IN_DELTA_VELOCITY | IOControl::IN_DELTA_ACTIVE_POWER |
89 IOControl::OUT_FIELD_VOLTAGE;
90 auto& ceManager = m_workspace->GetControlEditorManager();
91 ceManager.Open(data.avr,
static_cast<int>(m_workspace->GetProperties()->GetGeneralPropertiesData().plotLib), ioFlags);
99void GeneratorStabForm::OnOKButtonClick(wxCommandEvent& event)
105void GeneratorStabForm::OnSpeedGovernorButtonClick(wxCommandEvent& event)
107 if (ValidateData()) {
109 if (!data.speedGov) {
111 m_syncGenerator->SetElectricalData(data);
114 int ioFlags = IOControl::IN_VELOCITY | IOControl::IN_ACTIVE_POWER | IOControl::IN_REACTIVE_POWER |
115 IOControl::IN_INITIAL_VELOCITY | IOControl::IN_INITIAL_MEC_POWER | IOControl::OUT_MEC_POWER;
116 auto& ceManager = m_workspace->GetControlEditorManager();
117 ceManager.Open(data.speedGov,
static_cast<int>(m_workspace->GetProperties()->GetGeneralPropertiesData().plotLib), ioFlags);
125void GeneratorStabForm::OnSwitchingButtonClick(wxCommandEvent& event)
127 if (ValidateData()) {
129 swForm.SetTitle(_(
"Synchronous generator: Switching"));
135bool GeneratorStabForm::ValidateData()
139 data.plotSyncMachine = m_checkBoxPlotSyncMachine->GetValue();
141 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlInertia->GetValue(), data.inertia,
142 _(
"Value entered incorrectly in the field \"Inertia\".")))
145 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlDamping->GetValue(), data.damping,
146 _(
"Value entered incorrectly in the field \"Damping factor\".")))
149 data.useAVR = m_checkBoxUseAVR->GetValue();
150 data.useSpeedGovernor = m_checkBoxUseSG->GetValue();
152 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlRa->GetValue(), data.armResistance,
153 _(
"Value entered incorrectly in the field \"Armature resistance\".")))
156 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlXp->GetValue(), data.potierReactance,
157 _(
"Value entered incorrectly in the field \"Potier reactance\".")))
160 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlSat->GetValue(), data.satFactor,
161 _(
"Value entered incorrectly in the field \"Saturation factor\".")))
164 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlOCFreq->GetValue(), data.ocFrequency,
165 _(
"Value entered incorrectly in the field \"Open-circuit frequency\".")))
168 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlSyncXd->GetValue(), data.syncXd,
169 _(
"Value entered incorrectly in the field \"Synchronous direct-axis reactance\".")))
172 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlSyncXq->GetValue(), data.syncXq,
173 _(
"Value entered incorrectly in the field \"Synchronous quadrature-axis reactance\".")))
176 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlTranXd->GetValue(), data.transXd,
177 _(
"Value entered incorrectly in the field \"Transitory direct-axis reactance\".")))
180 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlTranXq->GetValue(), data.transXq,
181 _(
"Value entered incorrectly in the field \"Transitory quadrature-axis reactance\".")))
184 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlTranTd0->GetValue(), data.transTd0,
185 _(
"Value entered incorrectly in the field \"Transitory direct-axis time constant\".")))
188 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlTranTq0->GetValue(), data.transTq0,
189 _(
"Value entered incorrectly in the field \"Transitory quadrature-axis time constant\".")))
192 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlSubXd->GetValue(), data.subXd,
193 _(
"Value entered incorrectly in the field \"Subtransitory direct-axis reactance\".")))
196 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlSubXq->GetValue(), data.subXq,
197 _(
"Value entered incorrectly in the field \"Subtransitory quadrature-axis reactance\".")))
200 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlSubTd0->GetValue(), data.subTd0,
201 _(
"Value entered incorrectly in the field \"Subtransitory direct-axis time constant\".")))
204 if (!m_syncGenerator->
DoubleFromString(m_parent, m_textCtrlSubTq0->GetValue(), data.subTq0,
205 _(
"Value entered incorrectly in the field \"Subtransitory quadrature-axis time constant\".")))
208 m_syncGenerator->SetElectricalData(data);
212void GeneratorStabForm::UseAVRClick(wxCommandEvent& event)
214 m_buttonEditAVR->Enable(m_checkBoxUseAVR->GetValue());
216void GeneratorStabForm::UseSGClick(wxCommandEvent& event)
218 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.
This class manages the graphical and power elements. It is responsible for handling the user's intera...