102 lines
4.7 KiB
C#
102 lines
4.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using log4net;
|
|
using TBF.BenchControl.Generic;
|
|
using TBF.Boxes;
|
|
|
|
namespace TBF.BenchControl.Elde.RegulValveTandem
|
|
{
|
|
public class RegulValveTandem : ComponentBase, GenericDevices.IRegulValve
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(RegulValveTandem));
|
|
public override string ToString() { return string.Format("RegulValve({0})", Cfg.ToString(1)); }
|
|
|
|
public readonly RegulValveTandemCfg RegulValveTandemCfg;
|
|
|
|
IDictionary<float, float> dict;
|
|
public IDictionary<float, float> Dict { get { return dict; } }
|
|
|
|
ControlBoardDev controlBoard { get { return regulValve.ControlBoard; } }
|
|
|
|
readonly RegulValve.RegulValve regulValve;
|
|
readonly RegulValve.RegulValve fixedRV;
|
|
|
|
public int Idx1 { get { return regulValve.Idx1; } } /// 1..7
|
|
public int DacValueClosed { get { return regulValve.DacValueClosed; } } /// 0..1023
|
|
public int DacValueOpen { get { return regulValve.DacValueOpen; } } /// 0..1023
|
|
///
|
|
public int StableTime { get { return RegulValveTandemCfg.StableTime; } } /// 0=200ms, step=50ms, max. 1500ms (max.26)
|
|
public int FlowStableSec { get { return RegulValveTandemCfg.FlowStableSec; } } /// 0..60 sec
|
|
///
|
|
public float Position
|
|
{
|
|
get { return controlBoard.RValvePosition(Idx1); }
|
|
}
|
|
|
|
|
|
public RegulValveTandem(RegulValveTandemCfg cfg, IList<Generic.IComponent> components)
|
|
: base(cfg)
|
|
{
|
|
RegulValveTandemCfg = cfg;
|
|
|
|
regulValve = (RegulValve.RegulValve)TbfComponents.FindComponent(RegulValveTandemCfg.RegulValveName, components);
|
|
if (regulValve == null) throw new Exception("Cannot find regulation valve");
|
|
|
|
fixedRV = (RegulValve.RegulValve)TbfComponents.FindComponent(RegulValveTandemCfg.ParentName, components);
|
|
if (fixedRV == null) throw new Exception("Cannot find fixed RV");
|
|
|
|
this.dict = new Dictionary<float, float>();
|
|
|
|
log.Debug(this.ToString());
|
|
}
|
|
|
|
/// <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="pidCoef">PID coefficient (float)</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, FloatBox measuredFlow, int timeout)
|
|
{
|
|
return new SetFlowOp(controlBoard, 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, FloatBox measuredFlow, int timeout, float filterConstant)
|
|
{
|
|
return new SetFlowOp(controlBoard, 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(controlBoard, this, pctLo, pctHi, timeoutMs);
|
|
}
|
|
|
|
public IOperation ChangeRegulValvePositionOp(float timePulseSec)
|
|
{
|
|
return new ChangeRegulValvePositionOp(controlBoard, this, timePulseSec);
|
|
}
|
|
}
|
|
}
|