/// /// Copyright (c) 2013-2015 Sensus Metering Systems /// 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 dict; public IDictionary Dict { get { return dict; } } ControlBoardDev controlBoard { get { return regulValve.ControlBoard; } } readonly RegulValve.RegulValve regulValve; readonly RegulValve.RegulValve fixedRV; readonly float fixedPctLo; /// [%] readonly float fixedPctHi; /// [%] public int FlowStableSec { get { return RegulValveTandemCfg.FlowStableSec; } } /// 0..60 sec /// public bool IsCoax { get { return false; } } public float Position { get { return regulValve.Position; } } public RegulValveTandem() { } public RegulValveTandem(RegulValveTandemCfg cfg, IList 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.FixedRVName, components); if (fixedRV == null) throw new Exception("Cannot find fixed RV"); fixedPctLo = Math.Max(0.0f, RegulValveTandemCfg.FixedRVPosition - 3.0f); fixedPctHi = Math.Min(100.0f, RegulValveTandemCfg.FixedRVPosition + 3.0f); this.dict = new Dictionary(); log.Debug(this.ToString()); } /// /// Operation to set the water flow within tolerances /// Events: Event.None, Event.FlowReached, Event.FlowTimeOut /// /// Flowmeter component /// Lower limit of the required flow [m3/h] /// Higher limit of the required flow [m3/h] /// PID coefficient (float) /// Measured flow [m3/h] /// Timeout in [s] /// SetFlowOp instance public IOperation SetFlowOp(GenericDevices.IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi, float pidCoef, FloatBox measuredFlow, int timeout) { return new SetFlowOp(controlBoard, regulValve, fixedRV, fixedPctLo, fixedPctHi, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, timeout); } /// /// Operation to set the water flow within tolerances. Leave the measurement running. /// Events: Event.None, Event.FlowReached, Event.FlowTimeOut /// /// Flowmeter component /// Lower limit of the required flow [m3/h] /// Higher limit of the required flow [m3/h] /// Measured flow [m3/h] /// Timeout in [s] /// SetFlowOp instance public IOperation SetFlowAndMeasureOp(GenericDevices.IFlowMeter flowMeter, float requiredFlowLo, float requiredFlowHi, float pidCoef, FloatBox measuredFlow, int timeout, float filterConstant) { return new SetFlowOp(controlBoard, regulValve, fixedRV, fixedPctLo, fixedPctHi, flowMeter, requiredFlowLo, requiredFlowHi, pidCoef, measuredFlow, timeout, true); } /// /// Operation to set the regulation valve to a required position /// Events: Event.None /// /// Lower limit of the required valve position in [%] /// Higher limit of the required valve position in [%] /// SetPositionOp instance public IOperation SetRegulValvePositionOp(float pctLo, float pctHi, int timeoutMs) { return null; } public IOperation ChangeRegulValvePositionOp(float timePulseSec) { return null; } } }