Refactorization : BenchControl -> Rig
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2016 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using log4net;
|
||||
using TBF.Boxes;
|
||||
|
||||
namespace TBF.Rig.MettlerToledo.Multi
|
||||
{
|
||||
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;
|
||||
DoubleBox 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 DoubleBox 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()
|
||||
{
|
||||
tara.Val = 0.0f; // Don't do anything, tara = 0
|
||||
done = true;
|
||||
}
|
||||
|
||||
/// <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
|
||||
}
|
||||
|
||||
return Event.Busy;
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user