TankCfgCtrl displays ILevelMeter-s, DrainValve2 is in IScaleOrTank and TankWithLevelMsrmnt UI, ver. 2.18.1046

This commit is contained in:
Milan Hanajik
2018-10-25 18:09:08 +02:00
parent 025fa81941
commit e89ab89874
10 changed files with 87 additions and 40 deletions
+5 -3
View File
@@ -5,10 +5,11 @@ using System;
using System.Collections.Generic;
using log4net;
using Config.Entities;
using TBF.BenchControl.GenericDevices;
namespace TBF.BenchControl.Dummy.Balance
{
public class Component : ComponentBase, GenericDevices.IScale, IOperation
public class Component : ComponentBase, IScale, IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(Component));
public override string ToString()
@@ -28,8 +29,9 @@ namespace TBF.BenchControl.Dummy.Balance
public int ScaleNr { get { return 0; } }
public double Capacity { get { return 10000.0; } }
public GenericDevices.IValve DrainValve { get { return null; } }
public bool IsEmpty(double mass) { return true; }
public IValve DrainValve { get { return null; } }
public IValve DrainValve2 { get { return null; } }
public bool IsEmpty(double mass) { return true; }
public bool IsEmpty() { return true; }
public string Format { get { return "F3"; } }
public int EmptyTimeSec { get { return 5; } }
@@ -23,9 +23,10 @@ namespace TBF.BenchControl.GenericDevices
double Capacity { get; }
/// <summary>
/// Water tank drain valve or 'null'
/// Water tank drain valve or 'null'. DrainValve2 is open in the 2nd half of drain time period
/// </summary>
IValve DrainValve { get; }
IValve DrainValve2 { get; }
/// <summary>
/// Returns true if tank s empty, the last measured mass is less then some threshold
+1 -1
View File
@@ -20,7 +20,7 @@ namespace TBF.BenchControl.Hart.Nivotrack
/// <summary>
/// Root component for Modbus communication via serial port (RS485)
/// </summary>
public class Nivotrack : ComponentBase, IDevice, IOperation
public class Nivotrack : ComponentBase, IDevice, ILevelMeter, IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(Nivotrack));
public override string ToString() { return string.Format("Nivotrack({0})", Cfg.ToString(1)); }
@@ -9,6 +9,7 @@ using System.IO.Ports;
using log4net;
using Config.Entities;
using TBF.BenchControl.Generic;
using TBF.BenchControl.GenericDevices;
using TBF.Boxes;
namespace TBF.BenchControl.MettlerToledo.Multi
@@ -48,16 +49,17 @@ namespace TBF.BenchControl.MettlerToledo.Multi
protected static SerialPort serialPort;
protected static StringBuilder stringBuilder;
public int ScaleNr { get { return balanceNr; } }
public int IdNr { get { return balanceCfg.IdNr; } }
public double Capacity { get { return balanceCfg.Capacity; } }
public double Resolution { get { return balanceCfg.Resolution; } }
public int EmptyTimeSec { get { return balanceCfg.DrainTimeSec; } }
public int ScaleNr { get { return balanceNr; } }
public int IdNr { get { return balanceCfg.IdNr; } }
public double Capacity { get { return balanceCfg.Capacity; } }
public double Resolution { get { return balanceCfg.Resolution; } }
public int EmptyTimeSec { get { return balanceCfg.DrainTimeSec; } }
public IValve DrainValve2 { get { return null; } }
/// Buoyancy
public float BuoyancyTemp { get { return balanceCfg.BuoyancyTemp; } }
public float BuoyancyTemp { get { return balanceCfg.BuoyancyTemp; } }
public float BuoyancyPress { get { return balanceCfg.BuoyancyPress; } }
public float BuoyancyHumi { get { return balanceCfg.BuoyancyHumi; } }
public float BuoyancyHumi { get { return balanceCfg.BuoyancyHumi; } }
public double WeightStandardDensity { get { return balanceCfg.WeightStandardDensity; } }
@@ -9,6 +9,7 @@ using System.IO.Ports;
using log4net;
using Config.Entities;
using TBF.BenchControl.Generic;
using TBF.BenchControl.GenericDevices;
using TBF.Boxes;
namespace TBF.BenchControl.MettlerToledo.Standard
@@ -50,6 +51,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
public int ScaleNr { get { return balanceNr; } }
public double Capacity { get { return balanceCfg.Capacity; } }
public int EmptyTimeSec { get { return balanceCfg.DrainTimeSec; } }
public IValve DrainValve2 { get { return null; } }
/// Buoyancy
public float BuoyancyTemp { get { return balanceCfg.BuoyancyTemp; } }
@@ -2,17 +2,18 @@
/// Copyright (c) 2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using log4net;
using TBF.Boxes;
using TBF.BenchControl.Generic;
using System.Collections.Generic;
using TBF.BenchControl.GenericDevices;
namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
{
public class Tank : TBF.BenchControl.MettlerToledo.TankDraining, IDevice, GenericDevices.ITankWithVolumeMsrmnt, IOperation
public class Tank : TBF.BenchControl.MettlerToledo.TankDraining, IDevice, ITankWithVolumeMsrmnt, IOperation
{
/// <summary>
/// Info: StartMassMeasurement() and "Balnce response = .., Mass = ..."
@@ -56,6 +57,8 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
///
public double Capacity { get { return tankCfg.Capacity; } }
public int EmptyTimeSec { get { return tankCfg.DrainTimeSec; } }
public IValve DrainValve2 { get { return drainValve2; } }
IValve drainValve2;
public string Format { get { return "F3"; } }
@@ -99,6 +102,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
public void Initialize()
{
base.Initalize();
drainValve2 = TbfComponents.FindComponent(tankCfg.DrainValve2) as IValve;
useCalibTable = LoadCalibrationTable(tankCfg.CalibrationTable);
}
public void RunDeviceBefore() { }
@@ -31,7 +31,8 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
private int drainTimeSec;
public int DrainTimeSec { get { return drainTimeSec; } set { drainTimeSec = value; } }
public string DrainValve2;
public string LevelMeasurement; /// Name of a level measurement component, 'Various.ManualLevelMsrmnt' is used when left empty.
public string CalibrationTable; /// Path name of a calibration table in CSV format (column1 = height[mm], column2 = volume[l])
/// Volume calculation using formulas for std. tanks in Level2Volume() is used when left empty.
@@ -40,18 +40,21 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
if (parent.TbfComponents != null)
{
drainValveComboBox.Items.Add("---");
levelMeasurementComboBox.Items.Add("---");
foreach (var cmpnt in parent.TbfComponents)
{
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.Valve.ValveFactory)
IComponentFactory cmpntFact = TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName);
if (cmpntFact is Elde.Valve.ValveFactory)
{
drainValveComboBox.Items.Add(cmpnt.Name);
drainValve2ComboBox.Items.Add(cmpnt.Name);
}
}
levelMeasurementComboBox.Items.Add("---");
foreach (var cmpnt in parent.TbfComponents)
{
if (cmpnt is TBF.BenchControl.GenericDevices.ILevelMeter)
//if (cmpnt is TBF.BenchControl.GenericDevices.ILevelMeter) /// TODO: Preco nefunguje?
if (cmpntFact is Various.ManualLevelMsrmnt.Factory ||
cmpntFact is Hart.Nivotrack.Factory)
{
levelMeasurementComboBox.Items.Add(cmpnt.Name);
}
@@ -74,6 +77,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
capacityTextBox.Text = config.Capacity.ToString();
emptyTextBox.Text = config.Empty.ToString();
drainValveComboBox.Text = string.IsNullOrEmpty(config.DrainValve) ? "---" : config.DrainValve;
drainValve2ComboBox.Text = string.IsNullOrEmpty(config.DrainValve2) ? "---" : config.DrainValve2;
drainTimeTextBox.Text = config.DrainTimeSec.ToString();
levelMeasurementComboBox.Text = string.IsNullOrEmpty(config.LevelMeasurement) ? "---" : config.LevelMeasurement;
calibrationTableTextBox.Text = config.CalibrationTable;
@@ -85,6 +89,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
capacityTextBox.Enabled = true;
emptyTextBox.Enabled = true;
drainValveComboBox.Enabled = true;
drainValve2ComboBox.Enabled = true;
drainTimeTextBox.Enabled = true;
levelMeasurementComboBox.Enabled = true;
calibrationTableTextBox.Enabled = true;
@@ -111,6 +116,11 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format(Strings.Invalid_0, drainValveLabel.Text);
}
if (!drainValve2ComboBox.Items.Contains(drainValve2ComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + string.Format(Strings.Invalid_0, drainValve2Label.Text);
}
if (!int.TryParse(drainTimeTextBox.Text, out dummy) || dummy < 1 || dummy > 999)
{
flags |= CfgUpdateFlags.Error;
@@ -136,6 +146,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
config.Empty = Utils.ParseUFloat(emptyTextBox.Text);
config.DrainTimeSec = int.Parse(drainTimeTextBox.Text);
config.DrainValve = drainValveComboBox.Text.Equals("---") ? string.Empty : drainValveComboBox.Text;
config.DrainValve2 = drainValve2ComboBox.Text.Equals("---") ? string.Empty : drainValve2ComboBox.Text;
config.LevelMeasurement = levelMeasurementComboBox.Text.Equals("---") ? string.Empty : drainValveComboBox.Text;
config.CalibrationTable = calibrationTableTextBox.Text;
@@ -49,12 +49,14 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
this.levelMeasurementLabel = new System.Windows.Forms.Label();
this.calibrationTableTextBox = new System.Windows.Forms.TextBox();
this.calibrationTableLabel = new System.Windows.Forms.Label();
this.drainValve2ComboBox = new System.Windows.Forms.ComboBox();
this.drainValve2Label = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(127, 33);
this.nameTextBox.Location = new System.Drawing.Point(127, 31);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(142, 20);
this.nameTextBox.TabIndex = 2;
@@ -62,7 +64,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(16, 36);
this.nameLabel.Location = new System.Drawing.Point(16, 34);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
@@ -80,7 +82,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
// capacityLabel
//
this.capacityLabel.AutoSize = true;
this.capacityLabel.Location = new System.Drawing.Point(16, 72);
this.capacityLabel.Location = new System.Drawing.Point(16, 63);
this.capacityLabel.Name = "capacityLabel";
this.capacityLabel.Size = new System.Drawing.Size(75, 13);
this.capacityLabel.TabIndex = 5;
@@ -89,7 +91,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
// capacityTextBox
//
this.capacityTextBox.Enabled = false;
this.capacityTextBox.Location = new System.Drawing.Point(127, 69);
this.capacityTextBox.Location = new System.Drawing.Point(127, 60);
this.capacityTextBox.Name = "capacityTextBox";
this.capacityTextBox.Size = new System.Drawing.Size(43, 20);
this.capacityTextBox.TabIndex = 6;
@@ -97,7 +99,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(173, 72);
this.label2.Location = new System.Drawing.Point(173, 63);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(23, 13);
this.label2.TabIndex = 7;
@@ -106,7 +108,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(173, 94);
this.label3.Location = new System.Drawing.Point(173, 85);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(23, 13);
this.label3.TabIndex = 10;
@@ -115,7 +117,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
// emptyTextBox
//
this.emptyTextBox.Enabled = false;
this.emptyTextBox.Location = new System.Drawing.Point(127, 91);
this.emptyTextBox.Location = new System.Drawing.Point(127, 82);
this.emptyTextBox.Name = "emptyTextBox";
this.emptyTextBox.Size = new System.Drawing.Size(43, 20);
this.emptyTextBox.TabIndex = 9;
@@ -123,7 +125,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
// emptyLabel
//
this.emptyLabel.AutoSize = true;
this.emptyLabel.Location = new System.Drawing.Point(16, 94);
this.emptyLabel.Location = new System.Drawing.Point(16, 85);
this.emptyLabel.Name = "emptyLabel";
this.emptyLabel.Size = new System.Drawing.Size(109, 13);
this.emptyLabel.TabIndex = 8;
@@ -132,7 +134,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(176, 139);
this.label4.Location = new System.Drawing.Point(176, 153);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(24, 13);
this.label4.TabIndex = 17;
@@ -141,7 +143,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
// drainTimeTextBox
//
this.drainTimeTextBox.Enabled = false;
this.drainTimeTextBox.Location = new System.Drawing.Point(127, 136);
this.drainTimeTextBox.Location = new System.Drawing.Point(127, 150);
this.drainTimeTextBox.Name = "drainTimeTextBox";
this.drainTimeTextBox.Size = new System.Drawing.Size(43, 20);
this.drainTimeTextBox.TabIndex = 16;
@@ -149,7 +151,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(16, 139);
this.label5.Location = new System.Drawing.Point(16, 153);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(54, 13);
this.label5.TabIndex = 15;
@@ -159,7 +161,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
//
this.drainValveComboBox.Enabled = false;
this.drainValveComboBox.FormattingEnabled = true;
this.drainValveComboBox.Location = new System.Drawing.Point(127, 113);
this.drainValveComboBox.Location = new System.Drawing.Point(127, 104);
this.drainValveComboBox.Name = "drainValveComboBox";
this.drainValveComboBox.Size = new System.Drawing.Size(143, 21);
this.drainValveComboBox.TabIndex = 14;
@@ -167,7 +169,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
// drainValveLabel
//
this.drainValveLabel.AutoSize = true;
this.drainValveLabel.Location = new System.Drawing.Point(16, 116);
this.drainValveLabel.Location = new System.Drawing.Point(16, 107);
this.drainValveLabel.Name = "drainValveLabel";
this.drainValveLabel.Size = new System.Drawing.Size(61, 13);
this.drainValveLabel.TabIndex = 13;
@@ -177,7 +179,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
//
this.levelMeasurementComboBox.Enabled = false;
this.levelMeasurementComboBox.FormattingEnabled = true;
this.levelMeasurementComboBox.Location = new System.Drawing.Point(127, 172);
this.levelMeasurementComboBox.Location = new System.Drawing.Point(127, 180);
this.levelMeasurementComboBox.Name = "levelMeasurementComboBox";
this.levelMeasurementComboBox.Size = new System.Drawing.Size(143, 21);
this.levelMeasurementComboBox.TabIndex = 32;
@@ -185,7 +187,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
// levelMeasurementLabel
//
this.levelMeasurementLabel.AutoSize = true;
this.levelMeasurementLabel.Location = new System.Drawing.Point(16, 175);
this.levelMeasurementLabel.Location = new System.Drawing.Point(16, 183);
this.levelMeasurementLabel.Name = "levelMeasurementLabel";
this.levelMeasurementLabel.Size = new System.Drawing.Size(99, 13);
this.levelMeasurementLabel.TabIndex = 31;
@@ -194,7 +196,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
// calibrationTableTextBox
//
this.calibrationTableTextBox.Enabled = false;
this.calibrationTableTextBox.Location = new System.Drawing.Point(127, 207);
this.calibrationTableTextBox.Location = new System.Drawing.Point(127, 210);
this.calibrationTableTextBox.Name = "calibrationTableTextBox";
this.calibrationTableTextBox.Size = new System.Drawing.Size(244, 20);
this.calibrationTableTextBox.TabIndex = 34;
@@ -202,16 +204,36 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
// calibrationTableLabel
//
this.calibrationTableLabel.AutoSize = true;
this.calibrationTableLabel.Location = new System.Drawing.Point(16, 210);
this.calibrationTableLabel.Location = new System.Drawing.Point(16, 213);
this.calibrationTableLabel.Name = "calibrationTableLabel";
this.calibrationTableLabel.Size = new System.Drawing.Size(82, 13);
this.calibrationTableLabel.TabIndex = 33;
this.calibrationTableLabel.Text = "Calibration table";
//
// drainValve2ComboBox
//
this.drainValve2ComboBox.Enabled = false;
this.drainValve2ComboBox.FormattingEnabled = true;
this.drainValve2ComboBox.Location = new System.Drawing.Point(127, 127);
this.drainValve2ComboBox.Name = "drainValve2ComboBox";
this.drainValve2ComboBox.Size = new System.Drawing.Size(143, 21);
this.drainValve2ComboBox.TabIndex = 36;
//
// drainValve2Label
//
this.drainValve2Label.AutoSize = true;
this.drainValve2Label.Location = new System.Drawing.Point(16, 130);
this.drainValve2Label.Name = "drainValve2Label";
this.drainValve2Label.Size = new System.Drawing.Size(70, 13);
this.drainValve2Label.TabIndex = 35;
this.drainValve2Label.Text = "Drain valve 2";
//
// TankCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.drainValve2ComboBox);
this.Controls.Add(this.drainValve2Label);
this.Controls.Add(this.calibrationTableTextBox);
this.Controls.Add(this.calibrationTableLabel);
this.Controls.Add(this.levelMeasurementComboBox);
@@ -258,5 +280,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt
private System.Windows.Forms.Label levelMeasurementLabel;
private System.Windows.Forms.TextBox calibrationTableTextBox;
private System.Windows.Forms.Label calibrationTableLabel;
private System.Windows.Forms.ComboBox drainValve2ComboBox;
private System.Windows.Forms.Label drainValve2Label;
}
}