86 lines
3.6 KiB
C#
86 lines
3.6 KiB
C#
///
|
|
/// Copyright (c) 2013-2017 Sensus Metering Systems
|
|
///
|
|
using System.Collections.Generic;
|
|
using TBF.BenchControl.GenericDevices;
|
|
|
|
namespace TBF.BenchControl
|
|
{
|
|
public class OutputPath
|
|
{
|
|
public int ItemNr;
|
|
public string Name;
|
|
public float Qfrom;
|
|
public float Qto;
|
|
public IFlowMeter FlowMeter;
|
|
public IRegulValve 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<IValve> ValvesOpen;
|
|
public IList<IValve> ValvesClose;
|
|
|
|
/// Constructor from name, the rest is empty
|
|
public OutputPath(string name, int itemNr)
|
|
{
|
|
ItemNr = itemNr;
|
|
Name = name;
|
|
ValvesOpen = new List<IValve>();
|
|
ValvesClose = new List<IValve>();
|
|
}
|
|
|
|
/// Constructor from data entity
|
|
public OutputPath(Config.Entities.OutputPath outputPathEntity, IList<BenchControl.Generic.IComponent> components)
|
|
: this(outputPathEntity.Name, outputPathEntity.ItemNr)
|
|
{
|
|
Qfrom = outputPathEntity.Qfrom;
|
|
Qto = outputPathEntity.Qto;
|
|
FlowMeter = (IFlowMeter)TbfComponents.FindComponent(outputPathEntity.FlowMeter, components);
|
|
RegulValve = (IRegulValve)TbfComponents.FindComponent(outputPathEntity.RegValve, components);
|
|
PidCoef = outputPathEntity.PidCoef;
|
|
Diverter = (IDiverter)TbfComponents.FindComponent(outputPathEntity.Diverter, components);
|
|
TempDiv = (ITempMeter)TbfComponents.FindComponent(outputPathEntity.TempMtrDiv, components);
|
|
Scale = (IScaleOrTank)TbfComponents.FindComponent(outputPathEntity.Scale, components);
|
|
|
|
string[] svs = outputPathEntity.StartValve != null ? outputPathEntity.StartValve.Split(new char[] { '~' }) : new string[0];
|
|
int iTmp;
|
|
///
|
|
StartValve1 = (IValve)TbfComponents.FindComponent(((svs.Length > 0) ? svs[0] : string.Empty), components);
|
|
InvertSV1 = (svs.Length > 1) ? svs[1].Equals("i") : false;
|
|
StartValve2 = (IValve)TbfComponents.FindComponent(((svs.Length > 2) ? svs[2] : string.Empty), components);
|
|
InvertSV2 = (svs.Length > 3) ? svs[3].Equals("i") : false;
|
|
LagSV2 = (svs.Length > 4 && int.TryParse(svs[4], out iTmp)) ? iTmp : 0;
|
|
StartValve3 = (IValve)TbfComponents.FindComponent(((svs.Length > 5) ? svs[5] : string.Empty), components);
|
|
InvertSV3 = (svs.Length > 6) ? svs[6].Equals("i") : false;
|
|
LagSV3 = (svs.Length > 7 && int.TryParse(svs[7], out iTmp)) ? iTmp : 0;
|
|
|
|
string[] vOpen = outputPathEntity.ValvesOpen.Split(new char[] { ';' });
|
|
ValvesOpen = new List<IValve>();
|
|
foreach (var vName in vOpen) ValvesOpen.Add((IValve)TbfComponents.FindComponent(vName, components));
|
|
|
|
string[] vClose = outputPathEntity.ValvesClose.Split(new char[] { ';' });
|
|
ValvesClose = new List<IValve>();
|
|
foreach (var vName in vClose) ValvesClose.Add((IValve)TbfComponents.FindComponent(vName, components));
|
|
}
|
|
|
|
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 : "---");
|
|
}
|
|
}
|
|
}
|