118 lines
4.6 KiB
C#
118 lines
4.6 KiB
C#
///
|
|
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
|
///
|
|
using System.Collections.Generic;
|
|
using TBF.Rig.GenericDevices;
|
|
|
|
namespace TBF.Rig
|
|
{
|
|
public class OutputPath
|
|
{
|
|
public int ItemNr;
|
|
public string Name;
|
|
public float Qfrom;
|
|
public float Qto;
|
|
public string Selector;
|
|
public IFlowMeter FlowMeter;
|
|
public IRegValve RegulValve;
|
|
public float PidCoef;
|
|
public IDiverter Diverter;
|
|
public ITempMeter TempDiv;
|
|
public IScaleOrTank Scale;
|
|
public IValve StartValve1;
|
|
public bool InvertSV1;
|
|
public IValve StartValve2;
|
|
public bool InvertSV2;
|
|
public int LagSV2;
|
|
public IValve StartValve3;
|
|
public bool InvertSV3;
|
|
public int LagSV3;
|
|
public IList<RegValvePosition> RegVPositions;
|
|
public IList<IValve> ValvesOpen;
|
|
public IList<IValve> ValvesClose;
|
|
|
|
/// Constructor from name, the rest is empty
|
|
public OutputPath(string name, int itemNr)
|
|
{
|
|
ItemNr = itemNr;
|
|
Name = name;
|
|
RegVPositions = new List<RegValvePosition>();
|
|
ValvesOpen = new List<IValve>();
|
|
ValvesClose = new List<IValve>();
|
|
}
|
|
|
|
/// Constructor from data entity
|
|
public OutputPath(Config.Entities.OutputPath entity, IList<Rig.Generic.IComponent> components)
|
|
: this(entity.Name, entity.ItemNr)
|
|
{
|
|
Qfrom = entity.Qfrom;
|
|
Qto = entity.Qto;
|
|
Selector = entity.Selector;
|
|
FlowMeter = TbfComponents.FindComponent(entity.FlowMeter, components) as IFlowMeter;
|
|
RegulValve = TbfComponents.FindComponent(entity.RegulValve, components) as IRegValve;
|
|
PidCoef = entity.PidCoef;
|
|
Diverter = TbfComponents.FindComponent(entity.Diverter, components) as IDiverter;
|
|
TempDiv = TbfComponents.FindComponent(entity.TempDiv, components) as ITempMeter;
|
|
Scale = TbfComponents.FindComponent(entity.Scale, components) as IScaleOrTank;
|
|
|
|
string[] svs = entity.StartValve != null ? entity.StartValve.Split(new char[] { '~' }) : new string[0];
|
|
int iTmp;
|
|
///
|
|
StartValve1 = TbfComponents.FindComponent(((svs.Length > 0) ? svs[0] : string.Empty), components) as IValve;
|
|
InvertSV1 = (svs.Length > 1) ? svs[1].Equals("i") : false;
|
|
StartValve2 = TbfComponents.FindComponent(((svs.Length > 2) ? svs[2] : string.Empty), components) as IValve;
|
|
InvertSV2 = (svs.Length > 3) ? svs[3].Equals("i") : false;
|
|
LagSV2 = (svs.Length > 4 && int.TryParse(svs[4], out iTmp)) ? iTmp : 0;
|
|
StartValve3 = TbfComponents.FindComponent(((svs.Length > 5) ? svs[5] : string.Empty), components) as IValve;
|
|
InvertSV3 = (svs.Length > 6) ? svs[6].Equals("i") : false;
|
|
LagSV3 = (svs.Length > 7 && int.TryParse(svs[7], out iTmp)) ? iTmp : 0;
|
|
|
|
///
|
|
/// Output 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.Output && !(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<IValve>();
|
|
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<IValve>();
|
|
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} RV={1}, Flowm.={2}, Div.={3}, Scale={4}",
|
|
Name,
|
|
(RegulValve != null) ? RegulValve.Name : "---",
|
|
(FlowMeter != null) ? FlowMeter.Name : "---",
|
|
(Diverter != null) ? Diverter.Name : "---",
|
|
(Scale != null) ? Scale.Name : "---");
|
|
}
|
|
}
|
|
}
|