59 lines
1.5 KiB
C#
59 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using log4net;
|
|
|
|
namespace TBF.BenchControl.MettlerToledo
|
|
{
|
|
public class SetUnitsOp : IOperation
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(SetUnitsOp));
|
|
public override string ToString() { return string.Format("SetUnitsOp({0})", units); }
|
|
|
|
/// Set by the constructor
|
|
BalanceDev balanceDev;
|
|
BalanceDev.Units units;
|
|
|
|
/// <summary>
|
|
/// Events: BalanceDone, Error
|
|
/// </summary>
|
|
/// <param name="balanceDev">Balance device instance</param>
|
|
/// <param name="result">Reference to the serialNumber</param>
|
|
public SetUnitsOp(BalanceDev balanceDev, BalanceDev.Units units)
|
|
{
|
|
if (balanceDev == null) throw new ArgumentNullException("balanceDev");
|
|
this.balanceDev = balanceDev;
|
|
|
|
this.units = units;
|
|
|
|
log.Debug(this.ToString());
|
|
}
|
|
|
|
/// <summary>Start this operation</summary>
|
|
public void Start()
|
|
{
|
|
log.Debug("Start()");
|
|
balanceDev.SetUnits(units);
|
|
}
|
|
|
|
/// <summary>Run this operation</summary>
|
|
/// <returns>
|
|
/// Event.None
|
|
/// Event.BalanceDone
|
|
/// </returns>
|
|
public Event Run()
|
|
{
|
|
if (balanceDev.MsrmntState == MsrmntState.Valid) return Event.BalanceDone; /// Units set
|
|
if (balanceDev.MsrmntState == MsrmntState.Failed) return Event.Error; /// Failed
|
|
return Event.None; /// No result yet
|
|
}
|
|
|
|
/// <summary>Stop this operation</summary>
|
|
public void Stop()
|
|
{
|
|
log.Debug("Stop()");
|
|
}
|
|
}
|
|
}
|