ReadMassOp fixed, was freezing when draining tanks, ver. 2.12.547
This commit is contained in:
@@ -16,19 +16,19 @@ namespace TBF.BenchControl.MettlerToledo.Multi
|
||||
bool done;
|
||||
|
||||
/// Set by the constructor
|
||||
BalanceDev balanceDev;
|
||||
BalanceDev scale;
|
||||
DoubleBox result;
|
||||
|
||||
/// <summary>
|
||||
/// Events: BalanceDone, Error
|
||||
/// </summary>
|
||||
/// <param name="balanceDev">Balance device instance</param>
|
||||
/// <param name="scale">Balance device instance</param>
|
||||
/// <param name="requiredReadingsCount">Required mass readings count (>= 3)</param>
|
||||
/// <param name="result">Reference to the measured mass in kg</param>
|
||||
public ReadMassOp(BalanceDev balanceDev, ref DoubleBox result)
|
||||
public ReadMassOp(BalanceDev scale, ref DoubleBox result)
|
||||
{
|
||||
if (balanceDev == null) throw new ArgumentNullException("balanceDev");
|
||||
this.balanceDev = balanceDev;
|
||||
if (scale == null) throw new ArgumentNullException("scale");
|
||||
this.scale = scale;
|
||||
|
||||
this.result = result;
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi
|
||||
public void Start()
|
||||
{
|
||||
done = false;
|
||||
started = BalanceDev.GetImmediateMassMeasurement(balanceDev.IdNr, balanceDev.Name);
|
||||
started = BalanceDev.GetImmediateMassMeasurement(scale.IdNr, scale.Name);
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
@@ -52,22 +52,21 @@ namespace TBF.BenchControl.MettlerToledo.Multi
|
||||
{
|
||||
if (!started)
|
||||
{
|
||||
started = BalanceDev.GetImmediateMassMeasurement(balanceDev.IdNr, balanceDev.Name);
|
||||
if (!done) return Event.Busy;
|
||||
else return Event.BalanceDone;
|
||||
started = BalanceDev.GetImmediateMassMeasurement(scale.IdNr, scale.Name);
|
||||
if (!done)
|
||||
return Event.Busy;
|
||||
else
|
||||
return Event.BalanceDone;
|
||||
}
|
||||
else if (started && balanceDev.MsrmntState == MsrmntState.Valid)
|
||||
else if (started && scale.MsrmntState != MsrmntState.Busy)
|
||||
{
|
||||
result.Val = balanceDev.Mass;
|
||||
log.InfoFormat("ReadMassOp.Run() ... mass={0} ... returning Event.BalanceDone", balanceDev.Mass);
|
||||
if (scale.MsrmntState == MsrmntState.Valid) result.Val = scale.Mass;
|
||||
log.InfoFormat("ReadMassOp.Run() ... state={0}, mass={1} ... returning Event.BalanceDone",
|
||||
scale.MsrmntState, scale.Mass);
|
||||
done = true;
|
||||
started = false;
|
||||
return Event.BalanceDone; /// Mass read OK
|
||||
}
|
||||
else if (done)
|
||||
{
|
||||
return Event.BalanceDone; /// Mass has already been read (at least once)
|
||||
}
|
||||
else
|
||||
{
|
||||
return Event.Busy;
|
||||
|
||||
Reference in New Issue
Block a user