summaryrefslogtreecommitdiffstats
path: root/Project/GeneratorStabForm.cpp
blob: a651fe7e65c9abb9e92937b4b070c582d3076582 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include "GeneratorStabForm.h"
#include "SyncGenerator.h"

GeneratorStabForm::GeneratorStabForm(wxWindow* parent, SyncGenerator* syncGenerator) : GeneratorStabFormBase(parent)
{
    m_syncGenerator = syncGenerator;
    m_parent = parent;

    SyncGeneratorElectricalData data = syncGenerator->GetElectricalData();

    m_checkBoxPlotSyncMachine->SetValue(data.plotSyncMachine);

    m_textCtrlInertia->SetValue(wxString::FromDouble(data.inertia));
    m_textCtrlDamping->SetValue(wxString::FromDouble(data.damping));

    m_checkBoxUseAVR->SetValue(data.useAVR);
    m_buttonEditAVR->Enable(data.useAVR);

    m_checkBoxUseSG->SetValue(data.useSpeedGovernor);
    m_buttonEditSG->Enable(data.useSpeedGovernor);

    m_textCtrlRa->SetValue(wxString::FromDouble(data.armResistance));
    m_textCtrlXp->SetValue(wxString::FromDouble(data.potierReactance));
    m_textCtrlSat->SetValue(wxString::FromDouble(data.satFactor));

    m_textCtrlSyncXd->SetValue(wxString::FromDouble(data.syncXd));
    m_textCtrlSyncXq->SetValue(wxString::FromDouble(data.syncXq));

    m_textCtrlTranXd->SetValue(wxString::FromDouble(data.transXd));
    m_textCtrlTranXq->SetValue(wxString::FromDouble(data.transXq));
    m_textCtrlTranTd0->SetValue(wxString::FromDouble(data.transTd0));
    m_textCtrlTranTq0->SetValue(wxString::FromDouble(data.transTq0));

    m_textCtrlSubXd->SetValue(wxString::FromDouble(data.subXd));
    m_textCtrlSubXq->SetValue(wxString::FromDouble(data.subXq));
    m_textCtrlSubTd0->SetValue(wxString::FromDouble(data.subTd0));
    m_textCtrlSubTq0->SetValue(wxString::FromDouble(data.subTq0));
}

GeneratorStabForm::~GeneratorStabForm() {}
void GeneratorStabForm::OnCancelButtonClick(wxCommandEvent& event) { EndModal(wxID_CANCEL); }
void GeneratorStabForm::OnEditAVRButtonClick(wxCommandEvent& event) {}
void GeneratorStabForm::OnOKButtonClick(wxCommandEvent& event)
{
    if(ValidateData()) EndModal(wxID_OK);
}

void GeneratorStabForm::OnSpeedGovernorButtonClick(wxCommandEvent& event) {}
void GeneratorStabForm::OnSwitchingButtonClick(wxCommandEvent& event) {}
bool GeneratorStabForm::ValidateData()
{
    SyncGeneratorElectricalData data = m_syncGenerator->GetElectricalData();

    data.plotSyncMachine = m_checkBoxPlotSyncMachine->GetValue();

    if(!m_syncGenerator->DoubleFromString(m_parent, m_textCtrlInertia->GetValue(), data.inertia,
                                          _("Value entered incorrectly in the field \"Inertia\".")))
	return false;

    if(!m_syncGenerator->DoubleFromString(m_parent, m_textCtrlDamping->GetValue(), data.damping,
                                          _("Value entered incorrectly in the field \"Damping factor\".")))
	return false;

    data.useAVR = m_checkBoxUseAVR->GetValue();
    data.useSpeedGovernor = m_checkBoxUseSG->GetValue();

    if(!m_syncGenerator->DoubleFromString(m_parent, m_textCtrlRa->GetValue(), data.armResistance,
                                          _("Value entered incorrectly in the field \"Armature resistance\".")))
	return false;

    if(!m_syncGenerator->DoubleFromString(m_parent, m_textCtrlXp->GetValue(), data.potierReactance,
                                          _("Value entered incorrectly in the field \"Potier reactance\".")))
	return false;

    if(!m_syncGenerator->DoubleFromString(m_parent, m_textCtrlSat->GetValue(), data.satFactor,
                                          _("Value entered incorrectly in the field \"Saturation factor\".")))
	return false;

    if(!m_syncGenerator->DoubleFromString(
           m_parent, m_textCtrlSyncXd->GetValue(), data.syncXd,
           _("Value entered incorrectly in the field \"Synchronous direct-axis reactance\".")))
	return false;

    if(!m_syncGenerator->DoubleFromString(
           m_parent, m_textCtrlSyncXq->GetValue(), data.syncXq,
           _("Value entered incorrectly in the field \"Synchronous quadrature-axis reactance\".")))
	return false;

    if(!m_syncGenerator->DoubleFromString(
           m_parent, m_textCtrlTranXd->GetValue(), data.transXd,
           _("Value entered incorrectly in the field \"Transitory direct-axis reactance\".")))
	return false;

    if(!m_syncGenerator->DoubleFromString(
           m_parent, m_textCtrlTranXq->GetValue(), data.transXq,
           _("Value entered incorrectly in the field \"Transitory quadrature-axis reactance\".")))
	return false;

    if(!m_syncGenerator->DoubleFromString(
           m_parent, m_textCtrlTranTd0->GetValue(), data.transTd0,
           _("Value entered incorrectly in the field \"Transitory direct-axis time constant\".")))
	return false;

    if(!m_syncGenerator->DoubleFromString(
           m_parent, m_textCtrlTranTq0->GetValue(), data.transTq0,
           _("Value entered incorrectly in the field \"Transitory quadrature-axis time constant\".")))
	return false;

    if(!m_syncGenerator->DoubleFromString(
           m_parent, m_textCtrlSubXd->GetValue(), data.subXd,
           _("Value entered incorrectly in the field \"Subtransitory direct-axis reactance\".")))
	return false;

    if(!m_syncGenerator->DoubleFromString(
           m_parent, m_textCtrlSubXq->GetValue(), data.subXq,
           _("Value entered incorrectly in the field \"Subtransitory quadrature-axis reactance\".")))
	return false;

    if(!m_syncGenerator->DoubleFromString(
           m_parent, m_textCtrlSubTd0->GetValue(), data.subTd0,
           _("Value entered incorrectly in the field \"Subtransitory direct-axis time constant\".")))
	return false;

    if(!m_syncGenerator->DoubleFromString(
           m_parent, m_textCtrlSubTq0->GetValue(), data.subTq0,
           _("Value entered incorrectly in the field \"Subtransitory quadrature-axis time constant\".")))
	return false;

    m_syncGenerator->SetElectricalData(data);

    return true;
}
void GeneratorStabForm::UseAVRClick(wxCommandEvent& event) { m_buttonEditAVR->Enable(m_checkBoxUseAVR->GetValue()); }
void GeneratorStabForm::UseSGClick(wxCommandEvent& event) { m_buttonEditSG->Enable(m_checkBoxUseSG->GetValue()); }