63 lines
1.7 KiB
C#
63 lines
1.7 KiB
C#
///
|
|
/// Copyright (c) 2020 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using log4net;
|
|
using TBF.Boxes;
|
|
|
|
namespace TBF.BenchControl.Modbus.TempMeter.Meret
|
|
{
|
|
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 TempMeter tempMeter;
|
|
readonly Event eventDone;
|
|
readonly DoubleBox temp; /// Box for the measured value
|
|
|
|
/// <summary>
|
|
/// Events: TempDone or Error
|
|
/// </summary>
|
|
/// <param name="tempMeter">Pressure meter reference</param>
|
|
/// <param name="temp">Reference to the measured pressure variable, value is in bar</param>
|
|
/// <param name="eventDone">Event to be returned by Run() when completed OK</param>
|
|
public ReadTempOp(TempMeter tempMeter, ref DoubleBox temp, Event eventDone)
|
|
{
|
|
if (tempMeter == null) throw new ArgumentNullException("tempMeter");
|
|
this.tempMeter = tempMeter;
|
|
this.temp = temp;
|
|
this.eventDone = eventDone;
|
|
|
|
log.Debug(this.ToString());
|
|
}
|
|
public ReadTempOp(TempMeter pressureMeter, ref DoubleBox temp)
|
|
: this(pressureMeter, ref temp, Event.TempDone)
|
|
{
|
|
}
|
|
|
|
|
|
/// <summary>Start this operation</summary>
|
|
public void Start()
|
|
{
|
|
if (temp != null) temp.Val = tempMeter.ReadTemperature();
|
|
}
|
|
|
|
/// <summary>Run this operation</summary>
|
|
/// <returns>
|
|
/// Event.PressureInDone or Event.PressureOutDone
|
|
/// </returns>
|
|
public Event Run()
|
|
{
|
|
if (temp != null) temp.Val = tempMeter.ReadTemperature();
|
|
return eventDone;
|
|
}
|
|
|
|
/// <summary>Stop this operation</summary>
|
|
public void Stop()
|
|
{
|
|
}
|
|
}
|
|
}
|