ReadMassesOp operation corrected. Works with both scales (Standard/Multi)
This commit is contained in:
@@ -1,63 +0,0 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using log4net;
|
||||
|
||||
namespace TBF.BenchControl.MettlerToledo.Multi
|
||||
{
|
||||
public class ReadMassesOp : IOperation
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(ReadMassesOp));
|
||||
public override string ToString() { return string.Format("ReadMassesOp()"); }
|
||||
|
||||
bool done;
|
||||
|
||||
/// <summary>
|
||||
/// Events: BalanceDone, Error
|
||||
/// </summary>
|
||||
/// <param name="balanceDev">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 ReadMassesOp()
|
||||
{
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
done = false;
|
||||
for (int i = 0; i < BalanceDev.BalancesCount; i++)
|
||||
{
|
||||
BalanceDev.Balances[i].GetImmediateMassMeasurement();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns>
|
||||
/// Event.None
|
||||
/// Event.BalanceDone
|
||||
/// Event.Error . . . . . Current.Tick == null
|
||||
/// </returns>
|
||||
public Event Run()
|
||||
{
|
||||
if (done) return Event.BalanceDone; /// Mass has already been read
|
||||
|
||||
for (int i = 0; i < BalanceDev.BalancesCount; i++)
|
||||
{
|
||||
if (BalanceDev.Balances[i].MsrmntState == MsrmntState.Busy)
|
||||
{
|
||||
return Event.None;
|
||||
}
|
||||
}
|
||||
done = true;
|
||||
return Event.BalanceDone;
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user