121 lines
4.9 KiB
C#
121 lines
4.9 KiB
C#
///
|
|
/// Copyright (c) 2017-2020 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using log4net;
|
|
using SchematicDrawing;
|
|
using TBF.BenchControl.ControlBoard.Legacy;
|
|
using TBF.Boxes;
|
|
|
|
namespace TBF.BenchControl.Elde.RegulValveCoax
|
|
{
|
|
public class RegulValve : ComponentBase, GenericDevices.IRegulValve, IDrawingItCmpntWithSetpoint
|
|
{
|
|
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 IDrawingItem DrawingItem { get { return RegulValveCfg as IDrawingItem; } }
|
|
|
|
IDictionary<double, float> dict;
|
|
public IDictionary<double, float> Dict { get { return dict; } }
|
|
|
|
public readonly ControlBoardDev ControlBoard;
|
|
|
|
public ValveCategory Category { get { return RegulValveCfg.Category; } }
|
|
public int Idx1 { get { return RegulValveCfg.Idx1; } } /// 1..7
|
|
public int StableTime { get { return RegulValveCfg.StableTime; } } /// 0=200ms, step=50ms, max. 1500ms (max.26)
|
|
public int FlowStableSec { get { return RegulValveCfg.FlowStableSec; } } /// 0..60 sec
|
|
///
|
|
public bool IsCoax { get { return true; } }
|
|
///
|
|
public float Position { get { return ControlBoard.RValvePosition(Idx1); } }
|
|
///
|
|
public double SetpointVal
|
|
{
|
|
get { return (double)ControlBoard.RValvePosition(Idx1); }
|
|
set { } // TODO
|
|
}
|
|
///
|
|
public void IncreaseSetpoint()
|
|
{
|
|
/// TODO
|
|
}
|
|
///
|
|
public void DecreaseSetpoint()
|
|
{
|
|
/// TODO
|
|
}
|
|
|
|
|
|
public RegulValve()
|
|
{
|
|
}
|
|
|
|
public RegulValve(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
|
|
: base(cfg)
|
|
{
|
|
RegulValveCfg = cfg as RegulValveCfg;
|
|
|
|
ControlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
|
|
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
|
|
|
|
this.dict = new Dictionary<double, float>();
|
|
|
|
log.Warn(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, double requiredFlowLo, double requiredFlowHi, DoubleBox measuredFlow, int timeout)
|
|
{
|
|
return new SetFlowOp(ControlBoard, this, flowMeter, requiredFlowLo, requiredFlowHi, measuredFlow, RegulValveCfg.ReTryCommands, 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, double requiredFlowLo, double requiredFlowHi,
|
|
DoubleBox measuredFlow, int timeout, float filterConstant)
|
|
{
|
|
return new SetFlowOp(ControlBoard, this, flowMeter, requiredFlowLo, requiredFlowHi, measuredFlow, RegulValveCfg.ReTryCommands, 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);
|
|
}
|
|
}
|
|
}
|