Schematic drawing with live function, bench control by mouse, Dijkstra algo, vacuum, etc.

This commit is contained in:
Milan Hanajik
2020-06-14 13:01:53 +02:00
parent 2945049288
commit 1f67899a5c
223 changed files with 5684 additions and 3772 deletions
@@ -7,6 +7,7 @@ using System.Windows.Forms;
using System.IO.Ports;
using Config.Entities;
using TBF.BenchControl.Generic;
using TBF.UI.Bench.Components;
namespace TBF.BenchControl.MettlerToledo.Multi
{
@@ -97,10 +98,10 @@ namespace TBF.BenchControl.MettlerToledo.Multi
parent = ParentForm as ComponentParametersDlg;
if (parent == null) return;
if (parent.TbfComponents != null)
if (parent.CmpntEntities != null)
{
drainValveComboBox.Items.Add("---");
foreach (var cmpnt in parent.TbfComponents)
foreach (var cmpnt in parent.CmpntEntities)
{
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is BuiltIn.Valve.ValveFactory)
{
@@ -1,16 +1,17 @@
///
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
///
using System;
using System.IO;
using System.Collections.Generic;
using System.IO.Ports;
using System.Xml.Serialization;
using SchematicDrawing;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.MettlerToledo.Standard
{
public class BalanceCfg : ComponentCfgBase, GenericDevices.IScaleCfg, GenericDevices.ITankDrainingCfg
public class BalanceCfg : ComponentCfgBase, GenericDevices.IScaleCfg, GenericDevices.ITankDrainingCfg, IDrawingItemWithMeasuredVal
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(BalanceCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
@@ -33,8 +34,6 @@ namespace TBF.BenchControl.MettlerToledo.Standard
public string DrainValve { get; set; }
public int DrainTimeSec { get; set; }
public string Evaporation { get; set; }
public string Format;
/// Buoyancy related serialized parameters displayed in Metrology tab page
public float BuoyancyTemp { get; set; }
@@ -48,24 +47,45 @@ namespace TBF.BenchControl.MettlerToledo.Standard
public DateTime CalibValidDate { get; set; }
/// Schematic drawing info
public SchematicDrawing.Shape Shape { get; set; }
public Shape Shape { get; set; }
public int X { get; set; }
public int Y { get; set; }
public SchematicDrawing.Sz Sz { get; set; }
public SchematicDrawing.Orient Orient { get; set; }
public Sz Sz { get; set; }
public Orient Orient { get; set; }
public bool Flip { get; set; }
public int LblX { get; set; }
public int LblY { get; set; }
public SchematicDrawing.Orient LblOrient { get; set; }
public int ValX { get; set; }
public int ValY { get; set; }
public double ValFact { get; set; }
public string ValFmt { get; set; }
public SchematicDrawing.Orient ValOrient { get; set; }
public Orient LblOrient { get; set; }
public int MsrdX { get; set; }
public int MsrdY { get; set; }
public Orient MsrdOrient { get; set; }
public string MsrdFormat { get; set; }
public Config.Unit MsrdUnits { get; set; }
[XmlIgnore]
public IList<GNode> GNodes { get; set; }
[XmlIgnore]
public double MsrdValLimLo { get { return 0; } set { } }
[XmlIgnore]
public double MsrdValLimHi { get { return Capacity; } set { Capacity = (float)value; } }
/// Private parameterless constructor invoked by all other (public) constructors
BalanceCfg()
{
GNodes = new List<GNode>();
}
public BalanceCfg(IComponentFactory factory)
: this()
{
Shape = Shape.Scale;
Sz = Sz.M;
MsrdFormat = "{0:F3}";
MsrdUnits = Config.Unit.kg;
Factory = factory;
Name = "WT1";
ParentName = string.Empty;
ComPortNr = 3;
@@ -77,20 +97,14 @@ namespace TBF.BenchControl.MettlerToledo.Standard
Capacity = 200.0f;
Empty = 20.0f;
EmptyUp = 2.0f;
Format = "F3";
DrainValve = "VB1";
DrainTimeSec = 180;
DrainValve = "VB1";
DrainTimeSec = 180;
BuoyancyTemp = 20.0f;
BuoyancyPress = 1.0f;
BuoyancyHumi = 40.0f;
Shape = SchematicDrawing.Shape.Tank;
}
public BalanceCfg(IComponentFactory factory)
: this()
{
this.Factory = factory;
}
public string ToString(int i)
{
@@ -55,8 +55,6 @@ namespace TBF.BenchControl.MettlerToledo.Standard
this.label4 = new System.Windows.Forms.Label();
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.label6 = new System.Windows.Forms.Label();
@@ -64,6 +62,10 @@ namespace TBF.BenchControl.MettlerToledo.Standard
this.label7 = new System.Windows.Forms.Label();
this.evaporationComboBox = new System.Windows.Forms.ComboBox();
this.evaporationLabel = new System.Windows.Forms.Label();
this.unitsComboBox = new System.Windows.Forms.ComboBox();
this.unitsLabel = new System.Windows.Forms.Label();
this.formatTextBox = new System.Windows.Forms.TextBox();
this.formatLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// handshakeComboBox
@@ -275,23 +277,6 @@ namespace TBF.BenchControl.MettlerToledo.Standard
this.label5.TabIndex = 17;
this.label5.Text = "Drain time";
//
// formatTextBox
//
this.formatTextBox.Enabled = false;
this.formatTextBox.Location = new System.Drawing.Point(137, 50);
this.formatTextBox.Name = "formatTextBox";
this.formatTextBox.Size = new System.Drawing.Size(43, 20);
this.formatTextBox.TabIndex = 4;
//
// formatLabel
//
this.formatLabel.AutoSize = true;
this.formatLabel.Location = new System.Drawing.Point(26, 53);
this.formatLabel.Name = "formatLabel";
this.formatLabel.Size = new System.Drawing.Size(76, 13);
this.formatLabel.TabIndex = 3;
this.formatLabel.Text = "Decimal points";
//
// drainValveComboBox
//
this.drainValveComboBox.Enabled = false;
@@ -354,10 +339,49 @@ namespace TBF.BenchControl.MettlerToledo.Standard
this.evaporationLabel.TabIndex = 13;
this.evaporationLabel.Text = "Evaporation";
//
// unitsComboBox
//
this.unitsComboBox.Enabled = false;
this.unitsComboBox.FormattingEnabled = true;
this.unitsComboBox.Location = new System.Drawing.Point(137, 308);
this.unitsComboBox.Name = "unitsComboBox";
this.unitsComboBox.Size = new System.Drawing.Size(80, 21);
this.unitsComboBox.TabIndex = 35;
//
// unitsLabel
//
this.unitsLabel.AutoSize = true;
this.unitsLabel.Location = new System.Drawing.Point(27, 311);
this.unitsLabel.Name = "unitsLabel";
this.unitsLabel.Size = new System.Drawing.Size(31, 13);
this.unitsLabel.TabIndex = 34;
this.unitsLabel.Text = "Units";
//
// formatTextBox
//
this.formatTextBox.Enabled = false;
this.formatTextBox.Location = new System.Drawing.Point(137, 285);
this.formatTextBox.Name = "formatTextBox";
this.formatTextBox.Size = new System.Drawing.Size(130, 20);
this.formatTextBox.TabIndex = 33;
//
// formatLabel
//
this.formatLabel.AutoSize = true;
this.formatLabel.Location = new System.Drawing.Point(27, 288);
this.formatLabel.Name = "formatLabel";
this.formatLabel.Size = new System.Drawing.Size(71, 13);
this.formatLabel.TabIndex = 32;
this.formatLabel.Text = "Output format";
//
// BalanceCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.unitsComboBox);
this.Controls.Add(this.unitsLabel);
this.Controls.Add(this.formatTextBox);
this.Controls.Add(this.formatLabel);
this.Controls.Add(this.evaporationComboBox);
this.Controls.Add(this.evaporationLabel);
this.Controls.Add(this.label7);
@@ -365,8 +389,6 @@ namespace TBF.BenchControl.MettlerToledo.Standard
this.Controls.Add(this.emptyUpTextBox);
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.drainTimeTextBox);
this.Controls.Add(this.label5);
@@ -425,8 +447,6 @@ namespace TBF.BenchControl.MettlerToledo.Standard
private System.Windows.Forms.Label label4;
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;
private System.Windows.Forms.Label label6;
@@ -434,5 +454,9 @@ namespace TBF.BenchControl.MettlerToledo.Standard
private System.Windows.Forms.Label label7;
private System.Windows.Forms.ComboBox evaporationComboBox;
private System.Windows.Forms.Label evaporationLabel;
private System.Windows.Forms.ComboBox unitsComboBox;
private System.Windows.Forms.Label unitsLabel;
private System.Windows.Forms.TextBox formatTextBox;
private System.Windows.Forms.Label formatLabel;
}
}
@@ -6,6 +6,7 @@ using System.Windows.Forms;
using System.IO.Ports;
using Config.Entities;
using TBF.BenchControl.Generic;
using TBF.UI.Bench.Components;
namespace TBF.BenchControl.MettlerToledo.Standard
{
@@ -98,11 +99,11 @@ namespace TBF.BenchControl.MettlerToledo.Standard
parent = ParentForm as ComponentParametersDlg;
if (parent == null) return;
if (parent.TbfComponents != null)
if (parent.CmpntEntities != null)
{
evaporationComboBox.Items.Add("---");
drainValveComboBox.Items.Add("---");
foreach (var cmpnt in parent.TbfComponents)
foreach (var cmpnt in parent.CmpntEntities)
{
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is BuiltIn.Valve.ValveFactory)
{
@@ -115,6 +116,14 @@ namespace TBF.BenchControl.MettlerToledo.Standard
}
}
for (Config.Unit units = 0; units < global::Config.Unit.Count; units++)
{
if (global::Config.Units.IsQuantity(units, global::Config.Quantity.Mass))
{
unitsComboBox.Items.Add(units.ToString());
}
}
Redraw();
}
@@ -131,7 +140,6 @@ namespace TBF.BenchControl.MettlerToledo.Standard
capacityTextBox.Text = config.Capacity.ToString();
emptyTextBox.Text = config.Empty.ToString();
emptyUpTextBox.Text = config.EmptyUp.ToString();
formatTextBox.Text = (config.Format.Length > 1) ? config.Format.Substring(1) : config.Format;
evaporationComboBox.Text = string.IsNullOrEmpty(config.Evaporation) ? "---" : config.Evaporation;
drainValveComboBox.Text = string.IsNullOrEmpty(config.DrainValve) ? "---" : config.DrainValve;
drainTimeTextBox.Text = config.DrainTimeSec.ToString();
@@ -142,6 +150,9 @@ namespace TBF.BenchControl.MettlerToledo.Standard
dataBitsTextBox.Text = config.DataBits.ToString();
stopBitsComboBox.Text = config.StopBits.ToString();
handshakeComboBox.Text = config.Handshake.ToString();
formatTextBox.Text = config.MsrdFormat;
unitsComboBox.Text = config.MsrdUnits.ToString();
}
public void Unlock()
@@ -161,6 +172,9 @@ namespace TBF.BenchControl.MettlerToledo.Standard
dataBitsTextBox.Enabled = true;
stopBitsComboBox.Enabled = true;
handshakeComboBox.Enabled = true;
formatTextBox.Enabled = true;
unitsComboBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
@@ -199,11 +213,6 @@ namespace TBF.BenchControl.MettlerToledo.Standard
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Tank Empty Up' is not valid";
}
if (!int.TryParse(formatTextBox.Text, out dummy) || dummy < 0 || dummy > 9)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Decimal points' should be between 0 and 9";
}
if (!evaporationComboBox.Items.Contains(evaporationComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
@@ -219,6 +228,11 @@ namespace TBF.BenchControl.MettlerToledo.Standard
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Tank drain time' should be between 1 and 999 sec";
}
if (!unitsComboBox.Items.Contains(unitsComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Units'";
}
return flags;
}
@@ -233,7 +247,6 @@ namespace TBF.BenchControl.MettlerToledo.Standard
config.Capacity = Utils.ParseUFloat(capacityTextBox.Text);
config.Empty = Utils.ParseUFloat(emptyTextBox.Text);
config.EmptyUp = Utils.ParseUFloat(emptyUpTextBox.Text);
config.Format = "F" + formatTextBox.Text;
config.Evaporation = evaporationComboBox.Text.Equals("---") ? string.Empty : evaporationComboBox.Text;
config.DrainTimeSec = int.Parse(drainTimeTextBox.Text);
config.DrainValve = drainValveComboBox.Text.Equals("---") ? string.Empty : drainValveComboBox.Text;
@@ -245,6 +258,17 @@ namespace TBF.BenchControl.MettlerToledo.Standard
config.StopBits = GetStopBits(stopBitsComboBox.SelectedItem.ToString());
config.Handshake = GetHandshake(handshakeComboBox.SelectedItem.ToString());
config.MsrdFormat = formatTextBox.Text;
config.MsrdUnits = global::Config.Unit.None;
for (Config.Unit units = 0; units < global::Config.Unit.Count; units++)
{
if (unitsComboBox.Text == units.ToString())
{
config.MsrdUnits = units;
break;
}
}
return flags;
}
}
@@ -8,6 +8,7 @@ using System.Text;
using System.IO.Ports;
using log4net;
using Config.Entities;
using SchematicDrawing;
using TBF.BenchControl.Generic;
using TBF.BenchControl.GenericDevices;
using TBF.Boxes;
@@ -21,7 +22,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
/// <note>
/// Implemented and tested on 15.10.2013 by Milan Hanajik
/// </note>
public class BalanceDev : TankDraining, IDevice, GenericDevices.IScale, GenericDevices.IHasCalendarEvents, SchematicDrawing.IDrawingItemCmpnt
public class BalanceDev : TankDraining, IDevice, GenericDevices.IScale, GenericDevices.IHasCalendarEvents, IDrawingItCmpntWithMeasuredVal
{
/// <summary>
/// Info: StartMassMeasurement() and "Balnce response = .., Mass = ..."
@@ -31,7 +32,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
public override string ToString() { return string.Format("MettlerToledo.Standard.Balance({0})", Cfg.ToString(1)); }
protected readonly BalanceCfg balanceCfg;
public SchematicDrawing.IDrawingItemCfg DrawingItemCfg { get { return balanceCfg as SchematicDrawing.IDrawingItemCfg; } }
public IDrawingItem DrawingItem { get { return balanceCfg as IDrawingItem; } }
/// <summary>
/// Enumeration of balances via static fields and methods
@@ -72,16 +73,20 @@ namespace TBF.BenchControl.MettlerToledo.Standard
/// <summary>The mass after StartMassMeasurement() when MsrmntState == MsrmntState.Valid</summary>
public double Mass { get { return mass; } }
protected double mass;
public double MeasuredVal
{
get { return mass; }
set { } // TODO
}
/// <summary>The time stamp after StartMassMeasurement() when MsrmntState == MsrmntState.Valid</summary>
public int MsrmntTimeStamp { get { return msrmntTimeStamp; } }
protected int msrmntTimeStamp;
public string Format { get { return balanceCfg.Format; } }
public string Format { get { return balanceCfg.MsrdFormat; } }
public BalanceDev()
{
}
public BalanceDev() { }
/// <summary>
/// Constructor