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; /// /// Events: BalanceDone, Error /// /// Balance device instance /// Reference to the serialNumber public SetUnitsOp(BalanceDev balanceDev, BalanceDev.Units units) { if (balanceDev == null) throw new ArgumentNullException("balanceDev"); this.balanceDev = balanceDev; this.units = units; log.Debug(this.ToString()); } /// Start this operation public void Start() { log.Debug("Start()"); balanceDev.SetUnits(units); } /// Run this operation /// /// Event.None /// Event.BalanceDone /// 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 } /// Stop this operation public void Stop() { log.Debug("Stop()"); } } }