From df0a38e3c6187f55d31f8666882429a2037187b5 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Wed, 1 Mar 2017 14:40:10 +0100 Subject: [PATCH] MettlerToledo.TankDraining, ITankDrainingCfg, ITankDraining class/interfaces added, EmptyValve --> DrainValve --- .../GenericDevices/ITankDraining.cs | 14 ++ .../GenericDevices/ITankDrainingCfg.cs | 29 ++++ .../MettlerToledo/Standard/BalanceCfg.cs | 47 +++++- .../Standard/BalanceCfgCtrl.Designer.cs | 156 ++++++++++-------- .../MettlerToledo/Standard/BalanceCfgCtrl.cs | 133 +++++++++------ .../MettlerToledo/Standard/BalanceDev.cs | 6 +- .../MettlerToledo/TankDraining.cs | 26 +++ .../Resources/Strings.Designer.cs | 8 +- TestBenchFramework/Resources/Strings.resx | 8 +- TestBenchFramework/TBF.csproj | 3 + .../UiControls/PathsOutputCtrl.cs | 6 +- 11 files changed, 294 insertions(+), 142 deletions(-) create mode 100644 TestBenchFramework/BenchControl/GenericDevices/ITankDraining.cs create mode 100644 TestBenchFramework/BenchControl/GenericDevices/ITankDrainingCfg.cs create mode 100644 TestBenchFramework/BenchControl/MettlerToledo/TankDraining.cs diff --git a/TestBenchFramework/BenchControl/GenericDevices/ITankDraining.cs b/TestBenchFramework/BenchControl/GenericDevices/ITankDraining.cs new file mode 100644 index 000000000..f1a6b8a71 --- /dev/null +++ b/TestBenchFramework/BenchControl/GenericDevices/ITankDraining.cs @@ -0,0 +1,14 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace TBF.BenchControl.GenericDevices +{ + public interface ITankDraining + { + } +} diff --git a/TestBenchFramework/BenchControl/GenericDevices/ITankDrainingCfg.cs b/TestBenchFramework/BenchControl/GenericDevices/ITankDrainingCfg.cs new file mode 100644 index 000000000..7469a80cf --- /dev/null +++ b/TestBenchFramework/BenchControl/GenericDevices/ITankDrainingCfg.cs @@ -0,0 +1,29 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// + +namespace TBF.BenchControl.GenericDevices +{ + public interface ITankDrainingCfg + { + /// + /// Max. mass of water in 'kg' or volume in 'l' + /// + float Capacity { get; } + + /// + /// 'Empty' water mass in 'kg' or volume in 'l' + /// + float Empty { get; } + + /// + /// Time in [s] to drain the tank completely + /// + int DrainTimeSec { get; } + + /// + /// Name of the drain valve + /// + string DrainValve { get; } + } +} diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceCfg.cs b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceCfg.cs index 6769c432e..c0cf8c181 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceCfg.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceCfg.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2013-2016 Sensus Metering Systems +/// Copyright (c) 2013-2017 Sensus Metering Systems /// using System; using System.IO; @@ -10,7 +10,7 @@ using TBF.BenchControl.Generic; namespace TBF.BenchControl.MettlerToledo.Standard { - public class BalanceCfg : ComponentCfgBase, GenericDevices.IBalanceCfg, GenericDevices.ICalibInfoCfg + public class BalanceCfg : ComponentCfgBase, GenericDevices.IBalanceCfg, GenericDevices.ICalibInfoCfg, GenericDevices.ITankDrainingCfg { public IComponentCfgCtrl GetControl() { return new BalanceCfgCtrl(); } @@ -23,10 +23,38 @@ namespace TBF.BenchControl.MettlerToledo.Standard public int DataBits; public StopBits StopBits; public Handshake Handshake; - public float Capacity; /// Max. water mass in 'kg' or volume in 'l' - public float Empty; /// 'Empty' water mass in 'kg' or volume in 'l' + + /// Max. water mass in 'kg' or volume in 'l' + private float capacity; + public float Capacity + { + get { return capacity; } + set { capacity = value; } + } + + /// Mass threshold for 'Tank is empty' in 'kg' (or volume in 'l') + private float empty; + public float Empty + { + get { return empty; } + set { empty = value; } + } + + private string drainValve; + public string DrainValve + { + get { return drainValve; } + set { drainValve = value; } + } + + private int drainTimeSec; + public int DrainTimeSec + { + get { return drainTimeSec; } + set { drainTimeSec = value; } + } + public string Format; - public int EmptyTimeSec; /// s /// Buoyancy related serialized parameters displayed in Metrology tab page private float buoyancyTemp; @@ -78,7 +106,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard /// Private parameterless constructor invoked by all other (public) constructors BalanceCfg() { - Name = "WT"; + Name = "WT1"; ParentName = string.Empty; ComPortNr = 3; BaudRate = 2400; @@ -89,7 +117,8 @@ namespace TBF.BenchControl.MettlerToledo.Standard Capacity = 200.0f; Empty = 20.0f; Format = "F3"; - EmptyTimeSec = 180; + DrainValve = "VB1"; + DrainTimeSec = 180; BuoyancyTemp = 20.0f; BuoyancyPress = 1.0f; BuoyancyHumi = 40.0f; @@ -103,8 +132,8 @@ namespace TBF.BenchControl.MettlerToledo.Standard public string ToString(int i) { - return string.Format("Name={0}, {1}kg, empty={2}kg, fmt.={3}, emptyTm={4}s, Com{5}, {6}Bd, {7}-bits, parity={8}, stopBits={9}, {10}", - Name, Capacity, Empty, Format, EmptyTimeSec, ComPortNr, BaudRate, DataBits, Parity, StopBits, Handshake); + return string.Format("Name={0}, {1}kg, empty={2}kg, fmt.={3}, drainTm={4}s, Com{5}, {6}Bd, {7}-bits, parity={8}, stopBits={9}, {10}", + Name, Capacity, Empty, Format, DrainTimeSec, ComPortNr, BaudRate, DataBits, Parity, StopBits, Handshake); } } } diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceCfgCtrl.Designer.cs b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceCfgCtrl.Designer.cs index 1e3405098..3e5edcf60 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceCfgCtrl.Designer.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceCfgCtrl.Designer.cs @@ -53,45 +53,47 @@ namespace TBF.BenchControl.MettlerToledo.Standard this.emptyTextBox = new System.Windows.Forms.TextBox(); this.emptyLabel = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); - this.emptyTimeTextBox = new System.Windows.Forms.TextBox(); + this.drainTimeTextBox = new System.Windows.Forms.TextBox(); this.label5 = new System.Windows.Forms.Label(); this.formatTextBox = new System.Windows.Forms.TextBox(); this.formatLabel = new System.Windows.Forms.Label(); + this.drainValveComboBox = new System.Windows.Forms.ComboBox(); + this.drainingValveLabel = new System.Windows.Forms.Label(); this.SuspendLayout(); // // handshakeComboBox // this.handshakeComboBox.Enabled = false; this.handshakeComboBox.FormattingEnabled = true; - this.handshakeComboBox.Location = new System.Drawing.Point(236, 216); + this.handshakeComboBox.Location = new System.Drawing.Point(236, 222); this.handshakeComboBox.Name = "handshakeComboBox"; this.handshakeComboBox.Size = new System.Drawing.Size(43, 21); - this.handshakeComboBox.TabIndex = 25; + this.handshakeComboBox.TabIndex = 27; // // stopBitsComboBox // this.stopBitsComboBox.Enabled = false; this.stopBitsComboBox.FormattingEnabled = true; - this.stopBitsComboBox.Location = new System.Drawing.Point(236, 193); + this.stopBitsComboBox.Location = new System.Drawing.Point(236, 200); this.stopBitsComboBox.Name = "stopBitsComboBox"; this.stopBitsComboBox.Size = new System.Drawing.Size(43, 21); - this.stopBitsComboBox.TabIndex = 23; + this.stopBitsComboBox.TabIndex = 25; // // parityComboBox // this.parityComboBox.Enabled = false; this.parityComboBox.FormattingEnabled = true; - this.parityComboBox.Location = new System.Drawing.Point(100, 216); + this.parityComboBox.Location = new System.Drawing.Point(100, 222); this.parityComboBox.Name = "parityComboBox"; this.parityComboBox.Size = new System.Drawing.Size(43, 21); - this.parityComboBox.TabIndex = 19; + this.parityComboBox.TabIndex = 21; // // nameTextBox // this.nameTextBox.Enabled = false; - this.nameTextBox.Location = new System.Drawing.Point(136, 27); + this.nameTextBox.Location = new System.Drawing.Point(137, 27); this.nameTextBox.Name = "nameTextBox"; - this.nameTextBox.Size = new System.Drawing.Size(143, 20); + this.nameTextBox.Size = new System.Drawing.Size(142, 20); this.nameTextBox.TabIndex = 2; // // nameLabel @@ -106,7 +108,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard // classNameLabel // this.classNameLabel.AutoSize = true; - this.classNameLabel.Location = new System.Drawing.Point(133, 7); + this.classNameLabel.Location = new System.Drawing.Point(134, 9); this.classNameLabel.Name = "classNameLabel"; this.classNameLabel.Size = new System.Drawing.Size(89, 13); this.classNameLabel.TabIndex = 0; @@ -115,184 +117,204 @@ namespace TBF.BenchControl.MettlerToledo.Standard // handshakeLabel // this.handshakeLabel.AutoSize = true; - this.handshakeLabel.Location = new System.Drawing.Point(162, 219); + this.handshakeLabel.Location = new System.Drawing.Point(162, 225); this.handshakeLabel.Name = "handshakeLabel"; this.handshakeLabel.Size = new System.Drawing.Size(62, 13); - this.handshakeLabel.TabIndex = 24; + this.handshakeLabel.TabIndex = 26; this.handshakeLabel.Text = "Handshake"; // // stopBitsLabel // this.stopBitsLabel.AutoSize = true; - this.stopBitsLabel.Location = new System.Drawing.Point(162, 196); + this.stopBitsLabel.Location = new System.Drawing.Point(162, 203); this.stopBitsLabel.Name = "stopBitsLabel"; this.stopBitsLabel.Size = new System.Drawing.Size(49, 13); - this.stopBitsLabel.TabIndex = 22; + this.stopBitsLabel.TabIndex = 24; this.stopBitsLabel.Text = "Stop Bits"; // // dataBitsTextBox // this.dataBitsTextBox.Enabled = false; - this.dataBitsTextBox.Location = new System.Drawing.Point(236, 170); + this.dataBitsTextBox.Location = new System.Drawing.Point(236, 178); this.dataBitsTextBox.Name = "dataBitsTextBox"; this.dataBitsTextBox.Size = new System.Drawing.Size(43, 20); - this.dataBitsTextBox.TabIndex = 21; + this.dataBitsTextBox.TabIndex = 23; // // dataBitsLabel // this.dataBitsLabel.AutoSize = true; - this.dataBitsLabel.Location = new System.Drawing.Point(162, 173); + this.dataBitsLabel.Location = new System.Drawing.Point(162, 181); this.dataBitsLabel.Name = "dataBitsLabel"; this.dataBitsLabel.Size = new System.Drawing.Size(50, 13); - this.dataBitsLabel.TabIndex = 20; + this.dataBitsLabel.TabIndex = 22; this.dataBitsLabel.Text = "Data Bits"; // // partityLabel // this.partityLabel.AutoSize = true; - this.partityLabel.Location = new System.Drawing.Point(26, 221); + this.partityLabel.Location = new System.Drawing.Point(26, 225); this.partityLabel.Name = "partityLabel"; this.partityLabel.Size = new System.Drawing.Size(33, 13); - this.partityLabel.TabIndex = 18; + this.partityLabel.TabIndex = 20; this.partityLabel.Text = "Parity"; // // baudRateTextBox // this.baudRateTextBox.Enabled = false; - this.baudRateTextBox.Location = new System.Drawing.Point(100, 193); + this.baudRateTextBox.Location = new System.Drawing.Point(100, 200); this.baudRateTextBox.Name = "baudRateTextBox"; this.baudRateTextBox.Size = new System.Drawing.Size(43, 20); - this.baudRateTextBox.TabIndex = 17; + this.baudRateTextBox.TabIndex = 19; // // baudRateLabel // this.baudRateLabel.AutoSize = true; - this.baudRateLabel.Location = new System.Drawing.Point(26, 196); + this.baudRateLabel.Location = new System.Drawing.Point(26, 203); this.baudRateLabel.Name = "baudRateLabel"; - this.baudRateLabel.Size = new System.Drawing.Size(58, 13); - this.baudRateLabel.TabIndex = 16; - this.baudRateLabel.Text = "Baud Rate"; + this.baudRateLabel.Size = new System.Drawing.Size(53, 13); + this.baudRateLabel.TabIndex = 18; + this.baudRateLabel.Text = "Baud rate"; // // comPortNrTextBox // this.comPortNrTextBox.Enabled = false; - this.comPortNrTextBox.Location = new System.Drawing.Point(100, 170); + this.comPortNrTextBox.Location = new System.Drawing.Point(100, 178); this.comPortNrTextBox.Name = "comPortNrTextBox"; this.comPortNrTextBox.Size = new System.Drawing.Size(43, 20); - this.comPortNrTextBox.TabIndex = 15; + this.comPortNrTextBox.TabIndex = 17; // // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(26, 173); + this.label1.Location = new System.Drawing.Point(26, 181); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(68, 13); - this.label1.TabIndex = 14; - this.label1.Text = "Serial Port #:"; + this.label1.Size = new System.Drawing.Size(67, 13); + this.label1.TabIndex = 16; + this.label1.Text = "Serial port #:"; // // capacityLabel // this.capacityLabel.AutoSize = true; - this.capacityLabel.Location = new System.Drawing.Point(26, 54); + this.capacityLabel.Location = new System.Drawing.Point(26, 82); this.capacityLabel.Name = "capacityLabel"; - this.capacityLabel.Size = new System.Drawing.Size(76, 13); - this.capacityLabel.TabIndex = 3; - this.capacityLabel.Text = "Tank Capacity"; + this.capacityLabel.Size = new System.Drawing.Size(75, 13); + this.capacityLabel.TabIndex = 5; + this.capacityLabel.Text = "Tank capacity"; // // capacityTextBox // this.capacityTextBox.Enabled = false; - this.capacityTextBox.Location = new System.Drawing.Point(137, 51); + this.capacityTextBox.Location = new System.Drawing.Point(137, 79); this.capacityTextBox.Name = "capacityTextBox"; this.capacityTextBox.Size = new System.Drawing.Size(43, 20); - this.capacityTextBox.TabIndex = 4; + this.capacityTextBox.TabIndex = 6; // // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(186, 54); + this.label2.Location = new System.Drawing.Point(186, 82); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(19, 13); - this.label2.TabIndex = 5; + this.label2.TabIndex = 7; this.label2.Text = "kg"; // // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(186, 77); + this.label3.Location = new System.Drawing.Point(186, 104); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(19, 13); - this.label3.TabIndex = 8; + this.label3.TabIndex = 10; this.label3.Text = "kg"; // // emptyTextBox // this.emptyTextBox.Enabled = false; - this.emptyTextBox.Location = new System.Drawing.Point(137, 74); + this.emptyTextBox.Location = new System.Drawing.Point(137, 101); this.emptyTextBox.Name = "emptyTextBox"; this.emptyTextBox.Size = new System.Drawing.Size(43, 20); - this.emptyTextBox.TabIndex = 7; + this.emptyTextBox.TabIndex = 9; // // emptyLabel // this.emptyLabel.AutoSize = true; - this.emptyLabel.Location = new System.Drawing.Point(26, 77); + this.emptyLabel.Location = new System.Drawing.Point(26, 104); this.emptyLabel.Name = "emptyLabel"; - this.emptyLabel.Size = new System.Drawing.Size(64, 13); - this.emptyLabel.TabIndex = 6; - this.emptyLabel.Text = "Tank Empty"; + this.emptyLabel.Size = new System.Drawing.Size(109, 13); + this.emptyLabel.TabIndex = 8; + this.emptyLabel.Text = "Tank empty threshold"; // // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(186, 123); + this.label4.Location = new System.Drawing.Point(186, 149); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(24, 13); - this.label4.TabIndex = 13; + this.label4.TabIndex = 15; this.label4.Text = "sec"; // - // emptyTimeTextBox + // drainTimeTextBox // - this.emptyTimeTextBox.Enabled = false; - this.emptyTimeTextBox.Location = new System.Drawing.Point(137, 120); - this.emptyTimeTextBox.Name = "emptyTimeTextBox"; - this.emptyTimeTextBox.Size = new System.Drawing.Size(43, 20); - this.emptyTimeTextBox.TabIndex = 12; + this.drainTimeTextBox.Enabled = false; + this.drainTimeTextBox.Location = new System.Drawing.Point(137, 146); + this.drainTimeTextBox.Name = "drainTimeTextBox"; + this.drainTimeTextBox.Size = new System.Drawing.Size(43, 20); + this.drainTimeTextBox.TabIndex = 14; // // label5 // this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(26, 123); + this.label5.Location = new System.Drawing.Point(26, 149); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(90, 13); - this.label5.TabIndex = 11; - this.label5.Text = "Tank Empty Time"; + this.label5.Size = new System.Drawing.Size(54, 13); + this.label5.TabIndex = 13; + this.label5.Text = "Drain time"; // // formatTextBox // this.formatTextBox.Enabled = false; - this.formatTextBox.Location = new System.Drawing.Point(137, 97); + this.formatTextBox.Location = new System.Drawing.Point(137, 49); this.formatTextBox.Name = "formatTextBox"; this.formatTextBox.Size = new System.Drawing.Size(43, 20); - this.formatTextBox.TabIndex = 10; + this.formatTextBox.TabIndex = 4; // // formatLabel // this.formatLabel.AutoSize = true; - this.formatLabel.Location = new System.Drawing.Point(26, 100); + this.formatLabel.Location = new System.Drawing.Point(26, 52); this.formatLabel.Name = "formatLabel"; this.formatLabel.Size = new System.Drawing.Size(76, 13); - this.formatLabel.TabIndex = 9; + this.formatLabel.TabIndex = 3; this.formatLabel.Text = "Decimal points"; // + // drainValveComboBox + // + this.drainValveComboBox.Enabled = false; + this.drainValveComboBox.FormattingEnabled = true; + this.drainValveComboBox.Location = new System.Drawing.Point(137, 123); + this.drainValveComboBox.Name = "drainValveComboBox"; + this.drainValveComboBox.Size = new System.Drawing.Size(143, 21); + this.drainValveComboBox.TabIndex = 12; + // + // drainingValveLabel + // + this.drainingValveLabel.AutoSize = true; + this.drainingValveLabel.Location = new System.Drawing.Point(26, 126); + this.drainingValveLabel.Name = "drainingValveLabel"; + this.drainingValveLabel.Size = new System.Drawing.Size(61, 13); + this.drainingValveLabel.TabIndex = 11; + this.drainingValveLabel.Text = "Drain valve"; + // // BalanceCfgCtrl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.drainValveComboBox); + this.Controls.Add(this.drainingValveLabel); this.Controls.Add(this.formatTextBox); this.Controls.Add(this.formatLabel); this.Controls.Add(this.label4); - this.Controls.Add(this.emptyTimeTextBox); + this.Controls.Add(this.drainTimeTextBox); this.Controls.Add(this.label5); this.Controls.Add(this.label3); this.Controls.Add(this.emptyTextBox); @@ -347,9 +369,11 @@ namespace TBF.BenchControl.MettlerToledo.Standard private System.Windows.Forms.TextBox emptyTextBox; private System.Windows.Forms.Label emptyLabel; private System.Windows.Forms.Label label4; - private System.Windows.Forms.TextBox emptyTimeTextBox; + private System.Windows.Forms.TextBox drainTimeTextBox; private System.Windows.Forms.Label label5; private System.Windows.Forms.TextBox formatTextBox; private System.Windows.Forms.Label formatLabel; + private System.Windows.Forms.ComboBox drainValveComboBox; + private System.Windows.Forms.Label drainingValveLabel; } } diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceCfgCtrl.cs b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceCfgCtrl.cs index 00ad4d6ce..c87a121ec 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceCfgCtrl.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceCfgCtrl.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2017 Sensus Metering Systems /// using System; using System.Globalization; @@ -14,6 +14,8 @@ namespace TBF.BenchControl.MettlerToledo.Standard { static readonly ILog log = LogManager.GetLogger(typeof(BalanceCfgCtrl)); + ComponentParametersDlg parent; + public bool ShowMore { get { return false; } } BalanceCfg config; @@ -27,6 +29,55 @@ namespace TBF.BenchControl.MettlerToledo.Standard } } + + int GetParityIx(Parity par) + { + if (par == Parity.None) return 0; + if (par == Parity.Even) return 0; + if (par == Parity.Odd) return 0; + return -1; + } + Parity GetParity(string str) + { + if (str.Equals(Parity.None.ToString())) return Parity.None; + if (str.Equals(Parity.Even.ToString())) return Parity.Even; + if (str.Equals(Parity.Odd.ToString())) return Parity.Odd; + return (Parity)(-1); + } + + int GetStopBitsIx(StopBits sb) + { + if (sb == StopBits.None) return 0; + if (sb == StopBits.One) return 1; + if (sb == StopBits.OnePointFive) return 2; + if (sb == StopBits.Two) return 3; + return -1; + } + StopBits GetStopBits(string str) + { + if (str.Equals(StopBits.None.ToString())) return StopBits.None; + if (str.Equals(StopBits.One.ToString())) return StopBits.One; + if (str.Equals(StopBits.OnePointFive.ToString())) return StopBits.OnePointFive; + if (str.Equals(StopBits.Two.ToString())) return StopBits.Two; + return (StopBits)(-1); + } + + int GetHandshakeIx(Handshake par) + { + if (par == Handshake.None) return 0; + if (par == Handshake.RequestToSend) return 0; + if (par == Handshake.XOnXOff) return 0; + return -1; + } + Handshake GetHandshake(string str) + { + if (str.Equals(Handshake.None.ToString())) return Handshake.None; + if (str.Equals(Handshake.RequestToSend.ToString())) return Handshake.RequestToSend; + if (str.Equals(Handshake.XOnXOff.ToString())) return Handshake.XOnXOff; + return (Handshake)(-1); + } + + public BalanceCfgCtrl() { InitializeComponent(); @@ -45,55 +96,23 @@ namespace TBF.BenchControl.MettlerToledo.Standard handshakeComboBox.Items.Add(Handshake.XOnXOff.ToString()); } - int GetParityIx(Parity par) - { - if (par == Parity.None) return 0; - if (par == Parity.Even) return 0; - if (par == Parity.Odd) return 0; - return -1; - } - Parity GetParity(string str) - { - if (str.Equals(Parity.None.ToString())) return Parity.None; - if (str.Equals(Parity.Even.ToString())) return Parity.Even; - if (str.Equals(Parity.Odd.ToString())) return Parity.Odd; - return (Parity)(-1); - } - - int GetStopBitsIx(StopBits sb) - { - if (sb == StopBits.None) return 0; - if (sb == StopBits.One) return 1; - if (sb == StopBits.OnePointFive) return 2; - if (sb == StopBits.Two) return 3; - return -1; - } - StopBits GetStopBits(string str) - { - if (str.Equals(StopBits.None.ToString())) return StopBits.None; - if (str.Equals(StopBits.One.ToString())) return StopBits.One; - if (str.Equals(StopBits.OnePointFive.ToString())) return StopBits.OnePointFive; - if (str.Equals(StopBits.Two.ToString())) return StopBits.Two; - return (StopBits)(-1); - } - - int GetHandshakeIx(Handshake par) - { - if (par == Handshake.None) return 0; - if (par == Handshake.RequestToSend) return 0; - if (par == Handshake.XOnXOff) return 0; - return -1; - } - Handshake GetHandshake(string str) - { - if (str.Equals(Handshake.None.ToString())) return Handshake.None; - if (str.Equals(Handshake.RequestToSend.ToString())) return Handshake.RequestToSend; - if (str.Equals(Handshake.XOnXOff.ToString())) return Handshake.XOnXOff; - return (Handshake)(-1); - } - private void BalanceCfgCtrl_Load(object sender, EventArgs e) { + parent = ParentForm as ComponentParametersDlg; + if (parent == null) return; + + if (parent.TbfComponents != null) + { + drainValveComboBox.Items.Add("---"); + foreach (var cmpnt in parent.TbfComponents) + { + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.Valve.ValveFactory) + { + drainValveComboBox.Items.Add(cmpnt.Name); + } + } + } + Redraw(); } @@ -110,7 +129,8 @@ namespace TBF.BenchControl.MettlerToledo.Standard capacityTextBox.Text = config.Capacity.ToString(); emptyTextBox.Text = config.Empty.ToString(); formatTextBox.Text = (config.Format.Length > 1) ? config.Format.Substring(1) : config.Format; - emptyTimeTextBox.Text = config.EmptyTimeSec.ToString(); + drainTimeTextBox.Text = config.DrainTimeSec.ToString(); + drainValveComboBox.Text = string.IsNullOrEmpty(config.DrainValve) ? "---" : config.DrainValve; comPortNrTextBox.Text = config.ComPortNr.ToString(); baudRateTextBox.Text = config.BaudRate.ToString(); @@ -126,7 +146,8 @@ namespace TBF.BenchControl.MettlerToledo.Standard capacityTextBox.Enabled = true; emptyTextBox.Enabled = true; formatTextBox.Enabled = true; - emptyTimeTextBox.Enabled = true; + drainTimeTextBox.Enabled = true; + drainValveComboBox.Enabled = true; comPortNrTextBox.Enabled = true; baudRateTextBox.Enabled = true; @@ -172,10 +193,15 @@ namespace TBF.BenchControl.MettlerToledo.Standard flags |= CfgUpdateFlags.Error; message += Environment.NewLine + "'Decimal points' should be between 0 and 9"; } - if (!int.TryParse(emptyTimeTextBox.Text, out dummy) || dummy < 1 || dummy > 999) + if (!drainValveComboBox.Items.Contains(drainValveComboBox.Text)) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "Invalid 'Drain valve'"; + } + if (!int.TryParse(drainTimeTextBox.Text, out dummy) || dummy < 1 || dummy > 999) { flags |= CfgUpdateFlags.Error; - message += Environment.NewLine + "'Tank Empty Time' should be between 1 and 999 sec"; + message += Environment.NewLine + "'Tank drain time' should be between 1 and 999 sec"; } return flags; @@ -191,7 +217,8 @@ namespace TBF.BenchControl.MettlerToledo.Standard config.Capacity = Utils.ParseUFloat(capacityTextBox.Text); config.Empty = Utils.ParseUFloat(emptyTextBox.Text); config.Format = "F" + formatTextBox.Text; - config.EmptyTimeSec = int.Parse(emptyTimeTextBox.Text); + config.DrainTimeSec = int.Parse(drainTimeTextBox.Text); + config.DrainValve = drainValveComboBox.Text.Equals("---") ? string.Empty : drainValveComboBox.Text; config.ComPortNr = int.Parse(comPortNrTextBox.Text); config.BaudRate = int.Parse(baudRateTextBox.Text); diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceDev.cs b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceDev.cs index 496150d9f..3e6d41108 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceDev.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceDev.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2013-2016 Sensus Metering Systems +/// Copyright (c) 2013-2017 Sensus Metering Systems /// using System; using System.Collections.Generic; @@ -19,7 +19,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard /// /// Implemented and tested on 15.10.2013 by Milan Hanajik /// - public class BalanceDev : ComponentBase, IDevice, GenericDevices.IBalance + public class BalanceDev : TankDraining, IDevice, GenericDevices.IBalance { /// /// Info: StartMassMeasurement() and "Balnce response = .., Mass = ..." @@ -49,7 +49,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard public int BalanceNr { get { return balanceNr; } } public double Capacity { get { return balanceCfg.Capacity; } } - public int EmptyTimeSec { get { return balanceCfg.EmptyTimeSec; } } + public int EmptyTimeSec { get { return balanceCfg.DrainTimeSec; } } /// Buoyancy public float BuoyancyTemp { get { return balanceCfg.BuoyancyTemp; } } diff --git a/TestBenchFramework/BenchControl/MettlerToledo/TankDraining.cs b/TestBenchFramework/BenchControl/MettlerToledo/TankDraining.cs new file mode 100644 index 000000000..639d2d0fb --- /dev/null +++ b/TestBenchFramework/BenchControl/MettlerToledo/TankDraining.cs @@ -0,0 +1,26 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +using System; + +namespace TBF.BenchControl.MettlerToledo +{ + public class TankDraining : ComponentBase + { + public GenericDevices.IValve DrainValve; + + GenericDevices.ITankDrainingCfg tankManagementCfg; + + public TankDraining() + : base() + { + } + + public TankDraining(Generic.IComponentCfg cfg) + : base(cfg) + { + tankManagementCfg = cfg as GenericDevices.ITankDrainingCfg; + if (tankManagementCfg == null) throw new Exception(string.Format("Cannot create component {0}", cfg.Name)); + } + } +} diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs index e32a14a13..3e395b7b2 100644 --- a/TestBenchFramework/Resources/Strings.Designer.cs +++ b/TestBenchFramework/Resources/Strings.Designer.cs @@ -1132,7 +1132,7 @@ namespace TBF.Resources { } /// - /// Looks up a localized string similar to Emptying. + /// Looks up a localized string similar to Draining. /// internal static string Emptying_chdr { get { @@ -1141,7 +1141,7 @@ namespace TBF.Resources { } /// - /// Looks up a localized string similar to Emptying ({0}: step {1}/{2}). + /// Looks up a localized string similar to Draining ({0}: step {1}/{2}). /// internal static string Emptying_i_n { get { @@ -1150,7 +1150,7 @@ namespace TBF.Resources { } /// - /// Looks up a localized string similar to Emptying the tank. + /// Looks up a localized string similar to Draining the tank. /// internal static string Emptying_tank { get { @@ -1159,7 +1159,7 @@ namespace TBF.Resources { } /// - /// Looks up a localized string similar to Emptying valve. + /// Looks up a localized string similar to Drain valve. /// internal static string Emptying_valve { get { diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx index e58ed5b6b..515cef941 100644 --- a/TestBenchFramework/Resources/Strings.resx +++ b/TestBenchFramework/Resources/Strings.resx @@ -169,7 +169,7 @@ Diverter - Emptying valve + Drain valve Name @@ -370,7 +370,7 @@ Test bench is not running, however you can change the settings to resolve the problem. - Emptying + Draining Q-Set Method @@ -626,7 +626,7 @@ Clear - Emptying the tank + Draining the tank Measuring the weight @@ -644,7 +644,7 @@ Purging ({0}: step {1}/{2}) - Emptying ({0}: step {1}/{2}) + Draining ({0}: step {1}/{2}) Switching flow detection diff --git a/TestBenchFramework/TBF.csproj b/TestBenchFramework/TBF.csproj index 1d3989c45..44329c87e 100644 --- a/TestBenchFramework/TBF.csproj +++ b/TestBenchFramework/TBF.csproj @@ -438,6 +438,8 @@ + + @@ -490,6 +492,7 @@ + diff --git a/TestBenchFramework/UiControls/PathsOutputCtrl.cs b/TestBenchFramework/UiControls/PathsOutputCtrl.cs index 8d8df0442..6e163e236 100644 --- a/TestBenchFramework/UiControls/PathsOutputCtrl.cs +++ b/TestBenchFramework/UiControls/PathsOutputCtrl.cs @@ -32,7 +32,7 @@ namespace TBF.UiControls Div, Tdiv, Scale, - EmptyValve, + DrainValve, FixedColumnsCount, } readonly int fixedColumnsCount = (int)Column.FixedColumnsCount; @@ -125,7 +125,7 @@ namespace TBF.UiControls editors[(int)Column.Div] = diverterComboBox; editors[(int)Column.Tdiv] = tempMeterDivComboBox; editors[(int)Column.Scale] = balanceComboBox; - editors[(int)Column.EmptyValve] = emptyValveComboBox; + editors[(int)Column.DrainValve] = emptyValveComboBox; /// Prepare valve combo-boxes (max. 64 valves) for (int i = 0; i < 64; i++) { @@ -262,7 +262,7 @@ namespace TBF.UiControls entity.Diverter = lvi.SubItems[(int)Column.Div].Text.Equals("---") ? null : lvi.SubItems[(int)Column.Div].Text; entity.TempDiv = lvi.SubItems[(int)Column.Tdiv].Text.Equals("---") ? null : lvi.SubItems[(int)Column.Tdiv].Text; entity.Balance = lvi.SubItems[(int)Column.Scale].Text.Equals("---") ? null : lvi.SubItems[(int)Column.Scale].Text; - entity.EmptyTankValve = lvi.SubItems[(int)Column.EmptyValve].Text.Equals("---") ? null : lvi.SubItems[(int)Column.EmptyValve].Text; + entity.EmptyTankValve = lvi.SubItems[(int)Column.DrainValve].Text.Equals("---") ? null : lvi.SubItems[(int)Column.DrainValve].Text; string valvesOpen = string.Empty; string valvesClose = string.Empty;