Refactorization : BenchControl -> Rig
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
///
|
||||
/// Copyright (c) 2020 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using log4net;
|
||||
using TBF.Boxes;
|
||||
|
||||
namespace TBF.Rig.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;
|
||||
|
||||
/// <summary>
|
||||
/// Events: eventDone or Error
|
||||
/// </summary>
|
||||
/// <param name="analyzer">Water temperature meter reference</param>
|
||||
/// <param name="temperature">Reference to the measured temperature variable, value is in l</param>
|
||||
/// <param name="eventDone">Event to be returned by Run() when completed OK</param>
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
temperature.Val = analyzer.ReadTemperature();
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns>
|
||||
/// Event.temperatureDone
|
||||
/// </returns>
|
||||
public Event Run()
|
||||
{
|
||||
temperature.Val = analyzer.ReadTemperature();
|
||||
return eventDone;
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user