- RegulValve ADC Open/Close values calibration implemented
- 'More' button added to ComponentCfgCtrl-s - Dataflow from ComponentParametersDlg to components: CfgChangeHandler - Dataflow from components to ComponentParametersDlg: CmdResponseHandler - Detection of parameter changes and appropriate MesssageBox display: 1.warning message when component configuration change requires program restart 2.confirmation message box when any configuration changes would be lost
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Elde
|
||||
{
|
||||
public partial class ControlBoardCfgCtrl : UserControl, IComponentCfgCtrl
|
||||
{
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(ControlBoardCfgCtrl));
|
||||
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
ControlBoardCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
@@ -27,6 +32,10 @@ namespace TBF.BenchControl.Elde
|
||||
Redraw();
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
{
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
@@ -47,15 +56,15 @@ namespace TBF.BenchControl.Elde
|
||||
/// Called when user wants to close/save the configuration.
|
||||
/// </summary>
|
||||
/// <returns>See VerifyFlags</returns>
|
||||
public CfgVerifyFlags VerifyCfg(ref string message)
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgVerifyFlags flags = CfgVerifyFlags.None;
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
int dummy;
|
||||
if (!int.TryParse(comPortNrTextBox.Text, out dummy) || dummy <= 0 || dummy > 999)
|
||||
{
|
||||
message += "Control board serial port number is invalid";
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
}
|
||||
|
||||
return flags;
|
||||
@@ -64,12 +73,16 @@ namespace TBF.BenchControl.Elde
|
||||
/// <summary>
|
||||
/// Save settings to the configuration class.
|
||||
/// </summary>
|
||||
public void UpdateCfg()
|
||||
public CfgUpdateFlags UpdateCfg()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
///
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
|
||||
|
||||
this.Name = nameTextBox.Text;
|
||||
this.config.ComPortNr = int.Parse(comPortNrTextBox.Text);
|
||||
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Elde.Diverter
|
||||
{
|
||||
public partial class DiverterCfgCtrl : UserControl, IComponentCfgCtrl
|
||||
{
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(DiverterCfgCtrl));
|
||||
|
||||
ComponentParametersDlg parent;
|
||||
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
DiverterCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
@@ -42,6 +48,10 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
Redraw();
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
{
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
@@ -59,31 +69,35 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
bitPositionTextBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgVerifyFlags VerifyCfg(ref string message)
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgVerifyFlags flags = CfgVerifyFlags.None;
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
int dummy;
|
||||
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Parent Name'";
|
||||
}
|
||||
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 64)
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Bit Position' should be between 0 and 63";
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
public void UpdateCfg()
|
||||
public CfgUpdateFlags UpdateCfg()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
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.BitPosition = int.Parse(bitPositionTextBox.Text);
|
||||
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+16
-5
@@ -10,6 +10,9 @@ namespace TBF.BenchControl.Elde.FixedStartRegisterReader
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(RegisterReaderCfgCtrl));
|
||||
|
||||
ComponentParametersDlg parent;
|
||||
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
RegisterReaderCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
@@ -45,6 +48,10 @@ namespace TBF.BenchControl.Elde.FixedStartRegisterReader
|
||||
Redraw();
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
{
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
@@ -60,24 +67,28 @@ namespace TBF.BenchControl.Elde.FixedStartRegisterReader
|
||||
parentNameComboBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgVerifyFlags VerifyCfg(ref string message)
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgVerifyFlags flags = CfgVerifyFlags.None;
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Parent Name'";
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
public void UpdateCfg()
|
||||
public CfgUpdateFlags UpdateCfg()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
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;
|
||||
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@ namespace TBF.BenchControl.Elde.FlowMeter
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(FlowMeterCfgCtrl));
|
||||
|
||||
ComponentParametersDlg parent;
|
||||
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
FlowMeterCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
@@ -46,6 +49,10 @@ namespace TBF.BenchControl.Elde.FlowMeter
|
||||
Redraw();
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
{
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
@@ -65,38 +72,42 @@ namespace TBF.BenchControl.Elde.FlowMeter
|
||||
nominalFlowTextBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgVerifyFlags VerifyCfg(ref string message)
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgVerifyFlags flags = CfgVerifyFlags.None;
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
int dummy;
|
||||
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Parent Name'";
|
||||
}
|
||||
if (!int.TryParse(positionTextBox.Text, out dummy) || dummy < 1 || dummy > 7)
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Idx1' should be between 1 and 7";
|
||||
}
|
||||
float fdummy;
|
||||
if (!Utils.TryParseUFloat(nominalFlowTextBox.Text, out fdummy) || fdummy < 0.2 || fdummy > 1600)
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Nominal flow' should be between 0.2 and 1600";
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
public void UpdateCfg()
|
||||
public CfgUpdateFlags UpdateCfg()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
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);
|
||||
Utils.TryParseUFloat(nominalFlowTextBox.Text, out config.NominalFlow);
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@ namespace TBF.BenchControl.Elde.FlowMeterTwins
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(FlowMeterCfgCtrl));
|
||||
|
||||
ComponentParametersDlg parent;
|
||||
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
FlowMeterCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
@@ -51,6 +54,10 @@ namespace TBF.BenchControl.Elde.FlowMeterTwins
|
||||
Redraw();
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
{
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
@@ -72,43 +79,47 @@ namespace TBF.BenchControl.Elde.FlowMeterTwins
|
||||
nominalFlowTextBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgVerifyFlags VerifyCfg(ref string message)
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgVerifyFlags flags = CfgVerifyFlags.None;
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Parent Name'";
|
||||
}
|
||||
if (!flowMeter1ComboBox.Items.Contains(flowMeter1ComboBox.Text))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Flow Meter 1'";
|
||||
}
|
||||
if (!flowMeter2ComboBox.Items.Contains(flowMeter2ComboBox.Text))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Flow Meter 2'";
|
||||
}
|
||||
float fdummy;
|
||||
if (!Utils.TryParseUFloat(nominalFlowTextBox.Text, out fdummy) || fdummy < 0.2 || fdummy > 1600)
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Nominal flow' should be between 0.2 and 1600";
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
public void UpdateCfg()
|
||||
public CfgUpdateFlags UpdateCfg()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
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.FlowMeter1 = flowMeter1ComboBox.Text.Equals("---") ? string.Empty : flowMeter1ComboBox.Text;
|
||||
config.FlowMeter2 = flowMeter2ComboBox.Text.Equals("---") ? string.Empty : flowMeter2ComboBox.Text;
|
||||
Utils.TryParseUFloat(nominalFlowTextBox.Text, out config.NominalFlow);
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ namespace TBF.BenchControl.Elde.PressureMeter
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(PressureMeterCfgCtrl));
|
||||
|
||||
ComponentParametersDlg parent;
|
||||
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
PressureMeterCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
@@ -45,6 +48,10 @@ namespace TBF.BenchControl.Elde.PressureMeter
|
||||
Redraw();
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
{
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
@@ -64,37 +71,41 @@ namespace TBF.BenchControl.Elde.PressureMeter
|
||||
rs485AddressTextBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgVerifyFlags VerifyCfg(ref string message)
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgVerifyFlags flags = CfgVerifyFlags.None;
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
int dummy;
|
||||
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Parent Name'";
|
||||
}
|
||||
if (!int.TryParse(positionTextBox.Text, out dummy) || dummy < 0 || dummy > 7)
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Position' should be between 0 and 7";
|
||||
}
|
||||
if (!int.TryParse(rs485AddressTextBox.Text, out dummy) || dummy < 0 || dummy > 255)
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'RS485 Address' should be between 0 and 255";
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
public void UpdateCfg()
|
||||
public CfgUpdateFlags UpdateCfg()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
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.Idx0 = int.Parse(positionTextBox.Text);
|
||||
config.RS485Address = (byte)int.Parse(rs485AddressTextBox.Text);
|
||||
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ namespace TBF.BenchControl.Elde.Pump
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(PumpCfgCtrl));
|
||||
|
||||
ComponentParametersDlg parent;
|
||||
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
PumpCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
@@ -45,6 +48,10 @@ namespace TBF.BenchControl.Elde.Pump
|
||||
Redraw();
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
{
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
@@ -64,34 +71,38 @@ namespace TBF.BenchControl.Elde.Pump
|
||||
delayTextBox.Enabled = true;
|
||||
}
|
||||
|
||||
public void UpdateCfg()
|
||||
public CfgUpdateFlags UpdateCfg()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
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.BitPosition = int.Parse(bitPositionTextBox.Text);
|
||||
config.Delay = int.Parse(delayTextBox.Text);
|
||||
}
|
||||
|
||||
public CfgVerifyFlags VerifyCfg(ref string message)
|
||||
return flags;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgVerifyFlags flags = CfgVerifyFlags.None;
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
int dummy;
|
||||
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Parent Name'";
|
||||
}
|
||||
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 64)
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Bit Position' should be between 0 and 63";
|
||||
}
|
||||
if (!int.TryParse(delayTextBox.Text, out dummy) || dummy < 0 || dummy >= 300)
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Delay' should be between 0 and 300s (5min)";
|
||||
}
|
||||
return flags;
|
||||
|
||||
@@ -10,6 +10,9 @@ namespace TBF.BenchControl.Elde.PumpWithFM
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(PumpCfgCtrl));
|
||||
|
||||
ComponentParametersDlg parent;
|
||||
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
PumpCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
@@ -45,6 +48,10 @@ namespace TBF.BenchControl.Elde.PumpWithFM
|
||||
Redraw();
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
{
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
@@ -66,40 +73,44 @@ namespace TBF.BenchControl.Elde.PumpWithFM
|
||||
delayTextBox.Enabled = true;
|
||||
}
|
||||
|
||||
public void UpdateCfg()
|
||||
public CfgUpdateFlags UpdateCfg()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
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.BitPosition = int.Parse(bitPositionTextBox.Text);
|
||||
config.FMIndex = int.Parse(fmIndexTextBox.Text);
|
||||
config.Delay = int.Parse(delayTextBox.Text);
|
||||
}
|
||||
|
||||
public CfgVerifyFlags VerifyCfg(ref string message)
|
||||
return flags;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgVerifyFlags flags = CfgVerifyFlags.None;
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
int dummy;
|
||||
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Parent Name'";
|
||||
}
|
||||
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 64)
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Bit Position' should be between 0 and 63";
|
||||
}
|
||||
if (!int.TryParse(fmIndexTextBox.Text, out dummy) || dummy < 0)
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'FM Index' should be between 0 and FMPumpsCount - 1";
|
||||
}
|
||||
if (!int.TryParse(delayTextBox.Text, out dummy) || dummy < 0 || dummy >= 300)
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Delay' should be between 0 and 300s (5min)";
|
||||
}
|
||||
return flags;
|
||||
|
||||
@@ -10,6 +10,9 @@ namespace TBF.BenchControl.Elde.RegisterReader
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(RegisterReaderCfgCtrl));
|
||||
|
||||
ComponentParametersDlg parent;
|
||||
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
RegisterReaderCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
@@ -45,6 +48,10 @@ namespace TBF.BenchControl.Elde.RegisterReader
|
||||
Redraw();
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
{
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
@@ -62,31 +69,35 @@ namespace TBF.BenchControl.Elde.RegisterReader
|
||||
positionTextBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgVerifyFlags VerifyCfg(ref string message)
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgVerifyFlags flags = CfgVerifyFlags.None;
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
int dummy;
|
||||
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Parent Name'";
|
||||
}
|
||||
if (!int.TryParse(positionTextBox.Text, out dummy) || (dummy < 1))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Position' should be >= 1";
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
public void UpdateCfg()
|
||||
public CfgUpdateFlags UpdateCfg()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
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.Position = int.Parse(positionTextBox.Text);
|
||||
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,56 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
get { return controlBoard.RValvePosition(Idx1); }
|
||||
}
|
||||
|
||||
|
||||
#region Configuration Change Handling
|
||||
|
||||
public static void OnCfgChange(object sender, CfgChangeArgs args)
|
||||
{
|
||||
if (CfgChangeHandler == null) return;
|
||||
try { CfgChangeHandler(sender, args); }
|
||||
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
|
||||
}
|
||||
|
||||
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
|
||||
|
||||
public override void StartChangeHandler()
|
||||
{
|
||||
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
|
||||
{
|
||||
RegulValveCfg tmpcfg = args.Cfg as RegulValveCfg;
|
||||
if (tmpcfg != null && tmpcfg.Name.Equals(Name))
|
||||
{
|
||||
if (args.Command == CfgChangeCmd.CfgChange)
|
||||
{
|
||||
RegulValveCfg.PidCoef = tmpcfg.PidCoef;
|
||||
RegulValveCfg.StableTimeMs = tmpcfg.StableTimeMs;
|
||||
RegulValveCfg.FlowStableSec = tmpcfg.FlowStableSec;
|
||||
}
|
||||
else if (args.Command == CfgChangeCmd.RVOpenStep)
|
||||
{
|
||||
controlBoard.ValveMove(Idx1, RegulValveMode.PulseWidth, new float[2] { 0.05f, 0.05f }, StableTime);
|
||||
// TODO: avoid conflicts
|
||||
// TOTEST
|
||||
}
|
||||
else if (args.Command == CfgChangeCmd.RVCloseStep)
|
||||
{
|
||||
controlBoard.ValveMove(Idx1, RegulValveMode.PulseWidth, new float[2] { -0.05f, -0.05f }, StableTime);
|
||||
// TODO: avoid conflicts
|
||||
// TOTEST
|
||||
}
|
||||
else if (args.Command == CfgChangeCmd.GetRVAdc1 || args.Command == CfgChangeCmd.GetRVAdc2)
|
||||
{
|
||||
int adc = (int)controlBoard.AnalogInputRaw(Idx1, 0);
|
||||
// TOTEST
|
||||
RegulValveCfgCtrl.OnCmdResponse(this, new CmdResponseArgs(args.Command, adc));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endregion Configuration Change Handling
|
||||
|
||||
|
||||
public RegulValve(RegulValveCfg cfg, IList<Generic.IComponent> components)
|
||||
: base(cfg)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace TBF.BenchControl.Elde.RegulValve
|
||||
{
|
||||
public class RegulValveCfgChangeArgs : EventArgs
|
||||
{
|
||||
public CfgChangeCmd Command;
|
||||
public Generic.IComponentCfg Cfg;
|
||||
|
||||
public RegulValveCfgChangeArgs(CfgChangeCmd command, Generic.IComponentCfg cfg)
|
||||
{
|
||||
Command = command;
|
||||
Cfg = cfg;
|
||||
}
|
||||
}
|
||||
}
|
||||
+414
-204
@@ -28,210 +28,403 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.positionTextBox = new System.Windows.Forms.TextBox();
|
||||
this.positionLabel = new System.Windows.Forms.Label();
|
||||
this.parentNameLabel = new System.Windows.Forms.Label();
|
||||
this.nameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.nameLabel = new System.Windows.Forms.Label();
|
||||
this.classNameLabel = new System.Windows.Forms.Label();
|
||||
this.dacClosedLabel = new System.Windows.Forms.Label();
|
||||
this.dacClosedTextBox = new System.Windows.Forms.TextBox();
|
||||
this.dacOpenTextBox = new System.Windows.Forms.TextBox();
|
||||
this.dacOpenLabel = new System.Windows.Forms.Label();
|
||||
this.parentNameComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.pidCoefLabel = new System.Windows.Forms.Label();
|
||||
this.pidCoefTextBox = new System.Windows.Forms.TextBox();
|
||||
this.storedPosReuseCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.stableTimeTextBox = new System.Windows.Forms.TextBox();
|
||||
this.stableTimeLabel = new System.Windows.Forms.Label();
|
||||
this.flowStableSecTextBox = new System.Windows.Forms.TextBox();
|
||||
this.flowStableSecLabel = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// positionTextBox
|
||||
//
|
||||
this.positionTextBox.Enabled = false;
|
||||
this.positionTextBox.Location = new System.Drawing.Point(138, 78);
|
||||
this.positionTextBox.Name = "positionTextBox";
|
||||
this.positionTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.positionTextBox.TabIndex = 6;
|
||||
//
|
||||
// positionLabel
|
||||
//
|
||||
this.positionLabel.AutoSize = true;
|
||||
this.positionLabel.Location = new System.Drawing.Point(28, 81);
|
||||
this.positionLabel.Name = "positionLabel";
|
||||
this.positionLabel.Size = new System.Drawing.Size(18, 13);
|
||||
this.positionLabel.TabIndex = 5;
|
||||
this.positionLabel.Text = "ID";
|
||||
//
|
||||
// parentNameLabel
|
||||
//
|
||||
this.parentNameLabel.AutoSize = true;
|
||||
this.parentNameLabel.Location = new System.Drawing.Point(28, 57);
|
||||
this.parentNameLabel.Name = "parentNameLabel";
|
||||
this.parentNameLabel.Size = new System.Drawing.Size(69, 13);
|
||||
this.parentNameLabel.TabIndex = 3;
|
||||
this.parentNameLabel.Text = "Parent Name";
|
||||
//
|
||||
// nameTextBox
|
||||
//
|
||||
this.nameTextBox.Enabled = false;
|
||||
this.nameTextBox.Location = new System.Drawing.Point(138, 30);
|
||||
this.nameTextBox.Name = "nameTextBox";
|
||||
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
|
||||
this.nameTextBox.TabIndex = 2;
|
||||
//
|
||||
// nameLabel
|
||||
//
|
||||
this.nameLabel.AutoSize = true;
|
||||
this.nameLabel.Location = new System.Drawing.Point(28, 33);
|
||||
this.nameLabel.Name = "nameLabel";
|
||||
this.nameLabel.Size = new System.Drawing.Size(35, 13);
|
||||
this.nameLabel.TabIndex = 1;
|
||||
this.nameLabel.Text = "Name";
|
||||
//
|
||||
// classNameLabel
|
||||
//
|
||||
this.classNameLabel.AutoSize = true;
|
||||
this.classNameLabel.Location = new System.Drawing.Point(135, 9);
|
||||
this.classNameLabel.Name = "classNameLabel";
|
||||
this.classNameLabel.Size = new System.Drawing.Size(89, 13);
|
||||
this.classNameLabel.TabIndex = 0;
|
||||
this.classNameLabel.Text = "ComponentName";
|
||||
//
|
||||
// dacClosedLabel
|
||||
//
|
||||
this.dacClosedLabel.AutoSize = true;
|
||||
this.dacClosedLabel.Location = new System.Drawing.Point(28, 104);
|
||||
this.dacClosedLabel.Name = "dacClosedLabel";
|
||||
this.dacClosedLabel.Size = new System.Drawing.Size(93, 13);
|
||||
this.dacClosedLabel.TabIndex = 7;
|
||||
this.dacClosedLabel.Text = "DAC when Closed";
|
||||
//
|
||||
// dacClosedTextBox
|
||||
//
|
||||
this.dacClosedTextBox.Enabled = false;
|
||||
this.dacClosedTextBox.Location = new System.Drawing.Point(138, 101);
|
||||
this.dacClosedTextBox.Name = "dacClosedTextBox";
|
||||
this.dacClosedTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.dacClosedTextBox.TabIndex = 8;
|
||||
//
|
||||
// dacOpenTextBox
|
||||
//
|
||||
this.dacOpenTextBox.Enabled = false;
|
||||
this.dacOpenTextBox.Location = new System.Drawing.Point(138, 124);
|
||||
this.dacOpenTextBox.Name = "dacOpenTextBox";
|
||||
this.dacOpenTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.dacOpenTextBox.TabIndex = 10;
|
||||
//
|
||||
// dacOpenLabel
|
||||
//
|
||||
this.dacOpenLabel.AutoSize = true;
|
||||
this.dacOpenLabel.Location = new System.Drawing.Point(28, 127);
|
||||
this.dacOpenLabel.Name = "dacOpenLabel";
|
||||
this.dacOpenLabel.Size = new System.Drawing.Size(87, 13);
|
||||
this.dacOpenLabel.TabIndex = 9;
|
||||
this.dacOpenLabel.Text = "DAC when Open";
|
||||
//
|
||||
// parentNameComboBox
|
||||
//
|
||||
this.parentNameComboBox.Enabled = false;
|
||||
this.parentNameComboBox.FormattingEnabled = true;
|
||||
this.parentNameComboBox.Location = new System.Drawing.Point(138, 54);
|
||||
this.parentNameComboBox.Name = "parentNameComboBox";
|
||||
this.parentNameComboBox.Size = new System.Drawing.Size(130, 21);
|
||||
this.parentNameComboBox.TabIndex = 4;
|
||||
//
|
||||
// pidCoefLabel
|
||||
//
|
||||
this.pidCoefLabel.AutoSize = true;
|
||||
this.pidCoefLabel.Location = new System.Drawing.Point(28, 150);
|
||||
this.pidCoefLabel.Name = "pidCoefLabel";
|
||||
this.pidCoefLabel.Size = new System.Drawing.Size(78, 13);
|
||||
this.pidCoefLabel.TabIndex = 11;
|
||||
this.pidCoefLabel.Text = "PID Coefficient";
|
||||
//
|
||||
// pidCoefTextBox
|
||||
//
|
||||
this.pidCoefTextBox.Enabled = false;
|
||||
this.pidCoefTextBox.Location = new System.Drawing.Point(138, 147);
|
||||
this.pidCoefTextBox.Name = "pidCoefTextBox";
|
||||
this.pidCoefTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.pidCoefTextBox.TabIndex = 12;
|
||||
//
|
||||
// storedPosReuseCheckBox
|
||||
//
|
||||
this.storedPosReuseCheckBox.AutoSize = true;
|
||||
this.storedPosReuseCheckBox.Enabled = false;
|
||||
this.storedPosReuseCheckBox.Location = new System.Drawing.Point(31, 196);
|
||||
this.storedPosReuseCheckBox.Name = "storedPosReuseCheckBox";
|
||||
this.storedPosReuseCheckBox.Size = new System.Drawing.Size(162, 17);
|
||||
this.storedPosReuseCheckBox.TabIndex = 13;
|
||||
this.storedPosReuseCheckBox.Text = "Enable stored position re-use";
|
||||
this.storedPosReuseCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// stableTimeTextBox
|
||||
//
|
||||
this.stableTimeTextBox.Enabled = false;
|
||||
this.stableTimeTextBox.Location = new System.Drawing.Point(138, 170);
|
||||
this.stableTimeTextBox.Name = "stableTimeTextBox";
|
||||
this.stableTimeTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.stableTimeTextBox.TabIndex = 15;
|
||||
//
|
||||
// stableTimeLabel
|
||||
//
|
||||
this.stableTimeLabel.AutoSize = true;
|
||||
this.stableTimeLabel.Location = new System.Drawing.Point(28, 173);
|
||||
this.stableTimeLabel.Name = "stableTimeLabel";
|
||||
this.stableTimeLabel.Size = new System.Drawing.Size(81, 13);
|
||||
this.stableTimeLabel.TabIndex = 14;
|
||||
this.stableTimeLabel.Text = "Stable time [ms]";
|
||||
//
|
||||
// flowStableSecTextBox
|
||||
//
|
||||
this.flowStableSecTextBox.Enabled = false;
|
||||
this.flowStableSecTextBox.Location = new System.Drawing.Point(138, 219);
|
||||
this.flowStableSecTextBox.Name = "flowStableSecTextBox";
|
||||
this.flowStableSecTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.flowStableSecTextBox.TabIndex = 17;
|
||||
//
|
||||
// flowStableSecLabel
|
||||
//
|
||||
this.flowStableSecLabel.AutoSize = true;
|
||||
this.flowStableSecLabel.Location = new System.Drawing.Point(28, 222);
|
||||
this.flowStableSecLabel.Name = "flowStableSecLabel";
|
||||
this.flowStableSecLabel.Size = new System.Drawing.Size(74, 13);
|
||||
this.flowStableSecLabel.TabIndex = 16;
|
||||
this.flowStableSecLabel.Text = "Flow stable [s]";
|
||||
//
|
||||
// RegulValveCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.flowStableSecTextBox);
|
||||
this.Controls.Add(this.flowStableSecLabel);
|
||||
this.Controls.Add(this.stableTimeTextBox);
|
||||
this.Controls.Add(this.stableTimeLabel);
|
||||
this.Controls.Add(this.storedPosReuseCheckBox);
|
||||
this.Controls.Add(this.pidCoefTextBox);
|
||||
this.Controls.Add(this.pidCoefLabel);
|
||||
this.Controls.Add(this.parentNameComboBox);
|
||||
this.Controls.Add(this.dacOpenTextBox);
|
||||
this.Controls.Add(this.dacOpenLabel);
|
||||
this.Controls.Add(this.dacClosedTextBox);
|
||||
this.Controls.Add(this.dacClosedLabel);
|
||||
this.Controls.Add(this.positionTextBox);
|
||||
this.Controls.Add(this.positionLabel);
|
||||
this.Controls.Add(this.parentNameLabel);
|
||||
this.Controls.Add(this.nameTextBox);
|
||||
this.Controls.Add(this.nameLabel);
|
||||
this.Controls.Add(this.classNameLabel);
|
||||
this.Name = "RegulValveCfgCtrl";
|
||||
this.Size = new System.Drawing.Size(300, 250);
|
||||
this.Load += new System.EventHandler(this.RegulationValveCfgCtrl_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
this.positionTextBox = new System.Windows.Forms.TextBox();
|
||||
this.positionLabel = new System.Windows.Forms.Label();
|
||||
this.parentNameLabel = new System.Windows.Forms.Label();
|
||||
this.nameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.nameLabel = new System.Windows.Forms.Label();
|
||||
this.classNameLabel = new System.Windows.Forms.Label();
|
||||
this.dacClosedLabel = new System.Windows.Forms.Label();
|
||||
this.dacClosedTextBox = new System.Windows.Forms.TextBox();
|
||||
this.dacOpenTextBox = new System.Windows.Forms.TextBox();
|
||||
this.dacOpenLabel = new System.Windows.Forms.Label();
|
||||
this.parentNameComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.pidCoefLabel = new System.Windows.Forms.Label();
|
||||
this.pidCoefTextBox = new System.Windows.Forms.TextBox();
|
||||
this.storedPosReuseCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.stableTimeTextBox = new System.Windows.Forms.TextBox();
|
||||
this.stableTimeLabel = new System.Windows.Forms.Label();
|
||||
this.flowStableSecTextBox = new System.Windows.Forms.TextBox();
|
||||
this.flowStableSecLabel = new System.Windows.Forms.Label();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.setButton1 = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.ADC = new System.Windows.Forms.Label();
|
||||
this.getButton1 = new System.Windows.Forms.Button();
|
||||
this.pctTextBox1 = new System.Windows.Forms.TextBox();
|
||||
this.adcTextBox1 = new System.Windows.Forms.TextBox();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.setButton2 = new System.Windows.Forms.Button();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.getButton2 = new System.Windows.Forms.Button();
|
||||
this.pctTextBox2 = new System.Windows.Forms.TextBox();
|
||||
this.adcTextBox2 = new System.Windows.Forms.TextBox();
|
||||
this.groupBox3 = new System.Windows.Forms.GroupBox();
|
||||
this.closeButton = new System.Windows.Forms.Button();
|
||||
this.openButton = new System.Windows.Forms.Button();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.groupBox3.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// positionTextBox
|
||||
//
|
||||
this.positionTextBox.Enabled = false;
|
||||
this.positionTextBox.Location = new System.Drawing.Point(138, 78);
|
||||
this.positionTextBox.Name = "positionTextBox";
|
||||
this.positionTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.positionTextBox.TabIndex = 6;
|
||||
//
|
||||
// positionLabel
|
||||
//
|
||||
this.positionLabel.AutoSize = true;
|
||||
this.positionLabel.Location = new System.Drawing.Point(28, 81);
|
||||
this.positionLabel.Name = "positionLabel";
|
||||
this.positionLabel.Size = new System.Drawing.Size(18, 13);
|
||||
this.positionLabel.TabIndex = 5;
|
||||
this.positionLabel.Text = "ID";
|
||||
//
|
||||
// parentNameLabel
|
||||
//
|
||||
this.parentNameLabel.AutoSize = true;
|
||||
this.parentNameLabel.Location = new System.Drawing.Point(28, 57);
|
||||
this.parentNameLabel.Name = "parentNameLabel";
|
||||
this.parentNameLabel.Size = new System.Drawing.Size(69, 13);
|
||||
this.parentNameLabel.TabIndex = 3;
|
||||
this.parentNameLabel.Text = "Parent Name";
|
||||
//
|
||||
// nameTextBox
|
||||
//
|
||||
this.nameTextBox.Enabled = false;
|
||||
this.nameTextBox.Location = new System.Drawing.Point(138, 30);
|
||||
this.nameTextBox.Name = "nameTextBox";
|
||||
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
|
||||
this.nameTextBox.TabIndex = 2;
|
||||
//
|
||||
// nameLabel
|
||||
//
|
||||
this.nameLabel.AutoSize = true;
|
||||
this.nameLabel.Location = new System.Drawing.Point(28, 33);
|
||||
this.nameLabel.Name = "nameLabel";
|
||||
this.nameLabel.Size = new System.Drawing.Size(35, 13);
|
||||
this.nameLabel.TabIndex = 1;
|
||||
this.nameLabel.Text = "Name";
|
||||
//
|
||||
// classNameLabel
|
||||
//
|
||||
this.classNameLabel.AutoSize = true;
|
||||
this.classNameLabel.Location = new System.Drawing.Point(135, 9);
|
||||
this.classNameLabel.Name = "classNameLabel";
|
||||
this.classNameLabel.Size = new System.Drawing.Size(89, 13);
|
||||
this.classNameLabel.TabIndex = 0;
|
||||
this.classNameLabel.Text = "ComponentName";
|
||||
//
|
||||
// dacClosedLabel
|
||||
//
|
||||
this.dacClosedLabel.AutoSize = true;
|
||||
this.dacClosedLabel.Location = new System.Drawing.Point(28, 104);
|
||||
this.dacClosedLabel.Name = "dacClosedLabel";
|
||||
this.dacClosedLabel.Size = new System.Drawing.Size(93, 13);
|
||||
this.dacClosedLabel.TabIndex = 7;
|
||||
this.dacClosedLabel.Text = "DAC when Closed";
|
||||
//
|
||||
// dacClosedTextBox
|
||||
//
|
||||
this.dacClosedTextBox.Enabled = false;
|
||||
this.dacClosedTextBox.Location = new System.Drawing.Point(138, 101);
|
||||
this.dacClosedTextBox.Name = "dacClosedTextBox";
|
||||
this.dacClosedTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.dacClosedTextBox.TabIndex = 8;
|
||||
//
|
||||
// dacOpenTextBox
|
||||
//
|
||||
this.dacOpenTextBox.Enabled = false;
|
||||
this.dacOpenTextBox.Location = new System.Drawing.Point(138, 124);
|
||||
this.dacOpenTextBox.Name = "dacOpenTextBox";
|
||||
this.dacOpenTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.dacOpenTextBox.TabIndex = 10;
|
||||
//
|
||||
// dacOpenLabel
|
||||
//
|
||||
this.dacOpenLabel.AutoSize = true;
|
||||
this.dacOpenLabel.Location = new System.Drawing.Point(28, 127);
|
||||
this.dacOpenLabel.Name = "dacOpenLabel";
|
||||
this.dacOpenLabel.Size = new System.Drawing.Size(87, 13);
|
||||
this.dacOpenLabel.TabIndex = 9;
|
||||
this.dacOpenLabel.Text = "DAC when Open";
|
||||
//
|
||||
// parentNameComboBox
|
||||
//
|
||||
this.parentNameComboBox.Enabled = false;
|
||||
this.parentNameComboBox.FormattingEnabled = true;
|
||||
this.parentNameComboBox.Location = new System.Drawing.Point(138, 54);
|
||||
this.parentNameComboBox.Name = "parentNameComboBox";
|
||||
this.parentNameComboBox.Size = new System.Drawing.Size(130, 21);
|
||||
this.parentNameComboBox.TabIndex = 4;
|
||||
//
|
||||
// pidCoefLabel
|
||||
//
|
||||
this.pidCoefLabel.AutoSize = true;
|
||||
this.pidCoefLabel.Location = new System.Drawing.Point(28, 150);
|
||||
this.pidCoefLabel.Name = "pidCoefLabel";
|
||||
this.pidCoefLabel.Size = new System.Drawing.Size(78, 13);
|
||||
this.pidCoefLabel.TabIndex = 11;
|
||||
this.pidCoefLabel.Text = "PID Coefficient";
|
||||
//
|
||||
// pidCoefTextBox
|
||||
//
|
||||
this.pidCoefTextBox.Enabled = false;
|
||||
this.pidCoefTextBox.Location = new System.Drawing.Point(138, 147);
|
||||
this.pidCoefTextBox.Name = "pidCoefTextBox";
|
||||
this.pidCoefTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.pidCoefTextBox.TabIndex = 12;
|
||||
//
|
||||
// storedPosReuseCheckBox
|
||||
//
|
||||
this.storedPosReuseCheckBox.AutoSize = true;
|
||||
this.storedPosReuseCheckBox.Enabled = false;
|
||||
this.storedPosReuseCheckBox.Location = new System.Drawing.Point(31, 196);
|
||||
this.storedPosReuseCheckBox.Name = "storedPosReuseCheckBox";
|
||||
this.storedPosReuseCheckBox.Size = new System.Drawing.Size(162, 17);
|
||||
this.storedPosReuseCheckBox.TabIndex = 13;
|
||||
this.storedPosReuseCheckBox.Text = "Enable stored position re-use";
|
||||
this.storedPosReuseCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// stableTimeTextBox
|
||||
//
|
||||
this.stableTimeTextBox.Enabled = false;
|
||||
this.stableTimeTextBox.Location = new System.Drawing.Point(138, 170);
|
||||
this.stableTimeTextBox.Name = "stableTimeTextBox";
|
||||
this.stableTimeTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.stableTimeTextBox.TabIndex = 15;
|
||||
//
|
||||
// stableTimeLabel
|
||||
//
|
||||
this.stableTimeLabel.AutoSize = true;
|
||||
this.stableTimeLabel.Location = new System.Drawing.Point(28, 173);
|
||||
this.stableTimeLabel.Name = "stableTimeLabel";
|
||||
this.stableTimeLabel.Size = new System.Drawing.Size(81, 13);
|
||||
this.stableTimeLabel.TabIndex = 14;
|
||||
this.stableTimeLabel.Text = "Stable time [ms]";
|
||||
//
|
||||
// flowStableSecTextBox
|
||||
//
|
||||
this.flowStableSecTextBox.Enabled = false;
|
||||
this.flowStableSecTextBox.Location = new System.Drawing.Point(138, 219);
|
||||
this.flowStableSecTextBox.Name = "flowStableSecTextBox";
|
||||
this.flowStableSecTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.flowStableSecTextBox.TabIndex = 17;
|
||||
//
|
||||
// flowStableSecLabel
|
||||
//
|
||||
this.flowStableSecLabel.AutoSize = true;
|
||||
this.flowStableSecLabel.Location = new System.Drawing.Point(28, 222);
|
||||
this.flowStableSecLabel.Name = "flowStableSecLabel";
|
||||
this.flowStableSecLabel.Size = new System.Drawing.Size(74, 13);
|
||||
this.flowStableSecLabel.TabIndex = 16;
|
||||
this.flowStableSecLabel.Text = "Flow stable [s]";
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.setButton1);
|
||||
this.groupBox1.Controls.Add(this.label1);
|
||||
this.groupBox1.Controls.Add(this.ADC);
|
||||
this.groupBox1.Controls.Add(this.getButton1);
|
||||
this.groupBox1.Controls.Add(this.pctTextBox1);
|
||||
this.groupBox1.Controls.Add(this.adcTextBox1);
|
||||
this.groupBox1.Location = new System.Drawing.Point(17, 273);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(280, 68);
|
||||
this.groupBox1.TabIndex = 18;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Measured value 1";
|
||||
//
|
||||
// setButton1
|
||||
//
|
||||
this.setButton1.Location = new System.Drawing.Point(229, 21);
|
||||
this.setButton1.Name = "setButton1";
|
||||
this.setButton1.Size = new System.Drawing.Size(38, 33);
|
||||
this.setButton1.TabIndex = 5;
|
||||
this.setButton1.Text = "Set";
|
||||
this.setButton1.UseVisualStyleBackColor = true;
|
||||
this.setButton1.Click += new System.EventHandler(this.setButton1_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(209, 32);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(15, 13);
|
||||
this.label1.TabIndex = 4;
|
||||
this.label1.Text = "%";
|
||||
//
|
||||
// ADC
|
||||
//
|
||||
this.ADC.AutoSize = true;
|
||||
this.ADC.Location = new System.Drawing.Point(11, 32);
|
||||
this.ADC.Name = "ADC";
|
||||
this.ADC.Size = new System.Drawing.Size(32, 13);
|
||||
this.ADC.TabIndex = 3;
|
||||
this.ADC.Text = "ADC:";
|
||||
//
|
||||
// getButton1
|
||||
//
|
||||
this.getButton1.Location = new System.Drawing.Point(101, 22);
|
||||
this.getButton1.Name = "getButton1";
|
||||
this.getButton1.Size = new System.Drawing.Size(38, 33);
|
||||
this.getButton1.TabIndex = 2;
|
||||
this.getButton1.Text = "Get";
|
||||
this.getButton1.UseVisualStyleBackColor = true;
|
||||
this.getButton1.Click += new System.EventHandler(this.getButton1_Click);
|
||||
//
|
||||
// pctTextBox1
|
||||
//
|
||||
this.pctTextBox1.Location = new System.Drawing.Point(160, 28);
|
||||
this.pctTextBox1.Name = "pctTextBox1";
|
||||
this.pctTextBox1.Size = new System.Drawing.Size(46, 20);
|
||||
this.pctTextBox1.TabIndex = 1;
|
||||
//
|
||||
// adcTextBox1
|
||||
//
|
||||
this.adcTextBox1.Location = new System.Drawing.Point(47, 28);
|
||||
this.adcTextBox1.Name = "adcTextBox1";
|
||||
this.adcTextBox1.Size = new System.Drawing.Size(44, 20);
|
||||
this.adcTextBox1.TabIndex = 0;
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.setButton2);
|
||||
this.groupBox2.Controls.Add(this.label2);
|
||||
this.groupBox2.Controls.Add(this.label3);
|
||||
this.groupBox2.Controls.Add(this.getButton2);
|
||||
this.groupBox2.Controls.Add(this.pctTextBox2);
|
||||
this.groupBox2.Controls.Add(this.adcTextBox2);
|
||||
this.groupBox2.Location = new System.Drawing.Point(17, 350);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(280, 68);
|
||||
this.groupBox2.TabIndex = 19;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Measured value 2";
|
||||
//
|
||||
// setButton2
|
||||
//
|
||||
this.setButton2.Location = new System.Drawing.Point(229, 21);
|
||||
this.setButton2.Name = "setButton2";
|
||||
this.setButton2.Size = new System.Drawing.Size(38, 33);
|
||||
this.setButton2.TabIndex = 5;
|
||||
this.setButton2.Text = "Set";
|
||||
this.setButton2.UseVisualStyleBackColor = true;
|
||||
this.setButton2.Click += new System.EventHandler(this.setButton2_Click);
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(209, 32);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(15, 13);
|
||||
this.label2.TabIndex = 4;
|
||||
this.label2.Text = "%";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(11, 32);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(32, 13);
|
||||
this.label3.TabIndex = 3;
|
||||
this.label3.Text = "ADC:";
|
||||
//
|
||||
// getButton2
|
||||
//
|
||||
this.getButton2.Location = new System.Drawing.Point(101, 22);
|
||||
this.getButton2.Name = "getButton2";
|
||||
this.getButton2.Size = new System.Drawing.Size(38, 33);
|
||||
this.getButton2.TabIndex = 2;
|
||||
this.getButton2.Text = "Get";
|
||||
this.getButton2.UseVisualStyleBackColor = true;
|
||||
this.getButton2.Click += new System.EventHandler(this.getButton2_Click);
|
||||
//
|
||||
// pctTextBox2
|
||||
//
|
||||
this.pctTextBox2.Location = new System.Drawing.Point(160, 28);
|
||||
this.pctTextBox2.Name = "pctTextBox2";
|
||||
this.pctTextBox2.Size = new System.Drawing.Size(46, 20);
|
||||
this.pctTextBox2.TabIndex = 1;
|
||||
//
|
||||
// adcTextBox2
|
||||
//
|
||||
this.adcTextBox2.Location = new System.Drawing.Point(47, 28);
|
||||
this.adcTextBox2.Name = "adcTextBox2";
|
||||
this.adcTextBox2.Size = new System.Drawing.Size(44, 20);
|
||||
this.adcTextBox2.TabIndex = 0;
|
||||
//
|
||||
// groupBox3
|
||||
//
|
||||
this.groupBox3.Controls.Add(this.closeButton);
|
||||
this.groupBox3.Controls.Add(this.openButton);
|
||||
this.groupBox3.Location = new System.Drawing.Point(17, 427);
|
||||
this.groupBox3.Name = "groupBox3";
|
||||
this.groupBox3.Size = new System.Drawing.Size(280, 60);
|
||||
this.groupBox3.TabIndex = 20;
|
||||
this.groupBox3.TabStop = false;
|
||||
this.groupBox3.Text = "Regulation valve";
|
||||
//
|
||||
// closeButton
|
||||
//
|
||||
this.closeButton.Location = new System.Drawing.Point(14, 19);
|
||||
this.closeButton.Name = "closeButton";
|
||||
this.closeButton.Size = new System.Drawing.Size(107, 28);
|
||||
this.closeButton.TabIndex = 1;
|
||||
this.closeButton.Text = "Close";
|
||||
this.closeButton.UseVisualStyleBackColor = true;
|
||||
this.closeButton.Click += new System.EventHandler(this.closeButton_Click);
|
||||
//
|
||||
// openButton
|
||||
//
|
||||
this.openButton.Location = new System.Drawing.Point(160, 19);
|
||||
this.openButton.Name = "openButton";
|
||||
this.openButton.Size = new System.Drawing.Size(107, 28);
|
||||
this.openButton.TabIndex = 0;
|
||||
this.openButton.Text = "Open";
|
||||
this.openButton.UseVisualStyleBackColor = true;
|
||||
this.openButton.Click += new System.EventHandler(this.openButton_Click);
|
||||
//
|
||||
// RegulValveCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.groupBox3);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.flowStableSecTextBox);
|
||||
this.Controls.Add(this.flowStableSecLabel);
|
||||
this.Controls.Add(this.stableTimeTextBox);
|
||||
this.Controls.Add(this.stableTimeLabel);
|
||||
this.Controls.Add(this.storedPosReuseCheckBox);
|
||||
this.Controls.Add(this.pidCoefTextBox);
|
||||
this.Controls.Add(this.pidCoefLabel);
|
||||
this.Controls.Add(this.parentNameComboBox);
|
||||
this.Controls.Add(this.dacOpenTextBox);
|
||||
this.Controls.Add(this.dacOpenLabel);
|
||||
this.Controls.Add(this.dacClosedTextBox);
|
||||
this.Controls.Add(this.dacClosedLabel);
|
||||
this.Controls.Add(this.positionTextBox);
|
||||
this.Controls.Add(this.positionLabel);
|
||||
this.Controls.Add(this.parentNameLabel);
|
||||
this.Controls.Add(this.nameTextBox);
|
||||
this.Controls.Add(this.nameLabel);
|
||||
this.Controls.Add(this.classNameLabel);
|
||||
this.Name = "RegulValveCfgCtrl";
|
||||
this.Size = new System.Drawing.Size(300, 500);
|
||||
this.Load += new System.EventHandler(this.RegulationValveCfgCtrl_Load);
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox2.PerformLayout();
|
||||
this.groupBox3.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
@@ -255,5 +448,22 @@
|
||||
private System.Windows.Forms.Label stableTimeLabel;
|
||||
private System.Windows.Forms.TextBox flowStableSecTextBox;
|
||||
private System.Windows.Forms.Label flowStableSecLabel;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.Button setButton1;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label ADC;
|
||||
private System.Windows.Forms.Button getButton1;
|
||||
private System.Windows.Forms.TextBox pctTextBox1;
|
||||
private System.Windows.Forms.TextBox adcTextBox1;
|
||||
private System.Windows.Forms.GroupBox groupBox2;
|
||||
private System.Windows.Forms.Button setButton2;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Button getButton2;
|
||||
private System.Windows.Forms.TextBox pctTextBox2;
|
||||
private System.Windows.Forms.TextBox adcTextBox2;
|
||||
private System.Windows.Forms.GroupBox groupBox3;
|
||||
private System.Windows.Forms.Button closeButton;
|
||||
private System.Windows.Forms.Button openButton;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(RegulValveCfgCtrl));
|
||||
|
||||
ComponentParametersDlg parent;
|
||||
|
||||
public bool ShowMore { get { return true; } }
|
||||
|
||||
RegulValveCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
@@ -42,7 +45,21 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
}
|
||||
}
|
||||
|
||||
if (config != null)
|
||||
{
|
||||
adc1 = config.DacValueClosed;
|
||||
pct1 = 0;
|
||||
adc2 = config.DacValueOpen;
|
||||
pct2 = 100;
|
||||
}
|
||||
|
||||
Redraw();
|
||||
StartResponseHandler();
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
{
|
||||
StopResponseHandler();
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
@@ -59,7 +76,12 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
stableTimeTextBox.Text = config.StableTimeMs.ToString();
|
||||
storedPosReuseCheckBox.Checked = config.StoredPositionReuse;
|
||||
flowStableSecTextBox.Text = config.FlowStableSec.ToString();
|
||||
}
|
||||
|
||||
adcTextBox1.Text = adc1.ToString();
|
||||
adcTextBox2.Text = adc2.ToString();
|
||||
pctTextBox1.Text = pct1.ToString();
|
||||
pctTextBox2.Text = pct2.ToString();
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
{
|
||||
@@ -74,63 +96,219 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
flowStableSecTextBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgVerifyFlags VerifyCfg(ref string message)
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgVerifyFlags flags = CfgVerifyFlags.None;
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
int dummy;
|
||||
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Parent Name'";
|
||||
}
|
||||
if (!int.TryParse(positionTextBox.Text, out dummy) || dummy < 1 || dummy > 5)
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.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;
|
||||
flags |= CfgUpdateFlags.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;
|
||||
flags |= CfgUpdateFlags.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;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'PID Coefficient' should be between 0 and 100";
|
||||
}
|
||||
if (!int.TryParse(stableTimeTextBox.Text, out dummy) || dummy < 200 || dummy > 1500 || (dummy % 50) != 0)
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Stable time' should be between 200 and 1500 ms in 50 ms steps";
|
||||
}
|
||||
if (!int.TryParse(flowStableSecTextBox.Text, out dummy) || dummy < 0 || dummy > 60)
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Flow stable' should be between 0 and 60 sec";
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
public void UpdateCfg()
|
||||
public CfgUpdateFlags UpdateCfg()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
||||
|
||||
config.Name = nameTextBox.Text;
|
||||
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
|
||||
config.Idx1 = int.Parse(positionTextBox.Text);
|
||||
config.DacValueClosed = int.Parse(dacClosedTextBox.Text);
|
||||
config.DacValueOpen = int.Parse(dacOpenTextBox.Text);
|
||||
config.PidCoef = int.Parse(pidCoefTextBox.Text);
|
||||
config.StableTimeMs = int.Parse(stableTimeTextBox.Text);
|
||||
config.StoredPositionReuse = storedPosReuseCheckBox.Checked;
|
||||
config.FlowStableSec = int.Parse(flowStableSecTextBox.Text);
|
||||
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
|
||||
///
|
||||
if (!config.Name.Equals(nameTextBox.Text))
|
||||
{
|
||||
config.Name = nameTextBox.Text;
|
||||
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
|
||||
}
|
||||
|
||||
string parentname = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
|
||||
if (!config.ParentName.Equals(parentname))
|
||||
{
|
||||
config.ParentName = parentname;
|
||||
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
|
||||
}
|
||||
|
||||
int tmp = int.Parse(positionTextBox.Text);
|
||||
if (config.Idx1 != tmp)
|
||||
{
|
||||
config.Idx1 = tmp;
|
||||
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
|
||||
}
|
||||
|
||||
tmp = int.Parse(dacClosedTextBox.Text);
|
||||
if (config.DacValueClosed != tmp)
|
||||
{
|
||||
config.DacValueClosed = tmp;
|
||||
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
|
||||
}
|
||||
|
||||
tmp = int.Parse(dacOpenTextBox.Text);
|
||||
if (config.DacValueOpen != tmp)
|
||||
{
|
||||
config.DacValueOpen = tmp;
|
||||
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
|
||||
}
|
||||
|
||||
tmp = int.Parse(pidCoefTextBox.Text);
|
||||
if (config.PidCoef != tmp)
|
||||
{
|
||||
config.PidCoef = tmp;
|
||||
flags |= CfgUpdateFlags.AnyChange;
|
||||
}
|
||||
|
||||
tmp = int.Parse(stableTimeTextBox.Text);
|
||||
if (config.StableTimeMs != tmp)
|
||||
{
|
||||
config.StableTimeMs = tmp;
|
||||
flags |= CfgUpdateFlags.AnyChange;
|
||||
}
|
||||
|
||||
bool btmp = storedPosReuseCheckBox.Checked;
|
||||
if (config.StoredPositionReuse != btmp)
|
||||
{
|
||||
config.StoredPositionReuse = btmp;
|
||||
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
|
||||
}
|
||||
|
||||
tmp = int.Parse(flowStableSecTextBox.Text);
|
||||
if (config.FlowStableSec != tmp)
|
||||
{
|
||||
config.FlowStableSec = tmp;
|
||||
flags |= CfgUpdateFlags.AnyChange;
|
||||
}
|
||||
|
||||
if ((flags & CfgUpdateFlags.AnyChange) != 0)
|
||||
{
|
||||
RegulValve.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
int adc1;
|
||||
int pct1;
|
||||
|
||||
int adc2;
|
||||
int pct2;
|
||||
|
||||
private void openButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
RegulValve.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.RVOpenStep, config));
|
||||
}
|
||||
|
||||
private void closeButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
RegulValve.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.RVCloseStep, config));
|
||||
}
|
||||
|
||||
//
|
||||
private void getButton1_Click(object sender, EventArgs e)
|
||||
{
|
||||
RegulValve.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.GetRVAdc1, config));
|
||||
}
|
||||
|
||||
private void getButton2_Click(object sender, EventArgs e)
|
||||
{
|
||||
RegulValve.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.GetRVAdc2, config));
|
||||
}
|
||||
|
||||
private void setButton1_Click(object sender, EventArgs e)
|
||||
{
|
||||
setButton2_Click(sender, e); /// Both Save buttons have the same effect
|
||||
}
|
||||
|
||||
private void setButton2_Click(object sender, EventArgs e)
|
||||
{
|
||||
int tmpPct1;
|
||||
int tmpPct2;
|
||||
if ((int.TryParse(pctTextBox1.Text, out tmpPct1) && (tmpPct1 >= 0) && (tmpPct1 <= 100)) &&
|
||||
(int.TryParse(pctTextBox2.Text, out tmpPct2) && (tmpPct2 >= 0) && (tmpPct2 <= 100)))
|
||||
{
|
||||
pct1 = tmpPct1;
|
||||
pct2 = tmpPct2;
|
||||
UpdateValveOpenClose();
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateValveOpenClose()
|
||||
{
|
||||
if ((adc1 == adc2) || (pct1 == pct2)) return;
|
||||
|
||||
double factor = (float)(adc2 - adc1) / (float)(pct2 - pct1);
|
||||
int dacClosed = (int)((float)(0 - pct1) * factor + (float)adc1 + 0.5f);
|
||||
int dacOpen = (int)((float)(100 - pct1) * factor + (float)adc1 + 0.5f);
|
||||
|
||||
if ((dacClosed >= 0) && (dacOpen >= 0))
|
||||
{
|
||||
dacClosedTextBox.Text = dacClosed.ToString();
|
||||
dacOpenTextBox.Text = dacOpen.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
#region Configuration Change Handling
|
||||
|
||||
public static void OnCmdResponse(object sender, CmdResponseArgs args)
|
||||
{
|
||||
if (CmdResponseHandler == null) return;
|
||||
try { CmdResponseHandler(sender, args); }
|
||||
catch (Exception e) { log.Error("CmdResponseHandler(...) failed", e); }
|
||||
}
|
||||
|
||||
public static event EventHandler<CmdResponseArgs> CmdResponseHandler;
|
||||
|
||||
public void StartResponseHandler()
|
||||
{
|
||||
CmdResponseHandler += delegate(object sender, CmdResponseArgs args)
|
||||
{
|
||||
if (args.Command == CfgChangeCmd.GetRVAdc1)
|
||||
{
|
||||
adc1 = args.Response;
|
||||
adcTextBox1.Text = adc1.ToString();
|
||||
}
|
||||
else if (args.Command == CfgChangeCmd.GetRVAdc2)
|
||||
{
|
||||
adc2 = args.Response;
|
||||
adcTextBox2.Text = adc2.ToString();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void StopResponseHandler()
|
||||
{
|
||||
CmdResponseHandler = null;
|
||||
}
|
||||
|
||||
#endregion Configuration Change Handling
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@ namespace TBF.BenchControl.Elde.TempMeter
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(TempMeterCfgCtrl));
|
||||
|
||||
ComponentParametersDlg parent;
|
||||
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
TempMeterCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
@@ -46,6 +49,10 @@ namespace TBF.BenchControl.Elde.TempMeter
|
||||
Redraw();
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
{
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
@@ -73,59 +80,61 @@ namespace TBF.BenchControl.Elde.TempMeter
|
||||
a5TextBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgVerifyFlags VerifyCfg(ref string message)
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgVerifyFlags flags = CfgVerifyFlags.None;
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
int dummy;
|
||||
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Parent Name'";
|
||||
}
|
||||
if (!int.TryParse(positionTextBox.Text, out dummy) || dummy < 0 || dummy > 7)
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Position' should be between 0 and 7";
|
||||
}
|
||||
|
||||
float fdummy;
|
||||
if (!Utils.TryParseEFloat(a1TextBox.Text, out fdummy))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'A1' is not valid";
|
||||
}
|
||||
|
||||
if (!Utils.TryParseEFloat(a2TextBox.Text, out fdummy))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'A2' is not valid";
|
||||
}
|
||||
|
||||
if (!Utils.TryParseEFloat(a3TextBox.Text, out fdummy))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'A3' is not valid";
|
||||
}
|
||||
|
||||
if (!Utils.TryParseEFloat(a4TextBox.Text, out fdummy))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'A4' is not valid";
|
||||
}
|
||||
|
||||
if (!Utils.TryParseEFloat(a5TextBox.Text, out fdummy))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'A5' is not valid";
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
public void UpdateCfg()
|
||||
public CfgUpdateFlags UpdateCfg()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
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;
|
||||
@@ -135,6 +144,8 @@ namespace TBF.BenchControl.Elde.TempMeter
|
||||
Utils.TryParseEFloat(a3TextBox.Text, out config.A3) &&
|
||||
Utils.TryParseEFloat(a4TextBox.Text, out config.A4) &&
|
||||
Utils.TryParseEFloat(a5TextBox.Text, out config.A5);
|
||||
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ namespace TBF.BenchControl.Elde.Valve
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(ValveCfgCtrl));
|
||||
|
||||
ComponentParametersDlg parent;
|
||||
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
ValveCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
@@ -57,6 +60,10 @@ namespace TBF.BenchControl.Elde.Valve
|
||||
Redraw();
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
{
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
@@ -88,9 +95,11 @@ namespace TBF.BenchControl.Elde.Valve
|
||||
lagClosingTextBox.Enabled = true;
|
||||
}
|
||||
|
||||
public void UpdateCfg()
|
||||
public CfgUpdateFlags UpdateCfg()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
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;
|
||||
@@ -108,46 +117,48 @@ namespace TBF.BenchControl.Elde.Valve
|
||||
config.InvertCouple = invertCoupleCheckBox.Checked;
|
||||
config.LagOpening = int.Parse(lagOpeningTextBox.Text);
|
||||
config.LagClosing = int.Parse(lagClosingTextBox.Text);
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
public CfgVerifyFlags VerifyCfg(ref string message)
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgVerifyFlags flags = CfgVerifyFlags.None;
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
|
||||
|
||||
int dummy;
|
||||
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Parent Name'";
|
||||
}
|
||||
if (!categoryComboBox.Items.Contains(categoryComboBox.Text))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Category'";
|
||||
}
|
||||
if (!coupledToComboBox.Items.Contains(coupledToComboBox.Text))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Coupled To'";
|
||||
}
|
||||
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 64)
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Bit Position' should be between 0 and 63";
|
||||
}
|
||||
if (!int.TryParse(openCloseTimeTextBox.Text, out dummy) || dummy < 0 || dummy > 300)
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Open/close time' should be between 0 and 300 s";
|
||||
}
|
||||
if (!int.TryParse(lagOpeningTextBox.Text, out dummy))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Delay when opening' error";
|
||||
}
|
||||
if (!int.TryParse(lagClosingTextBox.Text, out dummy))
|
||||
{
|
||||
flags |= CfgVerifyFlags.Error;
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Delay when closing' error";
|
||||
}
|
||||
return flags;
|
||||
|
||||
Reference in New Issue
Block a user