MettlerToledo scales moved one level down in the directory and namespace structure.
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using log4net;
|
||||
using TBF.Boxes;
|
||||
|
||||
namespace TBF.BenchControl.MettlerToledo.Standard
|
||||
{
|
||||
public class TaringOp : IOperation
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(TaringOp));
|
||||
public override string ToString() { return string.Format("TaringOp(.,.)"); }
|
||||
|
||||
bool done;
|
||||
|
||||
/// Set by the constructor
|
||||
BalanceDev balanceDev;
|
||||
FloatBox tara;
|
||||
|
||||
/// <summary>
|
||||
/// Events: BalanceDone, Error
|
||||
/// </summary>
|
||||
/// <param name="balanceDev">Balance device instance</param>
|
||||
/// <param name="result">Reference to variable for 'tara' in kg</param>
|
||||
public TaringOp(BalanceDev balanceDev, ref FloatBox tara)
|
||||
{
|
||||
if (balanceDev == null) throw new ArgumentNullException("balanceDev");
|
||||
this.balanceDev = balanceDev;
|
||||
|
||||
this.tara = tara;
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
done = false;
|
||||
balanceDev.Taring();
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns>
|
||||
/// Event.None
|
||||
/// Event.BalanceDone
|
||||
/// Event.Error . . . . . Current.Tick == null
|
||||
/// </returns>
|
||||
public Event Run()
|
||||
{
|
||||
if (done) return Event.BalanceDone; /// Taring has been done already
|
||||
|
||||
if (balanceDev.MsrmntState == MsrmntState.Busy) return Event.Busy;
|
||||
|
||||
if (balanceDev.MsrmntState == MsrmntState.Overload)
|
||||
{
|
||||
tara.Val = balanceDev.Capacity;
|
||||
done = true;
|
||||
return Event.BalanceOverload;
|
||||
}
|
||||
|
||||
if (balanceDev.MsrmntState == MsrmntState.Valid)
|
||||
{
|
||||
tara.Val = balanceDev.Mass;
|
||||
done = true;
|
||||
return Event.BalanceDone; /// Taring completed
|
||||
}
|
||||
|
||||
balanceDev.Taring(); /// Failed -> repeat taring
|
||||
return Event.Busy;
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user