tbf/TBF/Rig/BenchPath.cs

76 lines
2.8 KiB
C#

///
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.Rig.GenericDevices;
namespace TBF.Rig
{
public class BenchPath
{
public int ItemNr;
public string Name;
public double Qfrom;
public double Qto;
public string Selector;
public ITempMeter TempMtrUp;
public ITempMeter TempMtrDown;
public IPressureMeter PressMtrUp;
public IPressureMeter PressMtrDown;
public IPressureMeter PressMtrDelta;
public IAdjustableMeter ElectricMtrUp;
public IAdjustableMeter ElectricMtrDown;
public IAdjustableMeter ElectricMtrDelta;
public IValve StopBFValve;
public IList<IValve> ValvesOpen;
public IList<IValve> ValvesClose;
/// Constructor from name, the rest is empty
public BenchPath(string name, int itemNr)
{
ItemNr = itemNr;
Name = name;
ValvesOpen = new List<IValve>();
ValvesClose = new List<IValve>();
}
/// Constructor from data entity
public BenchPath(Config.Entities.BenchPath entity, IList<Rig.Generic.IComponent> components)
: this(entity.Name, entity.ItemNr)
{
Qfrom = entity.Qfrom;
Qto = entity.Qto;
Selector = entity.Selector;
TempMtrUp = TbfComponents.FindComponent(entity.TempMtrUp, components) as ITempMeter;
TempMtrDown = TbfComponents.FindComponent(entity.TempMtrDown, components) as ITempMeter;
PressMtrUp = TbfComponents.FindComponent(entity.PressMtrUp, components) as IPressureMeter;
PressMtrDown = TbfComponents.FindComponent(entity.PressMtrDown, components) as IPressureMeter;
PressMtrDelta = TbfComponents.FindComponent(entity.PressMtrDelta, components) as IPressureMeter;
ElectricMtrUp = TbfComponents.FindComponent(entity.ElectricMtrUp, components) as IAdjustableMeter;
ElectricMtrDown = TbfComponents.FindComponent(entity.ElectricMtrDown, components) as IAdjustableMeter;
ElectricMtrDelta = TbfComponents.FindComponent(entity.ElectricMtrDelta, components) as IAdjustableMeter;
StopBFValve = TbfComponents.FindComponent(entity.StopBFValve, components) as IValve;
string[] vOpen = entity.ValvesOpen.Split(new char[] { ';' });
foreach (var vName in vOpen)
{
var cmpnt = TbfComponents.FindComponent(vName, components);
if (cmpnt is IValve) ValvesOpen.Add(cmpnt as IValve);
}
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} StopBF={1}", Name, (StopBFValve != null) ? StopBFValve.Name : "---");
}
}
}