Bug fix in TBF.Utils.GetRegulVallvesPositions( ), TBF crashed when fn. was called from OutputPath from UI.

This commit is contained in:
Milan Hanajik 2021-04-28 10:44:38 +02:00
parent 4464a2025b
commit 0553caac89
3 changed files with 10 additions and 4 deletions

View File

@ -53,7 +53,14 @@ namespace TBF.BenchControl
Diverter = (IDiverter)TbfComponents.FindComponent(entity.Diverter, components);
TempDiv = (ITempMeter)TbfComponents.FindComponent(entity.TempDiv, components);
Scale = (IScaleOrTank)TbfComponents.FindComponent(entity.Scale, components);
RegulValvesPct = string.IsNullOrEmpty(entity.RegulValvesPct) ? new float[0] : Utils.GetRegulValvesPositions(entity.RegulValvesPct);
int regvCount = 0;
foreach (var cmpnt in components)
{
if ((cmpnt is IRegulValve) && !(cmpnt is BenchControl.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;
///

View File

@ -645,7 +645,7 @@ namespace TBF.BenchControl.Sequences
}
/// Get regulation valve positioning operations
IList<IOperation> rvPosOps = GetRegValvePositioningOps(RegulValves, Utils.GetRegulValvesPositions(step.RegulValvesPct));
IList<IOperation> rvPosOps = GetRegValvePositioningOps(RegulValves, Utils.GetRegulValvesPositions(step.RegulValvesPct, RegulValves.Count));
/// 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.

View File

@ -193,9 +193,8 @@ namespace TBF
/// </summary>
/// <param name="entity">String from TransitionStep entity defining all RegulValve positions</param>
/// <returns>float[] of regulation valve positions from 0 to 100.0f</returns>
public static float[] GetRegulValvesPositions(string regulValvesPct)
public static float[] GetRegulValvesPositions(string regulValvesPct, int regvCount)
{
int regvCount = BenchControl.Sequences.SequenceBase.RegulValves.Count;
float[] result = new float[regvCount];
string[] rvPosStr = string.IsNullOrEmpty(regulValvesPct) ? new string[0] : regulValvesPct.Split(new char[] { ';' });