2017-12-18 12:35:29 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Copyright (c) 2017 Sensus Slovensko a.s.
|
|
|
|
|
|
///
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Windows.Forms;
|
2018-06-18 12:37:57 +00:00
|
|
|
|
using Config.Entities;
|
2017-12-18 12:35:29 +00:00
|
|
|
|
using TBF.BenchControl.Generic;
|
|
|
|
|
|
|
|
|
|
|
|
namespace TBF.BenchControl.Elde.FlowMeterTriplet
|
|
|
|
|
|
{
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
if (parent.TbfComponents != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var cmpnt in parent.TbfComponents)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.ControlBoardFactory)
|
|
|
|
|
|
{
|
|
|
|
|
|
parentNameComboBox.Items.Add(cmpnt.Name);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
|
|
|
|
|
|
positionTextBox.Text = config.Idx1.ToString();
|
|
|
|
|
|
nominalFlowTextBox.Text = config.NominalFlow.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Unlock()
|
|
|
|
|
|
{
|
|
|
|
|
|
nameTextBox.Enabled = true;
|
|
|
|
|
|
parentNameComboBox.Enabled = true;
|
|
|
|
|
|
positionTextBox.Enabled = true;
|
|
|
|
|
|
nominalFlowTextBox.Enabled = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public CfgUpdateFlags VerifyCfg(ref string message)
|
|
|
|
|
|
{
|
|
|
|
|
|
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
|
|
|
|
|
|
|
|
|
|
|
int dummy;
|
|
|
|
|
|
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
|
|
|
|
|
|
{
|
|
|
|
|
|
flags |= CfgUpdateFlags.Error;
|
|
|
|
|
|
message += Environment.NewLine + "Invalid 'Parent Name'";
|
|
|
|
|
|
}
|
|
|
|
|
|
#if MALTA_WSD25
|
|
|
|
|
|
if (!int.TryParse(positionTextBox.Text, out dummy) || dummy < 0 || dummy > 8)
|
|
|
|
|
|
{
|
|
|
|
|
|
flags |= CfgUpdateFlags.Error;
|
|
|
|
|
|
message += Environment.NewLine + "'Idx1' should be between 0 and 8";
|
|
|
|
|
|
}
|
|
|
|
|
|
#else
|
|
|
|
|
|
if (!int.TryParse(positionTextBox.Text, out dummy) || dummy < 1 || dummy > 7)
|
|
|
|
|
|
{
|
|
|
|
|
|
flags |= CfgUpdateFlags.Error;
|
|
|
|
|
|
message += Environment.NewLine + "'Idx1' should be between 1 and 7";
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
2019-04-11 11:45:28 +00:00
|
|
|
|
double ddummy;
|
|
|
|
|
|
if (!Utils.TryParseUDouble(nominalFlowTextBox.Text, out ddummy) || ddummy < 0.01 || ddummy > 1600)
|
2017-12-18 12:35:29 +00:00
|
|
|
|
{
|
|
|
|
|
|
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;
|
|
|
|
|
|
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
|
|
|
|
|
|
config.Idx1 = int.Parse(positionTextBox.Text);
|
2019-04-11 11:45:28 +00:00
|
|
|
|
Utils.TryParseUDouble(nominalFlowTextBox.Text, out config.NominalFlow);
|
2017-12-18 12:35:29 +00:00
|
|
|
|
|
|
|
|
|
|
return flags;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|