From ed36957d2d06ce9484e39be699bc41b521bdb090 Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Thu, 6 Apr 2017 17:12:09 -0300 Subject: Io form under implementation --- Project/IOControlForm.cpp | 89 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 Project/IOControlForm.cpp (limited to 'Project/IOControlForm.cpp') diff --git a/Project/IOControlForm.cpp b/Project/IOControlForm.cpp new file mode 100644 index 0000000..374ce27 --- /dev/null +++ b/Project/IOControlForm.cpp @@ -0,0 +1,89 @@ +#include "IOControlForm.h" + +IOControlForm::IOControlForm(wxWindow* parent, IOControl* ioControl) + : IOControlFormBase(parent) +{ + m_parent = parent; + m_ioControl = ioControl; + + int ioFlags = m_ioControl->GetIOFlags(); + int inChoiceNumber = -1; + int outChoiceNumber = -1; + + if(ioFlags & IOControl::IN_TERMINAL_VOLTAGE) { + m_choiceInput->Append(_("Terminal voltage")); + m_inputFlags.push_back(IOControl::IN_TERMINAL_VOLTAGE); + if(m_ioControl->GetValue() == IOControl::IN_TERMINAL_VOLTAGE) + inChoiceNumber = (int)m_inputFlags.size() - 1; + } + if(ioFlags & IOControl::IN_VELOCITY) { + m_choiceInput->Append(_("Velocity")); + m_inputFlags.push_back(IOControl::IN_VELOCITY); + if(m_ioControl->GetValue() == IOControl::IN_VELOCITY) + inChoiceNumber = (int)m_inputFlags.size() - 1; + } + if(ioFlags & IOControl::IN_ACTIVE_POWER) { + m_choiceInput->Append(_("Active power")); + m_inputFlags.push_back(IOControl::IN_ACTIVE_POWER); + if(m_ioControl->GetValue() == IOControl::IN_ACTIVE_POWER) + inChoiceNumber = (int)m_inputFlags.size() - 1; + } + if(ioFlags & IOControl::IN_REACTIVE_POWER) { + m_choiceInput->Append(_("Reactive power")); + m_inputFlags.push_back(IOControl::IN_REACTIVE_POWER); + if(m_ioControl->GetValue() == IOControl::IN_REACTIVE_POWER) + inChoiceNumber = (int)m_inputFlags.size() - 1; + } + if(ioFlags & IOControl::OUT_FIELD_VOLTAGE) { + m_choiceOutput->Append(_("Field voltage")); + m_outputFlags.push_back(IOControl::OUT_FIELD_VOLTAGE); + if(m_ioControl->GetValue() == IOControl::OUT_MEC_POWER) + outChoiceNumber = (int)m_outputFlags.size() - 1; + } + if(ioFlags & IOControl::OUT_MEC_POWER) { + m_choiceOutput->Append(_("Mechanical power")); + m_outputFlags.push_back(IOControl::OUT_MEC_POWER); + if(m_ioControl->GetValue() == IOControl::OUT_MEC_POWER) + outChoiceNumber = (int)m_outputFlags.size() - 1; + } + + if(inChoiceNumber != -1) { + m_choiceInput->SetSelection(inChoiceNumber); + m_checkBoxInput->SetValue(true); + m_checkBoxOutput->SetValue(false); + m_choiceOutput->Enable(false); + } else { + m_choiceInput->SetSelection(outChoiceNumber); + m_checkBoxInput->SetValue(false); + m_checkBoxOutput->SetValue(true); + m_choiceInput->Enable(false); + } + +} + +IOControlForm::~IOControlForm() +{ +} +void IOControlForm::OnOKButtonClick(wxCommandEvent& event) +{ + if(ValidateData()) EndModal(wxID_OK); +} + +bool IOControlForm::ValidateData() +{ + return false; +} + +void IOControlForm::OnInputChecked(wxCommandEvent& event) +{ + m_checkBoxOutput->SetValue(false); + m_choiceOutput->Enable(false); + m_choiceInput->Enable(true); +} + +void IOControlForm::OnOutputChecked(wxCommandEvent& event) +{ + m_checkBoxInput->SetValue(false); + m_choiceOutput->Enable(true); + m_choiceInput->Enable(false); +} -- cgit From d13b7013afa5ba1d40ee52e77eabd43bfd1b4acd Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Fri, 7 Apr 2017 17:49:47 -0300 Subject: generic controls gui implemented --- Project/IOControlForm.cpp | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'Project/IOControlForm.cpp') diff --git a/Project/IOControlForm.cpp b/Project/IOControlForm.cpp index 374ce27..8a848d9 100644 --- a/Project/IOControlForm.cpp +++ b/Project/IOControlForm.cpp @@ -1,69 +1,59 @@ #include "IOControlForm.h" -IOControlForm::IOControlForm(wxWindow* parent, IOControl* ioControl) - : IOControlFormBase(parent) +IOControlForm::IOControlForm(wxWindow* parent, IOControl* ioControl) : IOControlFormBase(parent) { m_parent = parent; m_ioControl = ioControl; - + int ioFlags = m_ioControl->GetIOFlags(); int inChoiceNumber = -1; int outChoiceNumber = -1; - + if(ioFlags & IOControl::IN_TERMINAL_VOLTAGE) { m_choiceInput->Append(_("Terminal voltage")); m_inputFlags.push_back(IOControl::IN_TERMINAL_VOLTAGE); - if(m_ioControl->GetValue() == IOControl::IN_TERMINAL_VOLTAGE) - inChoiceNumber = (int)m_inputFlags.size() - 1; + if(m_ioControl->GetValue() == IOControl::IN_TERMINAL_VOLTAGE) inChoiceNumber = (int)m_inputFlags.size() - 1; } if(ioFlags & IOControl::IN_VELOCITY) { m_choiceInput->Append(_("Velocity")); m_inputFlags.push_back(IOControl::IN_VELOCITY); - if(m_ioControl->GetValue() == IOControl::IN_VELOCITY) - inChoiceNumber = (int)m_inputFlags.size() - 1; + if(m_ioControl->GetValue() == IOControl::IN_VELOCITY) inChoiceNumber = (int)m_inputFlags.size() - 1; } if(ioFlags & IOControl::IN_ACTIVE_POWER) { m_choiceInput->Append(_("Active power")); m_inputFlags.push_back(IOControl::IN_ACTIVE_POWER); - if(m_ioControl->GetValue() == IOControl::IN_ACTIVE_POWER) - inChoiceNumber = (int)m_inputFlags.size() - 1; + if(m_ioControl->GetValue() == IOControl::IN_ACTIVE_POWER) inChoiceNumber = (int)m_inputFlags.size() - 1; } if(ioFlags & IOControl::IN_REACTIVE_POWER) { m_choiceInput->Append(_("Reactive power")); m_inputFlags.push_back(IOControl::IN_REACTIVE_POWER); - if(m_ioControl->GetValue() == IOControl::IN_REACTIVE_POWER) - inChoiceNumber = (int)m_inputFlags.size() - 1; + if(m_ioControl->GetValue() == IOControl::IN_REACTIVE_POWER) inChoiceNumber = (int)m_inputFlags.size() - 1; } if(ioFlags & IOControl::OUT_FIELD_VOLTAGE) { m_choiceOutput->Append(_("Field voltage")); m_outputFlags.push_back(IOControl::OUT_FIELD_VOLTAGE); - if(m_ioControl->GetValue() == IOControl::OUT_MEC_POWER) - outChoiceNumber = (int)m_outputFlags.size() - 1; + if(m_ioControl->GetValue() == IOControl::OUT_FIELD_VOLTAGE) outChoiceNumber = (int)m_outputFlags.size() - 1; } if(ioFlags & IOControl::OUT_MEC_POWER) { m_choiceOutput->Append(_("Mechanical power")); m_outputFlags.push_back(IOControl::OUT_MEC_POWER); - if(m_ioControl->GetValue() == IOControl::OUT_MEC_POWER) - outChoiceNumber = (int)m_outputFlags.size() - 1; + if(m_ioControl->GetValue() == IOControl::OUT_MEC_POWER) outChoiceNumber = (int)m_outputFlags.size() - 1; } - + if(inChoiceNumber != -1) { m_choiceInput->SetSelection(inChoiceNumber); m_checkBoxInput->SetValue(true); m_checkBoxOutput->SetValue(false); m_choiceOutput->Enable(false); } else { - m_choiceInput->SetSelection(outChoiceNumber); + m_choiceOutput->SetSelection(outChoiceNumber); m_checkBoxInput->SetValue(false); m_checkBoxOutput->SetValue(true); m_choiceInput->Enable(false); } - } -IOControlForm::~IOControlForm() -{ -} +IOControlForm::~IOControlForm() {} void IOControlForm::OnOKButtonClick(wxCommandEvent& event) { if(ValidateData()) EndModal(wxID_OK); @@ -71,11 +61,20 @@ void IOControlForm::OnOKButtonClick(wxCommandEvent& event) bool IOControlForm::ValidateData() { + if(m_checkBoxInput->GetValue() && m_choiceInput->GetSelection() != -1) { + m_ioControl->SetValue(m_inputFlags[m_choiceInput->GetSelection()]); + return true; + } else if(m_checkBoxOutput->GetValue() && m_choiceOutput->GetSelection() != -1) { + m_ioControl->SetValue(m_outputFlags[m_choiceOutput->GetSelection()]); + return true; + } + return false; } void IOControlForm::OnInputChecked(wxCommandEvent& event) { + m_checkBoxInput->SetValue(true); m_checkBoxOutput->SetValue(false); m_choiceOutput->Enable(false); m_choiceInput->Enable(true); @@ -83,6 +82,7 @@ void IOControlForm::OnInputChecked(wxCommandEvent& event) void IOControlForm::OnOutputChecked(wxCommandEvent& event) { + m_checkBoxOutput->SetValue(true); m_checkBoxInput->SetValue(false); m_choiceOutput->Enable(true); m_choiceInput->Enable(false); -- cgit