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
|
#include "Bus.h"
#include "FrequencyResponseForm.h"
FrequencyResponseForm::FrequencyResponseForm(wxWindow* parent) : FrequencyResponseFormBase(parent)
{
m_parent = parent;
}
FrequencyResponseForm::FrequencyResponseForm(wxWindow* parent,
std::vector<Bus*> busList,
int injCurrentBus,
double initFreq,
double endFreq,
double stepFreq)
: FrequencyResponseFormBase(parent)
{
m_parent = parent;
m_busList = busList;
// Set buses numbers and fill the choicebox
int busNumber = 0;
for(auto itb = m_busList.begin(); itb != m_busList.end(); itb++) {
Bus* bus = *itb;
BusElectricalData data = bus->GetElectricalData();
data.number = busNumber;
bus->SetElectricalData(data);
m_choiceBus->Append(data.name);
busNumber++;
}
Bus dummyBus;
m_textCtrlInitFreq->SetValue(dummyBus.StringFromDouble(initFreq));
m_textCtrlFinalFreq->SetValue(dummyBus.StringFromDouble(endFreq));
m_textCtrlStepFreq->SetValue(dummyBus.StringFromDouble(stepFreq));
m_choiceBus->SetSelection(injCurrentBus);
}
FrequencyResponseForm::~FrequencyResponseForm() {}
void FrequencyResponseForm::OnCancelButtonClick(wxCommandEvent& event) { EndModal(wxID_CANCEL); }
void FrequencyResponseForm::OnRunButtonClick(wxCommandEvent& event)
{
Bus dummyBus;
if(!dummyBus.DoubleFromString(m_parent, m_textCtrlInitFreq->GetValue(), m_initFreq,
_("Value entered incorrectly in the field \"Initial frequency\".")))
return;
if(!dummyBus.DoubleFromString(m_parent, m_textCtrlFinalFreq->GetValue(), m_endFreq,
_("Value entered incorrectly in the field \"Final frequency\".")))
return;
if(!dummyBus.DoubleFromString(m_parent, m_textCtrlStepFreq->GetValue(), m_stepFreq,
_("Value entered incorrectly in the field \"Frequency step\".")))
return;
if(m_choiceBus->GetSelection() == -1) {
wxMessageDialog msgDialog(m_parent, _("Injected current not selected"), _("Error"),
wxOK | wxCENTRE | wxICON_ERROR);
msgDialog.ShowModal();
return;
}
m_injBusNumber = m_choiceBus->GetSelection();
EndModal(wxID_OK);
}
|