RegValvePosition class with RV/position pair, FeedingPath RV positions used in sequences, ver. 2.30.1976

This commit is contained in:
Milan Hanajik 2022-11-02 10:14:30 +01:00
parent da7ac83c75
commit 0539844d85
12 changed files with 145 additions and 118 deletions

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number // Build Number
// Revision // Revision
// //
[assembly: AssemblyVersion("2.30.1971.0")] [assembly: AssemblyVersion("2.30.1976.0")]
[assembly: AssemblyFileVersion("2.30.1971.0")] [assembly: AssemblyFileVersion("2.30.1976.0")]

View File

@ -14,8 +14,7 @@ namespace TBF.Rig
public float Qto; public float Qto;
public string Selector; public string Selector;
public IValve Pump; /// pump to use with this path or null public IValve Pump; /// pump to use with this path or null
public IList<IRegValve> RegulValves; public IList<RegValvePosition> RegVPositions;
public IList<float> RegulValvesPct;
public IList<IValve> ValvesOpen; /// a list of valves to open or null public IList<IValve> ValvesOpen; /// a list of valves to open or null
public IList<IValve> ValvesClose; /// a list of valves to close or null public IList<IValve> ValvesClose; /// a list of valves to close or null
@ -24,10 +23,9 @@ namespace TBF.Rig
{ {
ItemNr = itemNr; ItemNr = itemNr;
Name = name; Name = name;
RegVPositions = new List<RegValvePosition>();
ValvesOpen = new List<IValve>(); ValvesOpen = new List<IValve>();
ValvesClose = new List<IValve>(); ValvesClose = new List<IValve>();
RegulValves = new List<IRegValve>();
RegulValvesPct = new List<float>();
} }
/// Constructor from data entity /// Constructor from data entity
@ -40,29 +38,22 @@ namespace TBF.Rig
Pump = TbfComponents.FindComponent(entity.Pump, components) as IValve; Pump = TbfComponents.FindComponent(entity.Pump, components) as IValve;
/// ///
/// Feeding regulation valve components /// Feeding regulation valves and their positions
/// ///
RegVPositions.Clear();
foreach (var cmpnt in components) foreach (var cmpnt in components)
{ {
IRegValve regValve = cmpnt as IRegValve; IRegValve rv = cmpnt as IRegValve;
if (regValve != null && regValve.Category == TBF.Rig.ValveCategory.Feeding) if (rv != null && rv.Category == TBF.Rig.ValveCategory.Feeding && !(rv is TBF.Rig.Elde.RegulValveTandem.RegulValveTandem))
{ {
RegulValves.Add(regValve); RegVPositions.Add(new RegValvePosition(rv));
} }
} }
TBF.Utils.UpdateRegVPositionsFromStr(ref RegVPositions, entity.RegulValvesPct);
/// ///
/// Feeding regulation valve precentages /// Regular valves to open
/// ///
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[] { ';' }); string[] vOpen = entity.ValvesOpen.Split(new char[] { ';' });
ValvesOpen = new List<IValve>(); ValvesOpen = new List<IValve>();
foreach (var vName in vOpen) foreach (var vName in vOpen)
@ -71,6 +62,9 @@ namespace TBF.Rig
if (cmpnt is IValve) ValvesOpen.Add(cmpnt as IValve); if (cmpnt is IValve) ValvesOpen.Add(cmpnt as IValve);
} }
///
/// Regular valves to close
///
string[] vClose = entity.ValvesClose.Split(new char[] { ';' }); string[] vClose = entity.ValvesClose.Split(new char[] { ';' });
ValvesClose = new List<IValve>(); ValvesClose = new List<IValve>();
foreach (var vName in vClose) foreach (var vName in vClose)

View File

@ -1,10 +1,7 @@
/// ///
/// Copyright (c) 2013-2015 Sensus Metering Systems /// Copyright (c) 2013-2015 Sensus Slovensko a.s.
/// ///
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TBF.Rig namespace TBF.Rig
{ {

View File

@ -27,7 +27,7 @@ namespace TBF.Rig
public IValve StartValve3; public IValve StartValve3;
public bool InvertSV3; public bool InvertSV3;
public int LagSV3; public int LagSV3;
public float[] RegulValvesPct; public IList<RegValvePosition> RegVPositions;
public IList<IValve> ValvesOpen; public IList<IValve> ValvesOpen;
public IList<IValve> ValvesClose; public IList<IValve> ValvesClose;
@ -36,6 +36,7 @@ namespace TBF.Rig
{ {
ItemNr = itemNr; ItemNr = itemNr;
Name = name; Name = name;
RegVPositions = new List<RegValvePosition>();
ValvesOpen = new List<IValve>(); ValvesOpen = new List<IValve>();
ValvesClose = new List<IValve>(); ValvesClose = new List<IValve>();
} }
@ -54,13 +55,6 @@ namespace TBF.Rig
TempDiv = TbfComponents.FindComponent(entity.TempDiv, components) as ITempMeter; TempDiv = TbfComponents.FindComponent(entity.TempDiv, components) as ITempMeter;
Scale = TbfComponents.FindComponent(entity.Scale, components) as IScaleOrTank; Scale = TbfComponents.FindComponent(entity.Scale, components) as IScaleOrTank;
int regvCount = 0;
foreach (var cmpnt in components)
{
if ((cmpnt is IRegValve) && !(cmpnt is Rig.Elde.RegulValveTandem.RegulValveTandem)) regvCount++;
}
RegulValvesPct = string.IsNullOrEmpty(entity.RegulValvesPct) ? new float[0] : Utils.GetRegulValvesPositions(entity.RegulValvesPct, regvCount);
string[] svs = entity.StartValve != null ? entity.StartValve.Split(new char[] { '~' }) : new string[0]; string[] svs = entity.StartValve != null ? entity.StartValve.Split(new char[] { '~' }) : new string[0];
int iTmp; int iTmp;
/// ///
@ -73,6 +67,23 @@ namespace TBF.Rig
InvertSV3 = (svs.Length > 6) ? svs[6].Equals("i") : false; InvertSV3 = (svs.Length > 6) ? svs[6].Equals("i") : false;
LagSV3 = (svs.Length > 7 && int.TryParse(svs[7], out iTmp)) ? iTmp : 0; LagSV3 = (svs.Length > 7 && int.TryParse(svs[7], out iTmp)) ? iTmp : 0;
///
/// Output regulation valves and their positions
///
RegVPositions.Clear();
foreach (var cmpnt in components)
{
IRegValve rv = cmpnt as IRegValve;
if (rv != null && rv.Category == TBF.Rig.ValveCategory.Output && !(rv is TBF.Rig.Elde.RegulValveTandem.RegulValveTandem))
{
RegVPositions.Add(new RegValvePosition(rv));
}
}
TBF.Utils.UpdateRegVPositionsFromStr(ref RegVPositions, entity.RegulValvesPct);
///
/// Regular valves to open
///
string[] vOpen = entity.ValvesOpen.Split(new char[] { ';' }); string[] vOpen = entity.ValvesOpen.Split(new char[] { ';' });
ValvesOpen = new List<IValve>(); ValvesOpen = new List<IValve>();
foreach (var vName in vOpen) foreach (var vName in vOpen)
@ -81,7 +92,10 @@ namespace TBF.Rig
if (cmpnt is IValve) ValvesOpen.Add(cmpnt as IValve); if (cmpnt is IValve) ValvesOpen.Add(cmpnt as IValve);
} }
string[] vClose = entity.ValvesClose.Split(new char[] { ';' }); ///
/// Regular valves to close
///
string[] vClose = entity.ValvesClose.Split(new char[] { ';' });
ValvesClose = new List<IValve>(); ValvesClose = new List<IValve>();
foreach (var vName in vClose) foreach (var vName in vClose)
{ {

View File

@ -0,0 +1,27 @@
///
/// Copyright (c) 2022 Sensus Slovensko a.s.
///
using System;
using TBF.Rig.GenericDevices;
namespace TBF.Rig
{
public class RegValvePosition
{
public IRegValve RegValve;
public float Position; /// 0 .. 100.0f is position in %, <0 (default -1.0f) means no change
public RegValvePosition(IRegValve regValve, float position)
{
RegValve = regValve;
Position = position;
}
/// Constructor with reg. valve and no position change
public RegValvePosition(IRegValve regValve)
{
RegValve = regValve;
Position = -1.0f;
}
}
}

View File

@ -38,13 +38,11 @@ namespace TBF.Rig.Sequences
///------------------------------------------------------------ ///------------------------------------------------------------
/// Global static variables set only once. /// Global static variables set only once.
///------------------------------------------------------------ ///------------------------------------------------------------
public static IList<IFlowMeter> FlowMeters; /// list of reference flowmeters public static IList<IFlowMeter> FlowMeters; /// list of reference flowmeters
public static IList<IRegValve> RegulValves; /// list of regulation valves public static IList<RegValvePosition> RegVPositions; /// list of regulation valves
public static IList<IRegValve> FeedingRegulValves; /// list of feeding regulation valves public static IList<IPumpFM> PumpsWithFM; /// list of FM controlled pumps
public static IList<IRegValve> OutputRegulValves; /// list of output regulation valves public static IList<IWaterMeter> WaterMeters; /// list of water meters
public static IList<IPumpFM> PumpsWithFM; /// list of FM controlled pumps public static IList<ICamera> Cameras; /// list of cameras
public static IList<IWaterMeter> WaterMeters; /// list of water meters
public static IList<ICamera> Cameras; /// list of cameras
///------------------------------------------------------------ ///------------------------------------------------------------
/// Procedure related (static) variables. /// Procedure related (static) variables.
@ -494,27 +492,28 @@ namespace TBF.Rig.Sequences
} }
/// return SetRegValvePositionOp operations for RV-s with changed positions /// <summary>
IList<IOperation> GetRegValvePositioningOps(IList<IRegValve> regValves, float[] regValvePositions) /// Returns a list of reg.valve positioning operations
/// </summary>
/// <param name="regVPositions">List of reg.valve/position pairs, position is in %, position LT 0 ... no operation</param>
/// <returns>List of reg.valve positioning operations</returns>
List<IOperation> GetRegVPositioningOps(IList<RegValvePosition> regVPositions)
{ {
IList<IOperation> rvPosOps = new List<IOperation>(); List<IOperation> rvPosOps = new List<IOperation>();
if (regValves != null && regValvePositions != null) if (regVPositions == null) return rvPosOps;
foreach (var rvp in regVPositions)
{ {
for (int i = 0; i < Math.Min(regValves.Count, regValvePositions.Length); i++) if (rvp.Position >= 0) /// Negative value means no position change
{ {
if (regValvePositions[i] >= 0) /// Negative value means no position change if (rvp.RegValve.IsCoax)
{ {
if (RegulValves[i].IsCoax) rvPosOps.Add(rvp.RegValve.SetRegulValvePositionOp(rvp.Position, -1, 60));
{ }
rvPosOps.Add(regValves[i].SetRegulValvePositionOp(regValvePositions[i], regValvePositions[i], 60)); else
} {
else rvPosOps.Add(rvp.RegValve.SetRegulValvePositionOp(rvp.Position - 3.0f, rvp.Position + 3.0f, 60));
{
float lo = Math.Max(0, regValvePositions[i] - 3.0f);
float hi = Math.Min(100.0f, regValvePositions[i] + 3.0f);
rvPosOps.Add(regValves[i].SetRegulValvePositionOp(lo, hi, 60));
}
} }
} }
} }
@ -608,7 +607,7 @@ namespace TBF.Rig.Sequences
string activity = string.Format(message, transitionSequence.Name, step.ItemNr + 1, stepsCount); string activity = string.Format(message, transitionSequence.Name, step.ItemNr + 1, stepsCount);
Bridge.OnActivity(this, activity); Bridge.OnActivity(this, activity);
Bridge.OnMessage(this, step.Message); Bridge.OnMessage(this, step.Message);
log.Info(activity + " " +step.Message); log.InfoFormat("{0} {1}", activity, step.Message);
//------------------------------------------------ //------------------------------------------------
/// Prepare operation to switch valves /// Prepare operation to switch valves
@ -646,8 +645,9 @@ namespace TBF.Rig.Sequences
} }
} }
/// Get regulation valve positioning operations
IList<IOperation> rvPosOps = GetRegValvePositioningOps(RegulValves, Utils.GetRegulValvesPositions(step.RegulValvesPct, RegulValves.Count)); Utils.UpdateRegVPositionsFromStr(ref RegVPositions, step.RegulValvesPct);
IList<IOperation> rvPosOps = GetRegVPositioningOps(RegVPositions);
/// Max. one SetRegulValvePositionOp can be started or stopped in one sub-step. /// Max. one SetRegulValvePositionOp can be started or stopped in one sub-step.
/// Therefore SetRegulValvePositionOp operations are added and removed to subsequent states one by one. /// Therefore SetRegulValvePositionOp operations are added and removed to subsequent states one by one.
@ -780,9 +780,11 @@ namespace TBF.Rig.Sequences
/// ///
/// Always set route at the beginning of this test /// Always set route at the beginning of this test
/// ///
List<IOperation> regVPosOps = GetRegVPositioningOps(inPath.RegVPositions);
regVPosOps.AddRange(GetRegVPositioningOps(outPath.RegVPositions));
Event evnt = PerformSteps(GenericDevices.ValveBase.Merge(inPath.ValvesOpen, benchPath.ValvesOpen, outPath.ValvesOpen), Event evnt = PerformSteps(GenericDevices.ValveBase.Merge(inPath.ValvesOpen, benchPath.ValvesOpen, outPath.ValvesOpen),
GenericDevices.ValveBase.Merge(inPath.ValvesClose, benchPath.ValvesClose, outPath.ValvesClose), GenericDevices.ValveBase.Merge(inPath.ValvesClose, benchPath.ValvesClose, outPath.ValvesClose),
GetRegValvePositioningOps(OutputRegulValves, outPath.RegulValvesPct), regVPosOps,
"SequenceBase : Transition : TestStart - Default action"); "SequenceBase : Transition : TestStart - Default action");
if (evnt == Event.Error || evnt == Event.UiCmdStop) return evnt; if (evnt == Event.Error || evnt == Event.UiCmdStop) return evnt;
@ -794,11 +796,15 @@ namespace TBF.Rig.Sequences
/// ///
/// Set route for the next test /// Set route for the next test
/// ///
List<IOperation> regVPosOps = GetRegVPositioningOps(nextInPath.RegVPositions);
regVPosOps.AddRange(GetRegVPositioningOps(nextOutPath.RegVPositions));
Event evnt = PerformSteps(GenericDevices.ValveBase.Merge(nextInPath.ValvesOpen, nextBenchPath.ValvesOpen, nextOutPath.ValvesOpen), Event evnt = PerformSteps(GenericDevices.ValveBase.Merge(nextInPath.ValvesOpen, nextBenchPath.ValvesOpen, nextOutPath.ValvesOpen),
GenericDevices.ValveBase.Merge(nextInPath.ValvesClose, nextBenchPath.ValvesClose, nextOutPath.ValvesClose), GenericDevices.ValveBase.Merge(nextInPath.ValvesClose, nextBenchPath.ValvesClose, nextOutPath.ValvesClose),
GetRegValvePositioningOps(OutputRegulValves, outPath.RegulValvesPct), regVPosOps,
"SequenceBase : AfterTestWithOverlap : Default action"); "SequenceBase : AfterTestWithOverlap : Default action");
if (evnt == Event.Error || evnt == Event.UiCmdStop) return evnt;
/// Set PID coefficient, etc. /// Set PID coefficient, etc.
int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
StateMachine.ControlBoard.SetFiltersPidShortPulses(filters, nextPidCoef, (nextTolerRed == 0) ? 0 : 1); StateMachine.ControlBoard.SetFiltersPidShortPulses(filters, nextPidCoef, (nextTolerRed == 0) ? 0 : 1);

View File

@ -1,5 +1,5 @@
/// ///
/// Copyright (c) 2013-2021 Sensus Slovensko a.s. /// Copyright (c) 2013-2022 Sensus Slovensko a.s.
/// ///
using System; using System;
using System.Text; using System.Text;
@ -225,9 +225,7 @@ namespace TBF.Rig
IList<IScaleOrTank> tanks = new List<IScaleOrTank>(); IList<IScaleOrTank> tanks = new List<IScaleOrTank>();
ProcessData.IperlHeads = new List<TestMethods.iPerlCommunication.iPerlHead.IperlHead>(); ProcessData.IperlHeads = new List<TestMethods.iPerlCommunication.iPerlHead.IperlHead>();
SequenceBase.FlowMeters = new List<IFlowMeter>(); SequenceBase.FlowMeters = new List<IFlowMeter>();
SequenceBase.RegulValves = new List<IRegValve>(); SequenceBase.RegVPositions = new List<RegValvePosition>();
SequenceBase.FeedingRegulValves = new List<IRegValve>();
SequenceBase.OutputRegulValves = new List<IRegValve>();
SequenceBase.PumpsWithFM = new List<IPumpFM>(); SequenceBase.PumpsWithFM = new List<IPumpFM>();
SequenceBase.WaterMeters = new List<IWaterMeter>(); SequenceBase.WaterMeters = new List<IWaterMeter>();
SequenceBase.Cameras = new List<ICamera>(); SequenceBase.Cameras = new List<ICamera>();
@ -259,10 +257,7 @@ namespace TBF.Rig
if (cmpnt is IFlowMeter) SequenceBase.FlowMeters.Add(cmpnt as IFlowMeter); if (cmpnt is IFlowMeter) SequenceBase.FlowMeters.Add(cmpnt as IFlowMeter);
if ((cmpnt is IRegValve) && !(cmpnt is Rig.Elde.RegulValveTandem.RegulValveTandem)) if ((cmpnt is IRegValve) && !(cmpnt is Rig.Elde.RegulValveTandem.RegulValveTandem))
{ {
IRegValve rv = cmpnt as IRegValve; SequenceBase.RegVPositions.Add(new RegValvePosition(cmpnt as IRegValve));
SequenceBase.RegulValves.Add(rv);
if (rv.Category == ValveCategory.Feeding) SequenceBase.FeedingRegulValves.Add(rv);
if (rv.Category == ValveCategory.Output) SequenceBase.OutputRegulValves.Add(rv);
} }
if (cmpnt is IPumpFM && !(cmpnt is Elde.PumpTandem.Pump)) if (cmpnt is IPumpFM && !(cmpnt is Elde.PumpTandem.Pump))
{ {

View File

@ -1258,6 +1258,7 @@
<Compile Include="Rig\RegisterReaders\SerialStream\FrameReceivedEventArgs.cs" /> <Compile Include="Rig\RegisterReaders\SerialStream\FrameReceivedEventArgs.cs" />
<Compile Include="Rig\RegisterReaders\SerialStream\DatastreamFrame.cs" /> <Compile Include="Rig\RegisterReaders\SerialStream\DatastreamFrame.cs" />
<Compile Include="Rig\RegisterReaders\SerialStream\ProcParams.cs" /> <Compile Include="Rig\RegisterReaders\SerialStream\ProcParams.cs" />
<Compile Include="Rig\RegValvePosition.cs" />
<Compile Include="Rig\Sequences\DeferredTestEvaluationData.cs" /> <Compile Include="Rig\Sequences\DeferredTestEvaluationData.cs" />
<Compile Include="Rig\Sequences\MainSeqUtils.cs" /> <Compile Include="Rig\Sequences\MainSeqUtils.cs" />
<Compile Include="Rig\Sequences\Plotter.cs" /> <Compile Include="Rig\Sequences\Plotter.cs" />

View File

@ -1,14 +1,14 @@
/// ///
/// Copyright (c) 2013-2017 Sensus Metering Systems /// Copyright (c) 2013-2022 Sensus Slovensko a.s.
/// ///
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Windows.Forms; using System.Windows.Forms;
using NHibernate; using NHibernate;
using log4net; using log4net;
using Config.Entities; using Common;
using Common.Forms; using Common.Forms;
using Config.Entities;
using TBF.Rig; using TBF.Rig;
using TBF.Rig.GenericDevices; using TBF.Rig.GenericDevices;
using TBF.Resources; using TBF.Resources;
@ -34,8 +34,8 @@ namespace TBF.UI.Bench.Paths
public IList<Rig.Generic.IComponent> TbfComponents; public IList<Rig.Generic.IComponent> TbfComponents;
public IList<IValve> Valves; public IList<IValve> Valves;
public IList<IRegValve> FeedingRegulValves; public IList<IRegValve> FeedingRegValves;
public IList<IRegValve> OutputRegulValves; public IList<IRegValve> OutputRegValves;
public ISession Session; /// One common DB session passed also to the controls inside tab pages public ISession Session; /// One common DB session passed also to the controls inside tab pages
public IList<Procedure> Procedures; public IList<Procedure> Procedures;
public IList<Test> Tests; public IList<Test> Tests;
@ -54,7 +54,7 @@ namespace TBF.UI.Bench.Paths
/// SharedDlgButtons configuration /// SharedDlgButtons configuration
sharedButtons.ParentForm = this; sharedButtons.ParentForm = this;
sharedButtons.RequiredGroupMembership = new Common.GID[] { Common.GID.Metrologists }; sharedButtons.RequiredGroupMembership = new GID[] { GID.Metrologists };
sharedButtons.OptionalButtons = SharedButtons.Buttons.Add | SharedButtons.Buttons.Remove | sharedButtons.OptionalButtons = SharedButtons.Buttons.Add | SharedButtons.Buttons.Remove |
SharedButtons.Buttons.Up | SharedButtons.Buttons.Down; SharedButtons.Buttons.Up | SharedButtons.Buttons.Down;
sharedButtons.Unlocked += Unlocked; sharedButtons.Unlocked += Unlocked;
@ -80,27 +80,26 @@ namespace TBF.UI.Bench.Paths
Valves = Rig.GenericDevices.ValveBase.MasterValves(TbfComponents); Valves = Rig.GenericDevices.ValveBase.MasterValves(TbfComponents);
/// Find all feeding regulation valves /// Find all feeding regulation valves
FeedingRegulValves = new List<IRegValve>(); FeedingRegValves = new List<IRegValve>();
OutputRegulValves = new List<IRegValve>(); OutputRegValves = new List<IRegValve>();
foreach (var cmpnt in TbfComponents) foreach (var cmpnt in TbfComponents)
{ {
IRegValve regValve = cmpnt as IRegValve; if (cmpnt is IRegValve && !(cmpnt is TBF.Rig.Elde.RegulValveTandem.RegulValveTandem))
if (regValve != null && !(cmpnt is TBF.Rig.Elde.RegulValveTandem.RegulValveTandem))
{ {
switch (regValve.Category) switch ((cmpnt as IRegValve).Category)
{ {
case ValveCategory.Feeding: case ValveCategory.Feeding:
FeedingRegulValves.Add(regValve); FeedingRegValves.Add(cmpnt as IRegValve);
break; break;
case ValveCategory.Output: case ValveCategory.Output:
OutputRegulValves.Add(regValve); OutputRegValves.Add(cmpnt as IRegValve);
break; break;
} }
} }
} }
/// Create the database session for paths /// Create the database session for paths
Session = TBF.DB.CreateSession(Common.DBKind.Config); Session = TBF.DB.CreateSession(DBKind.Config);
Procedures = Session.QueryOver<Procedure>().List(); Procedures = Session.QueryOver<Procedure>().List();
Tests = Session.QueryOver<Test>().List(); Tests = Session.QueryOver<Test>().List();

View File

@ -4,7 +4,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Globalization;
using System.Windows.Forms; using System.Windows.Forms;
using log4net; using log4net;
using Common; using Common;
@ -77,18 +76,18 @@ namespace TBF.UI.Bench.Paths
Columns.Add(Strings.Pump, (ls.FeedingColumnCount > 5) ? ls.FeedingColumnWidths[5] : 60 * parent.Dpi / Constants.Dpi100pct); Columns.Add(Strings.Pump, (ls.FeedingColumnCount > 5) ? ls.FeedingColumnWidths[5] : 60 * parent.Dpi / Constants.Dpi100pct);
int clmn = (int)Column.FixedColumnsCount; int clmn = (int)Column.FixedColumnsCount;
foreach (var rv in parent.FeedingRegulValves) foreach (var rv in parent.FeedingRegValves)
{ {
Columns.Add(rv.Cfg.Name, (ls.FeedingColumnCount > clmn) ? ls.FeedingColumnWidths[clmn] : 50 * parent.Dpi / Constants.Dpi100pct); Columns.Add(string.Format("{0} [%]", rv.Name), (ls.FeedingColumnCount > clmn) ? ls.FeedingColumnWidths[clmn] : 50 * parent.Dpi / Constants.Dpi100pct);
clmn++; clmn++;
} }
regvCount = clmn - (int)Column.FixedColumnsCount; regvCount = parent.FeedingRegValves.Count;
foreach (var vlv in parent.Valves) foreach (var vlv in parent.Valves)
{ {
if (vlv.Category == TBF.Rig.ValveCategory.Feeding) if (vlv.Category == TBF.Rig.ValveCategory.Feeding)
{ {
Columns.Add(vlv.Cfg.Name, (ls.FeedingColumnCount > clmn) ? ls.FeedingColumnWidths[clmn] : 50 * parent.Dpi / Constants.Dpi100pct); Columns.Add(vlv.Name, (ls.FeedingColumnCount > clmn) ? ls.FeedingColumnWidths[clmn] : 50 * parent.Dpi / Constants.Dpi100pct);
clmn++; clmn++;
} }
} }
@ -106,7 +105,7 @@ namespace TBF.UI.Bench.Paths
if (cmpnt is IPump) pumpCBox.Items.Add(cmpnt.Cfg.Name); if (cmpnt is IPump) pumpCBox.Items.Add(cmpnt.Cfg.Name);
} }
editors = new Control[fixedColumnsCount + regvCount + 64]; editors = new Control[fixedColumnsCount + regvCount + valvesCount];
/// ///
editors[(int)Column.Name] = new TextBox(); /// Name editors[(int)Column.Name] = new TextBox(); /// Name
editors[(int)Column.Qfrom] = new TextBox(); /// Q_from editors[(int)Column.Qfrom] = new TextBox(); /// Q_from
@ -126,8 +125,8 @@ namespace TBF.UI.Bench.Paths
editors[fixedColumnsCount + i] = cb; editors[fixedColumnsCount + i] = cb;
} }
/// Prepare valve combo-boxes (max. 64 valves) /// Prepare valve combo-boxes
for (int i = 0; i < 64; i++) for (int i = 0; i < valvesCount; i++)
{ {
ComboBox cb = new ComboBox(); ComboBox cb = new ComboBox();
cb.Items.Add("---"); cb.Items.Add("---");
@ -323,18 +322,18 @@ namespace TBF.UI.Bench.Paths
/// ///
/// Regulation valves /// Regulation valves
/// ///
string regulValvesPct = string.Empty; string regulVPositions = string.Empty;
for (int i = fixedColumnsCount; i < fixedColumnsCount + regvCount; i++) for (int i = fixedColumnsCount; i < fixedColumnsCount + regvCount; i++)
{ {
if (regulValvesPct.Length > 0) regulValvesPct += ";"; if (regulVPositions.Length > 0) regulVPositions += ";";
float fdummy; float fdummy;
if (lvi.SubItems[i].Text.Equals("---") || if (lvi.SubItems[i].Text.Equals("---") ||
(Utils.TryParseUFloat(lvi.SubItems[i].Text, out fdummy) && (fdummy >= 0) && (fdummy <= 100.0f))) (Utils.TryParseUFloat(lvi.SubItems[i].Text, out fdummy) && (fdummy >= 0) && (fdummy <= 100.0f)))
{ {
regulValvesPct += lvi.SubItems[i].Text; regulVPositions += lvi.SubItems[i].Text;
} }
} }
entity.RegulValvesPct = regulValvesPct; entity.RegulValvesPct = regulVPositions;
/// ///
/// Valves /// Valves

View File

@ -112,14 +112,14 @@ namespace TBF.UI.Bench.Paths
{ {
if (vlv.Category == ValveCategory.Output) if (vlv.Category == ValveCategory.Output)
{ {
Columns.Add(vlv.Cfg.Name, (ls.OutputColumnCount > clmn) ? ls.OutputColumnWidths[clmn] : 50 * parent.Dpi / Constants.Dpi100pct); Columns.Add(vlv.Name, (ls.OutputColumnCount > clmn) ? ls.OutputColumnWidths[clmn] : 50 * parent.Dpi / Constants.Dpi100pct);
clmn++; clmn++;
valvescount++; valvescount++;
} }
} }
foreach (var rvlv in parent.OutputRegulValves) foreach (var rv in parent.OutputRegValves)
{ {
Columns.Add(rvlv.Cfg.Name + " [%]", (ls.OutputColumnCount > clmn) ? ls.OutputColumnWidths[clmn] : 55 * parent.Dpi / Constants.Dpi100pct); Columns.Add(string.Format("{0} [%]", rv.Name), (ls.OutputColumnCount > clmn) ? ls.OutputColumnWidths[clmn] : 55 * parent.Dpi / Constants.Dpi100pct);
clmn++; clmn++;
regulValvesCount++; regulValvesCount++;
} }
@ -384,12 +384,12 @@ namespace TBF.UI.Bench.Paths
} }
} }
for (int i = 0; i < parent.OutputRegulValves.Count; i++ ) foreach (var rvp in path.RegVPositions)
{ {
int subItemNr = lvi.SubItems.Count; int subItemNr = lvi.SubItems.Count;
if (i < path.RegulValvesPct.Length && 0 <= path.RegulValvesPct[i] && path.RegulValvesPct[i] <= 100) if (0 <= rvp.Position && rvp.Position <= 100)
{ {
float rvPos = path.RegulValvesPct[i]; float rvPos = rvp.Position;
lvi.SubItems.Add(rvPos.ToString()); lvi.SubItems.Add(rvPos.ToString());
lvi.SubItems[subItemNr].BackColor = (rvPos == 0) ? Color.White : Color.LightGray; lvi.SubItems[subItemNr].BackColor = (rvPos == 0) ? Color.White : Color.LightGray;
} }

View File

@ -1,12 +1,11 @@
/// ///
/// Copyright (c) 2013-2015 Sensus Metering Systems /// Copyright (c) 2013-2022 Sensus Slovensko a.s.
/// ///
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO.Ports; using System.IO.Ports;
using System.Linq; using System.Linq;
using System.Text;
using Config.Entities; using Config.Entities;
using Dirichlet.Numerics; using Dirichlet.Numerics;
@ -190,37 +189,33 @@ namespace TBF
/// <summary> /// <summary>
/// Get an array of RegulValve positions from a string /// Update a list of regulation valve position pairs from a string
/// </summary> /// </summary>
/// <param name="entity">String from TransitionStep entity defining all RegulValve positions</param> /// <param name="regVPositionsStr">String with reg.valve positions in % separated by ';'</param>
/// <returns>float[] of regulation valve positions from 0 to 100.0f</returns> /// <param name="regVPositions">List with reg. valve / position pairs</param>
public static float[] GetRegulValvesPositions(string regulValvesPct, int regvCount) public static void UpdateRegVPositionsFromStr(ref IList<Rig.RegValvePosition> regVPositions, string regVPositionsStr)
{ {
float[] result = new float[regvCount]; string[] rvPosStr = string.IsNullOrEmpty(regVPositionsStr) ? new string[0] : regVPositionsStr.Split(new char[] { ';' });
string[] rvPosStr = string.IsNullOrEmpty(regulValvesPct) ? new string[0] : regulValvesPct.Split(new char[] { ';' }); for (int i = 0; i < Math.Min(rvPosStr.Length, regVPositions.Count); i++)
for (int i = 0; i < regvCount; i++)
{ {
float fdummy; float fdummy;
if ((i < rvPosStr.Length) && Utils.TryParseUFloat(rvPosStr[i], out fdummy) && if (Utils.TryParseUFloat(rvPosStr[i], out fdummy) && fdummy >= 0 && fdummy <= 100.0f)
(fdummy >= 0) && (fdummy <= 100.0f))
{ {
result[i] = fdummy; regVPositions[i].Position = fdummy;
} }
else // if ((i < rvPosStr.Length) && rvPosStr[i].Equals("---")) else //if (rvPosStr[i].Equals("---"))
{ {
result[i] = -1.0f; /// Negative value means no regulation valve position change regVPositions[i].Position = -1.0f; /// Negative value means no regulation valve position change
} }
} }
return result;
} }
/// <summary> /// <summary>
/// Get an array of Pump-With-FM power percentages from a string /// Get an array of Pump-With-FM power percentages from a string
/// </summary> /// </summary>
/// <param name="entity">String from TransitionStep entity defining all FM pump powers</param> /// <param name="pumpWithFMPcts">String from TransitionStep entity defining all FM pump powers</param>
/// <returns>float[] of FM-pump power percentages from 0 to 100.0f</returns> /// <returns>float[] of FM-pump power percentages from 0 to 100.0f</returns>
public static float[] GetPumpWithFMPcts(string pumpWithFMPcts) public static float[] GetPumpWithFMPcts(string pumpWithFMPcts)
{ {