69 lines
1.8 KiB
C#
69 lines
1.8 KiB
C#
///
|
|
/// Copyright (c) 2015-2020 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using log4net;
|
|
|
|
namespace TBF.BenchControl.MettlerToledo.Multi
|
|
{
|
|
public class ZeroOp : IOperation
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(ZeroOp));
|
|
public override string ToString() { return string.Format("ZeroOp(.,.)"); }
|
|
|
|
bool done;
|
|
|
|
/// Set by the constructor
|
|
BalanceDev balanceDev;
|
|
|
|
/// <summary>
|
|
/// Events: BalanceDone, Error
|
|
/// </summary>
|
|
/// <param name="balanceDev">Balance device instance</param>
|
|
public ZeroOp(BalanceDev balanceDev)
|
|
{
|
|
if (balanceDev == null) throw new ArgumentNullException("balanceDev");
|
|
this.balanceDev = balanceDev;
|
|
log.Debug(this.ToString());
|
|
}
|
|
|
|
/// <summary>Start this operation</summary>
|
|
public void Start()
|
|
{
|
|
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; /// Zero has been done already
|
|
|
|
if (balanceDev.MsrmntState == MsrmntState.Busy) return Event.Busy;
|
|
|
|
if (balanceDev.MsrmntState == MsrmntState.Overload)
|
|
{
|
|
done = true;
|
|
return Event.BalanceOverload;
|
|
}
|
|
|
|
if (balanceDev.MsrmntState == MsrmntState.Valid)
|
|
{
|
|
done = true;
|
|
return Event.BalanceDone; /// Zero completed
|
|
}
|
|
|
|
return Event.Busy;
|
|
}
|
|
|
|
/// <summary>Stop this operation</summary>
|
|
public void Stop()
|
|
{
|
|
}
|
|
}
|
|
}
|