/// /// Copyright (c) 2017 Sensus Metering Systems /// using System; using log4net; using TBF.Boxes; namespace TBF.BenchControl.Dummy.FlowMeter { public class ReadFlowOp : IOperation { private static readonly ILog log = LogManager.GetLogger(typeof(ReadFlowOp)); public override string ToString() { return string.Format("ReadFlowOp(.,{0},{1},.)", eventDone); } /// Set by the constructor readonly FlowMeter flowMeter; readonly DoubleBox flowBox; readonly Event eventDone; /// /// Events: FlowInDone, FlowOutDone or Error /// /// Flow meter reference /// Reference to the measured flow variable, value is in bar /// Event to be returned by Run() when completed OK public ReadFlowOp(FlowMeter flowMeter, ref DoubleBox flowBox, Event eventDone) { if (flowMeter == null) throw new ArgumentNullException("flowMeter"); this.flowMeter = flowMeter; this.eventDone = eventDone; this.flowBox = flowBox; log.Debug(this.ToString()); } public ReadFlowOp(FlowMeter flowMeter, ref DoubleBox flow) : this(flowMeter, ref flow, Event.FlowMeasurementDone) { } /// Start this operation public void Start() { } /// Run this operation /// /// Event.FlowInDone or Event.FlowOutDone /// public Event Run() { if (flowBox != null) flowBox.Val = flowMeter.ReadFlow(); return eventDone; } /// Stop this operation public void Stop() { } } }