73 lines
2.1 KiB
C#
73 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace TBF.BenchControl.GenericDevices
|
|
{
|
|
public class ValveBase
|
|
{
|
|
/// <summary>
|
|
/// Process the list of components and return all valves (masters and coupled)
|
|
/// </summary>
|
|
public static IList<IValve> AllValves(IList<Generic.IComponent> cmpnts)
|
|
{
|
|
IList<IValve> result = new List<IValve>();
|
|
foreach (var cmpnt in cmpnts) if (cmpnt is IValve) result.Add(cmpnt as IValve);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Process the list of components and return the masters valves
|
|
/// </summary>
|
|
public static IList<IValve> MasterValves(IList<Generic.IComponent> cmpnts)
|
|
{
|
|
IList<IValve> result = new List<IValve>();
|
|
foreach (var cmpnt in cmpnts)
|
|
{
|
|
IValve valve = cmpnt as IValve;
|
|
if (valve != null && valve.CoupledTo == null) result.Add(valve);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Process the list of components and return the coupled valves
|
|
/// </summary>
|
|
public static IList<IValve> CoupledValves(IList<Generic.IComponent> cmpnts)
|
|
{
|
|
IList<IValve> result = new List<IValve>();
|
|
foreach (var cmpnt in cmpnts)
|
|
{
|
|
IValve valve = cmpnt as IValve;
|
|
if (valve != null && valve.CoupledTo != null) result.Add(valve);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public static IList<IValve> MakeList(IValve valve)
|
|
{
|
|
IList<IValve> result = new List<IValve>();
|
|
if (valve != null) result.Add(valve);
|
|
return result;
|
|
}
|
|
|
|
public static IList<IValve> Merge(IList<IValve> valves1, IList<IValve> valves2)
|
|
{
|
|
IList<IValve> result = new List<IValve>();
|
|
if (valves1 != null) foreach (var valve in valves1) result.Add(valve);
|
|
if (valves2 != null) foreach (var valve in valves2) result.Add(valve);
|
|
return result;
|
|
}
|
|
|
|
public static IList<IValve> Merge(IList<IValve> valves1, IList<IValve> valves2, IList<IValve> valves3)
|
|
{
|
|
IList<IValve> result = new List<IValve>();
|
|
if (valves1 != null) foreach (var valve in valves1) result.Add(valve);
|
|
if (valves2 != null) foreach (var valve in valves2) result.Add(valve);
|
|
if (valves3 != null) foreach (var valve in valves3) result.Add(valve);
|
|
return result;
|
|
}
|
|
}
|
|
}
|