diff options
author | Thales Lima Oliveira <thaleslima.ufu@gmail.com> | 2019-07-18 09:22:27 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-18 09:22:27 -0300 |
commit | 8357c081eb75147bb8f94d8b6e367d88ea3898ed (patch) | |
tree | 9d9726fdcefb917475d6b33344d2b832d4e78ef8 /Project/FrequencyResponseForm.cpp | |
parent | 295b775ad53eb1e128b705e6028f9690dc6fa640 (diff) | |
parent | 7f46d390b8cc1d5f37560f52b222198dbc5e1225 (diff) | |
download | PSP.git-8357c081eb75147bb8f94d8b6e367d88ea3898ed.tar.gz PSP.git-8357c081eb75147bb8f94d8b6e367d88ea3898ed.tar.xz PSP.git-8357c081eb75147bb8f94d8b6e367d88ea3898ed.zip |
Merge pull request #50 from Thales1330/wip/induction-motor
Wip/induction motor
Diffstat (limited to 'Project/FrequencyResponseForm.cpp')
-rw-r--r-- | Project/FrequencyResponseForm.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/Project/FrequencyResponseForm.cpp b/Project/FrequencyResponseForm.cpp new file mode 100644 index 0000000..9672c0e --- /dev/null +++ b/Project/FrequencyResponseForm.cpp @@ -0,0 +1,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); +} |