iPerlSpecial: larger scale (WT1) serial protocol fix, TODO: fix WT2 serial protocol.
This commit is contained in:
@@ -313,7 +313,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
}
|
}
|
||||||
else if (fields[0].Equals("S")) /// Stable mass: field[1] = <mass> field[2] = "kg"
|
else if (fields[0].Equals("S")) /// Stable mass: field[1] = <mass> field[2] = "kg"
|
||||||
{
|
{
|
||||||
if (fields.Length >= 3 &&
|
if (fields.Length == 3 &&
|
||||||
float.TryParse(fields[1],
|
float.TryParse(fields[1],
|
||||||
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign,
|
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign,
|
||||||
CultureInfo.InvariantCulture,
|
CultureInfo.InvariantCulture,
|
||||||
@@ -325,6 +325,18 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
msrmntState = MsrmntState.Valid;
|
msrmntState = MsrmntState.Valid;
|
||||||
log.InfoFormat("{0} - Balance response = \"{1}<cr><lf>\", Mass = {2}", Name, received, mass);
|
log.InfoFormat("{0} - Balance response = \"{1}<cr><lf>\", Mass = {2}", Name, received, mass);
|
||||||
}
|
}
|
||||||
|
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}<cr><lf>\", Mass = {2}", Name, received, mass);
|
||||||
|
}
|
||||||
else if (fields.Length == 2 && fields[1].Equals("-"))
|
else if (fields.Length == 2 && fields[1].Equals("-"))
|
||||||
{
|
{
|
||||||
mass = 0;
|
mass = 0;
|
||||||
@@ -388,6 +400,25 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
|||||||
log.WarnFormat("{0} - Balance response = \"{1}<cr><lf>\", Overload or and unexpected error !!!", Name, received);
|
log.WarnFormat("{0} - Balance response = \"{1}<cr><lf>\", Overload or and unexpected error !!!", Name, received);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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}<cr><lf>\", Tara = {2}", Name, received, mass);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msrmntState = MsrmntState.Failed;
|
||||||
|
log.WarnFormat("{0} - Balance response = \"{1}<cr><lf>\", Overload or and unexpected error !!!", Name, received);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msrmntState = MsrmntState.Failed;
|
msrmntState = MsrmntState.Failed;
|
||||||
|
|||||||
Reference in New Issue
Block a user