tbf/TestBenchFramework/BenchControl/Dummy/RegulValve/RegulValve.cs

99 lines
3.7 KiB
C#

///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System.Collections.Generic;
using log4net;
using TBF.BenchControl.Generic;
using TBF.Boxes;
namespace TBF.BenchControl.Dummy.RegulValve
{
public class RegulValve : ComponentBase, IDevice, GenericDevices.IRegulValve
{
private static readonly ILog log = LogManager.GetLogger(typeof(RegulValve));
public override string ToString() { return string.Format("RegulValve({0})", Cfg.ToString(1)); }
public readonly RegulValveCfg RegulValveCfg;
public ValveCategory Category { get { return RegulValveCfg.Category; } }
///
public bool IsCoax { get { return false; } }
public float Position { get { return 50.0f; } }
IDictionary<float, float> dict;
public IDictionary<float, float> Dict { get { return dict; } }
public RegulValve()
{
}
public RegulValve(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
RegulValveCfg = cfg as RegulValveCfg;
dict = new Dictionary<float, float>();
log.Debug(this.ToString());
}
public void Initialize() { }
public void RunDeviceBefore() { }
public void RunDeviceAfter() { }
public void StopDevice() { }
/// <summary>
/// Operation to set the water flow within tolerances
/// Events: Event.None, Event.FlowReached, Event.FlowTimeOut
/// </summary>
/// <param name="flowMeter">Flowmeter component</param>
/// <param name="requiredFlowLo">Lower limit of the required flow [m3/h]</param>
/// <param name="requiredFlowHi">Higher limit of the required flow [m3/h]</param>
/// <param name="measuredFlow">Measured flow [m3/h]</param>
/// <param name="timeout">Timeout in [s]</param>
/// <returns>SetFlowOp instance</returns>
public IOperation SetFlowOp(GenericDevices.IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi,
float pidCoef, DoubleBox measuredFlow, int timeout)
{
return new SetFlowOp(this, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, timeout);
}
/// <summary>
/// Operation to set the water flow within tolerances. Leave the measurement running.
/// Events: Event.None, Event.FlowReached, Event.FlowTimeOut
/// </summary>
/// <param name="flowMeter">Flowmeter component</param>
/// <param name="requiredFlowLo">Lower limit of the required flow [m3/h]</param>
/// <param name="requiredFlowHi">Higher limit of the required flow [m3/h]</param>
/// <param name="measuredFlow">Measured flow [m3/h]</param>
/// <param name="timeout">Timeout in [s]</param>
/// <returns>SetFlowOp instance</returns>
public IOperation SetFlowAndMeasureOp(GenericDevices.IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi,
float pidCoef, DoubleBox measuredFlow, int timeout, float filterConstant)
{
return new SetFlowOp(this, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, timeout, true);
}
/// <summary>
/// Operation to set the regulation valve to a required position
/// Events: Event.None
/// </summary>
/// <param name="flowLo">Lower limit of the required valve position in [%]</param>
/// <param name="flowLo">Higher limit of the required valve position in [%]</param>
/// <returns>SetPositionOp instance</returns>
public IOperation SetRegulValvePositionOp(float pctLo, float pctHi, int timeoutMs)
{
return new SetRegulValvePositionOp(this, pctLo, pctHi, timeoutMs);
}
public IOperation ChangeRegulValvePositionOp(float timePulseSec)
{
return new ChangeRegulValvePositionOp(this, timePulseSec);
}
}
}