From bebb5e590981c5cc7e4331e80293a298691c736d Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Mon, 29 Mar 2021 22:42:04 +0200 Subject: [PATCH] Refactorization. --- TBF/Rig/OutputPath.cs | 28 ++++++++++++++-------------- TBF/Rig/Sequences/SequenceBase.cs | 4 ++-- TBF/Utils.cs | 8 ++++---- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/TBF/Rig/OutputPath.cs b/TBF/Rig/OutputPath.cs index da24df962..077b6d8de 100644 --- a/TBF/Rig/OutputPath.cs +++ b/TBF/Rig/OutputPath.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2013-2017 Sensus Metering Systems +/// Copyright (c) 2013-2017 Sensus Slovensko a.s. /// using System.Collections.Generic; using TBF.Rig.GenericDevices; @@ -39,19 +39,19 @@ namespace TBF.Rig } /// Constructor from data entity - public OutputPath(Config.Entities.OutputPath outputPathEntity, IList components) - : this(outputPathEntity.Name, outputPathEntity.ItemNr) + public OutputPath(Config.Entities.OutputPath entity, IList components) + : this(entity.Name, entity.ItemNr) { - Qfrom = outputPathEntity.Qfrom; - Qto = outputPathEntity.Qto; - FlowMeter = (IFlowMeter)TbfComponents.FindComponent(outputPathEntity.FlowMeter, components); - RegValve = (IRegValve)TbfComponents.FindComponent(outputPathEntity.RegValve, components); - PidCoef = outputPathEntity.PidCoef; - Diverter = (IDiverter)TbfComponents.FindComponent(outputPathEntity.Diverter, components); - TempMtrDiv = (ITempMeter)TbfComponents.FindComponent(outputPathEntity.TempMtrDiv, components); - Scale = (IScaleOrTank)TbfComponents.FindComponent(outputPathEntity.Scale, components); + Qfrom = entity.Qfrom; + Qto = entity.Qto; + FlowMeter = (IFlowMeter)TbfComponents.FindComponent(entity.FlowMeter, components); + RegValve = (IRegValve)TbfComponents.FindComponent(entity.RegValve, components); + PidCoef = entity.PidCoef; + Diverter = (IDiverter)TbfComponents.FindComponent(entity.Diverter, components); + TempMtrDiv = (ITempMeter)TbfComponents.FindComponent(entity.TempMtrDiv, components); + Scale = (IScaleOrTank)TbfComponents.FindComponent(entity.Scale, components); - string[] svs = outputPathEntity.StartValve != null ? outputPathEntity.StartValve.Split(new char[] { '~' }) : new string[0]; + string[] svs = entity.StartValve != null ? entity.StartValve.Split(new char[] { '~' }) : new string[0]; int iTmp; /// StartValve1 = (IValve)TbfComponents.FindComponent(((svs.Length > 0) ? svs[0] : string.Empty), components); @@ -63,11 +63,11 @@ namespace TBF.Rig InvertSV3 = (svs.Length > 6) ? svs[6].Equals("i") : false; LagSV3 = (svs.Length > 7 && int.TryParse(svs[7], out iTmp)) ? iTmp : 0; - string[] vOpen = outputPathEntity.ValvesOpen.Split(new char[] { ';' }); + string[] vOpen = entity.ValvesOpen.Split(new char[] { ';' }); ValvesOpen = new List(); foreach (var vName in vOpen) ValvesOpen.Add((IValve)TbfComponents.FindComponent(vName, components)); - string[] vClose = outputPathEntity.ValvesClose.Split(new char[] { ';' }); + string[] vClose = entity.ValvesClose.Split(new char[] { ';' }); ValvesClose = new List(); foreach (var vName in vClose) ValvesClose.Add((IValve)TbfComponents.FindComponent(vName, components)); } diff --git a/TBF/Rig/Sequences/SequenceBase.cs b/TBF/Rig/Sequences/SequenceBase.cs index f7c1fa854..c83e67d4f 100644 --- a/TBF/Rig/Sequences/SequenceBase.cs +++ b/TBF/Rig/Sequences/SequenceBase.cs @@ -594,7 +594,7 @@ namespace TBF.Rig.Sequences /// FM controlled pumps are canged imediately without using any state operations log.DebugFormat("step.PumpWithFMPcts = {0}", step.PumpWithFMPcts); - float[] allFMPumpPcts = Utils.GetPumpWithFMPcts(step); + float[] allFMPumpPcts = Utils.GetPumpWithFMPcts(step.PumpWithFMPcts); for (int i = 0; i < allFMPumpPcts.Length; i++) { float pwr = allFMPumpPcts[i]; @@ -609,7 +609,7 @@ namespace TBF.Rig.Sequences } /// Get new regulation valve positions, - float[] allRegvPositions = Utils.GetRegulValvesPositions(step); + float[] allRegvPositions = Utils.GetRegulValvesPositions(step.RegulValvesPct); /// Prepare necessary SetRegValvePositionOp operations for RV-s with changed positions IList rvPosOps = new List(); diff --git a/TBF/Utils.cs b/TBF/Utils.cs index 337cc24ba..f5d8f4b13 100644 --- a/TBF/Utils.cs +++ b/TBF/Utils.cs @@ -193,12 +193,12 @@ namespace TBF /// /// TransitionStep entity /// float[] of regulation valve positions from 0 to 100.0f - public static float[] GetRegulValvesPositions(TransitionStep step) + public static float[] GetRegulValvesPositions(string regulValvesPct) { int regvCount = Rig.Sequences.SequenceBase.RegulValves.Count; float[] result = new float[regvCount]; - string[] rvPosStr = (step.RegulValvesPct != null) ? step.RegulValvesPct.Split(new char[] { ';' }) : new string[0]; + string[] rvPosStr = (regulValvesPct != null) ? regulValvesPct.Split(new char[] { ';' }) : new string[0]; for (int i = 0; i < regvCount; i++) { float fdummy; @@ -222,12 +222,12 @@ namespace TBF /// /// TransitionStep entity /// float[] of FM-pump power percentages from 0 to 100.0f - public static float[] GetPumpWithFMPcts(TransitionStep step) + public static float[] GetPumpWithFMPcts(string pumpWithFMPcts) { int fmPumpCount = Rig.Sequences.SequenceBase.PumpsWithFM.Count; float[] result = new float[fmPumpCount]; - string[] fmPctsStr = (step.PumpWithFMPcts != null) ? step.PumpWithFMPcts.Split(new char[] { ';' }) : new string[0]; + string[] fmPctsStr = (pumpWithFMPcts != null) ? pumpWithFMPcts.Split(new char[] { ';' }) : new string[0]; for (int i = 0; i < fmPumpCount; i++) { float fdummy;