Elde.RegulValve supports 'ReTryCommands' parameter (default = false), ver. 2.11.365

This commit is contained in:
Milan Hanajik
2016-10-13 16:08:15 +02:00
parent caf43fedb3
commit 45e0f50562
8 changed files with 148 additions and 82 deletions
@@ -129,7 +129,7 @@ namespace TBF.BenchControl.Elde.RegulValve
/// <returns>SetFlowOp instance</returns>
public IOperation SetFlowOp(GenericDevices.IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi, float pidCoef, DoubleBox measuredFlow, int timeout)
{
return new SetFlowOp(ControlBoard, this, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, timeout);
return new SetFlowOp(ControlBoard, this, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, RegulValveCfg.ReTryCommands, timeout);
}
/// <summary>
@@ -144,7 +144,7 @@ namespace TBF.BenchControl.Elde.RegulValve
/// <returns>SetFlowOp instance</returns>
public IOperation SetFlowAndMeasureOp(GenericDevices.IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi, float pidCoef, DoubleBox measuredFlow, int timeout, float filterConstant)
{
return new SetFlowOp(ControlBoard, this, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, timeout, true);
return new SetFlowOp(ControlBoard, this, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, RegulValveCfg.ReTryCommands, timeout, true);
}
/// <summary>
@@ -21,8 +21,9 @@ namespace TBF.BenchControl.Elde.RegulValve
public int AdcValueClosed; /// 0..1023
public int AdcValueOpen; /// 0..1023
public int StableTimeMs; /// 200..1500 ms
public bool StoredPositionReuse; /// true = store and re-use previous regulation valve positions
public int FlowStableSec; /// 0..60 sec
public bool StoredPositionReuse; /// true = store and re-use previous regulation valve positions
public bool ReTryCommands;
/// <summary>
/// Stabilization time when setting the flow: 0=200ms, step 50ms, max. 1.5 sec.
@@ -45,21 +46,23 @@ namespace TBF.BenchControl.Elde.RegulValve
AdcValueClosed = 100;
AdcValueOpen = 500;
StableTimeMs = 500;
StoredPositionReuse = false;
FlowStableSec = 5;
StoredPositionReuse = false;
ReTryCommands = false;
}
public string ToString(int i)
{
return string.Format("Name={0}, Parent={1}, Idx1={2}, ADC-Closed={3}, ADC-Open={4}, StabTm={5}ms, PosReuse={6}, FlowStable={7}s",
return string.Format("Name={0}, Parent={1}, Idx1={2}, ADC-Closed={3}, ADC-Open={4}, StabTm={5}ms, FlowStable={6}s, PosReuse={7}, ReTryCmds={8}",
Name,
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
Idx1,
AdcValueClosed,
AdcValueOpen,
StableTimeMs,
FlowStableSec,
StoredPositionReuse,
FlowStableSec);
ReTryCommands);
}
}
}
@@ -69,6 +69,7 @@ namespace TBF.BenchControl.Elde.RegulValve
this.label4 = new System.Windows.Forms.Label();
this.categoryComboBox = new System.Windows.Forms.ComboBox();
this.categoryLabel = new System.Windows.Forms.Label();
this.reTryCommandsCheckBox = new System.Windows.Forms.CheckBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
@@ -81,7 +82,7 @@ namespace TBF.BenchControl.Elde.RegulValve
this.positionTextBox.Location = new System.Drawing.Point(138, 114);
this.positionTextBox.Name = "positionTextBox";
this.positionTextBox.Size = new System.Drawing.Size(46, 20);
this.positionTextBox.TabIndex = 7;
this.positionTextBox.TabIndex = 8;
//
// positionLabel
//
@@ -89,7 +90,7 @@ namespace TBF.BenchControl.Elde.RegulValve
this.positionLabel.Location = new System.Drawing.Point(28, 117);
this.positionLabel.Name = "positionLabel";
this.positionLabel.Size = new System.Drawing.Size(18, 13);
this.positionLabel.TabIndex = 6;
this.positionLabel.TabIndex = 7;
this.positionLabel.Text = "ID";
//
// parentNameLabel
@@ -133,7 +134,7 @@ namespace TBF.BenchControl.Elde.RegulValve
this.adcClosedLabel.Location = new System.Drawing.Point(28, 141);
this.adcClosedLabel.Name = "adcClosedLabel";
this.adcClosedLabel.Size = new System.Drawing.Size(93, 13);
this.adcClosedLabel.TabIndex = 8;
this.adcClosedLabel.TabIndex = 9;
this.adcClosedLabel.Text = "ADC when Closed";
//
// adcClosedTextBox
@@ -142,7 +143,7 @@ namespace TBF.BenchControl.Elde.RegulValve
this.adcClosedTextBox.Location = new System.Drawing.Point(138, 138);
this.adcClosedTextBox.Name = "adcClosedTextBox";
this.adcClosedTextBox.Size = new System.Drawing.Size(46, 20);
this.adcClosedTextBox.TabIndex = 9;
this.adcClosedTextBox.TabIndex = 10;
//
// adcOpenTextBox
//
@@ -150,7 +151,7 @@ namespace TBF.BenchControl.Elde.RegulValve
this.adcOpenTextBox.Location = new System.Drawing.Point(138, 162);
this.adcOpenTextBox.Name = "adcOpenTextBox";
this.adcOpenTextBox.Size = new System.Drawing.Size(46, 20);
this.adcOpenTextBox.TabIndex = 11;
this.adcOpenTextBox.TabIndex = 12;
//
// adcOpenLabel
//
@@ -158,7 +159,7 @@ namespace TBF.BenchControl.Elde.RegulValve
this.adcOpenLabel.Location = new System.Drawing.Point(28, 165);
this.adcOpenLabel.Name = "adcOpenLabel";
this.adcOpenLabel.Size = new System.Drawing.Size(87, 13);
this.adcOpenLabel.TabIndex = 10;
this.adcOpenLabel.TabIndex = 11;
this.adcOpenLabel.Text = "ADC when Open";
//
// parentNameComboBox
@@ -174,10 +175,10 @@ namespace TBF.BenchControl.Elde.RegulValve
//
this.storedPosReuseCheckBox.AutoSize = true;
this.storedPosReuseCheckBox.Enabled = false;
this.storedPosReuseCheckBox.Location = new System.Drawing.Point(31, 213);
this.storedPosReuseCheckBox.Location = new System.Drawing.Point(31, 239);
this.storedPosReuseCheckBox.Name = "storedPosReuseCheckBox";
this.storedPosReuseCheckBox.Size = new System.Drawing.Size(162, 17);
this.storedPosReuseCheckBox.TabIndex = 14;
this.storedPosReuseCheckBox.TabIndex = 17;
this.storedPosReuseCheckBox.Text = "Enable stored position re-use";
this.storedPosReuseCheckBox.UseVisualStyleBackColor = true;
//
@@ -187,7 +188,7 @@ namespace TBF.BenchControl.Elde.RegulValve
this.stableTimeTextBox.Location = new System.Drawing.Point(138, 186);
this.stableTimeTextBox.Name = "stableTimeTextBox";
this.stableTimeTextBox.Size = new System.Drawing.Size(46, 20);
this.stableTimeTextBox.TabIndex = 13;
this.stableTimeTextBox.TabIndex = 14;
//
// stableTimeLabel
//
@@ -195,13 +196,13 @@ namespace TBF.BenchControl.Elde.RegulValve
this.stableTimeLabel.Location = new System.Drawing.Point(28, 189);
this.stableTimeLabel.Name = "stableTimeLabel";
this.stableTimeLabel.Size = new System.Drawing.Size(81, 13);
this.stableTimeLabel.TabIndex = 12;
this.stableTimeLabel.TabIndex = 13;
this.stableTimeLabel.Text = "Stable time [ms]";
//
// flowStableSecTextBox
//
this.flowStableSecTextBox.Enabled = false;
this.flowStableSecTextBox.Location = new System.Drawing.Point(138, 237);
this.flowStableSecTextBox.Location = new System.Drawing.Point(138, 210);
this.flowStableSecTextBox.Name = "flowStableSecTextBox";
this.flowStableSecTextBox.Size = new System.Drawing.Size(46, 20);
this.flowStableSecTextBox.TabIndex = 16;
@@ -209,7 +210,7 @@ namespace TBF.BenchControl.Elde.RegulValve
// flowStableSecLabel
//
this.flowStableSecLabel.AutoSize = true;
this.flowStableSecLabel.Location = new System.Drawing.Point(28, 240);
this.flowStableSecLabel.Location = new System.Drawing.Point(28, 213);
this.flowStableSecLabel.Name = "flowStableSecLabel";
this.flowStableSecLabel.Size = new System.Drawing.Size(74, 13);
this.flowStableSecLabel.TabIndex = 15;
@@ -226,7 +227,7 @@ namespace TBF.BenchControl.Elde.RegulValve
this.groupBox1.Location = new System.Drawing.Point(10, 398);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(280, 59);
this.groupBox1.TabIndex = 18;
this.groupBox1.TabIndex = 19;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Measured value 1";
//
@@ -293,7 +294,7 @@ namespace TBF.BenchControl.Elde.RegulValve
this.groupBox2.Location = new System.Drawing.Point(10, 462);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(280, 59);
this.groupBox2.TabIndex = 19;
this.groupBox2.TabIndex = 20;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Measured value 2";
//
@@ -356,7 +357,7 @@ namespace TBF.BenchControl.Elde.RegulValve
this.groupBox3.Location = new System.Drawing.Point(10, 527);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(280, 60);
this.groupBox3.TabIndex = 20;
this.groupBox3.TabIndex = 21;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Regulation valve";
//
@@ -412,8 +413,8 @@ namespace TBF.BenchControl.Elde.RegulValve
this.categoryComboBox.FormattingEnabled = true;
this.categoryComboBox.Location = new System.Drawing.Point(138, 90);
this.categoryComboBox.Name = "categoryComboBox";
this.categoryComboBox.Size = new System.Drawing.Size(81, 21);
this.categoryComboBox.TabIndex = 5;
this.categoryComboBox.Size = new System.Drawing.Size(130, 21);
this.categoryComboBox.TabIndex = 6;
//
// categoryLabel
//
@@ -421,13 +422,25 @@ namespace TBF.BenchControl.Elde.RegulValve
this.categoryLabel.Location = new System.Drawing.Point(28, 93);
this.categoryLabel.Name = "categoryLabel";
this.categoryLabel.Size = new System.Drawing.Size(49, 13);
this.categoryLabel.TabIndex = 4;
this.categoryLabel.TabIndex = 5;
this.categoryLabel.Text = "Category";
//
// reTryCommandsCheckBox
//
this.reTryCommandsCheckBox.AutoSize = true;
this.reTryCommandsCheckBox.Enabled = false;
this.reTryCommandsCheckBox.Location = new System.Drawing.Point(31, 262);
this.reTryCommandsCheckBox.Name = "reTryCommandsCheckBox";
this.reTryCommandsCheckBox.Size = new System.Drawing.Size(108, 17);
this.reTryCommandsCheckBox.TabIndex = 18;
this.reTryCommandsCheckBox.Text = "Re-try commands";
this.reTryCommandsCheckBox.UseVisualStyleBackColor = true;
//
// RegulValveCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.reTryCommandsCheckBox);
this.Controls.Add(this.categoryComboBox);
this.Controls.Add(this.categoryLabel);
this.Controls.Add(this.groupBox4);
@@ -505,5 +518,6 @@ namespace TBF.BenchControl.Elde.RegulValve
private System.Windows.Forms.Label label4;
private System.Windows.Forms.ComboBox categoryComboBox;
private System.Windows.Forms.Label categoryLabel;
private System.Windows.Forms.CheckBox reTryCommandsCheckBox;
}
}
@@ -81,8 +81,9 @@ namespace TBF.BenchControl.Elde.RegulValve
adcClosedTextBox.Text = config.AdcValueClosed.ToString();
adcOpenTextBox.Text = config.AdcValueOpen.ToString();
stableTimeTextBox.Text = config.StableTimeMs.ToString();
storedPosReuseCheckBox.Checked = config.StoredPositionReuse;
flowStableSecTextBox.Text = config.FlowStableSec.ToString();
storedPosReuseCheckBox.Checked = config.StoredPositionReuse;
reTryCommandsCheckBox.Checked = config.ReTryCommands;
adcTextBox1.Text = adc1.ToString();
adcTextBox2.Text = adc2.ToString();
@@ -99,8 +100,9 @@ namespace TBF.BenchControl.Elde.RegulValve
adcClosedTextBox.Enabled = true;
adcOpenTextBox.Enabled = true;
stableTimeTextBox.Enabled = true;
storedPosReuseCheckBox.Enabled = true;
flowStableSecTextBox.Enabled = true;
storedPosReuseCheckBox.Enabled = true;
reTryCommandsCheckBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
@@ -214,13 +216,6 @@ namespace TBF.BenchControl.Elde.RegulValve
flags |= CfgUpdateFlags.AnyChange;
}
bool btmp = storedPosReuseCheckBox.Checked;
if (config.StoredPositionReuse != btmp)
{
config.StoredPositionReuse = btmp;
flags |= CfgUpdateFlags.RestartRqrd;
}
tmp = int.Parse(flowStableSecTextBox.Text);
if (config.FlowStableSec != tmp)
{
@@ -228,6 +223,20 @@ namespace TBF.BenchControl.Elde.RegulValve
flags |= CfgUpdateFlags.AnyChange;
}
bool btmp = storedPosReuseCheckBox.Checked;
if (config.StoredPositionReuse != btmp)
{
config.StoredPositionReuse = btmp;
flags |= CfgUpdateFlags.RestartRqrd;
}
btmp = reTryCommandsCheckBox.Checked;
if (config.ReTryCommands != btmp)
{
config.ReTryCommands = btmp;
flags |= CfgUpdateFlags.RestartRqrd;
}
if ((flags & CfgUpdateFlags.AnyChange) != 0)
{
RegulValve.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
@@ -31,6 +31,7 @@ namespace TBF.BenchControl.Elde.RegulValve
readonly float pidCoef;
readonly int timeout;
readonly bool leaveMeasurementRunning;
readonly bool reTryCommands;
readonly float nominalFlow;
@@ -43,12 +44,12 @@ namespace TBF.BenchControl.Elde.RegulValve
ValveMoveToPosition1, /// Wait 1 takt
ValveMoveToPosition2, /// This is actual move to position
ValveMoveToPosition3, /// Wait 1 takt
ValveMoveToPosition4, /// Verify
CheckStatePosition, /// Verify
SettingPosition,
ValveMoveToFlow1, /// Wait 1 takt
ValveMoveToFlow2, /// This is actual move to flow
ValveMoveToFlow3, /// Wait 1 takt
ValveMoveToFlow4, /// Verify
CheckStateFlow, /// Verify
SettingFlow,
FlowReached,
SendCommandAgain,
@@ -77,8 +78,8 @@ namespace TBF.BenchControl.Elde.RegulValve
/// <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>
public SetFlowOp(ControlBoardDev controlBoard, IRegulValve _regulValve, IFlowMeter flowMeter,
float requiredFlowLo, float requiredFlowHi, float pidCoef, DoubleBox measuredFlow,
int timeout, bool leaveMeasurementRunning)
float requiredFlowLo, float requiredFlowHi, float pidCoef, DoubleBox measuredFlow,
bool reTryCmds, int timeout, bool leaveMeasurementRunning)
{
if (controlBoard == null) throw new ArgumentNullException("ctrlBoard");
this.controlBoard = controlBoard;
@@ -107,6 +108,7 @@ namespace TBF.BenchControl.Elde.RegulValve
this.reqFlowAve = (reqFlowLo + reqFlowHi) / 2.0f;
this.pidCoef = pidCoef;
this.measuredFlow = measuredFlow;
this.reTryCommands = reTryCmds;
this.timeout = timeout;
@@ -120,8 +122,8 @@ namespace TBF.BenchControl.Elde.RegulValve
/// Events: FlowSet
/// </summary>
public SetFlowOp(ControlBoardDev controlBoard, IRegulValve regValve, IFlowMeter flowMeter,
float requiredFlowLo, float requiredFlowHi, float pidCoef, DoubleBox measuredFlow, int timeout)
: this(controlBoard, regValve, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, timeout, false)
float requiredFlowLo, float requiredFlowHi, float pidCoef, DoubleBox measuredFlow, bool reTryCmds, int timeout)
: this(controlBoard, regValve, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, reTryCmds, timeout, false)
{
}
@@ -130,8 +132,8 @@ namespace TBF.BenchControl.Elde.RegulValve
/// Events: FlowSet
/// </summary>
public SetFlowOp(ControlBoardDev controlBoard, IRegulValve regValve, IFlowMeter flowMeter,
float requiredFlowLo, float requiredFlowHi, float pidCoef, DoubleBox measuredFlow)
: this(controlBoard, regValve, flowMeter, requiredFlowLo, pidCoef, requiredFlowHi, measuredFlow, int.MaxValue, false)
float requiredFlowLo, float requiredFlowHi, float pidCoef, DoubleBox measuredFlow, bool reTryCmds)
: this(controlBoard, regValve, flowMeter, requiredFlowLo, pidCoef, requiredFlowHi, measuredFlow, reTryCmds, int.MaxValue, false)
{
}
@@ -209,7 +211,10 @@ namespace TBF.BenchControl.Elde.RegulValve
double flowMtrFreq = controlBoard.ReferenceFreq;
double flow = flowMtrFreq * nominalFlow / 2000.0;
if (measuredFlow != null) measuredFlow.Val = flow;
if (flowMtrFreq != 0)
{
if (measuredFlow != null) measuredFlow.Val = flow;
}
log.InfoFormat("SetFlowOp:Run() rv#={0} pos={1}% freq={2} flow={3} opState={4}",
regulValveNr, rvPosition.ToString("F1"), flowMtrFreq, flow, opState);
@@ -262,10 +267,17 @@ namespace TBF.BenchControl.Elde.RegulValve
}
else if (opState == OpState.ValveMoveToPosition3)
{
opState = OpState.ValveMoveToPosition4;
if (reTryCommands)
{
opState = OpState.CheckStatePosition;
}
else
{
opState = OpState.SettingPosition;
}
return Event.None;
}
else if (opState == OpState.ValveMoveToPosition4) /// Verify
else if (opState == OpState.CheckStatePosition) /// Verify
{
if (((ulong)controlBoard.StatusP & (ulong)StatusP.RefPulsesMsrmnt) == 0)
{
@@ -342,10 +354,17 @@ namespace TBF.BenchControl.Elde.RegulValve
}
else if (opState == OpState.ValveMoveToFlow3)
{
opState = OpState.ValveMoveToFlow4;
if (reTryCommands)
{
opState = OpState.CheckStateFlow;
}
else
{
opState = OpState.SettingFlow;
}
return Event.None;
}
else if (opState == OpState.ValveMoveToFlow4) /// Verify the flow setting
else if (opState == OpState.CheckStateFlow) /// Verify the flow setting
{
if (regulValveNr != CoaxValveNr && (((ulong)controlBoard.StatusP & (ulong)StatusP.RefPulsesMsrmnt) == 0 ||
(controlBoard.RegulValveState(regulValveNr) & RegulValveState.PwOrFreqRegul) != RegulValveState.PwOrFreqRegul))