62 lines
1.7 KiB
C#
62 lines
1.7 KiB
C#
///
|
|
/// Copyright (c) 2017 Sensus Metering Systems
|
|
///
|
|
using System;
|
|
using log4net;
|
|
using TBF.Boxes;
|
|
|
|
namespace TBF.BenchControl.Modbus.Easytherm
|
|
{
|
|
public class ReadTempOp : IOperation
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(ReadTempOp));
|
|
public override string ToString() { return string.Format("ReadTempOp({0},.,{1})", easytherm.Name, eventDone); }
|
|
|
|
/// Set by the constructor
|
|
Easytherm easytherm;
|
|
Event eventDone;
|
|
DoubleBox temp;
|
|
|
|
/// <summary>
|
|
/// Events: TempInDone, TempOutDone, TempDivDone or Error
|
|
/// </summary>
|
|
/// <param name="easytherm">TempMeter reference</param>
|
|
/// <param name="temp">Reference to the variable, value is in degree Celsius</param>
|
|
/// <param name="eventDone">Event to be returned by Run() when completed OK</param>
|
|
public ReadTempOp(Easytherm easytherm, ref DoubleBox temp, Event eventDone)
|
|
{
|
|
if (easytherm == null) throw new ArgumentNullException("easytherm");
|
|
this.easytherm = easytherm;
|
|
this.temp = temp;
|
|
this.eventDone = eventDone;
|
|
log.Debug(this.ToString());
|
|
}
|
|
|
|
public ReadTempOp(Easytherm tempMeter, ref DoubleBox temp)
|
|
: this(tempMeter, ref temp, Event.TempDone)
|
|
{
|
|
}
|
|
|
|
/// <summary>Start this operation</summary>
|
|
public void Start()
|
|
{
|
|
temp.Val = easytherm.ReadTemperature();
|
|
}
|
|
|
|
/// <summary>Run this operation</summary>
|
|
/// <returns>
|
|
/// Event.TempInDone, Event.TempOutDone or Event.TempDivDone
|
|
/// </returns>
|
|
public Event Run()
|
|
{
|
|
temp.Val = easytherm.ReadTemperature();
|
|
return eventDone;
|
|
}
|
|
|
|
/// <summary>Stop this operation</summary>
|
|
public void Stop()
|
|
{
|
|
}
|
|
}
|
|
}
|