RegulValveTandem op SetFlowOp should be functional, to be tested

This commit is contained in:
Milan Hanajik
2015-02-03 10:30:24 +01:00
parent ab8aa61a29
commit 5806a65a0c
10 changed files with 139 additions and 99 deletions
@@ -24,19 +24,19 @@ namespace TBF.BenchControl.Elde.RegulValve
/// Events: FlowSet, FlowTimeOut /// Events: FlowSet, FlowTimeOut
/// </summary> /// </summary>
/// <param name="controlBoard">Control board device</param> /// <param name="controlBoard">Control board device</param>
/// <param name="regulValve">Regulation valve component</param> /// <param name="_regulValve">Regulation valve component</param>
/// <param name="posLoPct">Lower limit of the position to be achieved</param> /// <param name="posLoPct">Lower limit of the position to be achieved</param>
/// <param name="posHiPct">Upper limit of the position to be achieved</param> /// <param name="posHiPct">Upper limit of the position to be achieved</param>
/// <param name="timeout">Timeout in sec. for setting the flow</param> /// <param name="timeout">Timeout in sec. for setting the flow</param>
/// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks> /// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks>
public ChangeRegulValvePositionOp(ControlBoardDev controlBoard, RegulValve regulValve, float timePulseSec) public ChangeRegulValvePositionOp(ControlBoardDev controlBoard, RegulValve _regulValve, float timePulseSec)
{ {
if (controlBoard == null) throw new ArgumentNullException("ctrlBoard"); if (controlBoard == null) throw new ArgumentNullException("ctrlBoard");
this.controlBoard = controlBoard; this.controlBoard = controlBoard;
this.regulValve = regulValve as RegulValve; regulValve = _regulValve as RegulValve;
if (regulValve == null) throw new ArgumentNullException("regValve is null or not Elde"); if (regulValve == null) throw new ArgumentNullException("regValve is null or not Elde");
this.regulValveNr = this.regulValve.Idx1; regulValveNr = this.regulValve.Idx1;
this.timePulseSec = timePulseSec; this.timePulseSec = timePulseSec;
@@ -53,7 +53,7 @@ namespace TBF.BenchControl.Elde.RegulValve
/// Events: FlowSet, FlowTimeOut /// Events: FlowSet, FlowTimeOut
/// </summary> /// </summary>
/// <param name="controlBoard">Control board device</param> /// <param name="controlBoard">Control board device</param>
/// <param name="regulValve">Regulation valve component</param> /// <param name="_regulValve">Regulation valve component</param>
/// <param name="flowMeter">Flowmeter component</param> /// <param name="flowMeter">Flowmeter component</param>
/// <param name="requiredFlowLo">Lower limit of the flow to be achieved in [m3/h]</param> /// <param name="requiredFlowLo">Lower limit of the flow to be achieved in [m3/h]</param>
/// <param name="requiredFlowHi">Upper limit of the flow to be achieved in [m3/h]</param> /// <param name="requiredFlowHi">Upper limit of the flow to be achieved in [m3/h]</param>
@@ -61,16 +61,16 @@ namespace TBF.BenchControl.Elde.RegulValve
/// <param name="timeout">Timeout for the flow setting in [s]</param> /// <param name="timeout">Timeout for the flow setting in [s]</param>
/// <param name="leaveMeasurementRunning">true = Leave the measurement running after op. stop</param> /// <param name="leaveMeasurementRunning">true = Leave the measurement running after op. stop</param>
/// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks> /// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks>
public SetFlowOp(ControlBoardDev controlBoard, IRegulValve regulValve, IFlowMeter flowMeter, public SetFlowOp(ControlBoardDev controlBoard, IRegulValve _regulValve, IFlowMeter flowMeter,
float requiredFlowLo, float requiredFlowHi, float pidCoef, FloatBox measuredFlow, float requiredFlowLo, float requiredFlowHi, float pidCoef, FloatBox measuredFlow,
int timeout, bool leaveMeasurementRunning) int timeout, bool leaveMeasurementRunning)
{ {
if (controlBoard == null) throw new ArgumentNullException("ctrlBoard"); if (controlBoard == null) throw new ArgumentNullException("ctrlBoard");
this.controlBoard = controlBoard; this.controlBoard = controlBoard;
this.regulValve = regulValve as Elde.RegulValve.RegulValve; regulValve = _regulValve as Elde.RegulValve.RegulValve;
if (regulValve == null) throw new ArgumentNullException("regValve is null or not Elde"); if (regulValve == null) throw new ArgumentNullException("regValve is null or not Elde");
this.regulValveNr = this.regulValve.Idx1; regulValveNr = this.regulValve.Idx1;
if (flowMeter is Elde.FlowMeter.FlowMeter) if (flowMeter is Elde.FlowMeter.FlowMeter)
{ {
@@ -178,7 +178,7 @@ namespace TBF.BenchControl.Elde.RegulValve
TestMethods tm = 0; TestMethods tm = 0;
StopDevs sd = 0; StopDevs sd = 0;
// 'regulValve.RegulValveCfg.PidCoef' replaced by a casted operation parameter 'pidCoef' // '_regulValve.RegulValveCfg.PidCoef' replaced by a casted operation parameter 'pidCoef'
controlBoard.SendCommand(Command.Start, flowMeterNr, controlBoard.Route, int.MaxValue, tm, controlBoard.SendCommand(Command.Start, flowMeterNr, controlBoard.Route, int.MaxValue, tm,
0.0f, (int)pidCoef, 0, sd); 0.0f, (int)pidCoef, 0, sd);
} }
@@ -31,7 +31,7 @@ namespace TBF.BenchControl.Elde.RegulValve
/// Events: FlowSet, FlowTimeOut /// Events: FlowSet, FlowTimeOut
/// </summary> /// </summary>
/// <param name="controlBoard">Control board device</param> /// <param name="controlBoard">Control board device</param>
/// <param name="regulValve">Regulation valve component</param> /// <param name="_regulValve">Regulation valve component</param>
/// <param name="posLoPct">Lower limit of the position to be achieved</param> /// <param name="posLoPct">Lower limit of the position to be achieved</param>
/// <param name="posHiPct">Upper limit of the position to be achieved</param> /// <param name="posHiPct">Upper limit of the position to be achieved</param>
/// <param name="timeout">Timeout in sec. for setting the flow</param> /// <param name="timeout">Timeout in sec. for setting the flow</param>
@@ -15,7 +15,7 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
/// Set by the constructor /// Set by the constructor
readonly ControlBoardDev controlBoard; readonly ControlBoardDev controlBoard;
readonly RegulValveTandem regulValve; readonly Elde.RegulValve.RegulValve regulValve;
readonly int regulValveNr; readonly int regulValveNr;
readonly float timePulseSec; readonly float timePulseSec;
@@ -24,19 +24,19 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
/// Events: FlowSet, FlowTimeOut /// Events: FlowSet, FlowTimeOut
/// </summary> /// </summary>
/// <param name="ControlBoard">Control board device</param> /// <param name="ControlBoard">Control board device</param>
/// <param name="regulValve">Regulation valve component</param> /// <param name="_regulValve">Regulation valve component</param>
/// <param name="posLoPct">Lower limit of the position to be achieved</param> /// <param name="posLoPct">Lower limit of the position to be achieved</param>
/// <param name="posHiPct">Upper limit of the position to be achieved</param> /// <param name="posHiPct">Upper limit of the position to be achieved</param>
/// <param name="timeout">Timeout in sec. for setting the flow</param> /// <param name="timeout">Timeout in sec. for setting the flow</param>
/// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks> /// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks>
public ChangeRegulValvePositionOp(ControlBoardDev controlBoard, RegulValveTandem regulValve, float timePulseSec) public ChangeRegulValvePositionOp(ControlBoardDev controlBoard, IRegulValve _regulValve, float timePulseSec)
{ {
if (controlBoard == null) throw new ArgumentNullException("ctrlBoard"); if (controlBoard == null) throw new ArgumentNullException("ctrlBoard");
this.controlBoard = controlBoard; this.controlBoard = controlBoard;
this.regulValve = regulValve as RegulValveTandem; regulValve = _regulValve as Elde.RegulValve.RegulValve;
if (regulValve == null) throw new ArgumentNullException("regValve is null or not Elde"); if (regulValve == null) throw new ArgumentNullException("regValve is null or not Elde");
this.regulValveNr = this.regulValve.Idx1; regulValveNr = this.regulValve.Idx1;
this.timePulseSec = timePulseSec; this.timePulseSec = timePulseSec;
@@ -21,16 +21,14 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
readonly RegulValve.RegulValve regulValve; readonly RegulValve.RegulValve regulValve;
readonly RegulValve.RegulValve fixedRV; readonly RegulValve.RegulValve fixedRV;
public int Idx1 { get { return regulValve.Idx1; } } /// 1..7 readonly float fixedPctLo; /// [%]
public int DacValueClosed { get { return regulValve.DacValueClosed; } } /// 0..1023 readonly float fixedPctHi; /// [%]
public int DacValueOpen { get { return regulValve.DacValueOpen; } } /// 0..1023
///
public int StableTime { get { return RegulValveTandemCfg.StableTime; } } /// 0=200ms, step=50ms, max. 1500ms (max.26)
public int FlowStableSec { get { return RegulValveTandemCfg.FlowStableSec; } } /// 0..60 sec public int FlowStableSec { get { return RegulValveTandemCfg.FlowStableSec; } } /// 0..60 sec
/// ///
public float Position public float Position
{ {
get { return controlBoard.RValvePosition(Idx1); } get { return regulValve.Position; }
} }
@@ -45,6 +43,9 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
fixedRV = (RegulValve.RegulValve)TbfComponents.FindComponent(RegulValveTandemCfg.ParentName, components); fixedRV = (RegulValve.RegulValve)TbfComponents.FindComponent(RegulValveTandemCfg.ParentName, components);
if (fixedRV == null) throw new Exception("Cannot find fixed RV"); if (fixedRV == null) throw new Exception("Cannot find fixed RV");
fixedPctLo = Math.Max(0.0f, RegulValveTandemCfg.FixedRVPosition - 3.0f);
fixedPctHi = Math.Min(100.0f, RegulValveTandemCfg.FixedRVPosition + 3.0f);
this.dict = new Dictionary<float, float>(); this.dict = new Dictionary<float, float>();
log.Debug(this.ToString()); log.Debug(this.ToString());
@@ -61,9 +62,11 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
/// <param name="measuredFlow">Measured flow [m3/h]</param> /// <param name="measuredFlow">Measured flow [m3/h]</param>
/// <param name="timeout">Timeout in [s]</param> /// <param name="timeout">Timeout in [s]</param>
/// <returns>SetFlowOp instance</returns> /// <returns>SetFlowOp instance</returns>
public IOperation SetFlowOp(GenericDevices.IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi, float pidCoef, FloatBox measuredFlow, int timeout) public IOperation SetFlowOp(GenericDevices.IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi,
float pidCoef, FloatBox measuredFlow, int timeout)
{ {
return new SetFlowOp(controlBoard, this, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, timeout); return new SetFlowOp(controlBoard, regulValve, fixedRV, fixedPctLo, fixedPctHi,
flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, timeout);
} }
/// <summary> /// <summary>
@@ -76,9 +79,11 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
/// <param name="measuredFlow">Measured flow [m3/h]</param> /// <param name="measuredFlow">Measured flow [m3/h]</param>
/// <param name="timeout">Timeout in [s]</param> /// <param name="timeout">Timeout in [s]</param>
/// <returns>SetFlowOp instance</returns> /// <returns>SetFlowOp instance</returns>
public IOperation SetFlowAndMeasureOp(GenericDevices.IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi, float pidCoef, FloatBox measuredFlow, int timeout, float filterConstant) public IOperation SetFlowAndMeasureOp(GenericDevices.IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi,
float pidCoef, FloatBox measuredFlow, int timeout, float filterConstant)
{ {
return new SetFlowOp(controlBoard, this, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, timeout, true); return new SetFlowOp(controlBoard, regulValve, fixedRV, fixedPctLo, fixedPctHi,
flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, timeout, true);
} }
/// <summary> /// <summary>
@@ -90,12 +95,12 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
/// <returns>SetPositionOp instance</returns> /// <returns>SetPositionOp instance</returns>
public IOperation SetRegulValvePositionOp(float pctLo, float pctHi, int timeoutMs) public IOperation SetRegulValvePositionOp(float pctLo, float pctHi, int timeoutMs)
{ {
return new SetRegulValvePositionOp(controlBoard, this, pctLo, pctHi, timeoutMs); return null;
} }
public IOperation ChangeRegulValvePositionOp(float timePulseSec) public IOperation ChangeRegulValvePositionOp(float timePulseSec)
{ {
return new ChangeRegulValvePositionOp(controlBoard, this, timePulseSec); return null;
} }
} }
} }
@@ -16,15 +16,10 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
/// ///
public string RegulValveName; /// Name of the regulation valve used to control the flow public string RegulValveName; /// Name of the regulation valve used to control the flow
public string FixedRVName; /// Name of the regulation valve with a fixed position public string FixedRVName; /// Name of the regulation valve with a fixed position
public int StableTimeMs; /// 200..1500 ms public float FixedRVPosition; /// Fixed RV position 0 .. 100 in [%]
public bool StoredPositionReuse; /// true = store and re-use previous regulation valve positions public bool StoredPositionReuse; /// true = store and re-use previous regulation valve positions
public int FlowStableSec; /// 0..60 sec public int FlowStableSec; /// 0..60 sec
/// <summary>
/// Stabilization time when setting the flow: 0=200ms, step 50ms, max. 1.5 sec.
/// </summary>
public int StableTime { get { return (StableTimeMs - 200) / 50; } }
/// Private parameterless constructor invoked by all other (public) constructors /// Private parameterless constructor invoked by all other (public) constructors
RegulValveTandemCfg() RegulValveTandemCfg()
{ {
@@ -34,7 +29,7 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
RegulValveName = "RV1"; RegulValveName = "RV1";
FixedRVName = "RV2"; FixedRVName = "RV2";
StableTimeMs = 500; FixedRVPosition = 50.0f;
StoredPositionReuse = false; StoredPositionReuse = false;
FlowStableSec = 5; FlowStableSec = 5;
} }
@@ -47,11 +42,11 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
public string ToString(int i) public string ToString(int i)
{ {
return string.Format("Name={0}, ControlledRVName={1}, ADC-FixedRVName={2}, StabTm={3}ms, PosReuse={4}, FlowStable={5}s", return string.Format("Name={0}, RegulVName={1}, FixedRVName={2}, FixedRVPos={3}%, PosReuse={4}, FlowStable={5}s",
Name, Name,
RegulValveName, RegulValveName,
FixedRVName, FixedRVName,
StableTimeMs, FixedRVPosition.ToString("F0"),
StoredPositionReuse, StoredPositionReuse,
FlowStableSec); FlowStableSec);
} }
@@ -61,7 +61,7 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
nameTextBox.Text = config.Name; nameTextBox.Text = config.Name;
regulValveNameComboBox.Text = string.IsNullOrEmpty(config.RegulValveName) ? "---" : config.RegulValveName; regulValveNameComboBox.Text = string.IsNullOrEmpty(config.RegulValveName) ? "---" : config.RegulValveName;
fixedRVNameComboBox.Text = string.IsNullOrEmpty(config.FixedRVName) ? "---" : config.FixedRVName; fixedRVNameComboBox.Text = string.IsNullOrEmpty(config.FixedRVName) ? "---" : config.FixedRVName;
stableTimeTextBox.Text = config.StableTimeMs.ToString(); fixedRVPositionTextBox.Text = config.FixedRVPosition.ToString("F0");
storedPosReuseCheckBox.Checked = config.StoredPositionReuse; storedPosReuseCheckBox.Checked = config.StoredPositionReuse;
flowStableSecTextBox.Text = config.FlowStableSec.ToString(); flowStableSecTextBox.Text = config.FlowStableSec.ToString();
} }
@@ -71,7 +71,7 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
nameTextBox.Enabled = true; nameTextBox.Enabled = true;
regulValveNameComboBox.Enabled = true; regulValveNameComboBox.Enabled = true;
fixedRVNameComboBox.Enabled = true; fixedRVNameComboBox.Enabled = true;
stableTimeTextBox.Enabled = true; fixedRVPositionTextBox.Enabled = true;
storedPosReuseCheckBox.Enabled = true; storedPosReuseCheckBox.Enabled = true;
flowStableSecTextBox.Enabled = true; flowStableSecTextBox.Enabled = true;
} }
@@ -93,7 +93,7 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
} }
int dummy; int dummy;
if (!int.TryParse(stableTimeTextBox.Text, out dummy) || dummy < 200 || dummy > 1500 || (dummy % 50) != 0) if (!int.TryParse(fixedRVPositionTextBox.Text, out dummy) || dummy < 0 || dummy > 100)
{ {
flags |= CfgUpdateFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Stable time' should be between 200 and 1500 ms in 50 ms steps"; message += Environment.NewLine + "'Stable time' should be between 200 and 1500 ms in 50 ms steps";
@@ -134,10 +134,10 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
flags |= CfgUpdateFlags.RestartRqrd; flags |= CfgUpdateFlags.RestartRqrd;
} }
int tmp = int.Parse(stableTimeTextBox.Text); int tmp = int.Parse(fixedRVPositionTextBox.Text);
if (config.StableTimeMs != tmp) if (config.FixedRVPosition != (float)tmp)
{ {
config.StableTimeMs = tmp; config.FixedRVPosition = (float)tmp;
flags |= CfgUpdateFlags.RestartRqrd; flags |= CfgUpdateFlags.RestartRqrd;
} }
@@ -34,18 +34,18 @@
this.classNameLabel = new System.Windows.Forms.Label(); this.classNameLabel = new System.Windows.Forms.Label();
this.regulValveNameComboBox = new System.Windows.Forms.ComboBox(); this.regulValveNameComboBox = new System.Windows.Forms.ComboBox();
this.storedPosReuseCheckBox = new System.Windows.Forms.CheckBox(); 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.flowStableSecTextBox = new System.Windows.Forms.TextBox();
this.flowStableSecLabel = new System.Windows.Forms.Label(); this.flowStableSecLabel = new System.Windows.Forms.Label();
this.fixedRVNameComboBox = new System.Windows.Forms.ComboBox(); this.fixedRVNameComboBox = new System.Windows.Forms.ComboBox();
this.fixedRVNameLabel = new System.Windows.Forms.Label(); this.fixedRVNameLabel = new System.Windows.Forms.Label();
this.fixedRVPositionTextBox = new System.Windows.Forms.TextBox();
this.fixedRVPositionLabel = new System.Windows.Forms.Label();
this.SuspendLayout(); this.SuspendLayout();
// //
// regulValveNameLabel // regulValveNameLabel
// //
this.regulValveNameLabel.AutoSize = true; this.regulValveNameLabel.AutoSize = true;
this.regulValveNameLabel.Location = new System.Drawing.Point(28, 69); this.regulValveNameLabel.Location = new System.Drawing.Point(28, 68);
this.regulValveNameLabel.Name = "regulValveNameLabel"; this.regulValveNameLabel.Name = "regulValveNameLabel";
this.regulValveNameLabel.Size = new System.Drawing.Size(87, 13); this.regulValveNameLabel.Size = new System.Drawing.Size(87, 13);
this.regulValveNameLabel.TabIndex = 3; this.regulValveNameLabel.TabIndex = 3;
@@ -81,7 +81,7 @@
// //
this.regulValveNameComboBox.Enabled = false; this.regulValveNameComboBox.Enabled = false;
this.regulValveNameComboBox.FormattingEnabled = true; this.regulValveNameComboBox.FormattingEnabled = true;
this.regulValveNameComboBox.Location = new System.Drawing.Point(138, 66); this.regulValveNameComboBox.Location = new System.Drawing.Point(138, 65);
this.regulValveNameComboBox.Name = "regulValveNameComboBox"; this.regulValveNameComboBox.Name = "regulValveNameComboBox";
this.regulValveNameComboBox.Size = new System.Drawing.Size(130, 21); this.regulValveNameComboBox.Size = new System.Drawing.Size(130, 21);
this.regulValveNameComboBox.TabIndex = 4; this.regulValveNameComboBox.TabIndex = 4;
@@ -97,23 +97,6 @@
this.storedPosReuseCheckBox.Text = "Enable stored position re-use"; this.storedPosReuseCheckBox.Text = "Enable stored position re-use";
this.storedPosReuseCheckBox.UseVisualStyleBackColor = true; this.storedPosReuseCheckBox.UseVisualStyleBackColor = true;
// //
// stableTimeTextBox
//
this.stableTimeTextBox.Enabled = false;
this.stableTimeTextBox.Location = new System.Drawing.Point(138, 144);
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, 147);
this.stableTimeLabel.Name = "stableTimeLabel";
this.stableTimeLabel.Size = new System.Drawing.Size(81, 13);
this.stableTimeLabel.TabIndex = 14;
this.stableTimeLabel.Text = "Stable time [ms]";
//
// flowStableSecTextBox // flowStableSecTextBox
// //
this.flowStableSecTextBox.Enabled = false; this.flowStableSecTextBox.Enabled = false;
@@ -135,7 +118,7 @@
// //
this.fixedRVNameComboBox.Enabled = false; this.fixedRVNameComboBox.Enabled = false;
this.fixedRVNameComboBox.FormattingEnabled = true; this.fixedRVNameComboBox.FormattingEnabled = true;
this.fixedRVNameComboBox.Location = new System.Drawing.Point(138, 93); this.fixedRVNameComboBox.Location = new System.Drawing.Point(138, 91);
this.fixedRVNameComboBox.Name = "fixedRVNameComboBox"; this.fixedRVNameComboBox.Name = "fixedRVNameComboBox";
this.fixedRVNameComboBox.Size = new System.Drawing.Size(130, 21); this.fixedRVNameComboBox.Size = new System.Drawing.Size(130, 21);
this.fixedRVNameComboBox.TabIndex = 22; this.fixedRVNameComboBox.TabIndex = 22;
@@ -143,22 +126,39 @@
// fixedRVNameLabel // fixedRVNameLabel
// //
this.fixedRVNameLabel.AutoSize = true; this.fixedRVNameLabel.AutoSize = true;
this.fixedRVNameLabel.Location = new System.Drawing.Point(28, 96); this.fixedRVNameLabel.Location = new System.Drawing.Point(28, 94);
this.fixedRVNameLabel.Name = "fixedRVNameLabel"; this.fixedRVNameLabel.Name = "fixedRVNameLabel";
this.fixedRVNameLabel.Size = new System.Drawing.Size(82, 13); this.fixedRVNameLabel.Size = new System.Drawing.Size(82, 13);
this.fixedRVNameLabel.TabIndex = 21; this.fixedRVNameLabel.TabIndex = 21;
this.fixedRVNameLabel.Text = "Fixed reg. valve"; this.fixedRVNameLabel.Text = "Fixed reg. valve";
// //
// fixedRVPositionTextBox
//
this.fixedRVPositionTextBox.Enabled = false;
this.fixedRVPositionTextBox.Location = new System.Drawing.Point(138, 117);
this.fixedRVPositionTextBox.Name = "fixedRVPositionTextBox";
this.fixedRVPositionTextBox.Size = new System.Drawing.Size(46, 20);
this.fixedRVPositionTextBox.TabIndex = 24;
//
// fixedRVPositionLabel
//
this.fixedRVPositionLabel.AutoSize = true;
this.fixedRVPositionLabel.Location = new System.Drawing.Point(28, 120);
this.fixedRVPositionLabel.Name = "fixedRVPositionLabel";
this.fixedRVPositionLabel.Size = new System.Drawing.Size(89, 13);
this.fixedRVPositionLabel.TabIndex = 23;
this.fixedRVPositionLabel.Text = "Fixed RV position";
//
// RegulValveTandemCfgCtrl // RegulValveTandemCfgCtrl
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.fixedRVPositionTextBox);
this.Controls.Add(this.fixedRVPositionLabel);
this.Controls.Add(this.fixedRVNameComboBox); this.Controls.Add(this.fixedRVNameComboBox);
this.Controls.Add(this.fixedRVNameLabel); this.Controls.Add(this.fixedRVNameLabel);
this.Controls.Add(this.flowStableSecTextBox); this.Controls.Add(this.flowStableSecTextBox);
this.Controls.Add(this.flowStableSecLabel); this.Controls.Add(this.flowStableSecLabel);
this.Controls.Add(this.stableTimeTextBox);
this.Controls.Add(this.stableTimeLabel);
this.Controls.Add(this.storedPosReuseCheckBox); this.Controls.Add(this.storedPosReuseCheckBox);
this.Controls.Add(this.regulValveNameComboBox); this.Controls.Add(this.regulValveNameComboBox);
this.Controls.Add(this.regulValveNameLabel); this.Controls.Add(this.regulValveNameLabel);
@@ -181,11 +181,11 @@
private System.Windows.Forms.Label classNameLabel; private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.ComboBox regulValveNameComboBox; private System.Windows.Forms.ComboBox regulValveNameComboBox;
private System.Windows.Forms.CheckBox storedPosReuseCheckBox; private System.Windows.Forms.CheckBox storedPosReuseCheckBox;
private System.Windows.Forms.TextBox stableTimeTextBox;
private System.Windows.Forms.Label stableTimeLabel;
private System.Windows.Forms.TextBox flowStableSecTextBox; private System.Windows.Forms.TextBox flowStableSecTextBox;
private System.Windows.Forms.Label flowStableSecLabel; private System.Windows.Forms.Label flowStableSecLabel;
private System.Windows.Forms.ComboBox fixedRVNameComboBox; private System.Windows.Forms.ComboBox fixedRVNameComboBox;
private System.Windows.Forms.Label fixedRVNameLabel; private System.Windows.Forms.Label fixedRVNameLabel;
private System.Windows.Forms.TextBox fixedRVPositionTextBox;
private System.Windows.Forms.Label fixedRVPositionLabel;
} }
} }
@@ -18,6 +18,10 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
readonly ControlBoardDev controlBoard; readonly ControlBoardDev controlBoard;
readonly Elde.RegulValve.RegulValve regulValve; readonly Elde.RegulValve.RegulValve regulValve;
readonly int regulValveNr; readonly int regulValveNr;
readonly Elde.RegulValve.RegulValve fixedRV;
readonly int fixedRVNr;
readonly float fixedPctLo;
readonly float fixedPctHi;
readonly int flowMeterNr; readonly int flowMeterNr;
readonly float reqFlowLo; readonly float reqFlowLo;
readonly float reqFlowHi; readonly float reqFlowHi;
@@ -32,9 +36,11 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
enum OpState enum OpState
{ {
Idle = 0, Idle = 0,
ValveMoveToPosition, IssueSetPositionCommand,
SettingPosition, SettingPosition,
ValveMoveToFlow, IssueSetPositionCommand_FixedRV,
SettingPosition_FixedRV,
IssueSetFlowCommand,
SettingFlow, SettingFlow,
FlowReached, FlowReached,
} }
@@ -53,7 +59,10 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
/// Events: FlowSet, FlowTimeOut /// Events: FlowSet, FlowTimeOut
/// </summary> /// </summary>
/// <param name="ControlBoard">Control board device</param> /// <param name="ControlBoard">Control board device</param>
/// <param name="regulValve">Regulation valve component</param> /// <param name="_regulValve">Regulation valve component</param>
/// <param name="fxdRV">Regulation valve set to a fixed position</param>
/// <param name="fixedPctLo">Lower limit of the fixed position of the fixed reg.v.</param>
/// <param name="fixedPctHi">Upper limit of the fixed position of the fixed reg.v.</param>
/// <param name="flowMeter">Flowmeter component</param> /// <param name="flowMeter">Flowmeter component</param>
/// <param name="requiredFlowLo">Lower limit of the flow to be achieved in [m3/h]</param> /// <param name="requiredFlowLo">Lower limit of the flow to be achieved in [m3/h]</param>
/// <param name="requiredFlowHi">Upper limit of the flow to be achieved in [m3/h]</param> /// <param name="requiredFlowHi">Upper limit of the flow to be achieved in [m3/h]</param>
@@ -61,16 +70,23 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
/// <param name="timeout">Timeout for the flow setting in [s]</param> /// <param name="timeout">Timeout for the flow setting in [s]</param>
/// <param name="leaveMeasurementRunning">true = Leave the measurement running after op. stop</param> /// <param name="leaveMeasurementRunning">true = Leave the measurement running after op. stop</param>
/// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks> /// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks>
public SetFlowOp(ControlBoardDev controlBoard, IRegulValve regulValve, IFlowMeter flowMeter, public SetFlowOp(ControlBoardDev controlBoard, IRegulValve regV, IRegulValve fxdRV, float fxdPctLo, float fxdPctHi,
float requiredFlowLo, float requiredFlowHi, float pidCoef, FloatBox measuredFlow, IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi, float pidCoef, FloatBox measuredFlow,
int timeout, bool leaveMeasurementRunning) int timeout, bool leaveMeasurementRunning)
{ {
if (controlBoard == null) throw new ArgumentNullException("ctrlBoard"); if (controlBoard == null) throw new ArgumentNullException("ctrlBoard");
this.controlBoard = controlBoard; this.controlBoard = controlBoard;
this.regulValve = regulValve as Elde.RegulValve.RegulValve; regulValve = regV as Elde.RegulValve.RegulValve;
if (regulValve == null) throw new ArgumentNullException("regValve is null or not Elde"); if (regulValve == null) throw new ArgumentNullException("regValve is null or not Elde");
this.regulValveNr = this.regulValve.Idx1; regulValveNr = regulValve.Idx1;
fixedRV = fxdRV as Elde.RegulValve.RegulValve;
if (fixedRV == null) throw new ArgumentNullException("regValve is null or not Elde");
fixedRVNr = fixedRV.Idx1;
this.fixedPctLo = fxdPctLo;
this.fixedPctHi = fxdPctHi;
if (flowMeter is Elde.FlowMeter.FlowMeter) if (flowMeter is Elde.FlowMeter.FlowMeter)
{ {
@@ -104,9 +120,9 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
/// Set required water flow - Do not leave the measurement running. /// Set required water flow - Do not leave the measurement running.
/// Events: FlowSet /// Events: FlowSet
/// </summary> /// </summary>
public SetFlowOp(ControlBoardDev controlBoard, IRegulValve regValve, IFlowMeter flowMeter, public SetFlowOp(ControlBoardDev controlBoard, IRegulValve regValve, IRegulValve fixedRV, float fixedPctLo, float fixedPctHi,
float requiredFlowLo, float requiredFlowHi, float pidCoef, FloatBox measuredFlow, int timeout) IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi, float pidCoef, FloatBox measuredFlow, int timeout)
: this(controlBoard, regValve, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, timeout, false) : this(controlBoard, regValve, fixedRV, fixedPctLo, fixedPctHi, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, timeout, false)
{ {
} }
@@ -114,9 +130,9 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
/// Set required water flow - No timeout. /// Set required water flow - No timeout.
/// Events: FlowSet /// Events: FlowSet
/// </summary> /// </summary>
public SetFlowOp(ControlBoardDev controlBoard, IRegulValve regValve, IFlowMeter flowMeter, public SetFlowOp(ControlBoardDev controlBoard, IRegulValve regValve, IRegulValve fixedRV, float fixedPctLo, float fixedPctHi,
float requiredFlowLo, float requiredFlowHi, float pidCoef, FloatBox measuredFlow) IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi, float pidCoef, FloatBox measuredFlow)
: this(controlBoard, regValve, flowMeter, requiredFlowLo, pidCoef, requiredFlowHi, measuredFlow, int.MaxValue, false) : this(controlBoard, regValve, fixedRV, fixedPctLo, fixedPctHi, flowMeter, requiredFlowLo, pidCoef, requiredFlowHi, measuredFlow, int.MaxValue, false)
{ {
} }
@@ -163,14 +179,14 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
log.InfoFormat("Start(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3} FETCHED: posLo={4} posHi={5}", log.InfoFormat("Start(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3} FETCHED: posLo={4} posHi={5}",
regulValveNr, flowMeterNr, reqFlowLo, reqFlowHi, targetPositionLo, targetPositionHi); regulValveNr, flowMeterNr, reqFlowLo, reqFlowHi, targetPositionLo, targetPositionHi);
opState = OpState.ValveMoveToPosition; opState = OpState.IssueSetPositionCommand;
} }
else else
{ {
log.InfoFormat("Start(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3}", log.InfoFormat("Start(): rv#={0} flowMtr#={1} TARGET: flowLo={2} flowHi={3}",
regulValveNr, flowMeterNr, reqFlowLo, reqFlowHi); regulValveNr, flowMeterNr, reqFlowLo, reqFlowHi);
opState = OpState.ValveMoveToFlow; opState = OpState.IssueSetPositionCommand_FixedRV;
} }
expireTime = StateMachine.Time + timeout; expireTime = StateMachine.Time + timeout;
@@ -178,7 +194,7 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
TestMethods tm = 0; TestMethods tm = 0;
StopDevs sd = 0; StopDevs sd = 0;
// 'regulValve.RegulValveTandemCfg.PidCoef' replaced by a casted operation parameter 'pidCoef' // '_regulValve.RegulValveTandemCfg.PidCoef' replaced by a casted operation parameter 'pidCoef'
controlBoard.SendCommand(Command.Start, flowMeterNr, controlBoard.Route, int.MaxValue, tm, controlBoard.SendCommand(Command.Start, flowMeterNr, controlBoard.Route, int.MaxValue, tm,
0.0f, (int)pidCoef, 0, sd); 0.0f, (int)pidCoef, 0, sd);
} }
@@ -190,6 +206,7 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
public Event Run() public Event Run()
{ {
float rvPosition = controlBoard.RValvePosition(regulValveNr); float rvPosition = controlBoard.RValvePosition(regulValveNr);
float fixedRVPosition = controlBoard.RValvePosition(fixedRVNr);
float flowMtrFreq = controlBoard.ReferenceFreq; float flowMtrFreq = controlBoard.ReferenceFreq;
float flow = flowMtrFreq * nominalFlow / 2000.0f; float flow = flowMtrFreq * nominalFlow / 2000.0f;
@@ -198,7 +215,7 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
log.InfoFormat("Run(): rv#={0} pos={1}% freq={2} flow={3} opState={4}", log.InfoFormat("Run(): rv#={0} pos={1}% freq={2} flow={3} opState={4}",
regulValveNr, rvPosition.ToString("F1"), flowMtrFreq, flow, opState); regulValveNr, rvPosition.ToString("F1"), flowMtrFreq, flow, opState);
if (opState == OpState.ValveMoveToPosition) if (opState == OpState.IssueSetPositionCommand)
{ {
/// ///
/// Done once, issues an appropriate ValveMove(...) command /// Done once, issues an appropriate ValveMove(...) command
@@ -217,11 +234,34 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
/// ///
if ((targetPositionLo <= rvPosition) && (rvPosition <= targetPositionHi)) if ((targetPositionLo <= rvPosition) && (rvPosition <= targetPositionHi))
{ {
opState = OpState.ValveMoveToFlow; opState = OpState.IssueSetPositionCommand_FixedRV;
} }
return Event.None; return Event.None;
} }
else if (opState == OpState.ValveMoveToFlow) else if (opState == OpState.IssueSetPositionCommand_FixedRV)
{
///
/// Done once, issues an appropriate ValveMove(...) command
///
controlBoard.ValveMove(fixedRVNr, RegulValveMode.TargetPosition,
new float[2] { fixedPctLo, fixedPctHi },
regulValve.StableTime);
opState = OpState.SettingPosition_FixedRV;
return Event.None;
}
else if (opState == OpState.SettingPosition_FixedRV)
{
///
/// Repeated untill position is reached
///
if ((fixedPctLo <= fixedRVPosition) && (fixedRVPosition <= fixedPctHi))
{
opState = OpState.IssueSetFlowCommand;
}
return Event.None;
}
else if (opState == OpState.IssueSetFlowCommand)
{ {
/// ///
/// Done once, issues an appropriate ValveMove(...) command /// Done once, issues an appropriate ValveMove(...) command
@@ -15,7 +15,7 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
/// Set by the constructor /// Set by the constructor
readonly ControlBoardDev controlBoard; readonly ControlBoardDev controlBoard;
readonly RegulValveTandem regulValve; readonly Elde.RegulValve.RegulValve regulValve;
readonly int regulValveNr; readonly int regulValveNr;
readonly float posLoPct; readonly float posLoPct;
readonly float posHiPct; readonly float posHiPct;
@@ -31,19 +31,19 @@ namespace TBF.BenchControl.Elde.RegulValveTandem
/// Events: FlowSet, FlowTimeOut /// Events: FlowSet, FlowTimeOut
/// </summary> /// </summary>
/// <param name="ControlBoard">Control board device</param> /// <param name="ControlBoard">Control board device</param>
/// <param name="regulValve">Regulation valve component</param> /// <param name="_regulValve">Regulation valve component</param>
/// <param name="posLoPct">Lower limit of the position to be achieved</param> /// <param name="posLoPct">Lower limit of the position to be achieved</param>
/// <param name="posHiPct">Upper limit of the position to be achieved</param> /// <param name="posHiPct">Upper limit of the position to be achieved</param>
/// <param name="timeout">Timeout in sec. for setting the flow</param> /// <param name="timeout">Timeout in sec. for setting the flow</param>
/// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks> /// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks>
public SetRegulValvePositionOp(ControlBoardDev controlBoard, RegulValveTandem regulValve, float posLoPct, float posHiPct, int timeout) public SetRegulValvePositionOp(ControlBoardDev controlBoard, IRegulValve regV, float posLoPct, float posHiPct, int timeout)
{ {
if (controlBoard == null) throw new ArgumentNullException("ctrlBoard"); if (controlBoard == null) throw new ArgumentNullException("ctrlBoard");
this.controlBoard = controlBoard; this.controlBoard = controlBoard;
this.regulValve = regulValve as RegulValveTandem; regulValve = regV as Elde.RegulValve.RegulValve;
if (regulValve == null) throw new ArgumentNullException("regValve is null or not Elde"); if (regulValve == null) throw new ArgumentNullException("regValve is null or not Elde");
this.regulValveNr = this.regulValve.Idx1; regulValveNr = this.regulValve.Idx1;
this.posLoPct = posLoPct; this.posLoPct = posLoPct;
this.posHiPct = posHiPct; this.posHiPct = posHiPct;