/// /// Copyright (c) 2020 Sensus Slovensko a.s. /// using System; using log4net; using TBF.Boxes; namespace TBF.BenchControl.Modbus.WaterAnalyzer { public class ReadTempOp : IOperation { private static readonly ILog log = LogManager.GetLogger(typeof(ReadTempOp)); public override string ToString() { return string.Format("ReadTempOp(.,{0},.)", eventDone); } /// Set by the constructor readonly Analyzer analyzer; readonly Event eventDone; /// Measured value DoubleBox temperature; /// /// Events: eventDone or Error /// /// Water temperature meter reference /// Reference to the measured temperature variable, value is in l /// Event to be returned by Run() when completed OK public ReadTempOp(Analyzer analyzer, ref DoubleBox temperature, Event eventDone) { if (analyzer == null) throw new ArgumentNullException("analyzer"); this.analyzer = analyzer; this.temperature = temperature; this.eventDone = eventDone; log.Debug(this.ToString()); } public ReadTempOp(Analyzer levelMeter, ref DoubleBox temperature) : this(levelMeter, ref temperature, Event.TempDone) { } /// Start this operation public void Start() { temperature.Val = analyzer.ReadTemperature(); } /// Run this operation /// /// Event.temperatureDone /// public Event Run() { temperature.Val = analyzer.ReadTemperature(); return eventDone; } /// Stop this operation public void Stop() { } } }