Initial commit almost identical to SVN-repo rev.340
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Elde.RegulValve
|
||||
{
|
||||
public partial class RegulValveCfgCtrl : UserControl, IComponentCfgCtrl
|
||||
{
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(RegulValveCfgCtrl));
|
||||
|
||||
ComponentParametersDlg parent;
|
||||
RegulValveCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
get { return config as IComponentCfg; }
|
||||
set
|
||||
{
|
||||
config = value as RegulValveCfg;
|
||||
Redraw();
|
||||
}
|
||||
}
|
||||
|
||||
public RegulValveCfgCtrl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void RegulationValveCfgCtrl_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();
|
||||
}
|
||||
|
||||
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.Position.ToString();
|
||||
dacClosedTextBox.Text = config.DacValueClosed.ToString();
|
||||
dacOpenTextBox.Text = config.DacValueOpen.ToString();
|
||||
pidCoefTextBox.Text = config.PidCoef.ToString();
|
||||
storedPosReuseCheckBox.Checked = config.StoredPositionReuse;
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
{
|
||||
nameTextBox.Enabled = true;
|
||||
parentNameComboBox.Enabled = true;
|
||||
positionTextBox.Enabled = true;
|
||||
dacClosedTextBox.Enabled = true;
|
||||
dacOpenTextBox.Enabled = true;
|
||||
pidCoefTextBox.Enabled = true;
|
||||
storedPosReuseCheckBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgVerifyFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgVerifyFlags flags = CfgVerifyFlags.None;
|
||||
|
||||
int dummy;
|
||||
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Parent Name'";
|
||||
}
|
||||
if (!int.TryParse(positionTextBox.Text, out dummy) || dummy < 1 || dummy > 5)
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
message += Environment.NewLine + "'Position' should be between 1 and 5";
|
||||
}
|
||||
if (!int.TryParse(dacClosedTextBox.Text, out dummy) || dummy < 0 || dummy > 1023)
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
message += Environment.NewLine + "'DAC when Closed' should be between 0 and 1023";
|
||||
}
|
||||
if (!int.TryParse(dacOpenTextBox.Text, out dummy) || dummy < 0 || dummy > 1023)
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
message += Environment.NewLine + "'DAC when Open' should be between 0 and 1023";
|
||||
}
|
||||
if (!int.TryParse(pidCoefTextBox.Text, out dummy) || dummy < 0 || dummy > 100)
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
message += Environment.NewLine + "'PID Coefficient' should be between 0 and 100";
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
public void UpdateCfg()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
|
||||
config.Name = nameTextBox.Text;
|
||||
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
|
||||
config.Position = int.Parse(positionTextBox.Text);
|
||||
config.DacValueClosed = int.Parse(dacClosedTextBox.Text);
|
||||
config.DacValueOpen = int.Parse(dacOpenTextBox.Text);
|
||||
config.PidCoef = int.Parse(pidCoefTextBox.Text);
|
||||
config.StoredPositionReuse = storedPosReuseCheckBox.Checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user