98 lines
2.9 KiB
C#
98 lines
2.9 KiB
C#
///
|
|
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace TBF.Rig.GenericDevices
|
|
{
|
|
public abstract class ValveBase : ComponentBase
|
|
{
|
|
/// <summary>
|
|
/// Invoke ComponentBase constructors
|
|
/// </summary>
|
|
public ValveBase() : base() { }
|
|
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 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 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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Process the list of components and return extended valves
|
|
/// </summary>
|
|
public static IList<Elde.ValveEx.Valve> ExtendedValves(IList<Generic.IComponent> cmpnts)
|
|
{
|
|
IList<Elde.ValveEx.Valve> result = new List<Elde.ValveEx.Valve>();
|
|
foreach (var cmpnt in cmpnts)
|
|
{
|
|
if (cmpnt is Elde.ValveEx.Valve) result.Add(cmpnt as Elde.ValveEx.Valve);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Create a list with one valved passed as an argument to this function
|
|
/// </summary>
|
|
/// <param name="valve">Valve</param>
|
|
/// <returns>List with one valve</returns>
|
|
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;
|
|
}
|
|
}
|
|
}
|