More logging in MettlerToledo.Standard component

This commit is contained in:
Milan Hanajik
2015-05-21 14:24:07 +02:00
parent a1668dc5dd
commit 31dc55ac35
5 changed files with 52 additions and 50 deletions
@@ -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>"));
}
}