83 lines
2.3 KiB
C#
83 lines
2.3 KiB
C#
///
|
|
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace TBF.BenchControl.GenericDevices
|
|
{
|
|
public class ValveBase : ComponentBase
|
|
{
|
|
/// <summary>
|
|
/// Invokes ComponentBase constructor
|
|
/// </summary>
|
|
public ValveBase(Generic.IComponentCfg cfg) : base(cfg)
|
|
{
|
|
}
|
|
|
|
/// <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;
|
|
}
|
|
}
|
|
}
|