Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
RateLimiterForm.cpp
1/*
2 * Copyright (C) 2017 Thales Lima Oliveira <thales@ufu.br>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#include "RateLimiterForm.h"
19#include "../elements/controlElement/RateLimiter.h"
20
21RateLimiterForm::RateLimiterForm(wxWindow* parent, RateLimiter* rateLimiter) : RateLimiterFormBase(parent)
22{
23 SetSize(GetBestSize());
24
25 m_rateLimiter = rateLimiter;
26 m_parent = parent;
27
28 m_textCtrlUpLimit->SetValue(m_rateLimiter->StringFromDouble(m_rateLimiter->GetUpLimit()));
29 m_textCtrlLowLimit->SetValue(m_rateLimiter->StringFromDouble(m_rateLimiter->GetLowLimit()));
30}
31
32RateLimiterForm::~RateLimiterForm() {}
33bool RateLimiterForm::ValidateData()
34{
35 double upLimit;
36 double lowLimit;
37
38 if(!m_rateLimiter->DoubleFromString(this, m_textCtrlUpLimit->GetValue(), upLimit,
39 _("Value entered incorrectly in the field \"Upper limit\".")))
40 return false;
41 if(!m_rateLimiter->DoubleFromString(this, m_textCtrlLowLimit->GetValue(), lowLimit,
42 _("Value entered incorrectly in the field \"Lower limit\".")))
43 return false;
44
45 m_rateLimiter->SetUpLimit(upLimit);
46 m_rateLimiter->SetLowLimit(lowLimit);
47
48 return true;
49}
50
51void RateLimiterForm::OnOKButtonClick(wxCommandEvent& event)
52{
53 if(ValidateData()) EndModal(wxID_OK);
54}
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.
Definition Element.cpp:505
Limits the rising and/or falling rate.
Definition RateLimiter.h:33