2017-01-25 15:15:11 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Copyright (c) 2017 Sensus Metering Systems
|
|
|
|
|
|
///
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Windows.Forms;
|
2018-06-18 12:37:57 +00:00
|
|
|
|
using Config.Entities;
|
2017-01-25 15:15:11 +00:00
|
|
|
|
using TBF.BenchControl.Generic;
|
|
|
|
|
|
|
2019-09-16 08:51:25 +00:00
|
|
|
|
|
2017-01-25 15:15:11 +00:00
|
|
|
|
namespace TBF.BenchControl.Dummy.FlowMeter
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class FlowMeterCfgCtrl : UserControl, IComponentCfgCtrl
|
|
|
|
|
|
{
|
|
|
|
|
|
ComponentParametersDlg parent;
|
|
|
|
|
|
|
|
|
|
|
|
public bool ShowMore { get { return false; } }
|
|
|
|
|
|
|
|
|
|
|
|
FlowMeterCfg config;
|
|
|
|
|
|
public IComponentCfg Config
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return config as IComponentCfg; }
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
config = value as FlowMeterCfg;
|
|
|
|
|
|
Redraw();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public FlowMeterCfgCtrl()
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void FlowMeterCfgCtrl_Load(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
parent = ParentForm as ComponentParametersDlg;
|
|
|
|
|
|
if (parent == null) return;
|
|
|
|
|
|
|
|
|
|
|
|
Redraw();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Closing()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Redraw()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (config == null) return; /// Control was not loaded, settings were not changed
|
|
|
|
|
|
|
|
|
|
|
|
classNameLabel.Text = config.Factory.ClassName;
|
|
|
|
|
|
nameTextBox.Text = config.Name;
|
|
|
|
|
|
nominalFlowTextBox.Text = config.NominalFlow.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Unlock()
|
|
|
|
|
|
{
|
|
|
|
|
|
nameTextBox.Enabled = true;
|
|
|
|
|
|
nominalFlowTextBox.Enabled = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public CfgUpdateFlags VerifyCfg(ref string message)
|
|
|
|
|
|
{
|
|
|
|
|
|
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
|
|
|
|
|
|
|
|
|
|
|
float fdummy;
|
|
|
|
|
|
if (!Utils.TryParseUFloat(nominalFlowTextBox.Text, out fdummy) || fdummy < 0.01 || fdummy > 1600)
|
|
|
|
|
|
{
|
|
|
|
|
|
flags |= CfgUpdateFlags.Error;
|
|
|
|
|
|
message += Environment.NewLine + "'Nominal flow' should be between 0.01 and 1600";
|
|
|
|
|
|
}
|
|
|
|
|
|
return flags;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public CfgUpdateFlags UpdateCfg()
|
|
|
|
|
|
{
|
|
|
|
|
|
CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
|
|
|
|
|
|
|
|
|
|
|
|
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
|
|
|
|
|
|
|
|
|
|
|
|
config.Name = nameTextBox.Text;
|
|
|
|
|
|
Utils.TryParseUFloat(nominalFlowTextBox.Text, out config.NominalFlow);
|
|
|
|
|
|
|
|
|
|
|
|
return flags;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|