More logging in MettlerToledo.Standard component
This commit is contained in:
@@ -115,11 +115,11 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
|
||||
if (msrmntState == MsrmntState.Busy)
|
||||
{
|
||||
log.Warn("ZeroWhenStable() returns without starting zeroing the scale because measurementState == MeasurementState.Busy");
|
||||
log.WarnFormat("{0} - ZeroWhenStable() returns without starting zeroing the scale because measurementState == MeasurementState.Busy", Name);
|
||||
return;
|
||||
}
|
||||
|
||||
log.Info("ZeroWhenStable()");
|
||||
log.InfoFormat("{0} - ZeroWhenStable()", Name);
|
||||
|
||||
msrmntState = MsrmntState.Busy;
|
||||
stringBuilder.Clear();
|
||||
@@ -132,11 +132,11 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
|
||||
if (msrmntState == MsrmntState.Busy)
|
||||
{
|
||||
log.Warn("Taring() returns without starting taring the scale because measurementState == MeasurementState.Busy");
|
||||
log.WarnFormat("{0} - Taring() returns without starting taring the scale because measurementState == MeasurementState.Busy", Name);
|
||||
return;
|
||||
}
|
||||
|
||||
log.Info("Taring()");
|
||||
log.InfoFormat("{0} - Taring()", Name);
|
||||
|
||||
msrmntState = MsrmntState.Busy;
|
||||
stringBuilder.Clear();
|
||||
@@ -152,11 +152,11 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
|
||||
if (msrmntState == MsrmntState.Busy)
|
||||
{
|
||||
log.Warn("GetStableMassMeasurement() returns without starting a measurement because measurementState == MeasurementState.Busy");
|
||||
log.WarnFormat("{0} - GetStableMassMeasurement() returns without starting a measurement because measurementState == MeasurementState.Busy", Name);
|
||||
return;
|
||||
}
|
||||
|
||||
log.Info("GetStableMassMeasurement()");
|
||||
log.InfoFormat("{0} - GetStableMassMeasurement()", Name);
|
||||
|
||||
msrmntState = MsrmntState.Busy;
|
||||
stringBuilder.Clear();
|
||||
@@ -172,11 +172,11 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
|
||||
if (msrmntState == MsrmntState.Busy)
|
||||
{
|
||||
log.Warn("GetImmediateMassMeasurement() returns without starting a measurement because measurementState == MeasurementState.Busy");
|
||||
log.WarnFormat("{0} - GetImmediateMassMeasurement() returns without starting a measurement because measurementState == MeasurementState.Busy", Name);
|
||||
return;
|
||||
}
|
||||
|
||||
log.Info("GetImmediateMassMeasurement()");
|
||||
log.InfoFormat("{0} - GetImmediateMassMeasurement()", Name);
|
||||
|
||||
msrmntState = MsrmntState.Busy;
|
||||
stringBuilder.Clear();
|
||||
@@ -203,11 +203,11 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
|
||||
if (msrmntState == MsrmntState.Busy)
|
||||
{
|
||||
log.Warn("SetUnits() returns without setting the units because measurementState == MeasurementState.Busy");
|
||||
log.WarnFormat("{0} - SetUnits() returns without setting the units because measurementState == MeasurementState.Busy", Name);
|
||||
return;
|
||||
}
|
||||
|
||||
log.InfoFormat("SetUnits({0})", unit);
|
||||
log.InfoFormat("{0} - SetUnits({1})", Name, unit);
|
||||
|
||||
msrmntState = MsrmntState.Busy;
|
||||
stringBuilder.Clear();
|
||||
@@ -235,14 +235,14 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
return;
|
||||
}
|
||||
|
||||
log.Debug("RunDevice()");
|
||||
log.DebugFormat("{0} - RunDevice()", Name);
|
||||
|
||||
if (msrmntState != MsrmntState.Busy) return; /// No measurement in progress
|
||||
|
||||
string justReceived = serialPort.ReadExisting();
|
||||
if (justReceived != null && justReceived.Length > 0)
|
||||
{
|
||||
log.Debug("RunDevice() received " + justReceived);
|
||||
log.DebugFormat("{0} - RunDevice() received {1}", Name, justReceived);
|
||||
stringBuilder.Append(justReceived);
|
||||
}
|
||||
|
||||
@@ -276,13 +276,13 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
mass = 0;
|
||||
Masses[balanceNr] = mass;
|
||||
//msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("Balance response = \"{0}<cr><lf>\"", received);
|
||||
log.InfoFormat("{0} - Balance response = \"{1}<cr><lf>\"", Name, received);
|
||||
return;
|
||||
}
|
||||
else if (fields.Length < 2)
|
||||
{
|
||||
msrmntState = MsrmntState.Failed;
|
||||
log.WarnFormat("Balance response = \"{0}<cr><lf>\", Unexpected error !!!", received);
|
||||
log.WarnFormat("{0} - Balance response = \"{1}<cr><lf>\", Unexpected error !!!", Name, received);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -293,13 +293,13 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
mass = 0;
|
||||
Masses[balanceNr] = mass;
|
||||
//msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("Balance response = \"{0}<cr><lf>\"", received);
|
||||
log.InfoFormat("{0} - Balance response = \"{1}<cr><lf>\"", Name, received);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
msrmntState = MsrmntState.Failed;
|
||||
log.WarnFormat("Balance response = \"{0}<cr><lf>\", error !!!", received);
|
||||
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"
|
||||
@@ -314,19 +314,19 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
if (fields[2].Equals("t")) mass *= 1000.0f;
|
||||
Masses[balanceNr] = mass;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("Balance response = \"{0}<cr><lf>\", Mass = {1}", received, mass);
|
||||
log.InfoFormat("{0} - Balance response = \"{1}<cr><lf>\", Mass = {2}", Name, received, mass);
|
||||
}
|
||||
else if (fields.Length == 2 && fields[1].Equals("-"))
|
||||
{
|
||||
mass = 0;
|
||||
Masses[balanceNr] = mass;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("Balance response = \"{0}<cr><lf>\", Mass = {1}", received, mass);
|
||||
log.InfoFormat("{0} - Balance response = \"{1}<cr><lf>\", Mass = {2}", Name, received, mass);
|
||||
}
|
||||
else
|
||||
{
|
||||
msrmntState = MsrmntState.Failed;
|
||||
log.WarnFormat("Balance response = \"{0}<cr><lf>\", Overload or and unexpected error !!!", received);
|
||||
log.WarnFormat("{0} Balance response = \"{1}<cr><lf>\", Overload or and unexpected error !!!", Name, received);
|
||||
bool b = float.TryParse(fields[1], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out mass);
|
||||
|
||||
}
|
||||
@@ -343,19 +343,19 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
if (fields[2].Equals("t")) mass *= 1000.0f;
|
||||
Masses[balanceNr] = mass;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("Balance response = \"{0}<cr><lf>\", Mass = {1}", received, mass);
|
||||
log.InfoFormat("{0} - Balance response = \"{1}<cr><lf>\", Mass = {2}", Name, received, mass);
|
||||
}
|
||||
else if (fields.Length == 2 && fields[1].Equals("-"))
|
||||
{
|
||||
mass = 0;
|
||||
Masses[balanceNr] = mass;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("Balance response = \"{0}<cr><lf>\", Mass = {1}", received, mass);
|
||||
log.InfoFormat("{0} - Balance response = \"{1}<cr><lf>\", Mass = {2}", Name, received, mass);
|
||||
}
|
||||
else
|
||||
{
|
||||
msrmntState = MsrmntState.Failed;
|
||||
log.WarnFormat("Balance response = \"{0}<cr><lf>\", Overload or and unexpected error !!!", received);
|
||||
log.WarnFormat("{0} - Balance response = \"{1}<cr><lf>\", Overload or and unexpected error !!!", Name, received);
|
||||
bool b = float.TryParse(fields[1], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out mass);
|
||||
|
||||
}
|
||||
@@ -371,18 +371,18 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
if (fields[2].Equals("g")) mass /= 1000.0f;
|
||||
if (fields[2].Equals("t")) mass *= 1000.0f;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("Balance response = \"{0}<cr><lf>\", Tara = {1}", received, mass);
|
||||
log.InfoFormat("{0} - Balance response = \"{1}<cr><lf>\", Tara = {2}", Name, received, mass);
|
||||
}
|
||||
else
|
||||
{
|
||||
msrmntState = MsrmntState.Failed;
|
||||
log.WarnFormat("Balance response = \"{0}<cr><lf>\", Overload or and unexpected error !!!", received);
|
||||
log.WarnFormat("{0} - Balance response = \"{1}<cr><lf>\", Overload or and unexpected error !!!", Name, received);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
msrmntState = MsrmntState.Failed;
|
||||
log.WarnFormat("Balance response = \"{0}<cr><lf>\", Unexpected error !!!", received);
|
||||
log.WarnFormat("{0} - Balance response = \"{1}<cr><lf>\", Unexpected error !!!", Name, received);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,11 +46,11 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
|
||||
if (msrmntState == MsrmntState.Busy)
|
||||
{
|
||||
log.Warn("GetSerialNumber() returns without getting the s/n because measurementState == MeasurementState.Busy");
|
||||
log.WarnFormat("{0} - GetSerialNumber() returns without getting the s/n because measurementState == MeasurementState.Busy", Name);
|
||||
return;
|
||||
}
|
||||
|
||||
log.Info("GetSerialNumber()");
|
||||
log.InfoFormat("{0} - GetSerialNumber()", Name);
|
||||
|
||||
msrmntState = MsrmntState.Busy;
|
||||
stringBuilder.Clear();
|
||||
@@ -72,14 +72,14 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
return;
|
||||
}
|
||||
|
||||
log.Debug("RunDevice()");
|
||||
log.DebugFormat("{0} - RunDevice()", Name);
|
||||
|
||||
if (base.msrmntState != MsrmntState.Busy) return; /// No measurement in progress
|
||||
|
||||
string justReceived = serialPort.ReadExisting();
|
||||
if (justReceived != null && justReceived.Length > 0)
|
||||
{
|
||||
log.Debug("RunDevice() received " + justReceived);
|
||||
log.DebugFormat("{0} - RunDevice() received {1}", Name, justReceived);
|
||||
stringBuilder.Append(justReceived);
|
||||
|
||||
if (stringBuilder.ToString().EndsWith("\r\n"))
|
||||
@@ -99,7 +99,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
if (fields.Length < 2)
|
||||
{
|
||||
msrmntState = MsrmntState.Failed;
|
||||
log.WarnFormat("Balance response = {0}, Unexpected error !!!",
|
||||
log.WarnFormat("{0} - Balance response = {1}, Unexpected error !!!", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
return;
|
||||
}
|
||||
@@ -110,13 +110,13 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
{
|
||||
serialNumber = fields[2].Substring(1, fields[2].Length - 2);
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("Balance response = {0}, s/n = {1}",
|
||||
log.InfoFormat("{0} - Balance response = {1}, s/n = {1}", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"), serialNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
msrmntState = MsrmntState.Failed;
|
||||
log.WarnFormat("Balance response = {0}, error !!!",
|
||||
log.WarnFormat("{0} - Balance response = {1}, error !!!", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
}
|
||||
}
|
||||
@@ -127,13 +127,13 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
mass = 0;
|
||||
Masses[balanceNr] = mass;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("Balance response = {0}",
|
||||
log.InfoFormat("{0} - Balance response = {1}", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
}
|
||||
else
|
||||
{
|
||||
msrmntState = MsrmntState.Failed;
|
||||
log.WarnFormat("Balance response = \"{0}\", error !!!",
|
||||
log.WarnFormat("{0} - Balance response = \"{1}\", error !!!", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
if (fields[3].Equals("t")) mass *= 1000.0f;
|
||||
Masses[balanceNr] = mass;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("Balance response = {0}, Mass = {1}",
|
||||
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") &&
|
||||
@@ -158,7 +158,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
if (fields[3].Equals("t")) mass *= 1000.0f;
|
||||
Masses[balanceNr] = mass;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("Balance response = {0}, Mass = {1}",
|
||||
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("-"))
|
||||
@@ -166,7 +166,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
mass = 0;
|
||||
Masses[balanceNr] = mass;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("Balance response = {0}, Mass = {1}",
|
||||
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("+"))
|
||||
@@ -174,7 +174,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
mass = Capacity;
|
||||
Masses[balanceNr] = mass;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("Balance response = {0}, Overload",
|
||||
log.InfoFormat("{0} - Balance response = {1}, Overload", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
}
|
||||
else if (fields.Length >= 2 && fields[1].Equals("I"))
|
||||
@@ -182,13 +182,13 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
mass = balanceCfg.Capacity;
|
||||
Masses[balanceNr] = mass;
|
||||
msrmntState = MsrmntState.Overload;
|
||||
log.InfoFormat("Balance response = {0}, Overload",
|
||||
log.InfoFormat("{0} - Balance response = {1}, Overload", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"), mass);
|
||||
}
|
||||
else
|
||||
{
|
||||
msrmntState = MsrmntState.Failed;
|
||||
log.WarnFormat("Balance response = \"{0}\", Overload or and unexpected error !!!",
|
||||
log.WarnFormat("{0} - Balance response = \"{1}\", Overload or and unexpected error !!!", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
}
|
||||
}
|
||||
@@ -201,20 +201,20 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
if (fields[3].Equals("g")) mass /= 1000.0f;
|
||||
if (fields[3].Equals("t")) mass *= 1000.0f;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("Balance response = {0}, Mass = {1}",
|
||||
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"))
|
||||
{
|
||||
mass = mass = balanceCfg.Capacity;
|
||||
msrmntState = MsrmntState.Overload;
|
||||
log.InfoFormat("Balance response = {0}, Overload",
|
||||
log.InfoFormat("{0} - Balance response = {1}, Overload", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"), mass);
|
||||
}
|
||||
else
|
||||
{
|
||||
msrmntState = MsrmntState.Failed;
|
||||
log.WarnFormat("Balance response = \"{0}\", Overload or and unexpected error !!!",
|
||||
log.WarnFormat("{0} - Balance response = \"{1}\", Overload or and unexpected error !!!", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
}
|
||||
}
|
||||
@@ -223,13 +223,13 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
if (fields.Length == 2 && fields[1].Equals("A"))
|
||||
{
|
||||
msrmntState = MsrmntState.Valid;
|
||||
log.InfoFormat("Balance response = \"{0}\"",
|
||||
log.InfoFormat("{0} - Balance response = \"{1}\"", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
}
|
||||
else
|
||||
{
|
||||
msrmntState = MsrmntState.Failed;
|
||||
log.WarnFormat("Balance response = \"{0}\", Unexpected error !!!",
|
||||
log.WarnFormat("{0} - Balance response = \"{1}\", Unexpected error !!!", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
}
|
||||
}
|
||||
@@ -241,7 +241,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
Masses[balanceNr] = mass;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
//msrmntState = MsrmntState.Overload;
|
||||
log.WarnFormat("Balance response = \"{0}\", Overload.",
|
||||
log.WarnFormat("{0} - Balance response = \"{1}\", Overload.", Name,
|
||||
received.Replace("\r", "<cr>").Replace("\n", "<lf>"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
log.Debug("Start()");
|
||||
log.Debug("{0} - Start()", balanceDev.Name);
|
||||
balanceDev.GetSerialNumber();
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
log.Debug("Stop()");
|
||||
log.Debug("{0} - Stop()", balanceDev.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
log.Debug("Start()");
|
||||
log.Debug("{0} - Start()", balanceDev.Name);
|
||||
balanceDev.SetUnits(units);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
log.Debug("Stop()");
|
||||
log.Debug("{0} - Stop()", balanceDev.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
log.Debug("{0} - Start()", balanceDev.Name);
|
||||
done = false;
|
||||
balanceDev.Taring();
|
||||
}
|
||||
@@ -74,6 +75,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
log.Debug("{0} - Stop()", balanceDev.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user