130 lines
4.9 KiB
C#
130 lines
4.9 KiB
C#
///
|
|
/// Copyright (c) 2021 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using log4net;
|
|
using SchematicDrawing;
|
|
using TBF.Rig.ControlBoard.Uni;
|
|
using TBF.Boxes;
|
|
|
|
namespace TBF.Rig.Uni.RegValveAnalog
|
|
{
|
|
public class RegValve : ComponentBase, GenericDevices.IRegValve, IDrawingItCmpntWithSetpoint
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(RegValve));
|
|
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
|
|
|
|
readonly RegValveCfg regValveCfg;
|
|
public ValveCategory Category { get { return regValveCfg.Category; } }
|
|
public int Idx1 { get { return regValveCfg.Idx1; } } /// 1..7
|
|
public int StableTime { get { return regValveCfg.StableTime; } } /// 0=200ms, step=50ms, max. 1500ms (max.26)
|
|
public int FlowStableSec { get { return regValveCfg.FlowStableSec; } } /// 0..60 sec
|
|
public bool StoredPositionReuse { get { return regValveCfg.StoredPositionReuse; } }
|
|
|
|
public IDrawingItem DrawingItem { get { return regValveCfg as IDrawingItem; } }
|
|
|
|
IDictionary<double, double> dict;
|
|
public IDictionary<double, double> Dict { get { return dict; } }
|
|
|
|
readonly UniCB uniCB;
|
|
|
|
///
|
|
public bool IsCoax { get { return true; } }
|
|
///
|
|
public double Position
|
|
{
|
|
get {
|
|
return 50.0; // TODO: was return uniCB.RValvePosition(Idx1);
|
|
}
|
|
}
|
|
///
|
|
public double SetpointVal
|
|
{
|
|
get { return Position; }
|
|
set { } // TODO
|
|
}
|
|
///
|
|
public void IncreaseSetpoint()
|
|
{
|
|
/// TODO
|
|
}
|
|
///
|
|
public void DecreaseSetpoint()
|
|
{
|
|
/// TODO
|
|
}
|
|
|
|
|
|
public RegValve()
|
|
{
|
|
}
|
|
|
|
public RegValve(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
|
|
: base(cfg)
|
|
{
|
|
regValveCfg = cfg as RegValveCfg;
|
|
|
|
uniCB = TbfComponents.FindComponent(cfg.ParentName, components) as UniCB;
|
|
if (uniCB == null) throw new Exception("Cannot find " + Name + " parent");
|
|
|
|
log.Warn(this.ToString());
|
|
}
|
|
|
|
public override void Initialize()
|
|
{
|
|
this.dict = new Dictionary<double, double>();
|
|
}
|
|
|
|
/// <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="qFrom">Lower limit of the required flow [m3/h]</param>
|
|
/// <param name="qTo">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>
|
|
/// <param name="delay">Flow setting starts after this delay in [s]</param>
|
|
/// <returns>SetFlowOp instance</returns>
|
|
public IOperation SetFlowOp(GenericDevices.IFlowMeter flowMeter, double qFrom, double qTo, DoubleBox measuredFlow, int timeout, int delay)
|
|
{
|
|
return new SetFlowOp(uniCB, this, flowMeter, qFrom, qTo, measuredFlow, regValveCfg.ReTryCommands, timeout, delay);
|
|
}
|
|
|
|
/// <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="qFrom">Lower limit of the required flow [m3/h]</param>
|
|
/// <param name="qTo">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 qFrom, double qTo,
|
|
DoubleBox measuredFlow, int timeout, float filterConstant)
|
|
{
|
|
return new SetFlowOp(uniCB, this, flowMeter, qFrom, qTo, measuredFlow, regValveCfg.ReTryCommands, timeout, 0, 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 SetRegValvePositionOp(double pctLo, double pctHi, int timeoutMs)
|
|
{
|
|
return new SetRegValvePositionOp(uniCB, this, pctLo, pctHi, timeoutMs);
|
|
}
|
|
|
|
public IOperation ChangeRegValvePositionOp(double timePulseSec)
|
|
{
|
|
return new ChangeRegValvePositionOp(uniCB, this, timePulseSec);
|
|
}
|
|
}
|
|
}
|