diff --git a/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs b/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs index 310205255..045b7510a 100644 --- a/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs +++ b/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs @@ -402,10 +402,11 @@ namespace TBF.BenchControl.Elde /// 'ulong' with bits of valves to open set to '1' /// 'ulong' with bits of valves to close set to '1' /// 'ulong' with bits of valves that have changed set to '1' - public ulong SetValves(ulong valvesToOpen, ulong valvesToClose) + public ulong SetValves(ulong valvesToOpen, ulong valvesToClose, IList extendedValves) { ulong oldRoute = route; route = (((route ^ valvesToInvert) | valvesToOpen) & (~valvesToClose)) ^ valvesToInvert; + foreach (var extV in extendedValves) extV.UpdateRoute(ref route); log.DebugFormat("SetValves(x,x), new route = {0}", Utils.ShowRoute(route)); sendCommandFlag = true; return oldRoute ^ route; diff --git a/TestBenchFramework/BenchControl/Elde/Valve/SetValvesOp.cs b/TestBenchFramework/BenchControl/Elde/Valve/SetValvesOp.cs index e19ba2eb7..d6fcc42b0 100644 --- a/TestBenchFramework/BenchControl/Elde/Valve/SetValvesOp.cs +++ b/TestBenchFramework/BenchControl/Elde/Valve/SetValvesOp.cs @@ -209,7 +209,7 @@ namespace TBF.BenchControl.Elde.Valve /// Start this operation public void Start() { - ulong changed = controlBoard.SetValves(switchPoints[0].MasksOpen, switchPoints[0].MasksClose); + ulong changed = controlBoard.SetValves(switchPoints[0].MasksOpen, switchPoints[0].MasksClose, StateMachine.ExtendedValves); swStartTime = StateMachine.Time; maxDelayTime = switchPoints[0].MaxDelay(changed); nextIx = 1; @@ -229,7 +229,7 @@ namespace TBF.BenchControl.Elde.Valve if (StateMachine.Time >= swStartTime + switchPoints[nextIx].TimeSec) { - ulong changed = controlBoard.SetValves(switchPoints[nextIx].MasksOpen, switchPoints[nextIx].MasksClose); + ulong changed = controlBoard.SetValves(switchPoints[nextIx].MasksOpen, switchPoints[nextIx].MasksClose, StateMachine.ExtendedValves); int nextDelay = switchPoints[nextIx].MaxDelay(changed); if (switchPoints[nextIx].TimeSec + nextDelay > maxDelayTime) diff --git a/TestBenchFramework/BenchControl/Elde/ValveEx/Valve.cs b/TestBenchFramework/BenchControl/Elde/ValveEx/Valve.cs new file mode 100644 index 000000000..df60971d4 --- /dev/null +++ b/TestBenchFramework/BenchControl/Elde/ValveEx/Valve.cs @@ -0,0 +1,83 @@ +/// +/// Copyright (c) 2015 Sensus Metering Systems +/// +using System; +using System.Collections.Generic; +using log4net; +using TBF.BenchControl.GenericDevices; + +namespace TBF.BenchControl.Elde.ValveEx +{ + public class Valve : ComponentBase, Generic.IComponent + { + private static readonly ILog log = LogManager.GetLogger(typeof(Valve)); + public override string ToString() { return string.Format("ValveEx({0})", Cfg.ToString(1)); } + + readonly ValveCfg valveCfg; + + public readonly ulong Mask; /// derived from bitPosition in the constructor + /// + public readonly IValve[] InputValves; + + public Valve() + { + } + + public Valve(ValveCfg cfg, IList components) + : base(cfg) + { + valveCfg = cfg; + + //controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components); + //if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent"); + + if (valveCfg.BitPosition < 0 || valveCfg.BitPosition >= 64) + { + throw new ArgumentOutOfRangeException("position"); + } + this.Mask = (((ulong)1) << valveCfg.BitPosition); + + InputValves = new IValve[valveCfg.InputValvesCount]; + InputValves[0] = TbfComponents.FindComponent(valveCfg.Input1) as IValve; + InputValves[1] = TbfComponents.FindComponent(valveCfg.Input2) as IValve; + if (InputValves.Length > 2) InputValves[2] = TbfComponents.FindComponent(valveCfg.Input3) as IValve; + if (InputValves.Length > 3) InputValves[3] = TbfComponents.FindComponent(valveCfg.Input4) as IValve; + if (InputValves.Length > 4) InputValves[4] = TbfComponents.FindComponent(valveCfg.Input5) as IValve; + + log.Debug(this.ToString()); + } + + public void UpdateRoute(ref ulong route) + { + bool output; + + if (valveCfg.LogicalOp == ValveExOperation.And) + { + output = true; + foreach (var valve in InputValves) + { + if (valve != null) output = output && valve.State; + } + } + else if (valveCfg.LogicalOp == ValveExOperation.Or) + { + output = false; + foreach (var valve in InputValves) + { + if (valve != null) output = output || valve.State; + } + } + else + return; + + if (output != valveCfg.InvertOutput) + { + route = route | Mask; /// Set the output bit to true + } + else + { + route = route & (~Mask); /// Reset the output bit to false + } + } + } +} diff --git a/TestBenchFramework/BenchControl/Elde/ValveEx/ValveCfg.cs b/TestBenchFramework/BenchControl/Elde/ValveEx/ValveCfg.cs new file mode 100644 index 000000000..1e396b4ce --- /dev/null +++ b/TestBenchFramework/BenchControl/Elde/ValveEx/ValveCfg.cs @@ -0,0 +1,67 @@ +/// +/// Copyright (c) 2015 Sensus Metering Systems +/// +using System.IO; +using System.Collections.Generic; +using System.Xml.Serialization; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.Elde.ValveEx +{ + public class ValveCfg : ComponentCfgBase, IChildComponentCfg + { + public IComponent GetComponent(IList components) { return new Valve(this, components); } + public IComponentCfgCtrl GetControl() { return new ValveCfgCtrl(); } + + /// + /// Serialized parameters + /// + public int BitPosition; /// Bit-position + /// + public ValveExOperation LogicalOp; /// Logical operation between input valves + public bool InvertOutput; /// Invert the output of logical operation + public int InputValvesCount; + public string Input1; /// Input valve 1 + public string Input2; /// Input valve 2 + public string Input3; /// Input valve 3 + public string Input4; /// Input valve 4 + public string Input5; /// Input valve 5 + + /// Private parameterless constructor invoked by all other (public) constructors + ValveCfg() + { + Name = "VEx"; + ParentName = string.Empty; + BitPosition = 0; + LogicalOp = ValveExOperation.And; + InvertOutput = false; + InputValvesCount = 2; + Input1 = string.Empty; + Input2 = string.Empty; + Input3 = string.Empty; + Input4 = string.Empty; + Input5 = string.Empty; + } + + public ValveCfg(IComponentFactory factory) + : this() + { + this.Factory = factory; + } + + public string ToString(int i) + { + return string.Format("Name={0}, Bit={1}, LogOp.={2}, Inv.Output={3}, #inputs={4}, I1={5}, I2={6}, I3={7}, I4={8}s, I5={9}", + Name, + BitPosition, + (LogicalOp == ValveExOperation.And) ? "AND" : "OR", + InvertOutput ? "yes" : "no", + InputValvesCount, + Input1, + Input2, + Input3, + Input4, + Input5); + } + } +} diff --git a/TestBenchFramework/BenchControl/Elde/ValveEx/ValveCfgCtrl.Designer.cs b/TestBenchFramework/BenchControl/Elde/ValveEx/ValveCfgCtrl.Designer.cs new file mode 100644 index 000000000..7927958f7 --- /dev/null +++ b/TestBenchFramework/BenchControl/Elde/ValveEx/ValveCfgCtrl.Designer.cs @@ -0,0 +1,291 @@ +/// +/// Copyright (c) 2015 Sensus Metering Systems +/// +namespace TBF.BenchControl.Elde.ValveEx +{ + partial class ValveCfgCtrl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.bitPositionTextBox = new System.Windows.Forms.TextBox(); + this.bitPositionLabel = 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.inputsCountLabel = new System.Windows.Forms.Label(); + this.inputsCountTextBox = new System.Windows.Forms.TextBox(); + this.logicalOpLabel = new System.Windows.Forms.Label(); + this.logicalOpComboBox = new System.Windows.Forms.ComboBox(); + this.invertedOutpCheckBox = new System.Windows.Forms.CheckBox(); + this.input1ComboBox = new System.Windows.Forms.ComboBox(); + this.input1Label = new System.Windows.Forms.Label(); + this.input2ComboBox = new System.Windows.Forms.ComboBox(); + this.input2Label = new System.Windows.Forms.Label(); + this.input3ComboBox = new System.Windows.Forms.ComboBox(); + this.input3Label = new System.Windows.Forms.Label(); + this.input4ComboBox = new System.Windows.Forms.ComboBox(); + this.input4Label = new System.Windows.Forms.Label(); + this.input5ComboBox = new System.Windows.Forms.ComboBox(); + this.input5Label = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // bitPositionTextBox + // + this.bitPositionTextBox.Enabled = false; + this.bitPositionTextBox.Location = new System.Drawing.Point(117, 58); + this.bitPositionTextBox.Name = "bitPositionTextBox"; + this.bitPositionTextBox.Size = new System.Drawing.Size(66, 20); + this.bitPositionTextBox.TabIndex = 4; + // + // bitPositionLabel + // + this.bitPositionLabel.AutoSize = true; + this.bitPositionLabel.Location = new System.Drawing.Point(17, 61); + this.bitPositionLabel.Name = "bitPositionLabel"; + this.bitPositionLabel.Size = new System.Drawing.Size(58, 13); + this.bitPositionLabel.TabIndex = 3; + this.bitPositionLabel.Text = "Bit position"; + // + // nameTextBox + // + this.nameTextBox.Enabled = false; + this.nameTextBox.Location = new System.Drawing.Point(117, 35); + 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(17, 38); + 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(115, 15); + this.classNameLabel.Name = "classNameLabel"; + this.classNameLabel.Size = new System.Drawing.Size(83, 13); + this.classNameLabel.TabIndex = 0; + this.classNameLabel.Text = "ComonentName"; + // + // inputsCountLabel + // + this.inputsCountLabel.AutoSize = true; + this.inputsCountLabel.Location = new System.Drawing.Point(17, 108); + this.inputsCountLabel.Name = "inputsCountLabel"; + this.inputsCountLabel.Size = new System.Drawing.Size(66, 13); + this.inputsCountLabel.TabIndex = 8; + this.inputsCountLabel.Text = "Inputs count"; + // + // inputsCountTextBox + // + this.inputsCountTextBox.Enabled = false; + this.inputsCountTextBox.Location = new System.Drawing.Point(117, 105); + this.inputsCountTextBox.Name = "inputsCountTextBox"; + this.inputsCountTextBox.Size = new System.Drawing.Size(66, 20); + this.inputsCountTextBox.TabIndex = 9; + this.inputsCountTextBox.TextChanged += new System.EventHandler(this.inputsCountTextBox_TextChanged); + // + // logicalOpLabel + // + this.logicalOpLabel.AutoSize = true; + this.logicalOpLabel.Location = new System.Drawing.Point(17, 84); + this.logicalOpLabel.Name = "logicalOpLabel"; + this.logicalOpLabel.Size = new System.Drawing.Size(88, 13); + this.logicalOpLabel.TabIndex = 6; + this.logicalOpLabel.Text = "Logical operation"; + // + // logicalOpComboBox + // + this.logicalOpComboBox.Enabled = false; + this.logicalOpComboBox.FormattingEnabled = true; + this.logicalOpComboBox.Location = new System.Drawing.Point(117, 81); + this.logicalOpComboBox.Name = "logicalOpComboBox"; + this.logicalOpComboBox.Size = new System.Drawing.Size(66, 21); + this.logicalOpComboBox.TabIndex = 7; + // + // invertedOutpCheckBox + // + this.invertedOutpCheckBox.AutoSize = true; + this.invertedOutpCheckBox.Enabled = false; + this.invertedOutpCheckBox.Location = new System.Drawing.Point(196, 61); + this.invertedOutpCheckBox.Name = "invertedOutpCheckBox"; + this.invertedOutpCheckBox.Size = new System.Drawing.Size(98, 17); + this.invertedOutpCheckBox.TabIndex = 5; + this.invertedOutpCheckBox.Text = "Inverted output"; + this.invertedOutpCheckBox.UseVisualStyleBackColor = true; + // + // input1ComboBox + // + this.input1ComboBox.Enabled = false; + this.input1ComboBox.FormattingEnabled = true; + this.input1ComboBox.Location = new System.Drawing.Point(117, 127); + this.input1ComboBox.Name = "input1ComboBox"; + this.input1ComboBox.Size = new System.Drawing.Size(130, 21); + this.input1ComboBox.TabIndex = 11; + // + // input1Label + // + this.input1Label.AutoSize = true; + this.input1Label.Location = new System.Drawing.Point(18, 130); + this.input1Label.Name = "input1Label"; + this.input1Label.Size = new System.Drawing.Size(40, 13); + this.input1Label.TabIndex = 10; + this.input1Label.Text = "Input 1"; + // + // input2ComboBox + // + this.input2ComboBox.Enabled = false; + this.input2ComboBox.FormattingEnabled = true; + this.input2ComboBox.Location = new System.Drawing.Point(117, 150); + this.input2ComboBox.Name = "input2ComboBox"; + this.input2ComboBox.Size = new System.Drawing.Size(130, 21); + this.input2ComboBox.TabIndex = 13; + // + // input2Label + // + this.input2Label.AutoSize = true; + this.input2Label.Location = new System.Drawing.Point(17, 153); + this.input2Label.Name = "input2Label"; + this.input2Label.Size = new System.Drawing.Size(40, 13); + this.input2Label.TabIndex = 12; + this.input2Label.Text = "Input 2"; + // + // input3ComboBox + // + this.input3ComboBox.Enabled = false; + this.input3ComboBox.FormattingEnabled = true; + this.input3ComboBox.Location = new System.Drawing.Point(117, 173); + this.input3ComboBox.Name = "input3ComboBox"; + this.input3ComboBox.Size = new System.Drawing.Size(130, 21); + this.input3ComboBox.TabIndex = 15; + // + // input3Label + // + this.input3Label.AutoSize = true; + this.input3Label.Location = new System.Drawing.Point(18, 176); + this.input3Label.Name = "input3Label"; + this.input3Label.Size = new System.Drawing.Size(40, 13); + this.input3Label.TabIndex = 14; + this.input3Label.Text = "Input 3"; + // + // input4ComboBox + // + this.input4ComboBox.Enabled = false; + this.input4ComboBox.FormattingEnabled = true; + this.input4ComboBox.Location = new System.Drawing.Point(117, 196); + this.input4ComboBox.Name = "input4ComboBox"; + this.input4ComboBox.Size = new System.Drawing.Size(130, 21); + this.input4ComboBox.TabIndex = 17; + // + // input4Label + // + this.input4Label.AutoSize = true; + this.input4Label.Location = new System.Drawing.Point(18, 199); + this.input4Label.Name = "input4Label"; + this.input4Label.Size = new System.Drawing.Size(40, 13); + this.input4Label.TabIndex = 16; + this.input4Label.Text = "Input 4"; + // + // input5ComboBox + // + this.input5ComboBox.Enabled = false; + this.input5ComboBox.FormattingEnabled = true; + this.input5ComboBox.Location = new System.Drawing.Point(117, 219); + this.input5ComboBox.Name = "input5ComboBox"; + this.input5ComboBox.Size = new System.Drawing.Size(130, 21); + this.input5ComboBox.TabIndex = 19; + // + // input5Label + // + this.input5Label.AutoSize = true; + this.input5Label.Location = new System.Drawing.Point(18, 222); + this.input5Label.Name = "input5Label"; + this.input5Label.Size = new System.Drawing.Size(40, 13); + this.input5Label.TabIndex = 18; + this.input5Label.Text = "Input 5"; + // + // ValveCfgCtrl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.input5ComboBox); + this.Controls.Add(this.input5Label); + this.Controls.Add(this.input4ComboBox); + this.Controls.Add(this.input4Label); + this.Controls.Add(this.input3ComboBox); + this.Controls.Add(this.input3Label); + this.Controls.Add(this.input2ComboBox); + this.Controls.Add(this.input2Label); + this.Controls.Add(this.input1ComboBox); + this.Controls.Add(this.input1Label); + this.Controls.Add(this.invertedOutpCheckBox); + this.Controls.Add(this.logicalOpComboBox); + this.Controls.Add(this.logicalOpLabel); + this.Controls.Add(this.inputsCountTextBox); + this.Controls.Add(this.inputsCountLabel); + this.Controls.Add(this.bitPositionTextBox); + this.Controls.Add(this.bitPositionLabel); + this.Controls.Add(this.nameTextBox); + this.Controls.Add(this.nameLabel); + this.Controls.Add(this.classNameLabel); + this.Name = "ValveCfgCtrl"; + this.Size = new System.Drawing.Size(300, 250); + this.Load += new System.EventHandler(this.ValveCfgCtrl_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox bitPositionTextBox; + private System.Windows.Forms.Label bitPositionLabel; + private System.Windows.Forms.TextBox nameTextBox; + private System.Windows.Forms.Label nameLabel; + private System.Windows.Forms.Label classNameLabel; + private System.Windows.Forms.Label inputsCountLabel; + private System.Windows.Forms.TextBox inputsCountTextBox; + private System.Windows.Forms.Label logicalOpLabel; + private System.Windows.Forms.ComboBox logicalOpComboBox; + private System.Windows.Forms.CheckBox invertedOutpCheckBox; + private System.Windows.Forms.ComboBox input1ComboBox; + private System.Windows.Forms.Label input1Label; + private System.Windows.Forms.ComboBox input2ComboBox; + private System.Windows.Forms.Label input2Label; + private System.Windows.Forms.ComboBox input3ComboBox; + private System.Windows.Forms.Label input3Label; + private System.Windows.Forms.ComboBox input4ComboBox; + private System.Windows.Forms.Label input4Label; + private System.Windows.Forms.ComboBox input5ComboBox; + private System.Windows.Forms.Label input5Label; + } +} diff --git a/TestBenchFramework/BenchControl/Elde/ValveEx/ValveCfgCtrl.cs b/TestBenchFramework/BenchControl/Elde/ValveEx/ValveCfgCtrl.cs new file mode 100644 index 000000000..9a39dbf9c --- /dev/null +++ b/TestBenchFramework/BenchControl/Elde/ValveEx/ValveCfgCtrl.cs @@ -0,0 +1,185 @@ +/// +/// Copyright (c) 2015 Sensus Metering Systems +/// +using System; +using System.Collections.Generic; +using System.Windows.Forms; +using log4net; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.Elde.ValveEx +{ + public partial class ValveCfgCtrl : UserControl, IComponentCfgCtrl + { + static readonly ILog log = LogManager.GetLogger(typeof(ValveCfgCtrl)); + + ComponentParametersDlg parent; + + public bool ShowMore { get { return false; } } + + ValveCfg config; + public IComponentCfg Config + { + get { return config as IComponentCfg; } + set + { + config = value as ValveCfg; + Redraw(); + } + } + + public ValveCfgCtrl() + { + InitializeComponent(); + } + + private void ValveCfgCtrl_Load(object sender, EventArgs e) + { + parent = ParentForm as ComponentParametersDlg; + if (parent == null) return; + + logicalOpComboBox.Items.Add("AND"); + logicalOpComboBox.Items.Add("OR"); + + if (parent.TbfComponents != null) + { + AddValvePumpItemsToCombo(input1ComboBox, parent.TbfComponents); + AddValvePumpItemsToCombo(input2ComboBox, parent.TbfComponents); + AddValvePumpItemsToCombo(input3ComboBox, parent.TbfComponents); + AddValvePumpItemsToCombo(input4ComboBox, parent.TbfComponents); + AddValvePumpItemsToCombo(input5ComboBox, parent.TbfComponents); + } + + Redraw(); + } + + void AddValvePumpItemsToCombo(ComboBox combo, IList components) + { + foreach (var cmpntEntity in components) + { + IComponent comp = TbfComponents.CmpntFactoryFromClassName(cmpntEntity.ClassName).DummyComponent(); + if (comp is GenericDevices.IValve ) + { + combo.Items.Add(cmpntEntity.Name); + } + } + } + + public void Closing() + { + } + + void Redraw() + { + if (config == null) return; /// Control was not loaded, settings were not changed + + classNameLabel.Text = config.Factory.ClassName; + nameTextBox.Text = config.Name; + bitPositionTextBox.Text = config.BitPosition.ToString(); + invertedOutpCheckBox.Checked = config.InvertOutput; + logicalOpComboBox.Text = (config.LogicalOp == ValveExOperation.And) ? "AND" : ((config.LogicalOp == ValveExOperation.Or) ? "OR" : "---"); + inputsCountTextBox.Text = config.InputValvesCount.ToString(); + input1ComboBox.Text = config.Input1; + input2ComboBox.Text = config.Input2; + input3ComboBox.Text = config.Input3; + input4ComboBox.Text = config.Input4; + input5ComboBox.Text = config.Input5; + } + + public void Unlock() + { + nameTextBox.Enabled = true; + bitPositionTextBox.Enabled = true; + invertedOutpCheckBox.Enabled = true; + logicalOpComboBox.Enabled = true; + inputsCountTextBox.Enabled = true; + input1ComboBox.Enabled = true; + input2ComboBox.Enabled = true; + input3ComboBox.Enabled = true; + input4ComboBox.Enabled = true; + input5ComboBox.Enabled = true; + } + + public CfgUpdateFlags UpdateCfg() + { + CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd; + + if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed + + config.Name = nameTextBox.Text; + config.BitPosition = int.Parse(bitPositionTextBox.Text); + config.InvertOutput = invertedOutpCheckBox.Checked; + config.LogicalOp = (logicalOpComboBox.Text == "AND") ? ValveExOperation.And : ValveExOperation.Or; + config.InputValvesCount = int.Parse(inputsCountTextBox.Text); + config.Input1 = input1ComboBox.Text.Equals("---") ? string.Empty : input1ComboBox.Text; + config.Input2 = input2ComboBox.Text.Equals("---") ? string.Empty : input2ComboBox.Text; + config.Input3 = input3ComboBox.Text.Equals("---") ? string.Empty : input3ComboBox.Text; + config.Input4 = input4ComboBox.Text.Equals("---") ? string.Empty : input4ComboBox.Text; + config.Input5 = input5ComboBox.Text.Equals("---") ? string.Empty : input5ComboBox.Text; + + return flags; + } + + public CfgUpdateFlags VerifyCfg(ref string message) + { + CfgUpdateFlags flags = CfgUpdateFlags.None; + + int dummy; + if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 64) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "'Bit Position' should be between 0 and 63"; + } + if (!logicalOpComboBox.Items.Contains(logicalOpComboBox.Text)) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "Invalid 'Category'"; + } + if (!int.TryParse(inputsCountTextBox.Text, out dummy) || dummy < 2 || dummy > 5) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "'Inputs count' out of range (2..5)"; + } + if (!input1ComboBox.Items.Contains(input1ComboBox.Text)) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "Invalid 'Input 1'"; + } + if (!input2ComboBox.Items.Contains(input2ComboBox.Text)) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "Invalid 'Input 2'"; + } + if (!input3ComboBox.Items.Contains(input3ComboBox.Text)) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "Invalid 'Input 3'"; + } + if (!input4ComboBox.Items.Contains(input4ComboBox.Text)) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "Invalid 'Input 4'"; + } + if (!input5ComboBox.Items.Contains(input5ComboBox.Text)) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "Invalid 'Input 5'"; + } + return flags; + } + + private void inputsCountTextBox_TextChanged(object sender, EventArgs e) + { + int count; + if (int.TryParse(inputsCountTextBox.Text, out count) && count >= 2 || count <= 5) + { + input3Label.Visible = (count >= 3); + input4Label.Visible = (count >= 4); + input5Label.Visible = (count >= 5); + input3ComboBox.Visible = (count >= 3); + input4ComboBox.Visible = (count >= 4); + input5ComboBox.Visible = (count >= 5); + } + } + } +} diff --git a/TestBenchFramework/BenchControl/Elde/ValveEx/ValveCfgCtrl.resx b/TestBenchFramework/BenchControl/Elde/ValveEx/ValveCfgCtrl.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TestBenchFramework/BenchControl/Elde/ValveEx/ValveCfgCtrl.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TestBenchFramework/BenchControl/Elde/ValveEx/ValveFactory.cs b/TestBenchFramework/BenchControl/Elde/ValveEx/ValveFactory.cs new file mode 100644 index 000000000..871ef0b27 --- /dev/null +++ b/TestBenchFramework/BenchControl/Elde/ValveEx/ValveFactory.cs @@ -0,0 +1,23 @@ +/// +/// Copyright (c) 2015 Sensus Metering Systems +/// +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.Elde.ValveEx +{ + public class ValveFactory : IComponentFactory + { + public string ClassName { get { return "ValveEx"; } } + + public void ResetStaticProperties() { Valve.ResetStaticProperties(); } + + public IComponent DummyComponent() { return new Valve(); } + + public IComponentCfg DefaultConfig() { return new ValveCfg(this); } + + public IComponentCfg CmpntCfgFromCmpntEntity(Entities.Component component) + { + return ComponentCfgBase.CreateFromDbEntity(typeof(ValveCfg), component, this); + } + } +} diff --git a/TestBenchFramework/BenchControl/Events.cs b/TestBenchFramework/BenchControl/Events.cs index ffdf6c100..975c1e435 100644 --- a/TestBenchFramework/BenchControl/Events.cs +++ b/TestBenchFramework/BenchControl/Events.cs @@ -51,6 +51,12 @@ namespace TBF.BenchControl None, /// Valve will not be shown in the paths } + public enum ValveExOperation + { + Or, + And, + } + public enum PumpProtocol { Modbus, /// Modbus protocol, default serial settings are 9600Bd, 8bits, NoP, 1stop diff --git a/TestBenchFramework/BenchControl/GenericDevices/ValveBase.cs b/TestBenchFramework/BenchControl/GenericDevices/ValveBase.cs index d1758ff2a..f897dd047 100644 --- a/TestBenchFramework/BenchControl/GenericDevices/ValveBase.cs +++ b/TestBenchFramework/BenchControl/GenericDevices/ValveBase.cs @@ -30,7 +30,7 @@ namespace TBF.BenchControl.GenericDevices } /// - /// Process the list of components and return the masters valves + /// Process the list of components and return masters valves /// public static IList MasterValves(IList cmpnts) { @@ -44,7 +44,7 @@ namespace TBF.BenchControl.GenericDevices } /// - /// Process the list of components and return the coupled valves + /// Process the list of components and return coupled valves /// public static IList CoupledValves(IList cmpnts) { @@ -57,6 +57,19 @@ namespace TBF.BenchControl.GenericDevices return result; } + /// + /// Process the list of components and return extended valves + /// + public static IList ExtendedValves(IList cmpnts) + { + IList result = new List(); + foreach (var cmpnt in cmpnts) + { + if (cmpnt is Elde.ValveEx.Valve) result.Add(cmpnt as Elde.ValveEx.Valve); + } + return result; + } + /// /// Create a list with one valved passed as an argument to this function /// diff --git a/TestBenchFramework/BenchControl/StateMachine.cs b/TestBenchFramework/BenchControl/StateMachine.cs index 462c768e3..7dbb2e51d 100644 --- a/TestBenchFramework/BenchControl/StateMachine.cs +++ b/TestBenchFramework/BenchControl/StateMachine.cs @@ -49,8 +49,9 @@ namespace TBF.BenchControl public static GenericDevices.IValve EmptyTankValve1; public static GenericDevices.IValve EmptyTankValve2; public static GenericDevices.IValve EmptyTankValve3; - public static IList MasterValves; /// list of directly controlled valves - public static IList CoupledValves; /// list of coupled valves + public static IList MasterValves; /// list of directly controlled valves + public static IList CoupledValves; /// list of coupled valves + public static IList ExtendedValves; /// list of extended valves /// Time and synchronization @@ -203,6 +204,7 @@ namespace TBF.BenchControl components = BenchControl.TbfComponents.LoadComponentsFromDB(FluentCommon.CreateSession(Database.Bench)); MasterValves = GenericDevices.ValveBase.MasterValves(components); CoupledValves = GenericDevices.ValveBase.CoupledValves(components); + ExtendedValves = GenericDevices.ValveBase.ExtendedValves(components); /// Find all balances (to initialize tank capacities in the control board) /// Find the control board diff --git a/TestBenchFramework/TBF.csproj b/TestBenchFramework/TBF.csproj index 6299a8192..696bd599c 100644 --- a/TestBenchFramework/TBF.csproj +++ b/TestBenchFramework/TBF.csproj @@ -210,6 +210,15 @@ TempMeterCfgCtrl.cs + + + + UserControl + + + ValveCfgCtrl.cs + + @@ -1315,6 +1324,9 @@ TempMeterCfgCtrl.cs + + ValveCfgCtrl.cs + ValveCfgCtrl.cs