diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceDev.cs b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceDev.cs index 7b4d5125a..1194d7c70 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceDev.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceDev.cs @@ -313,7 +313,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard } else if (fields[0].Equals("S")) /// Stable mass: field[1] = field[2] = "kg" { - if (fields.Length >= 3 && + if (fields.Length == 3 && float.TryParse(fields[1], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, @@ -325,7 +325,19 @@ namespace TBF.BenchControl.MettlerToledo.Standard msrmntState = MsrmntState.Valid; log.InfoFormat("{0} - Balance response = \"{1}\", Mass = {2}", Name, received, mass); } - else if (fields.Length == 2 && fields[1].Equals("-")) + else if (fields.Length == 4 && fields[1].Equals("S") && + float.TryParse(fields[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; + Masses[balanceNr] = mass; + msrmntState = MsrmntState.Valid; + log.InfoFormat("{0} - Balance response = \"{1}\", Mass = {2}", Name, received, mass); + } + else if (fields.Length == 2 && fields[1].Equals("-")) { mass = 0; Masses[balanceNr] = mass; @@ -388,7 +400,26 @@ namespace TBF.BenchControl.MettlerToledo.Standard log.WarnFormat("{0} - Balance response = \"{1}\", Overload or and unexpected error !!!", Name, received); } } - else + else if (fields[0].Equals("T")) /// Taring + { + if (fields.Length >= 4 && fields[1].Equals("S") && + float.TryParse(fields[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; + msrmntState = MsrmntState.Valid; + log.InfoFormat("{0} - Balance response = \"{1}\", Tara = {2}", Name, received, mass); + } + else + { + msrmntState = MsrmntState.Failed; + log.WarnFormat("{0} - Balance response = \"{1}\", Overload or and unexpected error !!!", Name, received); + } + } + else { msrmntState = MsrmntState.Failed; log.WarnFormat("{0} - Balance response = \"{1}\", Unexpected error !!!", Name, received);