diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index a3f2ba4e2..f24f49506 100644 --- a/TBF/Properties/AssemblyInfo.cs +++ b/TBF/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.30.1971.0")] -[assembly: AssemblyFileVersion("2.30.1971.0")] +[assembly: AssemblyVersion("2.30.1976.0")] +[assembly: AssemblyFileVersion("2.30.1976.0")] diff --git a/TBF/Rig/FeedingPath.cs b/TBF/Rig/FeedingPath.cs index 8b105a26f..93a649fae 100644 --- a/TBF/Rig/FeedingPath.cs +++ b/TBF/Rig/FeedingPath.cs @@ -14,8 +14,7 @@ namespace TBF.Rig public float Qto; public string Selector; public IValve Pump; /// pump to use with this path or null - public IList RegulValves; - public IList RegulValvesPct; + public IList RegVPositions; public IList ValvesOpen; /// a list of valves to open or null public IList ValvesClose; /// a list of valves to close or null @@ -24,10 +23,9 @@ namespace TBF.Rig { ItemNr = itemNr; Name = name; + RegVPositions = new List(); ValvesOpen = new List(); ValvesClose = new List(); - RegulValves = new List(); - RegulValvesPct = new List(); } /// Constructor from data entity @@ -40,29 +38,22 @@ namespace TBF.Rig 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) { - IRegValve regValve = cmpnt as IRegValve; - if (regValve != null && regValve.Category == TBF.Rig.ValveCategory.Feeding) + IRegValve rv = cmpnt as IRegValve; + 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[] { ';' }); ValvesOpen = new List(); foreach (var vName in vOpen) @@ -71,6 +62,9 @@ namespace TBF.Rig if (cmpnt is IValve) ValvesOpen.Add(cmpnt as IValve); } + /// + /// Regular valves to close + /// string[] vClose = entity.ValvesClose.Split(new char[] { ';' }); ValvesClose = new List(); foreach (var vName in vClose) diff --git a/TBF/Rig/IOperation.cs b/TBF/Rig/IOperation.cs index 4962b6779..08df049cd 100644 --- a/TBF/Rig/IOperation.cs +++ b/TBF/Rig/IOperation.cs @@ -1,10 +1,7 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2015 Sensus Slovensko a.s. /// using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace TBF.Rig { diff --git a/TBF/Rig/OutputPath.cs b/TBF/Rig/OutputPath.cs index d210ea1ab..acbc5f177 100644 --- a/TBF/Rig/OutputPath.cs +++ b/TBF/Rig/OutputPath.cs @@ -27,7 +27,7 @@ namespace TBF.Rig public IValve StartValve3; public bool InvertSV3; public int LagSV3; - public float[] RegulValvesPct; + public IList RegVPositions; public IList ValvesOpen; public IList ValvesClose; @@ -36,6 +36,7 @@ namespace TBF.Rig { ItemNr = itemNr; Name = name; + RegVPositions = new List(); ValvesOpen = new List(); ValvesClose = new List(); } @@ -54,13 +55,6 @@ namespace TBF.Rig TempDiv = TbfComponents.FindComponent(entity.TempDiv, components) as ITempMeter; 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]; int iTmp; /// @@ -73,6 +67,23 @@ namespace TBF.Rig InvertSV3 = (svs.Length > 6) ? svs[6].Equals("i") : false; 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[] { ';' }); ValvesOpen = new List(); foreach (var vName in vOpen) @@ -81,7 +92,10 @@ namespace TBF.Rig 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(); foreach (var vName in vClose) { diff --git a/TBF/Rig/RegValvePosition.cs b/TBF/Rig/RegValvePosition.cs new file mode 100644 index 000000000..ad214cb87 --- /dev/null +++ b/TBF/Rig/RegValvePosition.cs @@ -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; + } + } +} diff --git a/TBF/Rig/Sequences/SequenceBase.cs b/TBF/Rig/Sequences/SequenceBase.cs index fe9810fcd..af06e952c 100644 --- a/TBF/Rig/Sequences/SequenceBase.cs +++ b/TBF/Rig/Sequences/SequenceBase.cs @@ -38,13 +38,11 @@ namespace TBF.Rig.Sequences ///------------------------------------------------------------ /// Global static variables set only once. ///------------------------------------------------------------ - public static IList FlowMeters; /// list of reference flowmeters - public static IList RegulValves; /// list of regulation valves - public static IList FeedingRegulValves; /// list of feeding regulation valves - public static IList OutputRegulValves; /// list of output regulation valves - public static IList PumpsWithFM; /// list of FM controlled pumps - public static IList WaterMeters; /// list of water meters - public static IList Cameras; /// list of cameras + public static IList FlowMeters; /// list of reference flowmeters + public static IList RegVPositions; /// list of regulation valves + public static IList PumpsWithFM; /// list of FM controlled pumps + public static IList WaterMeters; /// list of water meters + public static IList Cameras; /// list of cameras ///------------------------------------------------------------ /// Procedure related (static) variables. @@ -494,27 +492,28 @@ namespace TBF.Rig.Sequences } - /// return SetRegValvePositionOp operations for RV-s with changed positions - IList GetRegValvePositioningOps(IList regValves, float[] regValvePositions) + /// + /// Returns a list of reg.valve positioning operations + /// + /// List of reg.valve/position pairs, position is in %, position LT 0 ... no operation + /// List of reg.valve positioning operations + List GetRegVPositioningOps(IList regVPositions) { - IList rvPosOps = new List(); + List rvPosOps = new List(); - 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(regValves[i].SetRegulValvePositionOp(regValvePositions[i], regValvePositions[i], 60)); - } - else - { - 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)); - } + rvPosOps.Add(rvp.RegValve.SetRegulValvePositionOp(rvp.Position, -1, 60)); + } + else + { + rvPosOps.Add(rvp.RegValve.SetRegulValvePositionOp(rvp.Position - 3.0f, rvp.Position + 3.0f, 60)); } } } @@ -608,7 +607,7 @@ namespace TBF.Rig.Sequences string activity = string.Format(message, transitionSequence.Name, step.ItemNr + 1, stepsCount); Bridge.OnActivity(this, activity); Bridge.OnMessage(this, step.Message); - log.Info(activity + " " +step.Message); + log.InfoFormat("{0} {1}", activity, step.Message); //------------------------------------------------ /// Prepare operation to switch valves @@ -646,8 +645,9 @@ namespace TBF.Rig.Sequences } } - /// Get regulation valve positioning operations - IList rvPosOps = GetRegValvePositioningOps(RegulValves, Utils.GetRegulValvesPositions(step.RegulValvesPct, RegulValves.Count)); + + Utils.UpdateRegVPositionsFromStr(ref RegVPositions, step.RegulValvesPct); + IList rvPosOps = GetRegVPositioningOps(RegVPositions); /// 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. @@ -780,9 +780,11 @@ namespace TBF.Rig.Sequences /// /// Always set route at the beginning of this test /// + List regVPosOps = GetRegVPositioningOps(inPath.RegVPositions); + regVPosOps.AddRange(GetRegVPositioningOps(outPath.RegVPositions)); Event evnt = PerformSteps(GenericDevices.ValveBase.Merge(inPath.ValvesOpen, benchPath.ValvesOpen, outPath.ValvesOpen), GenericDevices.ValveBase.Merge(inPath.ValvesClose, benchPath.ValvesClose, outPath.ValvesClose), - GetRegValvePositioningOps(OutputRegulValves, outPath.RegulValvesPct), + regVPosOps, "SequenceBase : Transition : TestStart - Default action"); if (evnt == Event.Error || evnt == Event.UiCmdStop) return evnt; @@ -794,11 +796,15 @@ namespace TBF.Rig.Sequences /// /// Set route for the next test /// + List regVPosOps = GetRegVPositioningOps(nextInPath.RegVPositions); + regVPosOps.AddRange(GetRegVPositioningOps(nextOutPath.RegVPositions)); Event evnt = PerformSteps(GenericDevices.ValveBase.Merge(nextInPath.ValvesOpen, nextBenchPath.ValvesOpen, nextOutPath.ValvesOpen), GenericDevices.ValveBase.Merge(nextInPath.ValvesClose, nextBenchPath.ValvesClose, nextOutPath.ValvesClose), - GetRegValvePositioningOps(OutputRegulValves, outPath.RegulValvesPct), + regVPosOps, "SequenceBase : AfterTestWithOverlap : Default action"); + if (evnt == Event.Error || evnt == Event.UiCmdStop) return evnt; + /// Set PID coefficient, etc. int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; StateMachine.ControlBoard.SetFiltersPidShortPulses(filters, nextPidCoef, (nextTolerRed == 0) ? 0 : 1); diff --git a/TBF/Rig/StateMachine.cs b/TBF/Rig/StateMachine.cs index a008d3596..200262bd3 100644 --- a/TBF/Rig/StateMachine.cs +++ b/TBF/Rig/StateMachine.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2013-2021 Sensus Slovensko a.s. +/// Copyright (c) 2013-2022 Sensus Slovensko a.s. /// using System; using System.Text; @@ -225,9 +225,7 @@ namespace TBF.Rig IList tanks = new List(); ProcessData.IperlHeads = new List(); SequenceBase.FlowMeters = new List(); - SequenceBase.RegulValves = new List(); - SequenceBase.FeedingRegulValves = new List(); - SequenceBase.OutputRegulValves = new List(); + SequenceBase.RegVPositions = new List(); SequenceBase.PumpsWithFM = new List(); SequenceBase.WaterMeters = new List(); SequenceBase.Cameras = new List(); @@ -259,10 +257,7 @@ namespace TBF.Rig if (cmpnt is IFlowMeter) SequenceBase.FlowMeters.Add(cmpnt as IFlowMeter); if ((cmpnt is IRegValve) && !(cmpnt is Rig.Elde.RegulValveTandem.RegulValveTandem)) { - IRegValve rv = 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); + SequenceBase.RegVPositions.Add(new RegValvePosition(cmpnt as IRegValve)); } if (cmpnt is IPumpFM && !(cmpnt is Elde.PumpTandem.Pump)) { diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index a0fa26228..db938cf48 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -1258,6 +1258,7 @@ + diff --git a/TBF/UI/Bench/Paths/PathsDlg.cs b/TBF/UI/Bench/Paths/PathsDlg.cs index f26745f7a..53bb6c84d 100644 --- a/TBF/UI/Bench/Paths/PathsDlg.cs +++ b/TBF/UI/Bench/Paths/PathsDlg.cs @@ -1,14 +1,14 @@ /// -/// Copyright (c) 2013-2017 Sensus Metering Systems +/// Copyright (c) 2013-2022 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; -using System.Globalization; using System.Windows.Forms; using NHibernate; using log4net; -using Config.Entities; +using Common; using Common.Forms; +using Config.Entities; using TBF.Rig; using TBF.Rig.GenericDevices; using TBF.Resources; @@ -34,8 +34,8 @@ namespace TBF.UI.Bench.Paths public IList TbfComponents; public IList Valves; - public IList FeedingRegulValves; - public IList OutputRegulValves; + public IList FeedingRegValves; + public IList OutputRegValves; public ISession Session; /// One common DB session passed also to the controls inside tab pages public IList Procedures; public IList Tests; @@ -54,7 +54,7 @@ namespace TBF.UI.Bench.Paths /// SharedDlgButtons configuration 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.Buttons.Up | SharedButtons.Buttons.Down; sharedButtons.Unlocked += Unlocked; @@ -80,27 +80,26 @@ namespace TBF.UI.Bench.Paths Valves = Rig.GenericDevices.ValveBase.MasterValves(TbfComponents); /// Find all feeding regulation valves - FeedingRegulValves = new List(); - OutputRegulValves = new List(); + FeedingRegValves = new List(); + OutputRegValves = new List(); foreach (var cmpnt in TbfComponents) { - IRegValve regValve = cmpnt as IRegValve; - if (regValve != null && !(cmpnt is TBF.Rig.Elde.RegulValveTandem.RegulValveTandem)) + if (cmpnt is IRegValve && !(cmpnt is TBF.Rig.Elde.RegulValveTandem.RegulValveTandem)) { - switch (regValve.Category) + switch ((cmpnt as IRegValve).Category) { case ValveCategory.Feeding: - FeedingRegulValves.Add(regValve); + FeedingRegValves.Add(cmpnt as IRegValve); break; case ValveCategory.Output: - OutputRegulValves.Add(regValve); + OutputRegValves.Add(cmpnt as IRegValve); break; } } } /// Create the database session for paths - Session = TBF.DB.CreateSession(Common.DBKind.Config); + Session = TBF.DB.CreateSession(DBKind.Config); Procedures = Session.QueryOver().List(); Tests = Session.QueryOver().List(); diff --git a/TBF/UI/Bench/Paths/PathsFeedingCtrl.cs b/TBF/UI/Bench/Paths/PathsFeedingCtrl.cs index de209c6fb..82e244499 100644 --- a/TBF/UI/Bench/Paths/PathsFeedingCtrl.cs +++ b/TBF/UI/Bench/Paths/PathsFeedingCtrl.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Drawing; -using System.Globalization; using System.Windows.Forms; using log4net; 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); 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++; } - regvCount = clmn - (int)Column.FixedColumnsCount; + regvCount = parent.FeedingRegValves.Count; foreach (var vlv in parent.Valves) { 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++; } } @@ -106,7 +105,7 @@ namespace TBF.UI.Bench.Paths 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.Qfrom] = new TextBox(); /// Q_from @@ -126,8 +125,8 @@ namespace TBF.UI.Bench.Paths editors[fixedColumnsCount + i] = cb; } - /// Prepare valve combo-boxes (max. 64 valves) - for (int i = 0; i < 64; i++) + /// Prepare valve combo-boxes + for (int i = 0; i < valvesCount; i++) { ComboBox cb = new ComboBox(); cb.Items.Add("---"); @@ -323,18 +322,18 @@ namespace TBF.UI.Bench.Paths /// /// Regulation valves /// - string regulValvesPct = string.Empty; + string regulVPositions = string.Empty; for (int i = fixedColumnsCount; i < fixedColumnsCount + regvCount; i++) { - if (regulValvesPct.Length > 0) regulValvesPct += ";"; + if (regulVPositions.Length > 0) regulVPositions += ";"; float fdummy; if (lvi.SubItems[i].Text.Equals("---") || (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 diff --git a/TBF/UI/Bench/Paths/PathsOutputCtrl.cs b/TBF/UI/Bench/Paths/PathsOutputCtrl.cs index df3aa6cfc..15926cdaf 100644 --- a/TBF/UI/Bench/Paths/PathsOutputCtrl.cs +++ b/TBF/UI/Bench/Paths/PathsOutputCtrl.cs @@ -112,14 +112,14 @@ namespace TBF.UI.Bench.Paths { 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++; 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++; 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; - 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[subItemNr].BackColor = (rvPos == 0) ? Color.White : Color.LightGray; } diff --git a/TBF/Utils.cs b/TBF/Utils.cs index cbecb5a8c..a87bbb800 100644 --- a/TBF/Utils.cs +++ b/TBF/Utils.cs @@ -1,12 +1,11 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2022 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using System.Globalization; using System.IO.Ports; using System.Linq; -using System.Text; using Config.Entities; using Dirichlet.Numerics; @@ -190,37 +189,33 @@ namespace TBF /// - /// Get an array of RegulValve positions from a string + /// Update a list of regulation valve position pairs from a string /// - /// String from TransitionStep entity defining all RegulValve positions - /// float[] of regulation valve positions from 0 to 100.0f - public static float[] GetRegulValvesPositions(string regulValvesPct, int regvCount) + /// String with reg.valve positions in % separated by ';' + /// List with reg. valve / position pairs + public static void UpdateRegVPositionsFromStr(ref IList 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 < regvCount; i++) + for (int i = 0; i < Math.Min(rvPosStr.Length, regVPositions.Count); i++) { float fdummy; - if ((i < rvPosStr.Length) && Utils.TryParseUFloat(rvPosStr[i], out fdummy) && - (fdummy >= 0) && (fdummy <= 100.0f)) + if (Utils.TryParseUFloat(rvPosStr[i], out fdummy) && 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; } /// /// Get an array of Pump-With-FM power percentages from a string /// - /// String from TransitionStep entity defining all FM pump powers + /// String from TransitionStep entity defining all FM pump powers /// float[] of FM-pump power percentages from 0 to 100.0f public static float[] GetPumpWithFMPcts(string pumpWithFMPcts) {