77 lines
2.3 KiB
C#
77 lines
2.3 KiB
C#
///
|
|
/// Copyright (c) 2022 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using log4net;
|
|
using TBF.Boxes;
|
|
|
|
namespace TBF.Rig.Modbus.TempControl.Novus
|
|
{
|
|
public enum SetpSource
|
|
{
|
|
TempArgument,
|
|
ProcParamA,
|
|
ProcParamB,
|
|
ProcParamC,
|
|
ProcParamD,
|
|
ProcParamE
|
|
}
|
|
|
|
public class SetTemperatureSetpointOp : IOperation
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(SetTemperatureSetpointOp));
|
|
public override string ToString() { return string.Format("SetTemperatureSetpointOp({0})", eventDone); }
|
|
|
|
/// Set by the constructor
|
|
readonly TControl tempControl;
|
|
readonly SetpSource spSrc;
|
|
readonly double temperature;
|
|
readonly Event eventDone;
|
|
|
|
/// <summary>
|
|
/// Events: PressureInDone, PressureOutDone or Error
|
|
/// </summary>
|
|
/// <param name="tempControl">Temp. controller reference</param>
|
|
/// <param name="eventDone">Event to be returned by Run() when completed OK</param>
|
|
public SetTemperatureSetpointOp(TControl tempControl, SetpSource spSrc, double temperature, Event eventDone = Event.ConditionNotMet)
|
|
{
|
|
if (tempControl == null) throw new ArgumentNullException("tempControl");
|
|
this.tempControl = tempControl;
|
|
this.spSrc = spSrc;
|
|
this.temperature = temperature;
|
|
this.eventDone = eventDone;
|
|
|
|
log.Debug(this.ToString());
|
|
}
|
|
|
|
/// <summary>Start this operation</summary>
|
|
public void Start()
|
|
{
|
|
double selectedTemp;
|
|
switch (spSrc)
|
|
{
|
|
default:
|
|
case SetpSource.TempArgument: selectedTemp = temperature; break;
|
|
case SetpSource.ProcParamA: selectedTemp = tempControl.ProcParamA; break;
|
|
case SetpSource.ProcParamB: selectedTemp = tempControl.ProcParamB; break;
|
|
case SetpSource.ProcParamC: selectedTemp = tempControl.ProcParamC; break;
|
|
case SetpSource.ProcParamD: selectedTemp = tempControl.ProcParamD; break;
|
|
case SetpSource.ProcParamE: selectedTemp = tempControl.ProcParamE; break;
|
|
}
|
|
|
|
tempControl.SetTemperatureSetpoint(selectedTemp);
|
|
}
|
|
|
|
/// <summary>Run this operation</summary>
|
|
public Event Run()
|
|
{
|
|
return eventDone;
|
|
}
|
|
|
|
/// <summary>Stop this operation</summary>
|
|
public void Stop()
|
|
{
|
|
}
|
|
}
|
|
}
|