59 lines
1.5 KiB
C#
59 lines
1.5 KiB
C#
///
|
|
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using log4net;
|
|
using TBF.Boxes;
|
|
|
|
namespace TBF.BenchControl.Modbus.UltrasoundLevelMeter
|
|
{
|
|
public class ReadStableLevelOp : IOperation
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(ReadLevelOp));
|
|
public override string ToString() { return string.Format("ReadLevelOp(.,.)"); }
|
|
|
|
/// Set by the constructor
|
|
readonly LevelMeter levelMeter;
|
|
readonly DoubleBox level;
|
|
readonly double sdev;
|
|
|
|
/// <summary>
|
|
/// Events: LevelDone or Error
|
|
/// </summary>
|
|
/// <param name="levelMeter">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 ReadStableLevelOp(LevelMeter levelMeter, ref DoubleBox level, double sdev)
|
|
{
|
|
if (levelMeter == null) throw new ArgumentNullException("levelMeter");
|
|
this.levelMeter = levelMeter;
|
|
this.level = level;
|
|
this.sdev = sdev;
|
|
|
|
log.Debug(this.ToString());
|
|
}
|
|
|
|
|
|
/// <summary>Start this operation</summary>
|
|
public void Start()
|
|
{
|
|
level.Val = levelMeter.ReadLevel();
|
|
}
|
|
|
|
/// <summary>Run this operation</summary>
|
|
/// <returns>
|
|
/// Event.LevelDone
|
|
/// </returns>
|
|
public Event Run()
|
|
{
|
|
level.Val = levelMeter.ReadLevel();
|
|
return Event.LevelDone;
|
|
}
|
|
|
|
/// <summary>Stop this operation</summary>
|
|
public void Stop()
|
|
{
|
|
}
|
|
}
|
|
}
|