ValveEx component added.
This commit is contained in:
@@ -402,10 +402,11 @@ namespace TBF.BenchControl.Elde
|
||||
/// <param name="valvesToOpen">'ulong' with bits of valves to open set to '1'</param>
|
||||
/// <param name="valvesToClose">'ulong' with bits of valves to close set to '1'</param>
|
||||
/// <returns>'ulong' with bits of valves that have changed set to '1'</returns>
|
||||
public ulong SetValves(ulong valvesToOpen, ulong valvesToClose)
|
||||
public ulong SetValves(ulong valvesToOpen, ulong valvesToClose, IList<Elde.ValveEx.Valve> 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;
|
||||
|
||||
@@ -209,7 +209,7 @@ namespace TBF.BenchControl.Elde.Valve
|
||||
/// <summary>Start this operation</summary>
|
||||
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)
|
||||
|
||||
@@ -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<Generic.IComponent> 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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<IComponent> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,291 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
///
|
||||
namespace TBF.BenchControl.Elde.ValveEx
|
||||
{
|
||||
partial class ValveCfgCtrl
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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<Entities.Component> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace TBF.BenchControl.GenericDevices
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process the list of components and return the masters valves
|
||||
/// Process the list of components and return masters valves
|
||||
/// </summary>
|
||||
public static IList<IValve> MasterValves(IList<Generic.IComponent> cmpnts)
|
||||
{
|
||||
@@ -44,7 +44,7 @@ namespace TBF.BenchControl.GenericDevices
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process the list of components and return the coupled valves
|
||||
/// Process the list of components and return coupled valves
|
||||
/// </summary>
|
||||
public static IList<IValve> CoupledValves(IList<Generic.IComponent> cmpnts)
|
||||
{
|
||||
@@ -57,6 +57,19 @@ namespace TBF.BenchControl.GenericDevices
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process the list of components and return extended valves
|
||||
/// </summary>
|
||||
public static IList<Elde.ValveEx.Valve> ExtendedValves(IList<Generic.IComponent> cmpnts)
|
||||
{
|
||||
IList<Elde.ValveEx.Valve> result = new List<Elde.ValveEx.Valve>();
|
||||
foreach (var cmpnt in cmpnts)
|
||||
{
|
||||
if (cmpnt is Elde.ValveEx.Valve) result.Add(cmpnt as Elde.ValveEx.Valve);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a list with one valved passed as an argument to this function
|
||||
/// </summary>
|
||||
|
||||
@@ -51,6 +51,7 @@ namespace TBF.BenchControl
|
||||
public static GenericDevices.IValve EmptyTankValve3;
|
||||
public static IList<IValve> MasterValves; /// list of directly controlled valves
|
||||
public static IList<IValve> CoupledValves; /// list of coupled valves
|
||||
public static IList<Elde.ValveEx.Valve> 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
|
||||
|
||||
@@ -210,6 +210,15 @@
|
||||
<DependentUpon>TempMeterCfgCtrl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\Elde\TempMeterInternal\TempMeterFactory.cs" />
|
||||
<Compile Include="BenchControl\Elde\ValveEx\Valve.cs" />
|
||||
<Compile Include="BenchControl\Elde\ValveEx\ValveCfg.cs" />
|
||||
<Compile Include="BenchControl\Elde\ValveEx\ValveCfgCtrl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\Elde\ValveEx\ValveCfgCtrl.designer.cs">
|
||||
<DependentUpon>ValveCfgCtrl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\Elde\ValveEx\ValveFactory.cs" />
|
||||
<Compile Include="BenchControl\MettlerToledo\KeepReadingMassesOp.cs" />
|
||||
<Compile Include="BenchControl\MettlerToledo\Multi\BalanceCfg.cs" />
|
||||
<Compile Include="BenchControl\MettlerToledo\Multi\BalanceCfgCtrl.cs">
|
||||
@@ -1315,6 +1324,9 @@
|
||||
<EmbeddedResource Include="BenchControl\Elde\TempMeter\TempMeterCfgCtrl.resx">
|
||||
<DependentUpon>TempMeterCfgCtrl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="BenchControl\Elde\ValveEx\ValveCfgCtrl.resx">
|
||||
<DependentUpon>ValveCfgCtrl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="BenchControl\Elde\Valve\ValveCfgCtrl.resx">
|
||||
<DependentUpon>ValveCfgCtrl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
||||
Reference in New Issue
Block a user