Delay added to IValve and Pumps, no delay functionality yet

This commit is contained in:
Milan Hanajik
2014-09-06 08:10:08 +02:00
parent 6933442e76
commit 87f42ba291
13 changed files with 102 additions and 23 deletions
@@ -23,10 +23,12 @@ namespace TBF.BenchControl.Elde.Pump
public string Name { get { return pumpCfg.Name; } } public string Name { get { return pumpCfg.Name; } }
public int Delay { get { return pumpCfg.Delay; } }
public ValveCategory Category { get { return ValveCategory.Feeding; } } /// Pump category is Feeding public ValveCategory Category { get { return ValveCategory.Feeding; } } /// Pump category is Feeding
public GenericDevices.IValve CoupledTo { get { return null; } } public GenericDevices.IValve CoupledTo { get { return null; } }
public bool Invert { get { return false; } } public bool InvertCouple { get { return false; } }
public int LagOpening { get { return 0; } } public int LagOpening { get { return 0; } }
public int LagClosing { get { return 0; } } public int LagClosing { get { return 0; } }
@@ -7,27 +7,30 @@ namespace TBF.BenchControl.Elde.Pump
public class PumpCfg : ComponentCfgBase, IChildComponentCfg public class PumpCfg : ComponentCfgBase, IChildComponentCfg
{ {
public int BitPosition; public int BitPosition;
public int Delay;
/// Parameterless constructor /// Parameterless constructor
public PumpCfg() public PumpCfg()
{ {
Delay = 1;
} }
/// Constructor /// Constructor
public PumpCfg(IComponentFactory factory, string name, string parentName, int bitPosition) public PumpCfg(IComponentFactory factory, string name, string parentName, int bitPosition, int delay)
: base(factory, name, parentName) : base(factory, name, parentName)
{ {
this.BitPosition = bitPosition; this.BitPosition = bitPosition;
this.Delay = delay;
} }
public IComponentCfg Clone() public IComponentCfg Clone()
{ {
return new PumpCfg(Factory, Name, ParentName, BitPosition); return new PumpCfg(Factory, Name, ParentName, BitPosition, Delay);
} }
public string ToString(int i) public string ToString(int i)
{ {
return string.Format("bit={0}", BitPosition); return string.Format("bit={0}, delay={1}s", BitPosition, Delay);
} }
public TBF.Entities.Component CreateDbEntity() public TBF.Entities.Component CreateDbEntity()
@@ -35,6 +35,8 @@
this.nameLabel = new System.Windows.Forms.Label(); this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label(); this.classNameLabel = new System.Windows.Forms.Label();
this.parentNameComboBox = new System.Windows.Forms.ComboBox(); this.parentNameComboBox = new System.Windows.Forms.ComboBox();
this.delayTextBox = new System.Windows.Forms.TextBox();
this.delayLabel = new System.Windows.Forms.Label();
this.SuspendLayout(); this.SuspendLayout();
// //
// bitPositionTextBox // bitPositionTextBox
@@ -98,10 +100,29 @@
this.parentNameComboBox.Size = new System.Drawing.Size(130, 21); this.parentNameComboBox.Size = new System.Drawing.Size(130, 21);
this.parentNameComboBox.TabIndex = 4; this.parentNameComboBox.TabIndex = 4;
// //
// delayTextBox
//
this.delayTextBox.Enabled = false;
this.delayTextBox.Location = new System.Drawing.Point(122, 124);
this.delayTextBox.Name = "delayTextBox";
this.delayTextBox.Size = new System.Drawing.Size(46, 20);
this.delayTextBox.TabIndex = 8;
//
// delayLabel
//
this.delayLabel.AutoSize = true;
this.delayLabel.Location = new System.Drawing.Point(36, 127);
this.delayLabel.Name = "delayLabel";
this.delayLabel.Size = new System.Drawing.Size(48, 13);
this.delayLabel.TabIndex = 7;
this.delayLabel.Text = "Delay [s]";
//
// PumpCfgCtrl // PumpCfgCtrl
// //
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.delayTextBox);
this.Controls.Add(this.delayLabel);
this.Controls.Add(this.parentNameComboBox); this.Controls.Add(this.parentNameComboBox);
this.Controls.Add(this.bitPositionTextBox); this.Controls.Add(this.bitPositionTextBox);
this.Controls.Add(this.bitPositionLabel); this.Controls.Add(this.bitPositionLabel);
@@ -126,5 +147,7 @@
private System.Windows.Forms.Label nameLabel; private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel; private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.ComboBox parentNameComboBox; private System.Windows.Forms.ComboBox parentNameComboBox;
private System.Windows.Forms.TextBox delayTextBox;
private System.Windows.Forms.Label delayLabel;
} }
} }
@@ -53,6 +53,7 @@ namespace TBF.BenchControl.Elde.Pump
nameTextBox.Text = config.Name; nameTextBox.Text = config.Name;
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName; parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
bitPositionTextBox.Text = config.BitPosition.ToString(); bitPositionTextBox.Text = config.BitPosition.ToString();
delayTextBox.Text = config.Delay.ToString();
} }
public void Unlock() public void Unlock()
@@ -60,6 +61,7 @@ namespace TBF.BenchControl.Elde.Pump
nameTextBox.Enabled = true; nameTextBox.Enabled = true;
parentNameComboBox.Enabled = true; parentNameComboBox.Enabled = true;
bitPositionTextBox.Enabled = true; bitPositionTextBox.Enabled = true;
delayTextBox.Enabled = true;
} }
public void UpdateCfg() public void UpdateCfg()
@@ -69,6 +71,7 @@ namespace TBF.BenchControl.Elde.Pump
config.Name = nameTextBox.Text; config.Name = nameTextBox.Text;
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text; config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
config.BitPosition = int.Parse(bitPositionTextBox.Text); config.BitPosition = int.Parse(bitPositionTextBox.Text);
config.Delay = int.Parse(delayTextBox.Text);
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgVerifyFlags VerifyCfg(ref string message)
@@ -86,6 +89,11 @@ namespace TBF.BenchControl.Elde.Pump
flags |= CfgVerifyFlags.Error; flags |= CfgVerifyFlags.Error;
message += Environment.NewLine + "'Bit Position' should be between 0 and 63"; 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;
message += Environment.NewLine + "'Delay' should be between 0 and 300s (5min)";
}
return flags; return flags;
} }
} }
@@ -16,7 +16,7 @@ namespace TBF.BenchControl.Elde.Pump
public IComponentCfg DefaultConfig(IList<Entities.Component> components) public IComponentCfg DefaultConfig(IList<Entities.Component> components)
{ {
return new PumpCfg(this, "Pump", "CB", 0); return new PumpCfg(this, "Pump", "CB", 0, 1);
} }
public IComponentCfgCtrl CreateCfgCtrl() public IComponentCfgCtrl CreateCfgCtrl()
@@ -23,10 +23,12 @@ namespace TBF.BenchControl.Elde.PumpWithFM
public string Name { get { return pumpCfg.Name; } } public string Name { get { return pumpCfg.Name; } }
public int Delay { get { return pumpCfg.Delay; } }
public ValveCategory Category { get { return ValveCategory.Feeding; } } /// Pump category is Feeding public ValveCategory Category { get { return ValveCategory.Feeding; } } /// Pump category is Feeding
public GenericDevices.IValve CoupledTo { get { return null; } } public GenericDevices.IValve CoupledTo { get { return null; } }
public bool Invert { get { return false; } } public bool InvertCouple { get { return false; } }
public int LagOpening { get { return 0; } } public int LagOpening { get { return 0; } }
public int LagClosing { get { return 0; } } public int LagClosing { get { return 0; } }
@@ -8,27 +8,30 @@ namespace TBF.BenchControl.Elde.PumpWithFM
{ {
public int BitPosition; public int BitPosition;
public int FMIndex; public int FMIndex;
public int Delay;
/// Parameterless constructor /// Parameterless constructor
public PumpCfg() public PumpCfg()
{ {
Delay = 1;
} }
/// Constructor /// Constructor
public PumpCfg(IComponentFactory factory, string name, string parentName, int bitPosition, int fmIndex) public PumpCfg(IComponentFactory factory, string name, string parentName, int bitPosition, int fmIndex, int delay)
: base(factory, name, parentName) : base(factory, name, parentName)
{ {
this.BitPosition = bitPosition; this.BitPosition = bitPosition;
this.FMIndex = fmIndex; this.FMIndex = fmIndex;
this.Delay = delay;
} }
public IComponentCfg Clone() public IComponentCfg Clone()
{ {
return new PumpCfg(Factory, Name, ParentName, BitPosition, FMIndex); return new PumpCfg(Factory, Name, ParentName, BitPosition, FMIndex, Delay);
} }
public string ToString(int i) public string ToString(int i)
{ {
return string.Format("bit={0}, fmIdx={1}", BitPosition, FMIndex); return string.Format("bit={0}, fmIdx={1}, delay={2}s", BitPosition, FMIndex, Delay);
} }
public TBF.Entities.Component CreateDbEntity() public TBF.Entities.Component CreateDbEntity()
@@ -37,6 +37,8 @@
this.parentNameComboBox = new System.Windows.Forms.ComboBox(); this.parentNameComboBox = new System.Windows.Forms.ComboBox();
this.fmIndexTextBox = new System.Windows.Forms.TextBox(); this.fmIndexTextBox = new System.Windows.Forms.TextBox();
this.fmIndexLabel = new System.Windows.Forms.Label(); this.fmIndexLabel = new System.Windows.Forms.Label();
this.delayTextBox = new System.Windows.Forms.TextBox();
this.delayLabel = new System.Windows.Forms.Label();
this.SuspendLayout(); this.SuspendLayout();
// //
// bitPositionTextBox // bitPositionTextBox
@@ -117,10 +119,29 @@
this.fmIndexLabel.TabIndex = 7; this.fmIndexLabel.TabIndex = 7;
this.fmIndexLabel.Text = "FM Index"; this.fmIndexLabel.Text = "FM Index";
// //
// delayTextBox
//
this.delayTextBox.Enabled = false;
this.delayTextBox.Location = new System.Drawing.Point(122, 149);
this.delayTextBox.Name = "delayTextBox";
this.delayTextBox.Size = new System.Drawing.Size(46, 20);
this.delayTextBox.TabIndex = 10;
//
// delayLabel
//
this.delayLabel.AutoSize = true;
this.delayLabel.Location = new System.Drawing.Point(36, 152);
this.delayLabel.Name = "delayLabel";
this.delayLabel.Size = new System.Drawing.Size(48, 13);
this.delayLabel.TabIndex = 9;
this.delayLabel.Text = "Delay [s]";
//
// PumpCfgCtrl // PumpCfgCtrl
// //
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.delayTextBox);
this.Controls.Add(this.delayLabel);
this.Controls.Add(this.fmIndexTextBox); this.Controls.Add(this.fmIndexTextBox);
this.Controls.Add(this.fmIndexLabel); this.Controls.Add(this.fmIndexLabel);
this.Controls.Add(this.parentNameComboBox); this.Controls.Add(this.parentNameComboBox);
@@ -149,5 +170,7 @@
private System.Windows.Forms.ComboBox parentNameComboBox; private System.Windows.Forms.ComboBox parentNameComboBox;
private System.Windows.Forms.TextBox fmIndexTextBox; private System.Windows.Forms.TextBox fmIndexTextBox;
private System.Windows.Forms.Label fmIndexLabel; private System.Windows.Forms.Label fmIndexLabel;
private System.Windows.Forms.TextBox delayTextBox;
private System.Windows.Forms.Label delayLabel;
} }
} }
@@ -54,6 +54,7 @@ namespace TBF.BenchControl.Elde.PumpWithFM
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName; parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
bitPositionTextBox.Text = config.BitPosition.ToString(); bitPositionTextBox.Text = config.BitPosition.ToString();
fmIndexTextBox.Text = config.FMIndex.ToString(); fmIndexTextBox.Text = config.FMIndex.ToString();
delayTextBox.Text = config.Delay.ToString();
} }
public void Unlock() public void Unlock()
@@ -62,6 +63,7 @@ namespace TBF.BenchControl.Elde.PumpWithFM
parentNameComboBox.Enabled = true; parentNameComboBox.Enabled = true;
bitPositionTextBox.Enabled = true; bitPositionTextBox.Enabled = true;
fmIndexTextBox.Enabled = true; fmIndexTextBox.Enabled = true;
delayTextBox.Enabled = true;
} }
public void UpdateCfg() public void UpdateCfg()
@@ -72,6 +74,7 @@ namespace TBF.BenchControl.Elde.PumpWithFM
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text; config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
config.BitPosition = int.Parse(bitPositionTextBox.Text); config.BitPosition = int.Parse(bitPositionTextBox.Text);
config.FMIndex = int.Parse(fmIndexTextBox.Text); config.FMIndex = int.Parse(fmIndexTextBox.Text);
config.Delay = int.Parse(delayTextBox.Text);
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgVerifyFlags VerifyCfg(ref string message)
@@ -94,6 +97,11 @@ namespace TBF.BenchControl.Elde.PumpWithFM
flags |= CfgVerifyFlags.Error; flags |= CfgVerifyFlags.Error;
message += Environment.NewLine + "'FM Index' should be between 0 and FMPumpsCount - 1"; 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;
message += Environment.NewLine + "'Delay' should be between 0 and 300s (5min)";
}
return flags; return flags;
} }
} }
@@ -19,7 +19,7 @@ namespace TBF.BenchControl.Elde.PumpWithFM
public IComponentCfg DefaultConfig(IList<Entities.Component> components) public IComponentCfg DefaultConfig(IList<Entities.Component> components)
{ {
return new PumpCfg(this, "Pump", "CB", 0, 0); return new PumpCfg(this, "Pump", "CB", 0, 0, 1);
} }
public IComponentCfgCtrl CreateCfgCtrl() public IComponentCfgCtrl CreateCfgCtrl()
@@ -14,11 +14,12 @@ namespace TBF.BenchControl.Elde.Valve
class SwitchPoint class SwitchPoint
{ {
public int TimeSec; public int TimeSec; /// Time [s]
public IList<IValve> VOpen; public IList<IValve> VOpen; /// List of valves to open in this point of time
public IList<IValve> VClose; public IList<IValve> VClose; /// List of valves to close in this point of time
public ulong MasksOpen; public ulong MasksOpen; /// OR-ed bitmasks of valves to open in this point of time
public ulong MasksClose; public ulong MasksClose; /// OR-ed bitmasks of valves to close in this point of time
public int MaxDelay; /// Max. delay in [s] of all valves to be opened or closed
} }
IList<SwitchPoint> switchPointsRaw; IList<SwitchPoint> switchPointsRaw;
@@ -39,8 +40,8 @@ namespace TBF.BenchControl.Elde.Valve
foreach (var valve in StateMachine.CoupledValves) foreach (var valve in StateMachine.CoupledValves)
{ {
if ((!valve.Invert && valvesOpen.Contains(valve.CoupledTo)) || if ((!valve.InvertCouple && valvesOpen.Contains(valve.CoupledTo)) ||
(valve.Invert && valvesClose.Contains(valve.CoupledTo))) (valve.InvertCouple && valvesClose.Contains(valve.CoupledTo)))
{ {
/// The coupled valve 'valve' is opening /// The coupled valve 'valve' is opening
int time = valve.LagOpening; int time = valve.LagOpening;
@@ -55,8 +56,8 @@ namespace TBF.BenchControl.Elde.Valve
VClose = new List<IValve>() }); VClose = new List<IValve>() });
} }
} }
else if ((!valve.Invert && valvesClose.Contains(valve.CoupledTo)) || else if ((!valve.InvertCouple && valvesClose.Contains(valve.CoupledTo)) ||
(valve.Invert && valvesOpen.Contains(valve.CoupledTo))) (valve.InvertCouple && valvesOpen.Contains(valve.CoupledTo)))
{ {
/// The coupled valve 'valve' is closing /// The coupled valve 'valve' is closing
int time = valve.LagClosing; int time = valve.LagClosing;
@@ -28,8 +28,9 @@ namespace TBF.BenchControl.Elde.Valve
public string Name { get { return valveCfg.Name; } } public string Name { get { return valveCfg.Name; } }
public ValveCategory Category { get { return valveCfg.Category; } } public ValveCategory Category { get { return valveCfg.Category; } }
public int Delay { get { return valveCfg.OpenCloseTime; } }
public IValve CoupledTo { get { return coupledTo; } } public IValve CoupledTo { get { return coupledTo; } }
public bool Invert { get { return valveCfg.InvertCouple; } } public bool InvertCouple { get { return valveCfg.InvertCouple; } }
public int LagOpening { get { return valveCfg.LagOpening; } } public int LagOpening { get { return valveCfg.LagOpening; } }
public int LagClosing { get { return valveCfg.LagClosing; } } public int LagClosing { get { return valveCfg.LagClosing; } }
@@ -14,6 +14,11 @@ namespace TBF.BenchControl.GenericDevices
/// </summary> /// </summary>
ValveCategory Category { get; } ValveCategory Category { get; }
/// <summary>
/// Delay of the valve in [s] (open or close time, whichever is larger)
/// </summary>
int Delay { get; }
/// <summary> /// <summary>
/// Coupled valve or null. /// Coupled valve or null.
/// This valve is a slave and follows the coupled valve, which is a master. /// This valve is a slave and follows the coupled valve, which is a master.
@@ -25,7 +30,7 @@ namespace TBF.BenchControl.GenericDevices
/// The coupled valve is inverted referred to the master valve. /// The coupled valve is inverted referred to the master valve.
/// This property is used only in case 'CoupledTo' is non-null. /// This property is used only in case 'CoupledTo' is non-null.
/// </summary> /// </summary>
bool Invert { get; } bool InvertCouple { get; }
/// <summary> /// <summary>
/// Delay (referred to the master valve) when opening this (coupled, slave) valve in [s] /// Delay (referred to the master valve) when opening this (coupled, slave) valve in [s]