/// /// Copyright (c) 2013-2022 Sensus Slovensko a.s. /// using System.Collections.Generic; using TBF.Rig.GenericDevices; namespace TBF.Rig { public class FeedingPath { public int ItemNr; public string Name; public float Qfrom; public float Qto; public string Selector; public IValve Pump; /// pump to use with this path or null public IList RegVPositions; public IList ValvesOpen; /// a list of valves to open or null public IList ValvesClose; /// a list of valves to close or null /// Constructor from name, the rest is empty public FeedingPath(string name, int itemNr) { ItemNr = itemNr; Name = name; RegVPositions = new List(); ValvesOpen = new List(); ValvesClose = new List(); } /// Constructor from data entity public FeedingPath(Config.Entities.FeedingPath entity, IList components) : this(entity.Name, entity.ItemNr) { Qfrom = entity.Qfrom; Qto = entity.Qto; Selector = entity.Selector; Pump = TbfComponents.FindComponent(entity.Pump, components) as IValve; /// /// Feeding regulation valves and their positions /// RegVPositions.Clear(); foreach (var cmpnt in components) { IRegValve rv = cmpnt as IRegValve; if (rv != null && rv.Category == TBF.Rig.ValveCategory.Feeding && !(rv is TBF.Rig.Elde.RegulValveTandem.RegulValveTandem)) { RegVPositions.Add(new RegValvePosition(rv)); } } TBF.Utils.UpdateRegVPositionsFromStr(ref RegVPositions, entity.RegulValvesPct); /// /// Regular valves to open /// string[] vOpen = entity.ValvesOpen.Split(new char[] { ';' }); ValvesOpen = new List(); foreach (var vName in vOpen) { var cmpnt = TbfComponents.FindComponent(vName, components); if (cmpnt is IValve) ValvesOpen.Add(cmpnt as IValve); } /// /// Regular valves to close /// string[] vClose = entity.ValvesClose.Split(new char[] { ';' }); ValvesClose = new List(); foreach (var vName in vClose) { var cmpnt = TbfComponents.FindComponent(vName, components); if (cmpnt is IValve) ValvesClose.Add(cmpnt as IValve); } } public override string ToString() { return string.Format("{0} Pump={1}", Name, (Pump != null) ? Pump.Name : "---"); } } }