ControlBoards, IControlBoard iface, Devices, test methods.
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TBF.BenchControl.GenericDevices;
|
||||
|
||||
namespace TBF.BenchControl.BuiltIn
|
||||
{
|
||||
public class ValveBase : ComponentBase
|
||||
{
|
||||
public ValveBase()
|
||||
{
|
||||
}
|
||||
|
||||
/// <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 masters valves
|
||||
/// </summary>
|
||||
public static IList<IValve> GetMasterValves(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<BuiltIn.ValveEx.Valve> ExtendedValves(IList<Generic.IComponent> cmpnts)
|
||||
{
|
||||
IList<BuiltIn.ValveEx.Valve> result = new List<BuiltIn.ValveEx.Valve>();
|
||||
foreach (var cmpnt in cmpnts)
|
||||
{
|
||||
if (cmpnt is BuiltIn.ValveEx.Valve) result.Add(cmpnt as BuiltIn.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user