/// /// Copyright (c) 2013-2015 Sensus Metering Systems /// using System; using log4net; namespace TBF.BenchControl.MettlerToledo { public class ReadMassesOp : IOperation { private static readonly ILog log = LogManager.GetLogger(typeof(ReadMassesOp)); public override string ToString() { return string.Format("ReadMassesOp()"); } bool done; /// /// Events: BalanceDone, Error /// /// Balance device instance /// Required mass readings count (>= 3) /// Reference to the measured mass in kg public ReadMassesOp() { log.Debug(this.ToString()); } /// Start this operation public void Start() { done = false; for (int i = 0; i < Standard.BalanceDev.BalancesCount; i++) { Standard.BalanceDev.Balances[i].GetImmediateMassMeasurement(); } } /// Run this operation /// /// Event.None /// Event.BalanceDone /// Event.Error . . . . . Current.Tick == null /// public Event Run() { if (done) return Event.BalanceDone; /// Mass has already been read for (int i = 0; i < Standard.BalanceDev.BalancesCount; i++) { if (Standard.BalanceDev.Balances[i].MsrmntState == MsrmntState.Busy) { return Event.None; } } for (int i = 0; i < Multi.BalanceDev.BalancesCount; i++) { if (Multi.BalanceDev.Balances[i].MsrmntState == MsrmntState.Busy) { return Event.None; } } done = true; return Event.BalanceDone; } /// Stop this operation public void Stop() { } } }