tbf/TBF/BenchControl/Modbus/WaterAnalyzer/ReadConductivityOp.cs
2020-04-21 09:12:56 +02:00

59 lines
1.5 KiB
C#

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