IRegulValve change, regulation valves support Category, Category saved in settings, used in Feeding Paths UI, not used in tests yet, ver. 2.11.364

This commit is contained in:
Milan Hanajik
2016-10-12 15:47:45 +02:00
parent 1388f459fe
commit caf43fedb3
19 changed files with 294 additions and 92 deletions
+30 -2
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System.Collections.Generic;
using TBF.BenchControl.GenericDevices;
@@ -12,7 +12,9 @@ namespace TBF.BenchControl
public string Name;
public float Qfrom;
public float Qto;
public IValve Pump; /// pump to use with this path or null
public IValve Pump; /// pump to use with this path or null
public IList<IRegulValve> RegulValves;
public IList<float> RegulValvesPct;
public IList<IValve> ValvesOpen; /// a list of valves to open or null
public IList<IValve> ValvesClose; /// a list of valves to close or null
@@ -23,6 +25,8 @@ namespace TBF.BenchControl
Name = name;
ValvesOpen = new List<IValve>();
ValvesClose = new List<IValve>();
RegulValves = new List<IRegulValve>();
RegulValvesPct = new List<float>();
}
/// Constructor from data entity
@@ -33,6 +37,30 @@ namespace TBF.BenchControl
Qto = entity.Qto;
Pump = (IValve)TbfComponents.FindComponent(entity.Pump, components);
///
/// Feeding regulation valve components
///
foreach (var cmpnt in components)
{
IRegulValve regValve = cmpnt as IRegulValve;
if (regValve != null && (regValve.Category == TBF.BenchControl.ValveCategory.Feeding || regValve.Category == TBF.BenchControl.ValveCategory.All))
{
RegulValves.Add(regValve);
}
}
///
/// Feeding regulation valve precentages
///
string[] rvPosStr = (entity.RegulValvesPct != null) ? entity.RegulValvesPct.Split(new char[] { ';' }) : new string[0];
for (int i = 0; i < RegulValves.Count; i++)
{
string str = (i < rvPosStr.Length) ? rvPosStr[i] : "---";
float pct;
if (!Utils.TryParseUFloat(str, out pct) || pct > 100.0f || str == "---") pct = 0;
RegulValvesPct.Add(pct);
}
string[] vOpen = entity.ValvesOpen.Split(new char[] { ';' });
ValvesOpen = new List<IValve>();
foreach (var vName in vOpen) ValvesOpen.Add((IValve)TbfComponents.FindComponent(vName, components));