MettlerToledo.Standard.BalanceDev/Old/NewDev clean-up, units (oz), 1st after draining, etc.
This commit is contained in:
parent
1d33b9651b
commit
31b167cd62
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2016-2020 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2016-2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Reflection;
|
||||
@ -36,6 +36,7 @@ namespace Config
|
||||
[Description("cf/s")] cfs, /// 1 cubic foot per second = 101.9406477312 m3/h
|
||||
|
||||
[Description("g")] g, /// 0.001 kg
|
||||
[Description("oz")] oz, /// 0.0283495231 kg
|
||||
[Description("lb")] lb, /// 0.45359237 kg
|
||||
[Description("kg")] kg, /// * 1 kilogram
|
||||
[Description("t")] t, /// 1000 kg
|
||||
@ -280,6 +281,7 @@ namespace Config
|
||||
return Quantity.Flow;
|
||||
|
||||
case Unit.g:
|
||||
case Unit.oz:
|
||||
case Unit.lb:
|
||||
case Unit.kg:
|
||||
case Unit.t:
|
||||
@ -397,6 +399,7 @@ namespace Config
|
||||
|
||||
/// Mass: internal representation in kg
|
||||
case Unit.g: return 1000 * v; /// 1 g = 0.001 kg
|
||||
case Unit.oz: return 35.273962 * v; /// 1 oz = 0.0283495231 kg
|
||||
case Unit.lb: return 2.2046226 * v; /// 1 lb = 0.45359237 kg
|
||||
case Unit.t: return 0.001 * v; /// 1 t = 1000 kg
|
||||
|
||||
@ -476,6 +479,7 @@ namespace Config
|
||||
|
||||
/// Mass: internal representation in kg
|
||||
case Unit.g: return 0.001 * v; /// 1 g = 0.001 kg
|
||||
case Unit.oz: return 0.0283495231 * v; /// 1 oz = 0.0283495231 kg
|
||||
case Unit.lb: return 0.45359237 * v; /// 1 lb = 0.45359237 kg
|
||||
case Unit.t: return 1000 * v; /// 1 t = 1000 kg
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.IO;
|
||||
@ -10,6 +10,14 @@ using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
{
|
||||
public enum ActionA1D
|
||||
{
|
||||
Zero,
|
||||
Tara,
|
||||
None,
|
||||
Count
|
||||
}
|
||||
|
||||
public class BalanceCfg : ComponentCfgBase, GenericDevices.IScaleCfg, GenericDevices.ITankDrainingCfg
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(BalanceCfg) })[0];
|
||||
@ -27,74 +35,26 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
public StopBits StopBits;
|
||||
public Handshake Handshake;
|
||||
|
||||
/// 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; } }
|
||||
|
||||
/// Mass threshold for 'Tank is empty' in 'kg' (or volume in 'l') when the drain valve is not open
|
||||
private float emptyUp;
|
||||
public float EmptyUp { get { return emptyUp; } set { emptyUp = 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; } }
|
||||
|
||||
private string evaporation;
|
||||
public string Evaporation { get { return evaporation; } set { evaporation = value; } }
|
||||
|
||||
public float Capacity { get; set; } /// Max. water mass in 'kg' or volume in 'l'
|
||||
public float Empty { get; set; } /// Mass threshold for 'Tank is empty' in 'kg' (or volume in 'l')
|
||||
public float EmptyUp { get; set; } /// Mass threshold for 'Tank is empty' in 'kg' (or volume in 'l') when the drain valve is not open
|
||||
public string Evaporation { get; set; }
|
||||
public string DrainValve { get; set; }
|
||||
public int DrainTimeSec { get; set; }
|
||||
public ActionA1D ActionAfter1stDraining { get; set; }
|
||||
public string Format;
|
||||
|
||||
/// Buoyancy related serialized parameters displayed in Metrology tab page
|
||||
private float buoyancyTemp;
|
||||
private float buoyancyPress;
|
||||
private float buoyancyHumi;
|
||||
private float weightStandardDensity;
|
||||
public float BuoyancyTemp
|
||||
{
|
||||
get { return buoyancyTemp; }
|
||||
set { buoyancyTemp = value; }
|
||||
}
|
||||
public float BuoyancyPress
|
||||
{
|
||||
get { return buoyancyPress; }
|
||||
set { buoyancyPress = value; }
|
||||
}
|
||||
public float BuoyancyHumi
|
||||
{
|
||||
get { return buoyancyHumi; }
|
||||
set { buoyancyHumi = value; }
|
||||
}
|
||||
public float WeightStandardDensity
|
||||
{
|
||||
get { return weightStandardDensity; }
|
||||
set { weightStandardDensity = value; }
|
||||
}
|
||||
public float BuoyancyTemp { get; set; }
|
||||
public float BuoyancyPress { get; set; }
|
||||
public float BuoyancyHumi { get; set; }
|
||||
public float WeightStandardDensity { get; set; }
|
||||
|
||||
/// Calibration info serialized parameters displayed in Metrology tab page
|
||||
string calibCertificateNr;
|
||||
DateTime calibDate;
|
||||
DateTime calibValidDate;
|
||||
public string CalibCertificateNr
|
||||
{
|
||||
get { return calibCertificateNr; }
|
||||
set { calibCertificateNr = value; }
|
||||
}
|
||||
public DateTime CalibDate
|
||||
{
|
||||
get { return calibDate; }
|
||||
set { calibDate = value; }
|
||||
}
|
||||
public DateTime CalibValidDate
|
||||
{
|
||||
get { return calibValidDate; }
|
||||
set { calibValidDate = value; }
|
||||
}
|
||||
public string CalibCertificateNr { get; set; }
|
||||
public DateTime CalibDate { get; set; }
|
||||
public DateTime CalibValidDate { get; set; }
|
||||
|
||||
|
||||
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
|
||||
@ -64,13 +64,15 @@ 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.afterFirstDrainingComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.afterFirstDrainingLabel = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// handshakeComboBox
|
||||
//
|
||||
this.handshakeComboBox.Enabled = false;
|
||||
this.handshakeComboBox.FormattingEnabled = true;
|
||||
this.handshakeComboBox.Location = new System.Drawing.Point(236, 252);
|
||||
this.handshakeComboBox.Location = new System.Drawing.Point(236, 273);
|
||||
this.handshakeComboBox.Name = "handshakeComboBox";
|
||||
this.handshakeComboBox.Size = new System.Drawing.Size(43, 21);
|
||||
this.handshakeComboBox.TabIndex = 31;
|
||||
@ -79,7 +81,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
//
|
||||
this.stopBitsComboBox.Enabled = false;
|
||||
this.stopBitsComboBox.FormattingEnabled = true;
|
||||
this.stopBitsComboBox.Location = new System.Drawing.Point(236, 229);
|
||||
this.stopBitsComboBox.Location = new System.Drawing.Point(236, 250);
|
||||
this.stopBitsComboBox.Name = "stopBitsComboBox";
|
||||
this.stopBitsComboBox.Size = new System.Drawing.Size(43, 21);
|
||||
this.stopBitsComboBox.TabIndex = 29;
|
||||
@ -88,7 +90,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
//
|
||||
this.parityComboBox.Enabled = false;
|
||||
this.parityComboBox.FormattingEnabled = true;
|
||||
this.parityComboBox.Location = new System.Drawing.Point(100, 252);
|
||||
this.parityComboBox.Location = new System.Drawing.Point(100, 273);
|
||||
this.parityComboBox.Name = "parityComboBox";
|
||||
this.parityComboBox.Size = new System.Drawing.Size(43, 21);
|
||||
this.parityComboBox.TabIndex = 25;
|
||||
@ -122,7 +124,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
// handshakeLabel
|
||||
//
|
||||
this.handshakeLabel.AutoSize = true;
|
||||
this.handshakeLabel.Location = new System.Drawing.Point(162, 255);
|
||||
this.handshakeLabel.Location = new System.Drawing.Point(162, 276);
|
||||
this.handshakeLabel.Name = "handshakeLabel";
|
||||
this.handshakeLabel.Size = new System.Drawing.Size(62, 13);
|
||||
this.handshakeLabel.TabIndex = 30;
|
||||
@ -131,7 +133,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
// stopBitsLabel
|
||||
//
|
||||
this.stopBitsLabel.AutoSize = true;
|
||||
this.stopBitsLabel.Location = new System.Drawing.Point(162, 232);
|
||||
this.stopBitsLabel.Location = new System.Drawing.Point(162, 253);
|
||||
this.stopBitsLabel.Name = "stopBitsLabel";
|
||||
this.stopBitsLabel.Size = new System.Drawing.Size(49, 13);
|
||||
this.stopBitsLabel.TabIndex = 28;
|
||||
@ -140,7 +142,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
// dataBitsTextBox
|
||||
//
|
||||
this.dataBitsTextBox.Enabled = false;
|
||||
this.dataBitsTextBox.Location = new System.Drawing.Point(236, 206);
|
||||
this.dataBitsTextBox.Location = new System.Drawing.Point(236, 227);
|
||||
this.dataBitsTextBox.Name = "dataBitsTextBox";
|
||||
this.dataBitsTextBox.Size = new System.Drawing.Size(43, 20);
|
||||
this.dataBitsTextBox.TabIndex = 27;
|
||||
@ -148,7 +150,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
// dataBitsLabel
|
||||
//
|
||||
this.dataBitsLabel.AutoSize = true;
|
||||
this.dataBitsLabel.Location = new System.Drawing.Point(162, 209);
|
||||
this.dataBitsLabel.Location = new System.Drawing.Point(162, 230);
|
||||
this.dataBitsLabel.Name = "dataBitsLabel";
|
||||
this.dataBitsLabel.Size = new System.Drawing.Size(50, 13);
|
||||
this.dataBitsLabel.TabIndex = 26;
|
||||
@ -157,7 +159,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
// partityLabel
|
||||
//
|
||||
this.partityLabel.AutoSize = true;
|
||||
this.partityLabel.Location = new System.Drawing.Point(26, 255);
|
||||
this.partityLabel.Location = new System.Drawing.Point(26, 276);
|
||||
this.partityLabel.Name = "partityLabel";
|
||||
this.partityLabel.Size = new System.Drawing.Size(33, 13);
|
||||
this.partityLabel.TabIndex = 24;
|
||||
@ -166,7 +168,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
// baudRateTextBox
|
||||
//
|
||||
this.baudRateTextBox.Enabled = false;
|
||||
this.baudRateTextBox.Location = new System.Drawing.Point(100, 229);
|
||||
this.baudRateTextBox.Location = new System.Drawing.Point(100, 250);
|
||||
this.baudRateTextBox.Name = "baudRateTextBox";
|
||||
this.baudRateTextBox.Size = new System.Drawing.Size(43, 20);
|
||||
this.baudRateTextBox.TabIndex = 23;
|
||||
@ -174,7 +176,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
// baudRateLabel
|
||||
//
|
||||
this.baudRateLabel.AutoSize = true;
|
||||
this.baudRateLabel.Location = new System.Drawing.Point(26, 232);
|
||||
this.baudRateLabel.Location = new System.Drawing.Point(26, 253);
|
||||
this.baudRateLabel.Name = "baudRateLabel";
|
||||
this.baudRateLabel.Size = new System.Drawing.Size(53, 13);
|
||||
this.baudRateLabel.TabIndex = 22;
|
||||
@ -183,7 +185,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
// comPortNrTextBox
|
||||
//
|
||||
this.comPortNrTextBox.Enabled = false;
|
||||
this.comPortNrTextBox.Location = new System.Drawing.Point(100, 206);
|
||||
this.comPortNrTextBox.Location = new System.Drawing.Point(100, 227);
|
||||
this.comPortNrTextBox.Name = "comPortNrTextBox";
|
||||
this.comPortNrTextBox.Size = new System.Drawing.Size(43, 20);
|
||||
this.comPortNrTextBox.TabIndex = 21;
|
||||
@ -191,7 +193,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(26, 209);
|
||||
this.label1.Location = new System.Drawing.Point(26, 230);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(67, 13);
|
||||
this.label1.TabIndex = 20;
|
||||
@ -354,10 +356,30 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
this.evaporationLabel.TabIndex = 13;
|
||||
this.evaporationLabel.Text = "Evaporation";
|
||||
//
|
||||
// afterFirstDrainingComboBox
|
||||
//
|
||||
this.afterFirstDrainingComboBox.Enabled = false;
|
||||
this.afterFirstDrainingComboBox.FormattingEnabled = true;
|
||||
this.afterFirstDrainingComboBox.Location = new System.Drawing.Point(137, 190);
|
||||
this.afterFirstDrainingComboBox.Name = "afterFirstDrainingComboBox";
|
||||
this.afterFirstDrainingComboBox.Size = new System.Drawing.Size(143, 21);
|
||||
this.afterFirstDrainingComboBox.TabIndex = 33;
|
||||
//
|
||||
// afterFirstDrainingLabel
|
||||
//
|
||||
this.afterFirstDrainingLabel.AutoSize = true;
|
||||
this.afterFirstDrainingLabel.Location = new System.Drawing.Point(26, 193);
|
||||
this.afterFirstDrainingLabel.Name = "afterFirstDrainingLabel";
|
||||
this.afterFirstDrainingLabel.Size = new System.Drawing.Size(86, 13);
|
||||
this.afterFirstDrainingLabel.TabIndex = 32;
|
||||
this.afterFirstDrainingLabel.Text = "After 1st draining";
|
||||
//
|
||||
// BalanceCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.afterFirstDrainingComboBox);
|
||||
this.Controls.Add(this.afterFirstDrainingLabel);
|
||||
this.Controls.Add(this.evaporationComboBox);
|
||||
this.Controls.Add(this.evaporationLabel);
|
||||
this.Controls.Add(this.label7);
|
||||
@ -434,5 +456,7 @@ 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 afterFirstDrainingComboBox;
|
||||
private System.Windows.Forms.Label afterFirstDrainingLabel;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
@ -79,6 +79,11 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
for (ActionA1D a = 0; a < ActionA1D.Count; a++)
|
||||
{
|
||||
afterFirstDrainingComboBox.Items.Add(a.ToString());
|
||||
}
|
||||
|
||||
parityComboBox.Items.Add(Parity.None.ToString());
|
||||
parityComboBox.Items.Add(Parity.Even.ToString());
|
||||
parityComboBox.Items.Add(Parity.Odd.ToString());
|
||||
@ -135,6 +140,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
evaporationComboBox.Text = string.IsNullOrEmpty(config.Evaporation) ? "---" : config.Evaporation;
|
||||
drainValveComboBox.Text = string.IsNullOrEmpty(config.DrainValve) ? "---" : config.DrainValve;
|
||||
drainTimeTextBox.Text = config.DrainTimeSec.ToString();
|
||||
afterFirstDrainingComboBox.Text = config.ActionAfter1stDraining.ToString();
|
||||
|
||||
comPortNrTextBox.Text = config.ComPortNr.ToString();
|
||||
baudRateTextBox.Text = config.BaudRate.ToString();
|
||||
@ -154,6 +160,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
evaporationComboBox.Enabled = true;
|
||||
drainValveComboBox.Enabled = true;
|
||||
drainTimeTextBox.Enabled = true;
|
||||
afterFirstDrainingComboBox.Enabled = true;
|
||||
|
||||
comPortNrTextBox.Enabled = true;
|
||||
baudRateTextBox.Enabled = true;
|
||||
@ -219,6 +226,11 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Tank drain time' should be between 1 and 999 sec";
|
||||
}
|
||||
if (!afterFirstDrainingComboBox.Items.Contains(afterFirstDrainingComboBox.Text))
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Avter 1st draining'";
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
@ -237,6 +249,14 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
config.Evaporation = evaporationComboBox.Text.Equals("---") ? string.Empty : evaporationComboBox.Text;
|
||||
config.DrainTimeSec = int.Parse(drainTimeTextBox.Text);
|
||||
config.DrainValve = drainValveComboBox.Text.Equals("---") ? string.Empty : drainValveComboBox.Text;
|
||||
for (ActionA1D a = 0; a < ActionA1D.Count; a++)
|
||||
{
|
||||
if (afterFirstDrainingComboBox.Text == a.ToString())
|
||||
{
|
||||
config.ActionAfter1stDraining = a;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
config.ComPortNr = int.Parse(comPortNrTextBox.Text);
|
||||
config.BaudRate = int.Parse(baudRateTextBox.Text);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -258,21 +258,11 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
serialPort.Write("SI\r\n");
|
||||
}
|
||||
|
||||
/// <summary>Units for SetUnits() argument</summary>
|
||||
public enum Units
|
||||
{
|
||||
g,
|
||||
kg,
|
||||
t,
|
||||
lb,
|
||||
oz
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the serial number
|
||||
/// </summary>
|
||||
/// <remarks>After a successful SetUnits(kg) mass is still sent in g. MH 15.10.2013</remarks>
|
||||
public void SendSetUnitsCmd(Units unit)
|
||||
public void SendSetUnitsCmd(Config.Unit unit)
|
||||
{
|
||||
if (balanceCfg.DebugLevel == DebugMode.Simulate) return;
|
||||
|
||||
@ -286,27 +276,28 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
stringBuilder.Clear();
|
||||
switch (unit)
|
||||
{
|
||||
case Units.g:
|
||||
case Config.Unit.g:
|
||||
log.InfoFormat("{0} - SetUnits({1}) - \"U g\\r\\n\"", Name, unit);
|
||||
serialPort.Write("U g\r\n");
|
||||
break;
|
||||
case Units.kg:
|
||||
log.InfoFormat("{0} - SetUnits({1}) - \"U kg\\r\\n\"", Name, unit);
|
||||
serialPort.Write("U kg\r\n");
|
||||
break;
|
||||
case Units.t:
|
||||
case Config.Unit.t:
|
||||
log.InfoFormat("{0} - SetUnits({1}) - \"U t\\r\\n\"", Name, unit);
|
||||
serialPort.Write("U t\r\n");
|
||||
break;
|
||||
case Units.lb:
|
||||
case Config.Unit.lb:
|
||||
log.InfoFormat("{0} - SetUnits({1}) - \"U lb\\r\\n\"", Name, unit);
|
||||
serialPort.Write("U lb\r\n");
|
||||
break;
|
||||
case Units.oz:
|
||||
case Config.Unit.oz:
|
||||
log.InfoFormat("{0} - SetUnits({1}) - \"U oz\\r\\n\"", Name, unit);
|
||||
serialPort.Write("U oz\r\n");
|
||||
break;
|
||||
}
|
||||
case Config.Unit.kg:
|
||||
default:
|
||||
log.InfoFormat("{0} - SetUnits({1}) - \"U kg\\r\\n\"", Name, unit);
|
||||
serialPort.Write("U kg\r\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -369,9 +360,9 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
received = tmp;
|
||||
}
|
||||
|
||||
string[] fields = received.Split(new char[] { ' ' });
|
||||
string[] field = received.Split(new char[] { ' ' });
|
||||
|
||||
if (fields.Length == 1 && fields[0].Equals("ZA")) /// Zero when stable
|
||||
if (field.Length == 1 && field[0] == "ZA") /// Zero when stable
|
||||
{
|
||||
mass = 0;
|
||||
Masses[balanceNr] = mass;
|
||||
@ -379,16 +370,16 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
log.InfoFormat("{0} - Balance response = \"{1}<cr><lf>\"", Name, received);
|
||||
return;
|
||||
}
|
||||
else if (fields.Length < 2)
|
||||
else if (field.Length < 2)
|
||||
{
|
||||
msrmntState = MsrmntState.Failed;
|
||||
log.WarnFormat("{0} - Balance response = \"{1}<cr><lf>\", Unexpected error !!!", Name, received);
|
||||
return;
|
||||
}
|
||||
|
||||
if (fields[0].Equals("Z")) /// Zero when stable
|
||||
if (field[0] == "Z") /// Zero when stable
|
||||
{
|
||||
if (fields.Length == 2 && fields[1].Equals("A"))
|
||||
if (field.Length == 2 && field[1] == "A")
|
||||
{
|
||||
mass = 0;
|
||||
Masses[balanceNr] = mass;
|
||||
@ -402,33 +393,31 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
log.WarnFormat("{0} - Balance response = \"{1}<cr><lf>\", error !!!", Name, received);
|
||||
}
|
||||
}
|
||||
else if (fields[0].Equals("S")) /// Stable mass: field[1] = <mass> field[2] = "kg"
|
||||
else if (field[0] == "S") /// Stable mass: field[1] = <mass> field[2] = "kg"
|
||||
{
|
||||
if (fields.Length == 3 &&
|
||||
double.TryParse(fields[1],
|
||||
if (field.Length == 3 &&
|
||||
double.TryParse(field[1],
|
||||
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign,
|
||||
CultureInfo.InvariantCulture,
|
||||
out mass))
|
||||
{
|
||||
if (fields[2].Equals("g")) mass /= 1000.0f;
|
||||
if (fields[2].Equals("t")) mass *= 1000.0f;
|
||||
mass = Config.Units.ConvertFrom(ParseUnit(field[2]), mass);
|
||||
Masses[balanceNr] = mass;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("{0} - Balance response = \"{1}<cr><lf>\", Mass = {2}", Name, received, mass);
|
||||
}
|
||||
else if (fields.Length == 4 && (fields[1].Equals("S") || fields[1].Equals("D")) &&
|
||||
double.TryParse(fields[2],
|
||||
else if (field.Length == 4 && (field[1] == "S" || field[1] == "D") &&
|
||||
double.TryParse(field[2],
|
||||
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign,
|
||||
CultureInfo.InvariantCulture,
|
||||
out mass))
|
||||
{
|
||||
if (fields[3].Equals("g")) mass /= 1000.0f;
|
||||
if (fields[3].Equals("t")) mass *= 1000.0f;
|
||||
mass = Config.Units.ConvertFrom(ParseUnit(field[3]), mass);
|
||||
Masses[balanceNr] = mass;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("{0} - Balance response = \"{1}<cr><lf>\", Mass = {2}", Name, received, mass);
|
||||
}
|
||||
else if (fields.Length == 2 && fields[1].Equals("-"))
|
||||
else if (field.Length == 2 && field[1] == "-")
|
||||
{
|
||||
mass = 0;
|
||||
Masses[balanceNr] = mass;
|
||||
@ -439,25 +428,24 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
{
|
||||
msrmntState = MsrmntState.Failed;
|
||||
log.WarnFormat("{0} Balance response = \"{1}<cr><lf>\", Overload or and unexpected error !!!", Name, received);
|
||||
bool b = double.TryParse(fields[1], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out mass);
|
||||
bool b = double.TryParse(field[1], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out mass);
|
||||
|
||||
}
|
||||
}
|
||||
else if (fields[0].Equals("SD")) /// Dynamic mass: field[1] = <mass> field[2] = "kg"
|
||||
else if (field[0] == "SD") /// Dynamic mass: field[1] = <mass> field[2] = "kg"
|
||||
{
|
||||
if (fields.Length >= 3 &&
|
||||
double.TryParse(fields[1],
|
||||
if (field.Length >= 3 &&
|
||||
double.TryParse(field[1],
|
||||
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign,
|
||||
CultureInfo.InvariantCulture,
|
||||
out mass))
|
||||
{
|
||||
if (fields[2].Equals("g")) mass /= 1000.0f;
|
||||
if (fields[2].Equals("t")) mass *= 1000.0f;
|
||||
mass = Config.Units.ConvertFrom(ParseUnit(field[2]), mass);
|
||||
Masses[balanceNr] = mass;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("{0} - Balance response = \"{1}<cr><lf>\", Mass = {2}", Name, received, mass);
|
||||
}
|
||||
else if (fields.Length == 2 && fields[1].Equals("-"))
|
||||
else if (field.Length == 2 && field[1] == "-")
|
||||
{
|
||||
mass = 0;
|
||||
Masses[balanceNr] = mass;
|
||||
@ -468,21 +456,20 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
{
|
||||
msrmntState = MsrmntState.Failed;
|
||||
log.WarnFormat("{0} - Balance response = \"{1}<cr><lf>\", Overload or and unexpected error !!!", Name, received);
|
||||
bool b = double.TryParse(fields[1], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out mass);
|
||||
bool b = double.TryParse(field[1], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out mass);
|
||||
|
||||
}
|
||||
}
|
||||
else if (fields[0].Equals("TB")) /// Taring
|
||||
else if (field[0] == "TB") /// Taring
|
||||
{
|
||||
if (fields.Length >= 3 &&
|
||||
double.TryParse(fields[1],
|
||||
if (field.Length >= 3 &&
|
||||
double.TryParse(field[1],
|
||||
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign,
|
||||
CultureInfo.InvariantCulture,
|
||||
out mass))
|
||||
{
|
||||
if (fields[2].Equals("g")) mass /= 1000.0f;
|
||||
if (fields[2].Equals("t")) mass *= 1000.0f;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
mass = Config.Units.ConvertFrom(ParseUnit(field[2]), mass);
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("{0} - Balance response = \"{1}<cr><lf>\", Tara = {2}", Name, received, mass);
|
||||
}
|
||||
else
|
||||
@ -491,16 +478,15 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
log.WarnFormat("{0} - Balance response = \"{1}<cr><lf>\", Overload or and unexpected error !!!", Name, received);
|
||||
}
|
||||
}
|
||||
else if (fields[0].Equals("T")) /// Taring
|
||||
else if (field[0] == "T") /// Taring
|
||||
{
|
||||
if (fields.Length >= 4 && fields[1].Equals("S") &&
|
||||
double.TryParse(fields[2],
|
||||
if (field.Length >= 4 && field[1] == "S" &&
|
||||
double.TryParse(field[2],
|
||||
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign,
|
||||
CultureInfo.InvariantCulture,
|
||||
out mass))
|
||||
{
|
||||
if (fields[3].Equals("g")) mass /= 1000.0f;
|
||||
if (fields[3].Equals("t")) mass *= 1000.0f;
|
||||
mass = Config.Units.ConvertFrom(ParseUnit(field[3]), mass);
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("{0} - Balance response = \"{1}<cr><lf>\", Tara = {2}", Name, received, mass);
|
||||
}
|
||||
@ -547,7 +533,16 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
/// <returns>ZeroOp reference</returns>
|
||||
public IOperation ZeroOp()
|
||||
{
|
||||
return new ZeroOp(this);
|
||||
switch (balanceCfg.ActionAfter1stDraining)
|
||||
{
|
||||
case ActionA1D.Zero:
|
||||
return new ZeroOp(this);
|
||||
case ActionA1D.Tara:
|
||||
DoubleBox dummy = new DoubleBox();
|
||||
return new TaringOp(this, ref dummy);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -592,5 +587,20 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse a string representing mass units.
|
||||
/// Defaults to 'kg'in case unitStr not recognized.
|
||||
/// </summary>
|
||||
/// <param name="unitStr">String: "kg", "g", "t", "lb" or "oz" expected</param>
|
||||
/// <returns></returns>
|
||||
protected Config.Unit ParseUnit(string unitStr)
|
||||
{
|
||||
if (unitStr == "g") return Config.Unit.g;
|
||||
if (unitStr == "t") return Config.Unit.t;
|
||||
if (unitStr == "lb") return Config.Unit.lb;
|
||||
if (unitStr == "oz") return Config.Unit.oz;
|
||||
return Config.Unit.kg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Globalization;
|
||||
@ -110,8 +110,8 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
received = tmp;
|
||||
}
|
||||
|
||||
string[] fields = received.Substring(0, received.Length - 2).Split(new char[] { ' ' });
|
||||
if (fields.Length < 2)
|
||||
string[] field = received.Substring(0, received.Length - 2).Split(new char[] { ' ' });
|
||||
if (field.Length < 2)
|
||||
{
|
||||
msrmntState = MsrmntState.Failed;
|
||||
log.WarnFormat("{0} - Balance response = {1}, Unexpected error !!!", Name,
|
||||
@ -119,11 +119,11 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
return;
|
||||
}
|
||||
|
||||
if (fields[0].Equals("I4")) /// Serial number
|
||||
if (field[0] == "I4" || field[0] == "IA") /// Serial number
|
||||
{
|
||||
if (fields.Length == 3 && fields[1].Equals("A") && fields[2].Length >= 3)
|
||||
if (field.Length == 3 && field[1] == "A" && field[2].Length >= 3)
|
||||
{
|
||||
serialNumber = fields[2].Substring(1, fields[2].Length - 2);
|
||||
serialNumber = field[2].Substring(1, field[2].Length - 2);
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.WarnFormat("{0} - Balance response = {1}, s/n = {2}", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"), serialNumber);
|
||||
@ -135,9 +135,9 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
}
|
||||
}
|
||||
else if (fields[0].Equals("Z")) /// Zero when stable
|
||||
else if (field[0] == "Z") /// Zero when stable
|
||||
{
|
||||
if (fields.Length == 2 && fields[1].Equals("A"))
|
||||
if (field.Length == 2 && field[1] == "A")
|
||||
{
|
||||
mass = 0;
|
||||
Masses[balanceNr] = mass;
|
||||
@ -152,20 +152,19 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
}
|
||||
}
|
||||
else if (fields[0].Equals("S")) /// Stable (field[1] == "S") or dynamic (field[1] == "D") mass measurement
|
||||
else if (field[0] == "S") /// Stable (field[1] == "S") or dynamic (field[1] == "D") mass measurement
|
||||
{
|
||||
if (fields.Length == 4 && (fields[1].Equals("S") || fields[1].Equals("D")) &&
|
||||
double.TryParse(fields[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite,
|
||||
if (field.Length == 4 && (field[1] == "S" || field[1] == "D") &&
|
||||
double.TryParse(field[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite,
|
||||
CultureInfo.InvariantCulture, out mass))
|
||||
{
|
||||
if (fields[3].Equals("g")) mass /= 1000.0f;
|
||||
if (fields[3].Equals("t")) mass *= 1000.0f;
|
||||
mass = Config.Units.ConvertFrom(ParseUnit(field[3]), mass);
|
||||
Masses[balanceNr] = mass;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("{0} - Balance response = {1}, Mass = {2}", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"), mass);
|
||||
}
|
||||
else if (fields.Length == 2 && fields[1].Equals("-"))
|
||||
else if (field.Length == 2 && field[1] == "-")
|
||||
{
|
||||
//mass = 0;
|
||||
//Masses[balanceNr] = mass;
|
||||
@ -173,7 +172,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
log.InfoFormat("{0} - Balance response = {1}, Mass = {2}", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"), mass);
|
||||
}
|
||||
else if (fields.Length == 2 && fields[1].Equals("+"))
|
||||
else if (field.Length == 2 && field[1] == "+")
|
||||
{
|
||||
//mass = Capacity;
|
||||
//Masses[balanceNr] = mass;
|
||||
@ -181,7 +180,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
log.InfoFormat("{0} - Balance response = {1}, Overload", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
}
|
||||
else if (fields.Length >= 2 && fields[1].Equals("I"))
|
||||
else if (field.Length >= 2 && field[1] == "I")
|
||||
{
|
||||
//mass = balanceCfg.Capacity;
|
||||
//Masses[balanceNr] = mass;
|
||||
@ -196,19 +195,18 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
}
|
||||
}
|
||||
else if (fields[0].Equals("T")) /// Taring
|
||||
else if (field[0] == "T") /// Taring
|
||||
{
|
||||
if (fields.Length == 4 && fields[1].Equals("S") &&
|
||||
double.TryParse(fields[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite,
|
||||
if (field.Length == 4 && field[1] == "S" &&
|
||||
double.TryParse(field[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite,
|
||||
CultureInfo.InvariantCulture, out mass))
|
||||
{
|
||||
if (fields[3].Equals("g")) mass /= 1000.0f;
|
||||
if (fields[3].Equals("t")) mass *= 1000.0f;
|
||||
mass = Config.Units.ConvertFrom(ParseUnit(field[3]), mass);
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.WarnFormat("{0} - Balance response = {1}, Mass = {2}", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"), mass);
|
||||
}
|
||||
else if (fields.Length >= 2 && fields[1].Equals("I"))
|
||||
else if (field.Length >= 2 && field[1] == "I")
|
||||
{
|
||||
mass = mass = balanceCfg.Capacity;
|
||||
msrmntState = MsrmntState.Overload;
|
||||
@ -222,9 +220,9 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
}
|
||||
}
|
||||
else if (fields[0].Equals("U"))
|
||||
else if (field[0] == "U")
|
||||
{
|
||||
if (fields.Length == 2 && fields[1].Equals("A"))
|
||||
if (field.Length == 2 && field[1] == "A")
|
||||
{
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("{0} - Balance response = \"{1}\"", Name,
|
||||
@ -237,9 +235,9 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
}
|
||||
}
|
||||
else if (fields[0].Equals("SI")) /// "SI I<cr><lf>" received in case of overload -> empty the tank
|
||||
else if (field[0] == "SI") /// "SI I<cr><lf>" received in case of overload -> empty the tank
|
||||
{
|
||||
if (fields.Length >= 2 && fields[1].Equals("I"))
|
||||
if (field.Length >= 2 && field[1] == "I")
|
||||
{
|
||||
mass = balanceCfg.Capacity;
|
||||
Masses[balanceNr] = mass;
|
||||
@ -268,7 +266,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
/// </summary>
|
||||
/// <param name="units"></param>
|
||||
/// <returns>SetUnitsOp instance reference casted to IOperaton</returns>
|
||||
public IOperation SetUnitsOp(Units units)
|
||||
public IOperation SetUnitsOp(Config.Unit units)
|
||||
{
|
||||
return new SetUnitsOp(this, units);
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2016-2020 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2016-2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -92,17 +92,17 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
received = tmp;
|
||||
}
|
||||
|
||||
string[] fields = received.Substring(0, received.Length - 2).Split(new char[] { ' ' });
|
||||
if (fields.Length < 2)
|
||||
string[] field = received.Substring(0, received.Length - 2).Split(new char[] { ' ' });
|
||||
if (field.Length < 2)
|
||||
{
|
||||
msrmntState = MsrmntState.Failed;
|
||||
log.WarnFormat("{0} - Balance response = {1}, Unexpected error !!!", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
return;
|
||||
}
|
||||
else if (fields[0].Equals("Z")) /// Zero when stable
|
||||
else if (field[0] == "Z") /// Zero when stable
|
||||
{
|
||||
if (fields.Length == 2 && fields[1].Equals("A"))
|
||||
if (field.Length == 2 && field[1] == "A")
|
||||
{
|
||||
mass = 0;
|
||||
Masses[balanceNr] = mass;
|
||||
@ -117,31 +117,29 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
}
|
||||
}
|
||||
else if (fields[0].Equals("S")) /// Stable (field[1] == "S") or dynamic (field[1] == "D") mass measurement
|
||||
else if (field[0] == "S") /// Stable (field[1] == "S") or dynamic (field[1] == "D") mass measurement
|
||||
{
|
||||
if (fields.Length == 4 && fields[1].Equals("S") &&
|
||||
double.TryParse(fields[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite,
|
||||
if (field.Length == 4 && field[1] == "S" &&
|
||||
double.TryParse(field[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite,
|
||||
CultureInfo.InvariantCulture, out mass))
|
||||
{
|
||||
if (fields[3].Equals("g")) mass /= 1000.0f;
|
||||
if (fields[3].Equals("t")) mass *= 1000.0f;
|
||||
mass = Config.Units.ConvertFrom(ParseUnit(field[3]), mass);
|
||||
Masses[balanceNr] = mass;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("{0} - Balance response = {1}, Mass = {2}", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"), mass);
|
||||
}
|
||||
else if (fields.Length == 4 && fields[1].Equals("D") &&
|
||||
double.TryParse(fields[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite,
|
||||
else if (field.Length == 4 && field[1] == "D" &&
|
||||
double.TryParse(field[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite,
|
||||
CultureInfo.InvariantCulture, out mass))
|
||||
{
|
||||
if (fields[3].Equals("g")) mass /= 1000.0f;
|
||||
if (fields[3].Equals("t")) mass *= 1000.0f;
|
||||
mass = Config.Units.ConvertFrom(ParseUnit(field[3]), mass);
|
||||
Masses[balanceNr] = mass;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("{0} - Balance response = {1}, Mass = {2}", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"), mass);
|
||||
}
|
||||
else if (fields.Length == 2 && fields[1].Equals("-"))
|
||||
else if (field.Length == 2 && field[1] == "-")
|
||||
{
|
||||
mass = 0;
|
||||
Masses[balanceNr] = mass;
|
||||
@ -149,7 +147,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
log.InfoFormat("{0} - Balance response = {1}, Mass = {2}", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"), mass);
|
||||
}
|
||||
else if (fields.Length == 2 && fields[1].Equals("+"))
|
||||
else if (field.Length == 2 && field[1] == "+")
|
||||
{
|
||||
mass = Capacity;
|
||||
Masses[balanceNr] = mass;
|
||||
@ -157,7 +155,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
log.InfoFormat("{0} - Balance response = {1}, Overload", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
}
|
||||
else if (fields.Length >= 2 && fields[1].Equals("I"))
|
||||
else if (field.Length >= 2 && field[1] == "I")
|
||||
{
|
||||
mass = balanceCfg.Capacity;
|
||||
Masses[balanceNr] = mass;
|
||||
@ -172,19 +170,18 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
}
|
||||
}
|
||||
else if (fields[0].Equals("T")) /// Taring
|
||||
else if (field[0] == "T") /// Taring
|
||||
{
|
||||
if (fields.Length == 4 && fields[1].Equals("S") &&
|
||||
double.TryParse(fields[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite,
|
||||
if (field.Length == 4 && field[1] == "S" &&
|
||||
double.TryParse(field[2], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowLeadingWhite,
|
||||
CultureInfo.InvariantCulture, out mass))
|
||||
{
|
||||
if (fields[3].Equals("g")) mass /= 1000.0f;
|
||||
if (fields[3].Equals("t")) mass *= 1000.0f;
|
||||
mass = Config.Units.ConvertFrom(ParseUnit(field[3]), mass);
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("{0} - Balance response = {1}, Mass = {2}", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"), mass);
|
||||
}
|
||||
else if (fields.Length >= 2 && fields[1].Equals("I"))
|
||||
else if (field.Length >= 2 && field[1] == "I")
|
||||
{
|
||||
mass = mass = balanceCfg.Capacity;
|
||||
msrmntState = MsrmntState.Overload;
|
||||
@ -198,9 +195,9 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
}
|
||||
}
|
||||
else if (fields[0].Equals("U"))
|
||||
else if (field[0] == "U")
|
||||
{
|
||||
if (fields.Length == 2 && fields[1].Equals("A"))
|
||||
if (field.Length == 2 && field[1] == "A")
|
||||
{
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("{0} - Balance response = \"{1}\"", Name,
|
||||
@ -213,9 +210,9 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
}
|
||||
}
|
||||
else if (fields[0].Equals("SI")) /// "SI I<cr><lf>" received in case of overload -> empty the tank
|
||||
else if (field[0] == "SI") /// "SI I<cr><lf>" received in case of overload -> empty the tank
|
||||
{
|
||||
if (fields.Length >= 2 && fields[1].Equals("I"))
|
||||
if (field.Length >= 2 && field[1] == "I")
|
||||
{
|
||||
mass = balanceCfg.Capacity;
|
||||
Masses[balanceNr] = mass;
|
||||
@ -234,7 +231,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
/// </summary>
|
||||
/// <param name="units"></param>
|
||||
/// <returns>SetUnitsOp instance reference casted to IOperaton</returns>
|
||||
public IOperation SetUnitsOp(Units units)
|
||||
public IOperation SetUnitsOp(Config.Unit units)
|
||||
{
|
||||
return new SetUnitsOp(this, units);
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -16,7 +16,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
|
||||
/// Set by the constructor
|
||||
BalanceDev scale;
|
||||
BalanceDev.Units units;
|
||||
Config.Unit units;
|
||||
bool activityStarted;
|
||||
|
||||
/// <summary>
|
||||
@ -24,7 +24,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
/// </summary>
|
||||
/// <param name="scale">Balance device instance</param>
|
||||
/// <param name="result">Reference to the serialNumber</param>
|
||||
public SetUnitsOp(BalanceDev scale, BalanceDev.Units units)
|
||||
public SetUnitsOp(BalanceDev scale, Config.Unit units)
|
||||
{
|
||||
if (scale == null) throw new ArgumentNullException("balanceDev");
|
||||
this.scale = scale;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user