diff --git a/TBF/BenchControl/Elde/Pump/Pump.cs b/TBF/BenchControl/BuiltIn/Pump/Pump.cs similarity index 84% rename from TBF/BenchControl/Elde/Pump/Pump.cs rename to TBF/BenchControl/BuiltIn/Pump/Pump.cs index ffc1dd7da..dcaee375a 100644 --- a/TBF/BenchControl/Elde/Pump/Pump.cs +++ b/TBF/BenchControl/BuiltIn/Pump/Pump.cs @@ -1,12 +1,13 @@ /// -/// Copyright (c) 2013-2016 Sensus Metering Systems +/// Copyright (c) 2013-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using Dirichlet.Numerics; using log4net; +using TBF.BenchControl.ControlBoard; -namespace TBF.BenchControl.Elde.Pump +namespace TBF.BenchControl.BuiltIn.Pump { public class Pump : ComponentBase, GenericDevices.IPump, GenericDevices.IValve { @@ -27,7 +28,7 @@ namespace TBF.BenchControl.Elde.Pump public float Power { get { return State ? 100.0f : 0; } } - readonly ControlBoardDev controlBoard; + readonly IControlBoard controlBoard; readonly int bitPosition; /// 0 .. 127 public readonly UInt128 Mask; /// derived from bitPosition in the constructor @@ -42,7 +43,7 @@ namespace TBF.BenchControl.Elde.Pump { pumpCfg = cfg as PumpCfg; - controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components); + controlBoard = TbfComponents.FindComponent(cfg.ParentName, components) as IControlBoard; if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent"); bitPosition = pumpCfg.BitPosition; diff --git a/TBF/BenchControl/Elde/Pump/PumpCfg.cs b/TBF/BenchControl/BuiltIn/Pump/PumpCfg.cs similarity index 96% rename from TBF/BenchControl/Elde/Pump/PumpCfg.cs rename to TBF/BenchControl/BuiltIn/Pump/PumpCfg.cs index 9aa64bf74..90f18e5b3 100644 --- a/TBF/BenchControl/Elde/Pump/PumpCfg.cs +++ b/TBF/BenchControl/BuiltIn/Pump/PumpCfg.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Xml.Serialization; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Elde.Pump +namespace TBF.BenchControl.BuiltIn.Pump { public class PumpCfg : ComponentCfgBase, IChildComponentCfg { diff --git a/TBF/BenchControl/Elde/Pump/PumpCfgCtrl.Designer.cs b/TBF/BenchControl/BuiltIn/Pump/PumpCfgCtrl.Designer.cs similarity index 99% rename from TBF/BenchControl/Elde/Pump/PumpCfgCtrl.Designer.cs rename to TBF/BenchControl/BuiltIn/Pump/PumpCfgCtrl.Designer.cs index 060f48b5d..760e8bf26 100644 --- a/TBF/BenchControl/Elde/Pump/PumpCfgCtrl.Designer.cs +++ b/TBF/BenchControl/BuiltIn/Pump/PumpCfgCtrl.Designer.cs @@ -1,7 +1,7 @@ /// /// Copyright (c) 2013-2015 Sensus Metering Systems /// -namespace TBF.BenchControl.Elde.Pump +namespace TBF.BenchControl.BuiltIn.Pump { partial class PumpCfgCtrl { diff --git a/TBF/BenchControl/Elde/Pump/PumpCfgCtrl.cs b/TBF/BenchControl/BuiltIn/Pump/PumpCfgCtrl.cs similarity index 95% rename from TBF/BenchControl/Elde/Pump/PumpCfgCtrl.cs rename to TBF/BenchControl/BuiltIn/Pump/PumpCfgCtrl.cs index b003c4018..94e8c33b3 100644 --- a/TBF/BenchControl/Elde/Pump/PumpCfgCtrl.cs +++ b/TBF/BenchControl/BuiltIn/Pump/PumpCfgCtrl.cs @@ -6,7 +6,7 @@ using System.Windows.Forms; using Config.Entities; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Elde.Pump +namespace TBF.BenchControl.BuiltIn.Pump { public partial class PumpCfgCtrl : UserControl, IComponentCfgCtrl { @@ -39,7 +39,7 @@ namespace TBF.BenchControl.Elde.Pump { foreach (var cmpnt in parent.TbfComponents) { - if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.ControlBoardFactory) + if (cmpnt.ClassName.Contains("ControlBoard")) { parentNameComboBox.Items.Add(cmpnt.Name); } diff --git a/TBF/BenchControl/Elde/Pump/PumpCfgCtrl.resx b/TBF/BenchControl/BuiltIn/Pump/PumpCfgCtrl.resx similarity index 100% rename from TBF/BenchControl/Elde/Pump/PumpCfgCtrl.resx rename to TBF/BenchControl/BuiltIn/Pump/PumpCfgCtrl.resx diff --git a/TBF/BenchControl/Elde/Pump/PumpFactory.cs b/TBF/BenchControl/BuiltIn/Pump/PumpFactory.cs similarity index 95% rename from TBF/BenchControl/Elde/Pump/PumpFactory.cs rename to TBF/BenchControl/BuiltIn/Pump/PumpFactory.cs index 05a5f3bd5..0c8530a26 100644 --- a/TBF/BenchControl/Elde/Pump/PumpFactory.cs +++ b/TBF/BenchControl/BuiltIn/Pump/PumpFactory.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Elde.Pump +namespace TBF.BenchControl.BuiltIn.Pump { public class PumpFactory : IComponentFactory { diff --git a/TBF/BenchControl/Elde/PumpTandem/Pump.cs b/TBF/BenchControl/BuiltIn/PumpTandem/Pump.cs similarity index 93% rename from TBF/BenchControl/Elde/PumpTandem/Pump.cs rename to TBF/BenchControl/BuiltIn/PumpTandem/Pump.cs index b2c6309c6..cb5e792c3 100644 --- a/TBF/BenchControl/Elde/PumpTandem/Pump.cs +++ b/TBF/BenchControl/BuiltIn/PumpTandem/Pump.cs @@ -1,12 +1,13 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using Dirichlet.Numerics; using log4net; +using TBF.BenchControl.ControlBoard.Legacy; -namespace TBF.BenchControl.Elde.PumpTandem +namespace TBF.BenchControl.BuiltIn.PumpTandem { public class Pump : ComponentBase, GenericDevices.IPumpFM, GenericDevices.IValve, IOperation { @@ -61,12 +62,12 @@ namespace TBF.BenchControl.Elde.PumpTandem pumpFm1 = pump1 as GenericDevices.IPumpFM; pumpFm2 = pump2 as GenericDevices.IPumpFM; - if (pump1 is Elde.Pump.Pump) { mask1 = (pump1 as Elde.Pump.Pump).Mask; } + if (pump1 is BuiltIn.Pump.Pump) { mask1 = (pump1 as BuiltIn.Pump.Pump).Mask; } else if (pump1 is Elde.PumpWithFM.Pump) { mask1 = (pump1 as Elde.PumpWithFM.Pump).Mask; } else if (pump1 is Danfoss.VLT2800.Pump) { mask1 = (pump1 as Danfoss.VLT2800.Pump).Mask; } else { mask1 = 0; } - if (pump2 is Elde.Pump.Pump) { mask2 = (pump2 as Elde.Pump.Pump).Mask; } + if (pump2 is BuiltIn.Pump.Pump) { mask2 = (pump2 as BuiltIn.Pump.Pump).Mask; } else if (pump2 is Elde.PumpWithFM.Pump) { mask2 = (pump2 as Elde.PumpWithFM.Pump).Mask; } else if (pump2 is Danfoss.VLT2800.Pump) { mask2 = (pump2 as Danfoss.VLT2800.Pump).Mask; } else { mask2 = 0; } diff --git a/TBF/BenchControl/Elde/PumpTandem/PumpCfg.cs b/TBF/BenchControl/BuiltIn/PumpTandem/PumpCfg.cs similarity index 96% rename from TBF/BenchControl/Elde/PumpTandem/PumpCfg.cs rename to TBF/BenchControl/BuiltIn/PumpTandem/PumpCfg.cs index 58cc202bf..bdae5682c 100644 --- a/TBF/BenchControl/Elde/PumpTandem/PumpCfg.cs +++ b/TBF/BenchControl/BuiltIn/PumpTandem/PumpCfg.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Xml.Serialization; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Elde.PumpTandem +namespace TBF.BenchControl.BuiltIn.PumpTandem { public class PumpCfg : ComponentCfgBase, IChildComponentCfg { diff --git a/TBF/BenchControl/Elde/PumpTandem/PumpCfgCtrl.Designer.cs b/TBF/BenchControl/BuiltIn/PumpTandem/PumpCfgCtrl.Designer.cs similarity index 99% rename from TBF/BenchControl/Elde/PumpTandem/PumpCfgCtrl.Designer.cs rename to TBF/BenchControl/BuiltIn/PumpTandem/PumpCfgCtrl.Designer.cs index b7d55423c..762a887d3 100644 --- a/TBF/BenchControl/Elde/PumpTandem/PumpCfgCtrl.Designer.cs +++ b/TBF/BenchControl/BuiltIn/PumpTandem/PumpCfgCtrl.Designer.cs @@ -1,7 +1,7 @@ /// /// Copyright (c) 2013-2015 Sensus Metering Systems /// -namespace TBF.BenchControl.Elde.PumpTandem +namespace TBF.BenchControl.BuiltIn.PumpTandem { partial class PumpCfgCtrl { diff --git a/TBF/BenchControl/Elde/PumpTandem/PumpCfgCtrl.cs b/TBF/BenchControl/BuiltIn/PumpTandem/PumpCfgCtrl.cs similarity index 93% rename from TBF/BenchControl/Elde/PumpTandem/PumpCfgCtrl.cs rename to TBF/BenchControl/BuiltIn/PumpTandem/PumpCfgCtrl.cs index d780f0d75..8e33ec3e9 100644 --- a/TBF/BenchControl/Elde/PumpTandem/PumpCfgCtrl.cs +++ b/TBF/BenchControl/BuiltIn/PumpTandem/PumpCfgCtrl.cs @@ -6,7 +6,7 @@ using System.Windows.Forms; using Config.Entities; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Elde.PumpTandem +namespace TBF.BenchControl.BuiltIn.PumpTandem { public partial class PumpCfgCtrl : UserControl, IComponentCfgCtrl { @@ -39,10 +39,10 @@ namespace TBF.BenchControl.Elde.PumpTandem { foreach (var cmpnt in parentDlg.TbfComponents) { - if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.Pump.PumpFactory || + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is BuiltIn.Pump.PumpFactory || TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.PumpWithFM.PumpFactory || TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Danfoss.VLT2800.PumpFactory || - TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.PumpTandem.PumpFactory) + TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is BuiltIn.PumpTandem.PumpFactory) { pump1ComboBox.Items.Add(cmpnt.Name); pump2ComboBox.Items.Add(cmpnt.Name); diff --git a/TBF/BenchControl/Elde/PumpTandem/PumpCfgCtrl.resx b/TBF/BenchControl/BuiltIn/PumpTandem/PumpCfgCtrl.resx similarity index 100% rename from TBF/BenchControl/Elde/PumpTandem/PumpCfgCtrl.resx rename to TBF/BenchControl/BuiltIn/PumpTandem/PumpCfgCtrl.resx diff --git a/TBF/BenchControl/Elde/PumpTandem/PumpFactory.cs b/TBF/BenchControl/BuiltIn/PumpTandem/PumpFactory.cs similarity index 94% rename from TBF/BenchControl/Elde/PumpTandem/PumpFactory.cs rename to TBF/BenchControl/BuiltIn/PumpTandem/PumpFactory.cs index 7bf37b0fc..c073a2574 100644 --- a/TBF/BenchControl/Elde/PumpTandem/PumpFactory.cs +++ b/TBF/BenchControl/BuiltIn/PumpTandem/PumpFactory.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Elde.PumpTandem +namespace TBF.BenchControl.BuiltIn.PumpTandem { public class PumpFactory : IComponentFactory { diff --git a/TBF/BenchControl/Elde/SetValvesOp.cs b/TBF/BenchControl/BuiltIn/SetValvesOp.cs similarity index 65% rename from TBF/BenchControl/Elde/SetValvesOp.cs rename to TBF/BenchControl/BuiltIn/SetValvesOp.cs index 949a5f1f5..9053c1fe6 100644 --- a/TBF/BenchControl/Elde/SetValvesOp.cs +++ b/TBF/BenchControl/BuiltIn/SetValvesOp.cs @@ -1,20 +1,21 @@ /// -/// Copyright (c) 2013-2018 Sensus Slovensko a.s. +/// Copyright (c) 2013-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; -using TBF.BenchControl.GenericDevices; using Dirichlet.Numerics; +using TBF.BenchControl.ControlBoard; +using TBF.BenchControl.GenericDevices; -namespace TBF.BenchControl.Elde +namespace TBF.BenchControl.BuiltIn { public class SetValvesOp : IOperation { private static readonly ILog log = LogManager.GetLogger(typeof(SetValvesOp)); /// Set by the constructor - ControlBoardDev controlBoard; + IControlBoard controlBoard; class SwitchPoint { @@ -42,9 +43,9 @@ namespace TBF.BenchControl.Elde foreach (var vlv in VOpen) { /// Skip the delay evaluation and update in case the valve/pump have not changed - if (vlv is Valve.Valve && ((vlv as Valve.Valve).Mask & changed) == 0) continue; + if (vlv is Valve.Valve && ((vlv as Valve.Valve).Mask & changed) == 0) continue; if (vlv is Pump.Pump && ((vlv as Pump.Pump).Mask & changed) == 0) continue; - if (vlv is PumpWithFM.Pump && ((vlv as PumpWithFM.Pump).Mask & changed) == 0) continue; + if (vlv is Elde.PumpWithFM.Pump && ((vlv as Elde.PumpWithFM.Pump).Mask & changed) == 0) continue; if (vlv is Danfoss.VLT2800.Pump && ((vlv as Danfoss.VLT2800.Pump).Mask & changed) == 0) continue; if ((vlv != null) && (vlv.Delay > max)) max = vlv.Delay; @@ -52,9 +53,9 @@ namespace TBF.BenchControl.Elde foreach (var vlv in VClose) { /// Skip the delay evaluation and update in case the valve/pump have not changed - if (vlv is Valve.Valve && ((vlv as Valve.Valve).Mask & changed) == 0) continue; + if (vlv is Valve.Valve && ((vlv as Valve.Valve).Mask & changed) == 0) continue; if (vlv is Pump.Pump && ((vlv as Pump.Pump).Mask & changed) == 0) continue; - if (vlv is PumpWithFM.Pump && ((vlv as PumpWithFM.Pump).Mask & changed) == 0) continue; + if (vlv is Elde.PumpWithFM.Pump && ((vlv as Elde.PumpWithFM.Pump).Mask & changed) == 0) continue; if (vlv is Danfoss.VLT2800.Pump && ((vlv as Danfoss.VLT2800.Pump).Mask & changed) == 0) continue; if ((vlv != null) && (vlv.Delay > max)) max = vlv.Delay; @@ -135,8 +136,8 @@ namespace TBF.BenchControl.Elde } else { - lastAdded.VOpen = ValveBase.Merge(lastAdded.VOpen, first.VOpen); - lastAdded.VClose = ValveBase.Merge(lastAdded.VClose, first.VClose); + lastAdded.VOpen = ValveBase.Merge(lastAdded.VOpen, first.VOpen); + lastAdded.VClose = ValveBase.Merge(lastAdded.VClose, first.VClose); } unsorted.Remove(first); } @@ -152,20 +153,20 @@ namespace TBF.BenchControl.Elde point.MasksOpen = 0; foreach (var valve in point.VOpen) { - if (valve is Valve.Valve) point.MasksOpen |= (valve as Valve.Valve).Mask; - if (valve is Pump.Pump) point.MasksOpen |= (valve as Pump.Pump).Mask; - if (valve is PumpWithFM.Pump) point.MasksOpen |= (valve as PumpWithFM.Pump).Mask; - if (valve is Danfoss.VLT2800.Pump) point.MasksOpen |= (valve as Danfoss.VLT2800.Pump).Mask; - if (valve is PumpTandem.Pump) point.MasksOpen |= (valve as PumpTandem.Pump).Mask; + if (valve is Valve.Valve) point.MasksOpen |= (valve as Valve.Valve).Mask; + if (valve is Pump.Pump) point.MasksOpen |= (valve as Pump.Pump).Mask; + if (valve is Elde.PumpWithFM.Pump) point.MasksOpen |= (valve as Elde.PumpWithFM.Pump).Mask; + if (valve is Danfoss.VLT2800.Pump) point.MasksOpen |= (valve as Danfoss.VLT2800.Pump).Mask; + if (valve is PumpTandem.Pump) point.MasksOpen |= (valve as PumpTandem.Pump).Mask; } point.MasksClose = 0; foreach (var valve in point.VClose) { - if (valve is Valve.Valve) point.MasksClose |= (valve as Valve.Valve).Mask; - if (valve is Pump.Pump) point.MasksClose |= (valve as Pump.Pump).Mask; - if (valve is PumpWithFM.Pump) point.MasksClose |= (valve as PumpWithFM.Pump).Mask; - if (valve is Danfoss.VLT2800.Pump) point.MasksClose |= (valve as Danfoss.VLT2800.Pump).Mask; - if (valve is PumpTandem.Pump) point.MasksClose |= (valve as PumpTandem.Pump).Mask; + if (valve is Valve.Valve) point.MasksClose |= (valve as Valve.Valve).Mask; + if (valve is Pump.Pump) point.MasksClose |= (valve as Pump.Pump).Mask; + if (valve is Elde.PumpWithFM.Pump) point.MasksClose |= (valve as Elde.PumpWithFM.Pump).Mask; + if (valve is Danfoss.VLT2800.Pump) point.MasksClose |= (valve as Danfoss.VLT2800.Pump).Mask; + if (valve is PumpTandem.Pump) point.MasksClose |= (valve as PumpTandem.Pump).Mask; } point.TimeSec += timeShift; } @@ -176,14 +177,14 @@ namespace TBF.BenchControl.Elde /// Open and/or close multiple valves. /// Events: ValvesSet /// - /// Control board device + /// Control board device /// A list of opening master valves /// A list of closing master valves /// Only Elde.Valve valves are used, other valves on the lists are ignored - public SetValvesOp(ControlBoardDev controlBoard, IList valvesOpen, IList valvesClose) + public SetValvesOp(IControlBoard cb, IList valvesOpen, IList valvesClose) { - if (controlBoard == null) throw new ArgumentNullException("ctrlBoard"); - this.controlBoard = controlBoard; + controlBoard = cb; + if (controlBoard == null) throw new ArgumentNullException("ctrlBoard"); if (valvesOpen == null) valvesOpen = new List(); if (valvesClose == null) valvesClose = new List(); @@ -199,12 +200,12 @@ namespace TBF.BenchControl.Elde /// Open one valve and/or close one valve. /// Events: ValvesSet /// - /// Control board device + /// Control board device /// Valve to be opened /// Valve to be closed /// Only Elde.Valve valves are used, other valves on the lists are ignored - public SetValvesOp(ControlBoardDev controlBoard, IValve valveOpen, IValve valveClose) - : this(controlBoard, ValveBase.MakeList(valveOpen), ValveBase.MakeList(valveClose)) + public SetValvesOp(IControlBoard cb, IValve valveOpen, IValve valveClose) + : this(cb, ValveBase.MakeList(valveOpen), ValveBase.MakeList(valveClose)) { } @@ -213,49 +214,61 @@ namespace TBF.BenchControl.Elde /// Events: ValvesSet /// /// Control board device - /// true: close start valve, false: open start valve + /// true: open start valve, false: close start valve /// OutputPath specifying the start valve and associated valves/pumps /// Only Elde.Valve valves are used, other valves on the lists are ignored - public SetValvesOp(ControlBoardDev controlBoard, bool close, OutputPath outPath) + public SetValvesOp(IControlBoard cb, bool open, OutputPath outPath) { - if (controlBoard == null) throw new ArgumentNullException("ctrlBoard"); - this.controlBoard = controlBoard; + controlBoard = cb; + if (controlBoard == null) throw new ArgumentNullException("ctrlBoard"); IList none = new List(); /// An empty list of valves switchPointsRaw = new List(); - if (close) + if (open) { - if (outPath.InvertSV1) AddSwitchPoints(switchPointsRaw, ValveBase.MakeList(outPath.StartValve1), none, 0); - else AddSwitchPoints(switchPointsRaw, none, ValveBase.MakeList(outPath.StartValve1), 0); + if (outPath.InvertSV1) + AddSwitchPoints(switchPointsRaw, none, ValveBase.MakeList(outPath.StartValve1), 0); /// close SV1 + else + AddSwitchPoints(switchPointsRaw, ValveBase.MakeList(outPath.StartValve1), none, 0); /// open SV1 if (outPath.StartValve2 != null) { - if (outPath.InvertSV2) AddSwitchPoints(switchPointsRaw, ValveBase.MakeList(outPath.StartValve2), none, outPath.LagSV2); - else AddSwitchPoints(switchPointsRaw, none, ValveBase.MakeList(outPath.StartValve2), outPath.LagSV2); + if (outPath.InvertSV2) + AddSwitchPoints(switchPointsRaw, none, ValveBase.MakeList(outPath.StartValve2), -outPath.LagSV2); /// close SV2 after lag + else + AddSwitchPoints(switchPointsRaw, ValveBase.MakeList(outPath.StartValve2), none, -outPath.LagSV2); /// open SV2 after lag } if (outPath.StartValve3 != null) { - if (outPath.InvertSV3) AddSwitchPoints(switchPointsRaw, ValveBase.MakeList(outPath.StartValve3), none, outPath.LagSV3); - else AddSwitchPoints(switchPointsRaw, none, ValveBase.MakeList(outPath.StartValve3), outPath.LagSV3); + if (outPath.InvertSV3) + AddSwitchPoints(switchPointsRaw, none, ValveBase.MakeList(outPath.StartValve3), -outPath.LagSV3); /// close SV3 after lag + else + AddSwitchPoints(switchPointsRaw, ValveBase.MakeList(outPath.StartValve3), none, -outPath.LagSV3); /// open SV3 after lag } } else { - if (outPath.InvertSV1) AddSwitchPoints(switchPointsRaw, none, ValveBase.MakeList(outPath.StartValve1), 0); - else AddSwitchPoints(switchPointsRaw, ValveBase.MakeList(outPath.StartValve1), none, 0); + if (outPath.InvertSV1) + AddSwitchPoints(switchPointsRaw, ValveBase.MakeList(outPath.StartValve1), none, 0); /// open SV1 + else + AddSwitchPoints(switchPointsRaw, none, ValveBase.MakeList(outPath.StartValve1), 0); /// close SV1 if (outPath.StartValve2 != null) { - if (outPath.InvertSV2) AddSwitchPoints(switchPointsRaw, none, ValveBase.MakeList(outPath.StartValve2), -outPath.LagSV2); - else AddSwitchPoints(switchPointsRaw, ValveBase.MakeList(outPath.StartValve2), none, -outPath.LagSV2); + if (outPath.InvertSV2) + AddSwitchPoints(switchPointsRaw, ValveBase.MakeList(outPath.StartValve2), none, outPath.LagSV2); /// open SV2 after lag + else + AddSwitchPoints(switchPointsRaw, none, ValveBase.MakeList(outPath.StartValve2), outPath.LagSV2); /// close SV2 after lag } if (outPath.StartValve3 != null) { - if (outPath.InvertSV3) AddSwitchPoints(switchPointsRaw, none, ValveBase.MakeList(outPath.StartValve3), -outPath.LagSV3); - else AddSwitchPoints(switchPointsRaw, ValveBase.MakeList(outPath.StartValve3), none, -outPath.LagSV3); + if (outPath.InvertSV3) + AddSwitchPoints(switchPointsRaw, ValveBase.MakeList(outPath.StartValve3), none, outPath.LagSV3); /// open SV3 after lag + else + AddSwitchPoints(switchPointsRaw, none, ValveBase.MakeList(outPath.StartValve3), outPath.LagSV3); /// close SV3 after lag } } @@ -281,8 +294,7 @@ namespace TBF.BenchControl.Elde { if (nextIx >= switchPoints.Count) { - if (StateMachine.Time >= swStartTime + maxDelayTime) return Event.ValvesSet; - else return Event.ValvesBusy; + return (StateMachine.Time >= swStartTime + maxDelayTime) ? Event.ValvesSet : Event.ValvesBusy; } if (StateMachine.Time >= swStartTime + switchPoints[nextIx].TimeSec) diff --git a/TBF/BenchControl/Elde/Valve/Valve.cs b/TBF/BenchControl/BuiltIn/Valve/Valve.cs similarity index 88% rename from TBF/BenchControl/Elde/Valve/Valve.cs rename to TBF/BenchControl/BuiltIn/Valve/Valve.cs index bfc698b55..433bc2a25 100644 --- a/TBF/BenchControl/Elde/Valve/Valve.cs +++ b/TBF/BenchControl/BuiltIn/Valve/Valve.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2013-2016 Sensus Metering Systems +/// Copyright (c) 2013-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -7,16 +7,16 @@ using Dirichlet.Numerics; using log4net; using TBF.BenchControl.GenericDevices; -namespace TBF.BenchControl.Elde.Valve +namespace TBF.BenchControl.BuiltIn.Valve { - public class Valve : GenericDevices.ValveBase, IValve + public class Valve : ValveBase, IValve { private static readonly ILog log = LogManager.GetLogger(typeof(Valve)); public override string ToString() { return string.Format("Valve({0})", Cfg.ToString(1)); } readonly ValveCfg valveCfg; - readonly ControlBoardDev controlBoard; + readonly TBF.BenchControl.ControlBoard.IControlBoard controlBoard; public ValveCategory Category { get { return valveCfg.Category; } } public int Delay { get { return valveCfg.OpenCloseTime; } } @@ -43,7 +43,7 @@ namespace TBF.BenchControl.Elde.Valve { valveCfg = cfg as ValveCfg; - controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components); + controlBoard = TbfComponents.FindComponent(cfg.ParentName, components) as TBF.BenchControl.ControlBoard.IControlBoard; if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent"); if (valveCfg.BitPosition < 0 || valveCfg.BitPosition >= 128) diff --git a/TBF/BenchControl/Elde/Valve/ValveCfg.cs b/TBF/BenchControl/BuiltIn/Valve/ValveCfg.cs similarity index 98% rename from TBF/BenchControl/Elde/Valve/ValveCfg.cs rename to TBF/BenchControl/BuiltIn/Valve/ValveCfg.cs index 3b8f3b80a..d35c0fb5f 100644 --- a/TBF/BenchControl/Elde/Valve/ValveCfg.cs +++ b/TBF/BenchControl/BuiltIn/Valve/ValveCfg.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Xml.Serialization; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Elde.Valve +namespace TBF.BenchControl.BuiltIn.Valve { public class ValveCfg : ComponentCfgBase, IChildComponentCfg { diff --git a/TBF/BenchControl/Elde/Valve/ValveCfgCtrl.Designer.cs b/TBF/BenchControl/BuiltIn/Valve/ValveCfgCtrl.Designer.cs similarity index 99% rename from TBF/BenchControl/Elde/Valve/ValveCfgCtrl.Designer.cs rename to TBF/BenchControl/BuiltIn/Valve/ValveCfgCtrl.Designer.cs index ad480f05d..908c94e57 100644 --- a/TBF/BenchControl/Elde/Valve/ValveCfgCtrl.Designer.cs +++ b/TBF/BenchControl/BuiltIn/Valve/ValveCfgCtrl.Designer.cs @@ -1,7 +1,7 @@ /// /// Copyright (c) 2013-2015 Sensus Metering Systems /// -namespace TBF.BenchControl.Elde.Valve +namespace TBF.BenchControl.BuiltIn.Valve { partial class ValveCfgCtrl { diff --git a/TBF/BenchControl/Elde/Valve/ValveCfgCtrl.cs b/TBF/BenchControl/BuiltIn/Valve/ValveCfgCtrl.cs similarity index 97% rename from TBF/BenchControl/Elde/Valve/ValveCfgCtrl.cs rename to TBF/BenchControl/BuiltIn/Valve/ValveCfgCtrl.cs index 6106bcbf5..3f6fd8e00 100644 --- a/TBF/BenchControl/Elde/Valve/ValveCfgCtrl.cs +++ b/TBF/BenchControl/BuiltIn/Valve/ValveCfgCtrl.cs @@ -6,7 +6,7 @@ using System.Windows.Forms; using Config.Entities; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Elde.Valve +namespace TBF.BenchControl.BuiltIn.Valve { public partial class ValveCfgCtrl : UserControl, IComponentCfgCtrl { @@ -47,11 +47,11 @@ namespace TBF.BenchControl.Elde.Valve coupledToComboBox.Items.Add("---"); foreach (var cmpnt in parent.TbfComponents) { - if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.ControlBoardFactory) - { + if (cmpnt.ClassName.Contains("ControlBoard")) + { parentNameComboBox.Items.Add(cmpnt.Name); } - if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.Valve.ValveFactory) + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is BuiltIn.Valve.ValveFactory) { coupledToComboBox.Items.Add(cmpnt.Name); } diff --git a/TBF/BenchControl/Elde/Valve/ValveCfgCtrl.resx b/TBF/BenchControl/BuiltIn/Valve/ValveCfgCtrl.resx similarity index 100% rename from TBF/BenchControl/Elde/Valve/ValveCfgCtrl.resx rename to TBF/BenchControl/BuiltIn/Valve/ValveCfgCtrl.resx diff --git a/TBF/BenchControl/Elde/Valve/ValveFactory.cs b/TBF/BenchControl/BuiltIn/Valve/ValveFactory.cs similarity index 94% rename from TBF/BenchControl/Elde/Valve/ValveFactory.cs rename to TBF/BenchControl/BuiltIn/Valve/ValveFactory.cs index cd1b5a071..4f42a0a89 100644 --- a/TBF/BenchControl/Elde/Valve/ValveFactory.cs +++ b/TBF/BenchControl/BuiltIn/Valve/ValveFactory.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Elde.Valve +namespace TBF.BenchControl.BuiltIn.Valve { public class ValveFactory : IComponentFactory { diff --git a/TBF/BenchControl/GenericDevices/ValveBase.cs b/TBF/BenchControl/BuiltIn/ValveBase.cs similarity index 85% rename from TBF/BenchControl/GenericDevices/ValveBase.cs rename to TBF/BenchControl/BuiltIn/ValveBase.cs index f897dd047..894b6277e 100644 --- a/TBF/BenchControl/GenericDevices/ValveBase.cs +++ b/TBF/BenchControl/BuiltIn/ValveBase.cs @@ -3,8 +3,9 @@ /// using System; using System.Collections.Generic; +using TBF.BenchControl.GenericDevices; -namespace TBF.BenchControl.GenericDevices +namespace TBF.BenchControl.BuiltIn { public class ValveBase : ComponentBase { @@ -32,7 +33,7 @@ namespace TBF.BenchControl.GenericDevices /// /// Process the list of components and return masters valves /// - public static IList MasterValves(IList cmpnts) + public static IList GetMasterValves(IList cmpnts) { IList result = new List(); foreach (var cmpnt in cmpnts) @@ -60,12 +61,12 @@ namespace TBF.BenchControl.GenericDevices /// /// Process the list of components and return extended valves /// - public static IList ExtendedValves(IList cmpnts) + public static IList ExtendedValves(IList cmpnts) { - IList result = new List(); + IList result = new List(); foreach (var cmpnt in cmpnts) { - if (cmpnt is Elde.ValveEx.Valve) result.Add(cmpnt as Elde.ValveEx.Valve); + if (cmpnt is BuiltIn.ValveEx.Valve) result.Add(cmpnt as BuiltIn.ValveEx.Valve); } return result; } diff --git a/TBF/BenchControl/Elde/ValveEx/Valve.cs b/TBF/BenchControl/BuiltIn/ValveEx/Valve.cs similarity index 75% rename from TBF/BenchControl/Elde/ValveEx/Valve.cs rename to TBF/BenchControl/BuiltIn/ValveEx/Valve.cs index b734e9770..c33d5ff0b 100644 --- a/TBF/BenchControl/Elde/ValveEx/Valve.cs +++ b/TBF/BenchControl/BuiltIn/ValveEx/Valve.cs @@ -7,7 +7,7 @@ using log4net; using TBF.BenchControl.GenericDevices; using Dirichlet.Numerics; -namespace TBF.BenchControl.Elde.ValveEx +namespace TBF.BenchControl.BuiltIn.ValveEx { public class Valve : ComponentBase, Generic.IComponent { @@ -16,7 +16,7 @@ namespace TBF.BenchControl.Elde.ValveEx readonly ValveCfg valveCfg; - public readonly UInt128 Mask; /// derived from bitPosition in the constructor + public readonly UInt128 Mask; /// derived from bitPosition in the constructor /// public readonly IValve[] InputValves; @@ -41,12 +41,18 @@ namespace TBF.BenchControl.Elde.ValveEx InputValves = new IValve[valveCfg.InputValvesCount]; InputValves[0] = TbfComponents.FindComponent(valveCfg.Input1, components) as IValve; InputValves[1] = TbfComponents.FindComponent(valveCfg.Input2, components) as IValve; - if (InputValves.Length > 2) - InputValves[2] = TbfComponents.FindComponent(valveCfg.Input3, components) as IValve; - if (InputValves.Length > 3) - InputValves[3] = TbfComponents.FindComponent(valveCfg.Input4, components) as IValve; - if (InputValves.Length > 4) - InputValves[4] = TbfComponents.FindComponent(valveCfg.Input5, components) as IValve; + if (InputValves.Length > 2) + { + InputValves[2] = TbfComponents.FindComponent(valveCfg.Input3, components) as IValve; + } + if (InputValves.Length > 3) + { + InputValves[3] = TbfComponents.FindComponent(valveCfg.Input4, components) as IValve; + } + if (InputValves.Length > 4) + { + InputValves[4] = TbfComponents.FindComponent(valveCfg.Input5, components) as IValve; + } log.Debug(this.ToString()); } diff --git a/TBF/BenchControl/Elde/ValveEx/ValveCfg.cs b/TBF/BenchControl/BuiltIn/ValveEx/ValveCfg.cs similarity index 97% rename from TBF/BenchControl/Elde/ValveEx/ValveCfg.cs rename to TBF/BenchControl/BuiltIn/ValveEx/ValveCfg.cs index a620c1dfb..21c7e1dfe 100644 --- a/TBF/BenchControl/Elde/ValveEx/ValveCfg.cs +++ b/TBF/BenchControl/BuiltIn/ValveEx/ValveCfg.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Xml.Serialization; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Elde.ValveEx +namespace TBF.BenchControl.BuiltIn.ValveEx { public class ValveCfg : ComponentCfgBase, IComponentCfg { diff --git a/TBF/BenchControl/Elde/ValveEx/ValveCfgCtrl.Designer.cs b/TBF/BenchControl/BuiltIn/ValveEx/ValveCfgCtrl.Designer.cs similarity index 99% rename from TBF/BenchControl/Elde/ValveEx/ValveCfgCtrl.Designer.cs rename to TBF/BenchControl/BuiltIn/ValveEx/ValveCfgCtrl.Designer.cs index 7927958f7..776e9d174 100644 --- a/TBF/BenchControl/Elde/ValveEx/ValveCfgCtrl.Designer.cs +++ b/TBF/BenchControl/BuiltIn/ValveEx/ValveCfgCtrl.Designer.cs @@ -1,7 +1,7 @@ /// /// Copyright (c) 2015 Sensus Metering Systems /// -namespace TBF.BenchControl.Elde.ValveEx +namespace TBF.BenchControl.BuiltIn.ValveEx { partial class ValveCfgCtrl { diff --git a/TBF/BenchControl/Elde/ValveEx/ValveCfgCtrl.cs b/TBF/BenchControl/BuiltIn/ValveEx/ValveCfgCtrl.cs similarity index 99% rename from TBF/BenchControl/Elde/ValveEx/ValveCfgCtrl.cs rename to TBF/BenchControl/BuiltIn/ValveEx/ValveCfgCtrl.cs index 106c9d355..c62e26112 100644 --- a/TBF/BenchControl/Elde/ValveEx/ValveCfgCtrl.cs +++ b/TBF/BenchControl/BuiltIn/ValveEx/ValveCfgCtrl.cs @@ -7,7 +7,7 @@ using System.Windows.Forms; using Config.Entities; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Elde.ValveEx +namespace TBF.BenchControl.BuiltIn.ValveEx { public partial class ValveCfgCtrl : UserControl, IComponentCfgCtrl { diff --git a/TBF/BenchControl/Elde/ValveEx/ValveCfgCtrl.resx b/TBF/BenchControl/BuiltIn/ValveEx/ValveCfgCtrl.resx similarity index 100% rename from TBF/BenchControl/Elde/ValveEx/ValveCfgCtrl.resx rename to TBF/BenchControl/BuiltIn/ValveEx/ValveCfgCtrl.resx diff --git a/TBF/BenchControl/Elde/ValveEx/ValveFactory.cs b/TBF/BenchControl/BuiltIn/ValveEx/ValveFactory.cs similarity index 94% rename from TBF/BenchControl/Elde/ValveEx/ValveFactory.cs rename to TBF/BenchControl/BuiltIn/ValveEx/ValveFactory.cs index 3ad803c14..6e24c6b44 100644 --- a/TBF/BenchControl/Elde/ValveEx/ValveFactory.cs +++ b/TBF/BenchControl/BuiltIn/ValveEx/ValveFactory.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Elde.ValveEx +namespace TBF.BenchControl.BuiltIn.ValveEx { public class ValveFactory : IComponentFactory { diff --git a/TBF/BenchControl/ControlBoard/IControlBoard.cs b/TBF/BenchControl/ControlBoard/IControlBoard.cs new file mode 100644 index 000000000..dad9651b6 --- /dev/null +++ b/TBF/BenchControl/ControlBoard/IControlBoard.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using Config.Entities; +using Dirichlet.Numerics; +using TBF.BenchControl.Generic; +using TBF.BenchControl.GenericDevices; + +namespace TBF.BenchControl.ControlBoard +{ + public interface IControlBoard : IDevice, IValveControl + { + void InitializeComponent(object thirdPartyComponent, UInt128 valvesToInvert, double[] tankCapacities); + + /// + /// Display value in a third party component, update UI + /// + /// String parameter + /// Integer parameter + /// Value to be displayed + void UpdateUI(string sParam, int iParam, double value); + + /// + /// Called on beginning of a test + /// + void ClearProcessValues(); + + + /// + /// Values valid always + /// + UInt128 Route { get; } /// State of valves + UInt64 DigitalInputs { get; } /// Inputs + + /// + /// Values valid during a test + /// + double RefFrequency { get; } + double RefFlow { get; } + + /// + /// Last test results + /// + double TestTime { get; } + int RefPulses { get; } + + double TestTimeWM(int wmNr1); + int RefPulsesWM(int wmNr1); + int PulsesWM(int wmNr1); + + float ValveOpenCloseTime { get; } /// Start valve open or close time in sec + + + /// + /// Select devices used for control and measurement + /// + /// + OutputPath Devices { set; get; } + + /// + /// Returns operation which sets the flow. Events: + /// + /// Lower flow limit + /// Upper flow limit + /// Reference to calss keeping current flow value + /// Timeout in seconds + /// Operation + IOperation SetFlowOp(double flowLimLo, double flowLimHi, TBF.Boxes.DoubleBox measuredFlow, int timeout); + + IOperation StopFlowRegulationOp(); + + /// + /// Start a test, Events: MeasurementStarted + /// + /// Int32 parameter 1 + /// Double parameter 1 (alternative lower flow limit) + /// Double parameter 2 (alternative upper flow limit) + /// Operation + IOperation StartTestOp(Test test, int iParam = 0, double dParam1 = 0, double dParam2 = 0); + + IOperation ReadDiverterTransitionOp(bool isStart, Sequences.Statistics plotter, int batchNr, string testName, int repetition); + + /// + /// Returns operation with events: Event.MeasurementCompleted or Event.None + /// + /// Operation + IOperation QueryMeasurementEndOp(); + + IOperation StopPreviousOp(); + } +} diff --git a/TBF/BenchControl/Elde/Common.cs b/TBF/BenchControl/ControlBoard/Legacy/Common.cs similarity index 98% rename from TBF/BenchControl/Elde/Common.cs rename to TBF/BenchControl/ControlBoard/Legacy/Common.cs index ca5bd2214..f421c59ab 100644 --- a/TBF/BenchControl/Elde/Common.cs +++ b/TBF/BenchControl/ControlBoard/Legacy/Common.cs @@ -3,7 +3,7 @@ /// using System; -namespace TBF.BenchControl.Elde +namespace TBF.BenchControl.ControlBoard.Legacy { public enum Command { diff --git a/TBF/BenchControl/Elde/ControlBoardCfg.cs b/TBF/BenchControl/ControlBoard/Legacy/ControlBoardCfg.cs similarity index 96% rename from TBF/BenchControl/Elde/ControlBoardCfg.cs rename to TBF/BenchControl/ControlBoard/Legacy/ControlBoardCfg.cs index 14ce8c71a..5b7412337 100644 --- a/TBF/BenchControl/Elde/ControlBoardCfg.cs +++ b/TBF/BenchControl/ControlBoard/Legacy/ControlBoardCfg.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Xml.Serialization; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Elde +namespace TBF.BenchControl.ControlBoard.Legacy { public class ControlBoardCfg : ComponentCfgBase, IComponentCfg { diff --git a/TBF/BenchControl/Elde/ControlBoardCfgCtrl.Designer.cs b/TBF/BenchControl/ControlBoard/Legacy/ControlBoardCfgCtrl.Designer.cs similarity index 99% rename from TBF/BenchControl/Elde/ControlBoardCfgCtrl.Designer.cs rename to TBF/BenchControl/ControlBoard/Legacy/ControlBoardCfgCtrl.Designer.cs index cf34a7ffd..4de9fe709 100644 --- a/TBF/BenchControl/Elde/ControlBoardCfgCtrl.Designer.cs +++ b/TBF/BenchControl/ControlBoard/Legacy/ControlBoardCfgCtrl.Designer.cs @@ -1,7 +1,7 @@ /// /// Copyright (c) 2013-2015 Sensus Metering Systems /// -namespace TBF.BenchControl.Elde +namespace TBF.BenchControl.ControlBoard.Legacy { partial class ControlBoardCfgCtrl { diff --git a/TBF/BenchControl/Elde/ControlBoardCfgCtrl.cs b/TBF/BenchControl/ControlBoard/Legacy/ControlBoardCfgCtrl.cs similarity index 96% rename from TBF/BenchControl/Elde/ControlBoardCfgCtrl.cs rename to TBF/BenchControl/ControlBoard/Legacy/ControlBoardCfgCtrl.cs index c1cca8279..9583923cc 100644 --- a/TBF/BenchControl/Elde/ControlBoardCfgCtrl.cs +++ b/TBF/BenchControl/ControlBoard/Legacy/ControlBoardCfgCtrl.cs @@ -1,12 +1,12 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2015 Sensus Slovensko a.s. /// using System; using System.Windows.Forms; using Config.Entities; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Elde +namespace TBF.BenchControl.ControlBoard.Legacy { public partial class ControlBoardCfgCtrl : UserControl, IComponentCfgCtrl { diff --git a/TBF/BenchControl/Elde/ControlBoardCfgCtrl.resx b/TBF/BenchControl/ControlBoard/Legacy/ControlBoardCfgCtrl.resx similarity index 100% rename from TBF/BenchControl/Elde/ControlBoardCfgCtrl.resx rename to TBF/BenchControl/ControlBoard/Legacy/ControlBoardCfgCtrl.resx diff --git a/TBF/BenchControl/Elde/ControlBoardDev.cs b/TBF/BenchControl/ControlBoard/Legacy/ControlBoardDev.cs similarity index 73% rename from TBF/BenchControl/Elde/ControlBoardDev.cs rename to TBF/BenchControl/ControlBoard/Legacy/ControlBoardDev.cs index 36c79039c..5cfc941e3 100644 --- a/TBF/BenchControl/Elde/ControlBoardDev.cs +++ b/TBF/BenchControl/ControlBoard/Legacy/ControlBoardDev.cs @@ -1,19 +1,19 @@ /// -/// Copyright (c) 2013-2019 Sensus Slovensko a.s. +/// Copyright (c) 2013-2020 Sensus Slovensko a.s. /// using System; using System.Text; using System.IO.Ports; using System.Collections.Generic; +using log4net; using Config.Entities; using Dirichlet.Numerics; using TBF.BenchControl.Generic; using TBF.BenchControl.GenericDevices; -using log4net; -namespace TBF.BenchControl.Elde +namespace TBF.BenchControl.ControlBoard.Legacy { - public class ControlBoardDev : ComponentBase, IDevice, IValveControl + public class ControlBoardDev : ComponentBase, IControlBoard { private static readonly ILog log = LogManager.GetLogger(typeof(ControlBoardDev)); public override string ToString() { return string.Format("ControlBoard({0})", Cfg.ToString(1)); } @@ -43,11 +43,9 @@ namespace TBF.BenchControl.Elde /// prsNr0 = 0 .. nrPressureMeters-1 (zero based) /// public StatusP StatusP { get { return controlCom.StatusP; } } - public int EtPulses(int wmNr1) { return controlCom.EtPulses(wmNr1); } public int EtPulsesK { get { return controlCom.EtPulsesK; } } public int EtPulses2 { get { return controlCom.EtPulses2; } } /// DEWA_300: pulses from I12 public int EtPulses3 { get { return controlCom.EtPulses3; } } /// DEWA_300: pulses from I13 - public UInt16 WMeterPulses(int wmNr1) { return controlCom.WMeterPulses(wmNr1); } public int WMeterReference(int wmNr0) { return controlCom.WMeterReference(wmNr0); } public uint RegulValveDAC(int rvNr0) { return controlCom.RegulValveDAC(rvNr0); } public float Pressure(int prsNr0) { return controlCom.Pressure(prsNr0); } @@ -55,13 +53,11 @@ namespace TBF.BenchControl.Elde public RegulValveState RegulValveState(int rvNr1) { return (RegulValveState)controlCom.RegulValveState(rvNr1); } public UInt128 RRoute { get { return controlCom.RRoute; } } public uint DivTime(int id) { return controlCom.DivTime(id); } - public float TTime { get { return controlCom.TTime; } } - public float ImpulseTime(int wmNr1) { return controlCom.ImpulseTime(wmNr1); } public uint FmState { get { return controlCom.FmState; } } public uint BeginState(int wmNr0) { return controlCom.BeginState(wmNr0); } - public double ReferenceFreq { get { return controlCom.ReferenceFreq; } } /// In [Hz] 0..2500, nom.=2000 + public double RefFrequency { get { return controlCom.ReferenceFreq; } } /// In [Hz] 0..2500, nom.=2000 public double ReferenceFreqs(int i) { return controlCom.ReferenceFreqs(i); } - public double ReferenceFlow { get { return controlCom.ReferenceFlow; } } + public double RefFlow { get { return controlCom.ReferenceFlow; } } public float RValvePosition(int rvNr1) { return controlCom.RValvePosition(rvNr1); } public float DivSamples(int time, int divIx0) { return controlCom.DivSamples(time, divIx0); } /// Time unit is 2 ms public int ScopeSamples(int i, int j, int k) { return controlCom.ScopeSamples(i, j, k); } @@ -81,6 +77,16 @@ namespace TBF.BenchControl.Elde bool previousEmergencyStop; + /// + /// IControlBoard interface + /// + public int RefPulses { get { return controlCom.EtPulses(0); } } + public double TestTime { get { return (double)controlCom.TTime; } } + public int RefPulsesWM(int wmNr1) { return (wmNr1 > 0 && wmNr1 <= Config.Data.WMsCount) ? controlCom.EtPulses(wmNr1) : 0; } + public int PulsesWM(int wmNr1) { return (wmNr1 > 0 && wmNr1 <= Config.Data.WMsCount) ? unwrappedWMPulses[wmNr1] : 0; } + public double TestTimeWM(int wmNr1) { return (wmNr1 > 0 && wmNr1 <= Config.Data.WMsCount) ? (double)controlCom.ImpulseTime(wmNr1) : 0; } + + public void DiverterToTank(int flowMtrNr) { cbCommandQueue.Enqueue(new SendCommandArgs(Command.Start, flowMtrNr, int.MaxValue, int.MaxValue, TestMethods.Diverter | TestMethods.Synchro, StopDevs.None)); @@ -169,12 +175,53 @@ namespace TBF.BenchControl.Elde UInt128 valvesToInvert; /// Route = valesToInvert ^ RequiredRouteWithoutInvertedVlaves readonly UInt128 routeMask; /// This mask masks out virtual valves, routeMask is set in the constructor + + public OutputPath Devices + { + set { devices = value; } + get { return devices; } + } + OutputPath devices; + + int[] filters; float[] FMFreq; int regConst; int shortImp; + private int[] unwrappedWMPulses; /// Initialized to zeros + /// + private void UnwrapPulses() + { + for (int i = 1; i <= Config.Data.WMsCount; i++) + { + UInt16 lowerWord = controlCom.WMeterPulses(i); + int uncorrected = (int)(((uint)unwrappedWMPulses[i] & 0xFFFF0000) | lowerWord); + if (Math.Abs(uncorrected - unwrappedWMPulses[i]) <= Int16.MaxValue) + { + unwrappedWMPulses[i] = uncorrected; + } + else if (Math.Abs(uncorrected + 65536 - unwrappedWMPulses[i]) <= Int16.MaxValue) + { + unwrappedWMPulses[i] = uncorrected + 65536; + } + else if (Math.Abs(uncorrected - 65536 - unwrappedWMPulses[i]) <= Int16.MaxValue) + { + unwrappedWMPulses[i] = uncorrected - 65536; + } + } + } + /// + public void ClearProcessValues() + { + for (int i = 1; i <= Config.Data.WMsCount; i++) + { + unwrappedWMPulses[i] = 0; + } + UnwrapPulses(); + } + /// /// Set values to be applied during a test @@ -266,9 +313,19 @@ namespace TBF.BenchControl.Elde } - public void SetReservoirTemp(int nr, float temp) + /// + /// Display value in ELDE component, update UI + /// + /// String parameter + /// Integer parameter + /// Value to be displayed + public void UpdateUI(string sParam, int iParam, double value) { - controlCom.SetReservoirTemp(nr, temp); + if (sParam == "ReservoirTemp") + { + controlCom.SetReservoirTemp(iParam, (float)value); + return; + } } public ControlBoardDev() @@ -283,6 +340,9 @@ namespace TBF.BenchControl.Elde { controlBoardCfg = cfg as ControlBoardCfg; + /// Buffers used in UnwrapPulses() and PulsesWM(wmNr1) + unwrappedWMPulses = new int[Config.Data.WMsCount + 1]; + cbCommandQueue = new Queue(); lastSentFilters = new uint[FiltersCount]; @@ -311,21 +371,8 @@ namespace TBF.BenchControl.Elde /// /// Specific pre-initialization for control board only /// - /// - public void InitializeComponent( -#if DN100 - ControlCom2VB.ControlCom2panel ctrlBrdComponent, -#elif MUNICH || FUZHOU_150 - ControlComponent3Munich.UserControl1 ctrlBrdComponent, -#elif FUZHOU_300 - ControlComponent3F300.UserControl1 ctrlBrdComponent, -#elif IZRAEL_200 || PUCHONG_200 || GENESIS || BERLIN || GELSENWASSER || SLM_150 || PETERSBURG_200 - ControlComponent_Izrael2014.UserControl1 ctrlBrdComponent, -#else /// all newer benches - ControlComponent_Torino2015.UserControl1 ctrlBrdComponent, -#endif - UInt128 valvesToInvert, - double[] tankCapacities) + /// + public void InitializeComponent(object eldeComponent, UInt128 valvesToInvert, double[] tankCapacities) { this.valvesToInvert = valvesToInvert; this.benchModelRoute = valvesToInvert; @@ -336,7 +383,9 @@ namespace TBF.BenchControl.Elde } else { - /// Default number of scales (and BalanceRange length) is 2. + controlCom = new ControlComWrap(eldeComponent); + + /// Default number of scales (and BalanceRange length) is 2. /// If there are more scales, BalanceRange length is larger. int scalesCnt = Math.Max(2, tankCapacities.Length); BalanceRange = new uint[scalesCnt]; @@ -344,7 +393,6 @@ namespace TBF.BenchControl.Elde { BalanceRange[i] = (uint)((i < tankCapacities.Length) ? tankCapacities[i] : 0); } - controlCom = new ControlComWrap(ctrlBrdComponent); } } @@ -380,7 +428,8 @@ namespace TBF.BenchControl.Elde { if (DebugLevel == DebugMode.Simulate) return; controlCom.RunDeviceBefore(); - } + UnwrapPulses(); + } /// /// Used in RunDeviceAfter() when sending commands @@ -532,7 +581,7 @@ namespace TBF.BenchControl.Elde /// 'ulong' with bits of valves to open set to '1' /// 'ulong' with bits of valves to close set to '1' /// 'ulong' with bits of valves that have changed set to '1' - public UInt128 SetValves(UInt128 valvesToOpen, UInt128 valvesToClose, IList extendedValves) + public UInt128 SetValves(UInt128 valvesToOpen, UInt128 valvesToClose, IList extendedValves) { UInt128 oldRoute = benchModelRoute; benchModelRoute = (((benchModelRoute ^ valvesToInvert) | valvesToOpen) & (~valvesToClose)) ^ valvesToInvert; @@ -575,7 +624,7 @@ namespace TBF.BenchControl.Elde /// Created operation public IOperation SetValvesOp(IValve valveOpen, IValve valveClose) { - return new SetValvesOp(this, valveOpen, valveClose); + return new BuiltIn.SetValvesOp(this, valveOpen, valveClose); } /// @@ -587,28 +636,138 @@ namespace TBF.BenchControl.Elde /// Created operation public IOperation SetValvesOp(IList valvesOpen, IList valvesClose) { - return new SetValvesOp(this, valvesOpen, valvesClose); + return new BuiltIn.SetValvesOp(this, valvesOpen, valvesClose); } /// - /// Starts the measurement. - /// Events: MeasurementStarted + /// Open start/stop valve. + /// Events: ValvesSet, ValvesBusy, Error /// - /// Flow meter - /// An array of register readers - /// Number of reference pulses to complete the test /// Created operation - public IOperation StartMeasurementOp(OutputPath outputPath, TestMethods method, - double requiredFlowLo, double requiredFlowHi, int refPulses) + public IOperation OpenStartValveOp() + { + return new BuiltIn.SetValvesOp(this, true, devices); + } + + /// + /// Close start/stop valve. + /// Events: ValvesSet, ValvesBusy, Error + /// + /// Created operation + public IOperation CloseStartValveOp() + { + return new BuiltIn.SetValvesOp(this, false, devices); + } + + public IOperation SetFlowOp(double reqrdFlowLo, double reqrdFlowHi, TBF.Boxes.DoubleBox measuredFlow, int timeout) + { + if (Devices.RegulValve == null || Devices.FlowMeter == null) return null; + + return Devices.RegulValve.SetFlowOp(Devices.FlowMeter, reqrdFlowLo, reqrdFlowHi, measuredFlow, timeout); + } + + + /// + /// Start a test, Events: MeasurementStarted + /// + /// Int32 parameter 1 + /// Double parameter 1 (alternative lower flow limit) + /// Double parameter 2 (alternative upper flow limit) + /// Operation + public IOperation StartTestOp(Test test, int iParam = 0, double dParam1 = 0, double dParam2 = 0) { - if (controlBoardCfg.DebugLevel == DebugMode.Simulate) - { - return new Operations.ReturnGivenEventOp(Event.MeasurementStarted); - } - else - { - return new StartMeasurementOp(this, outputPath, method, requiredFlowLo, requiredFlowHi, refPulses); - } + if (controlBoardCfg.DebugLevel == DebugMode.Simulate) + { + return new Operations.ReturnGivenEventOp(Event.MeasurementStarted); + } + + /// Get total number of pulses + int totalPulses = Convert.ToInt32(Math.Round(test.Volume / devices.FlowMeter.LtrPerPulse)); + + /// Get method class string + string methodClass; + if (!StateMachine.TestMethod2Class.TryGetValue(test.Name, out methodClass)) return null; + + if (methodClass.Contains("TestMethods.Adjustment.")) + { + return new StartMeasurementOp(this, devices, TestMethods.Synchro, test.Qfrom, test.Qto, totalPulses); + } + if (methodClass.Contains("TestMethods.CombinedWithDetection.")) + { + return new StartMeasurementOp(this, devices, (TestMethods.Diverter | TestMethods.Synchro), dParam1, dParam2, totalPulses); + } + if (methodClass == "TestMethods.DiverterTest") + { + if (iParam == 0) return null; + return new StartMeasurementOp(this, devices, (TestMethods.Diverter | TestMethods.Synchro), test.Qfrom, test.Qto, totalPulses / iParam); + } + if (methodClass == "TestMethods.Dummy") + { + } + if (methodClass == "TestMethods.Endurance") + { + return new StartMeasurementOp(this, devices, TestMethods.Synchro, test.Qfrom, test.Qto, totalPulses); + } + if (methodClass.Contains("TestMethods.FixedStart.")) + { + return new StartMeasurementOp(this, devices, TestMethods.Synchro, test.Qfrom, test.Qto, 2 * totalPulses); + } + if (methodClass.Contains("TestMethods.FixedStartAdvanced.")) + { + return new StartMeasurementOp(this, devices, TestMethods.Synchro, test.Qfrom, test.Qto, 2 * totalPulses); + } + if (methodClass.Contains("TestMethods.FixedStartDefferedEval.")) + { + return new StartMeasurementOp(this, devices, TestMethods.Synchro, test.Qfrom, test.Qto, 2 * totalPulses); + } + if (methodClass.Contains("TestMethods.FixedStartMassCollDeferredEval.")) + { + return new StartMeasurementOp(this, devices, (TestMethods.Diverter | TestMethods.Synchro), test.Qfrom, test.Qto, 2 * totalPulses); + } + if (methodClass.Contains("TestMethods.FixedStartMassCollection.")) + { + return new StartMeasurementOp(this, devices, (TestMethods.Diverter | TestMethods.FixedStart), test.Qfrom, test.Qto, 2 * totalPulses); + } + if (methodClass.Contains("TestMethods.FixedStartTankCollection.")) + { + return new StartMeasurementOp(this, devices, (TestMethods.Diverter | TestMethods.Synchro), test.Qfrom, test.Qto, (totalPulses * 5 / 4)); + } + if (methodClass.Contains("TestMethods.FlyingStart.")) + { + return new StartMeasurementOp(this, devices, TestMethods.Synchro, test.Qfrom, test.Qto, totalPulses); + } + if (methodClass.Contains("TestMethods.FlyingStartFirstRepetWithMassColl.")) + { + TestMethods tm = (iParam == 1) ? (TestMethods.Diverter | TestMethods.Synchro) : TestMethods.Synchro; + return new StartMeasurementOp(this, devices, tm, test.Qfrom, test.Qto, totalPulses); + } + if (methodClass.Contains("TestMethods.FlyingStartMassCollComparative.")) + { + return new StartMeasurementOp(this, devices, (TestMethods.Diverter | TestMethods.Synchro), test.Qfrom, test.Qto, totalPulses); + } + if (methodClass.Contains("TestMethods.FlyingStartMassCollection.")) + { + return new StartMeasurementOp(this, devices, (TestMethods.Diverter | TestMethods.Synchro), test.Qfrom, test.Qto, totalPulses); + } + if (methodClass.Contains("TestMethods.FlyingStartMassCollProlonged.")) + { + if (iParam == 0) return null; + return new StartMeasurementOp(this, devices, (TestMethods.Diverter | TestMethods.Synchro), test.Qfrom, test.Qto, totalPulses, iParam); + } + if (methodClass.Contains("TestMethods.FlyingStartTankCollection.")) + { + return new StartMeasurementOp(this, devices, (TestMethods.Diverter | TestMethods.Synchro), test.Qfrom, test.Qto, totalPulses); + } + if (methodClass == "TestMethods.PulsesTest") + { + return new StartMeasurementOp(this, devices, TestMethods.Synchro, test.Qfrom, test.Qto, totalPulses); + } + if (methodClass == "TestMethods.PulsesTestManual") + { + return new StartMeasurementOp(this, devices, TestMethods.Synchro, test.Qfrom, test.Qto, totalPulses); + } + + return null; } /// @@ -619,7 +778,7 @@ namespace TBF.BenchControl.Elde /// An array of register readers /// Number of reference pulses to complete the test /// Created operation - public IOperation StartProlongedMeasurementOp(OutputPath outputPath, TestMethods method, + public IOperation StartProlongedMeasurementOp(OutputPath outputPath, double requiredFlowLo, double requiredFlowHi, int totalRefPulses, int massRefPulses) { @@ -629,7 +788,8 @@ namespace TBF.BenchControl.Elde } else { - return new StartMeasurementOp(this, outputPath, method, requiredFlowLo, requiredFlowHi, totalRefPulses, massRefPulses); + return new StartMeasurementOp(this, outputPath, TestMethods.Diverter | TestMethods.Synchro | TestMethods.MassAndContinue, + requiredFlowLo, requiredFlowHi, totalRefPulses, massRefPulses); } } @@ -646,17 +806,11 @@ namespace TBF.BenchControl.Elde /// Test name (without repetitions) /// Repetition number /// Created operation - public IOperation ReadDiverterTransitionOp(IDiverter div, int runsCountWhenSendingCmd, int runsCountWhenReadingDiv, bool toTank, - Sequences.Statistics plotter, int batchNr, string testName, int repetition) + public IOperation ReadDiverterTransitionOp(bool isStart, Sequences.Statistics plotter, int batchNr, string testName, int repetition) { - if (controlBoardCfg.DebugLevel == DebugMode.Simulate) - { - return new Operations.ReturnGivenEventOp(Event.None); - } - else - { - return new ReadDiverterTransitionOp(this, div, runsCountWhenSendingCmd, runsCountWhenReadingDiv, toTank, plotter, batchNr, testName, repetition); - } + if (controlBoardCfg.DebugLevel == DebugMode.Simulate) return new Operations.ReturnGivenEventOp(Event.None); + + return new ReadDiverterTransitionOp(this, devices.Diverter, 1, 3, isStart, plotter, batchNr, testName, repetition); } /// @@ -674,9 +828,9 @@ namespace TBF.BenchControl.Elde /// Events: FlowRegulationStopped /// /// Created operation - public IOperation StopFlowRegulationOp(OutputPath outputPath) + public IOperation StopFlowRegulationOp() { - return new StopFlowRegulationOp(this, outputPath); + return new StopFlowRegulationOp(this); } /// diff --git a/TBF/BenchControl/Elde/ControlBoardFactory.cs b/TBF/BenchControl/ControlBoard/Legacy/ControlBoardFactory.cs similarity index 78% rename from TBF/BenchControl/Elde/ControlBoardFactory.cs rename to TBF/BenchControl/ControlBoard/Legacy/ControlBoardFactory.cs index f43213c8b..7b3319e9e 100644 --- a/TBF/BenchControl/Elde/ControlBoardFactory.cs +++ b/TBF/BenchControl/ControlBoard/Legacy/ControlBoardFactory.cs @@ -1,14 +1,14 @@ /// -/// Copyright (c) 2013-2016 Sensus Metering Systems +/// Copyright (c) 2013-2020 Sensus Slovensko a.s. /// using System.Collections.Generic; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Elde +namespace TBF.BenchControl.ControlBoard.Legacy { public class ControlBoardFactory : IComponentFactory { - public string ClassName { get { return "ControlBoard"; } } + public string ClassName { get { return "ControlBoard"; } } /// Max. number of components of this class in the system public int MaxCount { get { return 1; } } @@ -28,7 +28,7 @@ namespace TBF.BenchControl.Elde public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) { - return ComponentCfgBase.CreateFromDbEntity(Elde.ControlBoardCfg.Serializer, component, this); + return ComponentCfgBase.CreateFromDbEntity(ControlBoardCfg.Serializer, component, this); } public void ResetStaticProperties() { ControlBoardDev.ResetStaticProperties(); } diff --git a/TBF/BenchControl/Elde/ControlComSim.cs b/TBF/BenchControl/ControlBoard/Legacy/ControlComSim.cs similarity index 99% rename from TBF/BenchControl/Elde/ControlComSim.cs rename to TBF/BenchControl/ControlBoard/Legacy/ControlComSim.cs index fe6d26903..38f15edee 100644 --- a/TBF/BenchControl/Elde/ControlComSim.cs +++ b/TBF/BenchControl/ControlBoard/Legacy/ControlComSim.cs @@ -7,7 +7,7 @@ using System.Text; using Dirichlet.Numerics; using log4net; -namespace TBF.BenchControl.Elde +namespace TBF.BenchControl.ControlBoard.Legacy { public class ControlComSim : IControlCom { diff --git a/TBF/BenchControl/Elde/ControlComWrap.cs b/TBF/BenchControl/ControlBoard/Legacy/ControlComWrap.cs similarity index 97% rename from TBF/BenchControl/Elde/ControlComWrap.cs rename to TBF/BenchControl/ControlBoard/Legacy/ControlComWrap.cs index 5caeedf7c..2624a0dff 100644 --- a/TBF/BenchControl/Elde/ControlComWrap.cs +++ b/TBF/BenchControl/ControlBoard/Legacy/ControlComWrap.cs @@ -5,7 +5,7 @@ using System; using Dirichlet.Numerics; using log4net; -namespace TBF.BenchControl.Elde +namespace TBF.BenchControl.ControlBoard.Legacy { public class ControlComWrap : IControlCom { @@ -186,19 +186,20 @@ namespace TBF.BenchControl.Elde /// Constructor that initializes the control board component reference /// /// -#if DN100 - public ControlComWrap(ControlCom2VB.ControlCom2panel ctrlBrdComponent) -#elif MUNICH || FUZHOU_150 - public ControlComWrap(ControlComponent3Munich.UserControl1 ctrlBrdComponent) -#elif FUZHOU_300 - public ControlComWrap(ControlComponent3F300.UserControl1 ctrlBrdComponent) -#elif IZRAEL_200 || PUCHONG_200 || GENESIS || BERLIN || GELSENWASSER || SLM_150 || PETERSBURG_200 - public ControlComWrap(ControlComponent_Izrael2014.UserControl1 ctrlBrdComponent) -#else /// all newer benches - public ControlComWrap(ControlComponent_Torino2015.UserControl1 ctrlBrdComponent) -#endif + public ControlComWrap(object eldeComponent) { - this.ctrlBrdComponent = ctrlBrdComponent; +#if DN100 + ctrlBrdComponent = eldeComponent as ControlCom2VB.ControlCom2panel; +#elif MUNICH || FUZHOU_150 + ctrlBrdComponent = eldeComponent as ControlComponent3Munich.UserControl1; +#elif FUZHOU_300 + ctrlBrdComponent = eldeComponent as ControlComponent3F300.UserControl1; +#elif IZRAEL_200 || PUCHONG_200 || GENESIS || BERLIN || GELSENWASSER || SLM_150 || PETERSBURG_200 + ctrlBrdComponent = eldeComponent as ControlComponent_Izrael2014.UserControl1; +#else /// all newer benches + ctrlBrdComponent = eldeComponent as ControlComponent_Torino2015.UserControl1; +#endif + if (ctrlBrdComponent == null) throw new Exception("Wrong ELDE component"); } diff --git a/TBF/BenchControl/Elde/ExecuteCommandOp.cs b/TBF/BenchControl/ControlBoard/Legacy/ExecuteCommandOp.cs similarity index 98% rename from TBF/BenchControl/Elde/ExecuteCommandOp.cs rename to TBF/BenchControl/ControlBoard/Legacy/ExecuteCommandOp.cs index 9c90a2e66..fd3c04861 100644 --- a/TBF/BenchControl/Elde/ExecuteCommandOp.cs +++ b/TBF/BenchControl/ControlBoard/Legacy/ExecuteCommandOp.cs @@ -4,7 +4,7 @@ using System; using log4net; -namespace TBF.BenchControl.Elde +namespace TBF.BenchControl.ControlBoard.Legacy { public class ExecuteCommandOp : IOperation { diff --git a/TBF/BenchControl/Elde/IControlCom.cs b/TBF/BenchControl/ControlBoard/Legacy/IControlCom.cs similarity index 98% rename from TBF/BenchControl/Elde/IControlCom.cs rename to TBF/BenchControl/ControlBoard/Legacy/IControlCom.cs index e105b589a..520c18056 100644 --- a/TBF/BenchControl/Elde/IControlCom.cs +++ b/TBF/BenchControl/ControlBoard/Legacy/IControlCom.cs @@ -4,7 +4,7 @@ using System; using Dirichlet.Numerics; -namespace TBF.BenchControl.Elde +namespace TBF.BenchControl.ControlBoard.Legacy { interface IControlCom { diff --git a/TBF/BenchControl/Elde/QueryMeasurementEndOp.cs b/TBF/BenchControl/ControlBoard/Legacy/QueryMeasurementEndOp.cs similarity index 96% rename from TBF/BenchControl/Elde/QueryMeasurementEndOp.cs rename to TBF/BenchControl/ControlBoard/Legacy/QueryMeasurementEndOp.cs index 2b5837bbb..9d2dbd503 100644 --- a/TBF/BenchControl/Elde/QueryMeasurementEndOp.cs +++ b/TBF/BenchControl/ControlBoard/Legacy/QueryMeasurementEndOp.cs @@ -4,7 +4,7 @@ using System; using log4net; -namespace TBF.BenchControl.Elde +namespace TBF.BenchControl.ControlBoard.Legacy { public class QueryMeasurementEndOp : IOperation { diff --git a/TBF/BenchControl/Elde/ReadDiverterTransitionOp.cs b/TBF/BenchControl/ControlBoard/Legacy/ReadDiverterTransitionOp.cs similarity index 99% rename from TBF/BenchControl/Elde/ReadDiverterTransitionOp.cs rename to TBF/BenchControl/ControlBoard/Legacy/ReadDiverterTransitionOp.cs index 992f79bfa..23ced55b7 100644 --- a/TBF/BenchControl/Elde/ReadDiverterTransitionOp.cs +++ b/TBF/BenchControl/ControlBoard/Legacy/ReadDiverterTransitionOp.cs @@ -5,7 +5,7 @@ using System; using log4net; using TBF.Boxes; -namespace TBF.BenchControl.Elde +namespace TBF.BenchControl.ControlBoard.Legacy { public class ReadDiverterTransitionOp : IOperation { diff --git a/TBF/BenchControl/Elde/ReadFlowOp.cs b/TBF/BenchControl/ControlBoard/Legacy/ReadFlowOp.cs similarity index 97% rename from TBF/BenchControl/Elde/ReadFlowOp.cs rename to TBF/BenchControl/ControlBoard/Legacy/ReadFlowOp.cs index 4e46d466a..b4bcb8164 100644 --- a/TBF/BenchControl/Elde/ReadFlowOp.cs +++ b/TBF/BenchControl/ControlBoard/Legacy/ReadFlowOp.cs @@ -5,7 +5,7 @@ using System; using log4net; using TBF.Boxes; -namespace TBF.BenchControl.Elde +namespace TBF.BenchControl.ControlBoard.Legacy { public class ReadFlowOp : IOperation { diff --git a/TBF/BenchControl/Elde/SendCommandArgs.cs b/TBF/BenchControl/ControlBoard/Legacy/SendCommandArgs.cs similarity index 94% rename from TBF/BenchControl/Elde/SendCommandArgs.cs rename to TBF/BenchControl/ControlBoard/Legacy/SendCommandArgs.cs index 8357d1f0c..b75f42b56 100644 --- a/TBF/BenchControl/Elde/SendCommandArgs.cs +++ b/TBF/BenchControl/ControlBoard/Legacy/SendCommandArgs.cs @@ -4,7 +4,7 @@ using System; using Dirichlet.Numerics; -namespace TBF.BenchControl.Elde +namespace TBF.BenchControl.ControlBoard.Legacy { public class SendCommandArgs { diff --git a/TBF/BenchControl/Elde/StartMeasurementOp.cs b/TBF/BenchControl/ControlBoard/Legacy/StartMeasurementOp.cs similarity index 99% rename from TBF/BenchControl/Elde/StartMeasurementOp.cs rename to TBF/BenchControl/ControlBoard/Legacy/StartMeasurementOp.cs index 228a638f8..643871325 100644 --- a/TBF/BenchControl/Elde/StartMeasurementOp.cs +++ b/TBF/BenchControl/ControlBoard/Legacy/StartMeasurementOp.cs @@ -5,7 +5,7 @@ using System; using log4net; using TBF.BenchControl.GenericDevices; -namespace TBF.BenchControl.Elde +namespace TBF.BenchControl.ControlBoard.Legacy { public class StartMeasurementOp : IOperation { diff --git a/TBF/BenchControl/Elde/StopFlowRegulationOp.cs b/TBF/BenchControl/ControlBoard/Legacy/StopFlowRegulationOp.cs similarity index 86% rename from TBF/BenchControl/Elde/StopFlowRegulationOp.cs rename to TBF/BenchControl/ControlBoard/Legacy/StopFlowRegulationOp.cs index 9546d3f86..f4bdc3dd3 100644 --- a/TBF/BenchControl/Elde/StopFlowRegulationOp.cs +++ b/TBF/BenchControl/ControlBoard/Legacy/StopFlowRegulationOp.cs @@ -4,7 +4,7 @@ using System; using log4net; -namespace TBF.BenchControl.Elde +namespace TBF.BenchControl.ControlBoard.Legacy { class StopFlowRegulationOp : IOperation { @@ -20,13 +20,13 @@ namespace TBF.BenchControl.Elde /// Events: None or PreviousStopped /// /// Control board component reference - public StopFlowRegulationOp(ControlBoardDev controlBoardDev, OutputPath outputPath) + public StopFlowRegulationOp(ControlBoardDev controlBoardDev) { if (controlBoardDev == null) throw new ArgumentNullException("controlBoardDev"); this.controlBoard = controlBoardDev; - if (outputPath.FlowMeter == null) throw new ArgumentNullException("Flow meter is missing"); - flowMeterNr = outputPath.FlowMeter.Idx1; + if (controlBoardDev.Devices.FlowMeter == null) throw new ArgumentNullException("Flow meter is missing"); + flowMeterNr = controlBoardDev.Devices.FlowMeter.Idx1; log.Debug(this.ToString()); } diff --git a/TBF/BenchControl/Elde/StopPreviousOp.cs b/TBF/BenchControl/ControlBoard/Legacy/StopPreviousOp.cs similarity index 98% rename from TBF/BenchControl/Elde/StopPreviousOp.cs rename to TBF/BenchControl/ControlBoard/Legacy/StopPreviousOp.cs index a1d3b859b..64580603c 100644 --- a/TBF/BenchControl/Elde/StopPreviousOp.cs +++ b/TBF/BenchControl/ControlBoard/Legacy/StopPreviousOp.cs @@ -4,7 +4,7 @@ using System; using log4net; -namespace TBF.BenchControl.Elde +namespace TBF.BenchControl.ControlBoard.Legacy { public class StopPreviousOp : IOperation { diff --git a/TBF/BenchControl/TestBenchSim.cs b/TBF/BenchControl/ControlBoard/Legacy/TestBenchSim.cs similarity index 99% rename from TBF/BenchControl/TestBenchSim.cs rename to TBF/BenchControl/ControlBoard/Legacy/TestBenchSim.cs index e4114741b..67851c71d 100644 --- a/TBF/BenchControl/TestBenchSim.cs +++ b/TBF/BenchControl/ControlBoard/Legacy/TestBenchSim.cs @@ -1,11 +1,11 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2020 Sensus Slovensko a.s. /// using System; using Dirichlet.Numerics; using log4net; -namespace TBF.BenchControl +namespace TBF.BenchControl.ControlBoard.Legacy { /// /// Test bench model inherited by all classes for the simulation of devices. @@ -493,7 +493,7 @@ namespace TBF.BenchControl const ulong Path5 = 0; #endif /// Run this device - public static void RunDevice(int regulValveNo, int refFlowmtrNo, Elde.StatusP statusP) + public static void RunDevice(int regulValveNo, int refFlowmtrNo, StatusP statusP) { TestBenchSim.regulValveNo = regulValveNo; TestBenchSim.refFlowmtrNo = refFlowmtrNo; diff --git a/TBF/BenchControl/ControlBoard/New/CBoard.cs b/TBF/BenchControl/ControlBoard/New/CBoard.cs new file mode 100644 index 000000000..4d59579f3 --- /dev/null +++ b/TBF/BenchControl/ControlBoard/New/CBoard.cs @@ -0,0 +1,182 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using log4net; +using Config.Entities; +using Dirichlet.Numerics; +using TBF.BenchControl.Generic; +using TBF.BenchControl.GenericDevices; + +namespace TBF.BenchControl.ControlBoard.New +{ + public class CBoard : ComponentBase, IControlBoard + { + private static readonly ILog log = LogManager.GetLogger(typeof(CBoard)); + public override string ToString() { return string.Format("CBoard({0})", Cfg.ToString(1)); } + + readonly CBoardCfg cBoardCfg; + + public OutputPath Devices + { + set { devices = value; } + get { return devices; } + } + OutputPath devices; + + public CBoard() + { + } + + /// + /// Constructor + /// + public CBoard(Generic.IComponentCfg cfg) + : base(cfg) + { + cBoardCfg = cfg as CBoardCfg; + + } + + public void InitializeComponent(object thirdPartyComponent, UInt128 valvesToInvert, double[] tankCapacities) + { + this.valvesToInvert = valvesToInvert; + this.benchModelRoute = valvesToInvert; + } + + + public void Initialize() { } + public void RunDeviceBefore() { } + public void RunDeviceAfter() { } + public void StopDevice() { } + public void StopDevice2() { } + + + /// + /// IControlBoard interface + /// + + /// + /// Route: 128-bit word representing the current state of all valves and pumps + /// + public UInt128 Route { get { return benchModelRoute; } } + UInt128 benchModelRoute; + UInt128 valvesToInvert; /// Route = valesToInvert ^ RequiredRouteWithoutInvertedVlaves + readonly UInt128 routeMask; /// This mask masks out virtual valves, routeMask is set in the constructor + + public UInt64 DigitalInputs { get { return 0; } } + + public double RefFrequency { get { return 0; } } + public double RefFlow { get { return 0; } } + + /// + /// Last test result + /// + public int RefPulses { get { return 0; } } + public double TestTime { get { return 1.0; } } + public int RefPulsesWM(int wmNr1) { return (wmNr1 > 0 && wmNr1 <= Config.Data.WMsCount) ? 0 : 0; } + public int PulsesWM(int wmNr1) { return (wmNr1 > 0 && wmNr1 <= Config.Data.WMsCount) ? 0 : 0; } + public double TestTimeWM(int wmNr1) { return (wmNr1 > 0 && wmNr1 <= Config.Data.WMsCount) ? 1.0 : 1.0; } + + + public void UpdateUI(string sParam, int iParam, double value) { } + public void ClearProcessValues() { } + + public UInt128 SetValves(UInt128 valvesToOpen, UInt128 valvesToClose, IList extendedValves) + { + return routeMask; + } + + /// + /// Open one valve and/or close one valve. + /// Events: ValvesSet + /// + /// Valve to be opened + /// Valve to be closed + /// Created operation + public IOperation SetValvesOp(IValve valveOpen, IValve valveClose) + { + return new BuiltIn.SetValvesOp(this, valveOpen, valveClose); + } + + /// + /// Open and/or close multiple valves. + /// Events: ValvesSet + /// + /// A list of valves to be opened + /// A list of valves to be closed + /// Created operation + public IOperation SetValvesOp(IList valvesOpen, IList valvesClose) + { + return new BuiltIn.SetValvesOp(this, valvesOpen, valvesClose); + } + + /// + /// Open start/stop valve. + /// Events: ValvesSet, ValvesBusy, Error + /// + /// Created operation + public IOperation OpenStartValveOp() + { + return new BuiltIn.SetValvesOp(this, true, devices); + } + + /// + /// Close start/stop valve. + /// Events: ValvesSet, ValvesBusy, Error + /// + /// Created operation + public IOperation CloseStartValveOp() + { + return new BuiltIn.SetValvesOp(this, false, devices); + } + + public float ValveOpenCloseTime { get { return 0.1f; } } + + + public IOperation SetFlowOp(double reqrdFlowLo, double reqrdFlowHi, TBF.Boxes.DoubleBox measuredFlow, int timeout) + { + return null; /// TODO + } + + public IOperation StopFlowRegulationOp() + { + return null; /// TODO + } + + /// + /// Start a test, Events: MeasurementStarted + /// + /// Int32 parameter 1 + /// Double parameter 1 (alternative lower flow limit) + /// Double parameter 2 (alternative upper flow limit) + /// Operation + public IOperation StartTestOp(Test test, int iParam = 0, double dParam1 = 0, double dParam2 = 0) + { + return null; /// TODO + } + + public IOperation QueryMeasurementEndOp() + { + return null; /// TODO + } + + public IOperation StopMeasurementOp() + { + return null; /// TODO + } + + public IOperation ReadDiverterTransitionOp(bool isStart, Sequences.Statistics plotter, int batchNr, string testName, int repetition) + { + return null; /// TODO + } + + public IOperation StopPreviousOp() + { + return null; + } + } +} diff --git a/TBF/BenchControl/ControlBoard/New/CBoardCfg.cs b/TBF/BenchControl/ControlBoard/New/CBoardCfg.cs new file mode 100644 index 000000000..db59b6621 --- /dev/null +++ b/TBF/BenchControl/ControlBoard/New/CBoardCfg.cs @@ -0,0 +1,46 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System.IO; +using System.Collections.Generic; +using System.Xml.Serialization; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.ControlBoard.New +{ + public class CBoardCfg : ComponentCfgBase, IComponentCfg + { + public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(CBoardCfg) })[0]; + public override XmlSerializer GetSerializer() { return Serializer; } + + public IComponentCfgCtrl GetControl() { return new CBoardCfgCtrl(); } + + /// + /// Serialized parameters + /// + public int ComPortNr; + public int VirtualValvesRangeLo; + public int VirtualValvesRangeHi; + + /// Private parameterless constructor invoked by all other (public) constructors + CBoardCfg() + { + Name = "CB"; + ParentName = string.Empty; + ComPortNr = 1; + VirtualValvesRangeLo = 50; + VirtualValvesRangeHi = 59; + } + + public CBoardCfg(IComponentFactory factory) + : this() + { + this.Factory = factory; + } + + public string ToString(int i) + { + return string.Format("Name={0}, Com{1}, VVRangeLo={2}, VVRangeHi={3}", Name, ComPortNr, VirtualValvesRangeLo, VirtualValvesRangeHi); + } + } +} diff --git a/TBF/BenchControl/ControlBoard/New/CBoardCfgCtrl.Designer.cs b/TBF/BenchControl/ControlBoard/New/CBoardCfgCtrl.Designer.cs new file mode 100644 index 000000000..f8b4cf270 --- /dev/null +++ b/TBF/BenchControl/ControlBoard/New/CBoardCfgCtrl.Designer.cs @@ -0,0 +1,155 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +namespace TBF.BenchControl.ControlBoard.New +{ + partial class CBoardCfgCtrl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.comPortNrLabel = new System.Windows.Forms.Label(); + this.comPortNrTextBox = new System.Windows.Forms.TextBox(); + this.classNameLabel = new System.Windows.Forms.Label(); + this.nameLabel = new System.Windows.Forms.Label(); + this.nameTextBox = new System.Windows.Forms.TextBox(); + this.vValveRangeLoTextBox = new System.Windows.Forms.TextBox(); + this.vValveRangeLoLabel = new System.Windows.Forms.Label(); + this.vValveRangeHiTextBox = new System.Windows.Forms.TextBox(); + this.vValveRangeHiLabel = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // comPortNrLabel + // + this.comPortNrLabel.AutoSize = true; + this.comPortNrLabel.Location = new System.Drawing.Point(42, 85); + this.comPortNrLabel.Name = "comPortNrLabel"; + this.comPortNrLabel.Size = new System.Drawing.Size(95, 13); + this.comPortNrLabel.TabIndex = 0; + this.comPortNrLabel.Text = "Serial port number:"; + // + // comPortNrTextBox + // + this.comPortNrTextBox.Enabled = false; + this.comPortNrTextBox.Location = new System.Drawing.Point(166, 82); + this.comPortNrTextBox.Name = "comPortNrTextBox"; + this.comPortNrTextBox.Size = new System.Drawing.Size(80, 20); + this.comPortNrTextBox.TabIndex = 1; + // + // classNameLabel + // + this.classNameLabel.AutoSize = true; + this.classNameLabel.Location = new System.Drawing.Point(163, 26); + this.classNameLabel.Name = "classNameLabel"; + this.classNameLabel.Size = new System.Drawing.Size(83, 13); + this.classNameLabel.TabIndex = 2; + this.classNameLabel.Text = "ComonentName"; + // + // nameLabel + // + this.nameLabel.AutoSize = true; + this.nameLabel.Location = new System.Drawing.Point(42, 60); + this.nameLabel.Name = "nameLabel"; + this.nameLabel.Size = new System.Drawing.Size(35, 13); + this.nameLabel.TabIndex = 3; + this.nameLabel.Text = "Name"; + // + // nameTextBox + // + this.nameTextBox.Enabled = false; + this.nameTextBox.Location = new System.Drawing.Point(166, 57); + this.nameTextBox.Name = "nameTextBox"; + this.nameTextBox.Size = new System.Drawing.Size(80, 20); + this.nameTextBox.TabIndex = 4; + // + // vValveRangeLoTextBox + // + this.vValveRangeLoTextBox.Enabled = false; + this.vValveRangeLoTextBox.Location = new System.Drawing.Point(166, 107); + this.vValveRangeLoTextBox.Name = "vValveRangeLoTextBox"; + this.vValveRangeLoTextBox.Size = new System.Drawing.Size(80, 20); + this.vValveRangeLoTextBox.TabIndex = 6; + // + // vValveRangeLoLabel + // + this.vValveRangeLoLabel.AutoSize = true; + this.vValveRangeLoLabel.Location = new System.Drawing.Point(42, 110); + this.vValveRangeLoLabel.Name = "vValveRangeLoLabel"; + this.vValveRangeLoLabel.Size = new System.Drawing.Size(118, 13); + this.vValveRangeLoLabel.TabIndex = 5; + this.vValveRangeLoLabel.Text = "Virtual valves range Lo:"; + // + // vValveRangeHiTextBox + // + this.vValveRangeHiTextBox.Enabled = false; + this.vValveRangeHiTextBox.Location = new System.Drawing.Point(166, 132); + this.vValveRangeHiTextBox.Name = "vValveRangeHiTextBox"; + this.vValveRangeHiTextBox.Size = new System.Drawing.Size(80, 20); + this.vValveRangeHiTextBox.TabIndex = 8; + // + // vValveRangeHiLabel + // + this.vValveRangeHiLabel.AutoSize = true; + this.vValveRangeHiLabel.Location = new System.Drawing.Point(42, 135); + this.vValveRangeHiLabel.Name = "vValveRangeHiLabel"; + this.vValveRangeHiLabel.Size = new System.Drawing.Size(116, 13); + this.vValveRangeHiLabel.TabIndex = 7; + this.vValveRangeHiLabel.Text = "Virtual valves range Hi:"; + // + // ControlBoardCfgCtrl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.vValveRangeHiTextBox); + this.Controls.Add(this.vValveRangeHiLabel); + this.Controls.Add(this.vValveRangeLoTextBox); + this.Controls.Add(this.vValveRangeLoLabel); + this.Controls.Add(this.nameTextBox); + this.Controls.Add(this.nameLabel); + this.Controls.Add(this.classNameLabel); + this.Controls.Add(this.comPortNrTextBox); + this.Controls.Add(this.comPortNrLabel); + this.Name = "ControlBoardCfgCtrl"; + this.Size = new System.Drawing.Size(300, 200); + this.Load += new System.EventHandler(this.ControlBoardCfgCtrl_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label comPortNrLabel; + private System.Windows.Forms.TextBox comPortNrTextBox; + private System.Windows.Forms.Label classNameLabel; + private System.Windows.Forms.Label nameLabel; + private System.Windows.Forms.TextBox nameTextBox; + private System.Windows.Forms.TextBox vValveRangeLoTextBox; + private System.Windows.Forms.Label vValveRangeLoLabel; + private System.Windows.Forms.TextBox vValveRangeHiTextBox; + private System.Windows.Forms.Label vValveRangeHiLabel; + } +} diff --git a/TBF/BenchControl/ControlBoard/New/CBoardCfgCtrl.cs b/TBF/BenchControl/ControlBoard/New/CBoardCfgCtrl.cs new file mode 100644 index 000000000..f87b82d8c --- /dev/null +++ b/TBF/BenchControl/ControlBoard/New/CBoardCfgCtrl.cs @@ -0,0 +1,105 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System; +using System.Windows.Forms; +using Config.Entities; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.ControlBoard.New +{ + public partial class CBoardCfgCtrl : UserControl, IComponentCfgCtrl + { + public bool ShowMore { get { return false; } } + + CBoardCfg config; + public IComponentCfg Config + { + get { return config as IComponentCfg; } + set + { + config = value as CBoardCfg; + Redraw(); + } + } + + public CBoardCfgCtrl() + { + InitializeComponent(); + } + + private void ControlBoardCfgCtrl_Load(object sender, EventArgs e) + { + Redraw(); + } + + public void Closing() + { + } + + void Redraw() + { + if (config == null) return; /// Control was not loaded, settings were not changed + + classNameLabel.Text = config.Factory.ClassName; + nameTextBox.Text = config.Name; + comPortNrTextBox.Text = config.ComPortNr.ToString(); + vValveRangeLoTextBox.Text = config.VirtualValvesRangeLo.ToString(); + vValveRangeHiTextBox.Text = config.VirtualValvesRangeHi.ToString(); + } + + public void Unlock() + { + nameTextBox.Enabled = true; + comPortNrTextBox.Enabled = true; + vValveRangeLoTextBox.Enabled = true; + vValveRangeHiTextBox.Enabled = true; + } + + /// + /// Verify current user controls for validity. + /// Called when user wants to close/save the configuration. + /// + /// See VerifyFlags + public CfgUpdateFlags VerifyCfg(ref string message) + { + CfgUpdateFlags flags = CfgUpdateFlags.None; + + int dummy; + if (!int.TryParse(comPortNrTextBox.Text, out dummy) || dummy <= 0 || dummy > 999) + { + message += "Control board serial port number is invalid"; + flags |= CfgUpdateFlags.Error; + } + if (!int.TryParse(vValveRangeLoTextBox.Text, out dummy) || dummy < 0 || dummy > 63) + { + message += "Virtual valves range Lo is invalid"; + flags |= CfgUpdateFlags.Error; + } + if (!int.TryParse(vValveRangeHiTextBox.Text, out dummy) || dummy < 0 || dummy > 63) + { + message += "Virtual valves range Hi is invalid"; + flags |= CfgUpdateFlags.Error; + } + + return flags; + } + + /// + /// Save settings to the configuration class. + /// + public CfgUpdateFlags UpdateCfg() + { + CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd; + + if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed + + this.Name = nameTextBox.Text; + this.config.ComPortNr = int.Parse(comPortNrTextBox.Text); + this.config.VirtualValvesRangeLo = int.Parse(vValveRangeLoTextBox.Text); + this.config.VirtualValvesRangeHi = int.Parse(vValveRangeHiTextBox.Text); + + return flags; + } + } +} diff --git a/TBF/BenchControl/Elde/FixedStartRegisterReader/RegisterReaderCfgCtrl.resx b/TBF/BenchControl/ControlBoard/New/CBoardCfgCtrl.resx similarity index 100% rename from TBF/BenchControl/Elde/FixedStartRegisterReader/RegisterReaderCfgCtrl.resx rename to TBF/BenchControl/ControlBoard/New/CBoardCfgCtrl.resx diff --git a/TBF/BenchControl/ControlBoard/New/CBoardFactory.cs b/TBF/BenchControl/ControlBoard/New/CBoardFactory.cs new file mode 100644 index 000000000..deb6e6cbe --- /dev/null +++ b/TBF/BenchControl/ControlBoard/New/CBoardFactory.cs @@ -0,0 +1,36 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System.Collections.Generic; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.ControlBoard.New +{ + public class CBoardFactory : IComponentFactory + { + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } + + /// Max. number of components of this class in the system + public int MaxCount { get { return 1; } } + + public IComponent DummyComponent() { return new CBoard(); } + + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new CBoard(cfg); } + + public IComponentCfg DefaultConfig() { return new CBoardCfg(this); } + + public IComponentCfgCtrl CreateCfgCtrl() { return new CBoardCfgCtrl(); } + + public IComponent ComponentFromCmpntCfg(IComponentCfg config, IList components) + { + return new CBoard((CBoardCfg)config); + } + + public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) + { + return ComponentCfgBase.CreateFromDbEntity(CBoardCfg.Serializer, component, this); + } + + public void ResetStaticProperties() { } + } +} diff --git a/TBF/BenchControl/ControlBoard/Papouch/CBoard.cs b/TBF/BenchControl/ControlBoard/Papouch/CBoard.cs new file mode 100644 index 000000000..6c2ca9ece --- /dev/null +++ b/TBF/BenchControl/ControlBoard/Papouch/CBoard.cs @@ -0,0 +1,278 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using log4net; +using Config.Entities; +using Dirichlet.Numerics; +using TBF.BenchControl.Generic; +using TBF.BenchControl.GenericDevices; +using TBF.BenchControl.Modbus; + +namespace TBF.BenchControl.ControlBoard.Papouch +{ + public class CBoard : ComponentBase, IControlBoard + { + private static readonly ILog log = LogManager.GetLogger(typeof(CBoard)); + public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(1)); } + + readonly CBoardCfg cBoardCfg; + readonly GenericDevices.IModbus modbus; + + public QuidoVariant Variant { get { return cBoardCfg.Variant; } } + + private ushort currentOutputs; + private DateTime lastOutputsChange; + + public OutputPath Devices + { + set { devices = value; } + get { return devices; } + } + OutputPath devices; + + public CBoard() + { + } + + /// + /// Constructor + /// + public CBoard(Generic.IComponentCfg cfg, IList components) + : base(cfg) + { + cBoardCfg = cfg as CBoardCfg; + + modbus = (GenericDevices.IModbus)TbfComponents.FindComponent(cfg.ParentName, components); + if (modbus == null) throw new Exception("Cannot find " + Name + " parent"); + + log.Debug(this.ToString()); + } + + public void InitializeComponent(object thirdPartyComponent, UInt128 valvesToInvert, double[] tankCapacities) + { + this.valvesToInvert = valvesToInvert; + this.benchModelRoute = valvesToInvert; + } + + + public void Initialize() + { + } + + public void RunDeviceBefore() + { + if (cBoardCfg.DebugLevel == Config.Entities.DebugMode.Simulate) return; + + if (modbus.ReceivedTelegrams[cBoardCfg.ModbusAddress].Count > 0) + { + byte[] telegram = modbus.ReceivedTelegrams[cBoardCfg.ModbusAddress].Dequeue(); + + if ((telegram.Length >= 8) && (telegram[1] == 0x11) && (telegram[2] == telegram.Length - 5)) + { + int msgLen = telegram.Length - 7; + byte modbusAddress = telegram[3]; + string msg = Encoding.ASCII.GetString(telegram, 5, msgLen); + string s = string.Format("QuidoRS detected: Address={0}, Message={1}", modbusAddress, msg); + Debug.WriteLine(s); + log.Warn(s); + } + } + } + + public void RunDeviceAfter() { } + public void StopDevice() { SendOutputs(0); } + public void StopDevice2() { } + + + /// + /// Set outputs of QuidoRS board + /// + /// output value + public void SetOutputs(ushort outputs) + { + lock (this) + { + SendOutputs(currentOutputs); + } + } + + /// + /// Set bit(s) specified by a bitMask. Leave other bits unaffeced. + /// + /// Specifies bit(s) to set + /// output value + public void SetBit(ushort bitMask) + { + lock (this) + { + SendOutputs(currentOutputs); + } + } + + /// + /// Reset bit(s) specified by a bitMask. Leave other bits unaffeced. + /// + /// Specifies bit(s) to reset + /// output value + public void ResetBit(ushort bitMask) + { + lock (this) + { + SendOutputs(currentOutputs); + } + } + + private void SendOutputs(ushort outputs) + { + byte addr = cBoardCfg.ModbusAddress; + byte cmd = (byte)Function.ForceMultipleCoils; + byte dataLo = (byte)(outputs & 0xFF); + byte dataHi = (byte)(outputs >> 8); + + if (cBoardCfg.Variant == QuidoVariant.QuidoRS_2_16) + { + modbus.SendMessage(new byte[] { addr, cmd, 0, 0, 0, 16, 2, dataLo, dataHi, 0, 0 }); + } + else if (cBoardCfg.Variant == QuidoVariant.QuidoRS_4_4) + { + modbus.SendMessage(new byte[] { addr, cmd, 0, 0, 0, 4, 1, dataLo, 0, 0 }); + } + else if (cBoardCfg.Variant == QuidoVariant.QuidoRS_8_8) + { + modbus.SendMessage(new byte[] { addr, cmd, 0, 0, 0, 8, 1, dataLo, 0, 0 }); + } + + lastOutputsChange = DateTime.Now; + } + + + /// + /// IControlBoard interface + /// + + /// + /// Route: 128-bit word representing the current state of all valves and pumps + /// + public UInt128 Route { get { return benchModelRoute; } } + UInt128 benchModelRoute; + UInt128 valvesToInvert; /// Route = valesToInvert ^ RequiredRouteWithoutInvertedVlaves + readonly UInt128 routeMask; /// This mask masks out virtual valves, routeMask is set in the constructor + + public UInt64 DigitalInputs { get { return 0; } } + + public double RefFrequency { get { return 0; } } + public double RefFlow { get { return 0; } } + + /// + /// Last test result + /// + public int RefPulses { get { return 0; } } + public double TestTime { get { return 1.0; } } + public int RefPulsesWM(int wmNr1) { return (wmNr1 > 0 && wmNr1 <= Config.Data.WMsCount) ? 0 : 0; } + public int PulsesWM(int wmNr1) { return (wmNr1 > 0 && wmNr1 <= Config.Data.WMsCount) ? 0 : 0; } + public double TestTimeWM(int wmNr1) { return (wmNr1 > 0 && wmNr1 <= Config.Data.WMsCount) ? 1.0 : 1.0; } + + + public void UpdateUI(string sParam, int iParam, double value) { } + public void ClearProcessValues() { } + + public UInt128 SetValves(UInt128 valvesToOpen, UInt128 valvesToClose, IList extendedValves) + { + return routeMask; + } + + /// + /// Open one valve and/or close one valve. + /// Events: ValvesSet + /// + /// Valve to be opened + /// Valve to be closed + /// Created operation + public IOperation SetValvesOp(IValve valveOpen, IValve valveClose) + { + return new BuiltIn.SetValvesOp(this, valveOpen, valveClose); + } + + /// + /// Open and/or close multiple valves. + /// Events: ValvesSet + /// + /// A list of valves to be opened + /// A list of valves to be closed + /// Created operation + public IOperation SetValvesOp(IList valvesOpen, IList valvesClose) + { + return new BuiltIn.SetValvesOp(this, valvesOpen, valvesClose); + } + + /// + /// Open start/stop valve. + /// Events: ValvesSet, ValvesBusy, Error + /// + /// Created operation + public IOperation OpenStartValveOp() + { + return new BuiltIn.SetValvesOp(this, true, devices); + } + + /// + /// Close start/stop valve. + /// Events: ValvesSet, ValvesBusy, Error + /// + /// Created operation + public IOperation CloseStartValveOp() + { + return new BuiltIn.SetValvesOp(this, false, devices); + } + + public float ValveOpenCloseTime { get { return 0.1f; } } + + + public IOperation SetFlowOp(double reqrdFlowLo, double reqrdFlowHi, TBF.Boxes.DoubleBox measuredFlow, int timeout) + { + return null; /// TODO + } + + public IOperation StopFlowRegulationOp() + { + return null; /// TODO + } + + /// + /// Start a test, Events: MeasurementStarted + /// + /// Int32 parameter 1 + /// Double parameter 1 (alternative lower flow limit) + /// Double parameter 2 (alternative upper flow limit) + /// Operation + public IOperation StartTestOp(Test test, int iParam = 0, double dParam1 = 0, double dParam2 = 0) + { + return null; /// TODO + } + + public IOperation QueryMeasurementEndOp() + { + return null; /// TODO + } + + public IOperation StopMeasurementOp() + { + return null; /// TODO + } + + public IOperation ReadDiverterTransitionOp(bool isStart, Sequences.Statistics plotter, int batchNr, string testName, int repetition) + { + return null; + } + + public IOperation StopPreviousOp() + { + return null; + } + } +} diff --git a/TBF/BenchControl/ControlBoard/Papouch/CBoardCfg.cs b/TBF/BenchControl/ControlBoard/Papouch/CBoardCfg.cs new file mode 100644 index 000000000..48ab99681 --- /dev/null +++ b/TBF/BenchControl/ControlBoard/Papouch/CBoardCfg.cs @@ -0,0 +1,62 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System.IO; +using System.Collections.Generic; +using System.Xml.Serialization; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.ControlBoard.Papouch +{ + public enum QuidoVariant + { + QuidoRS_2_16, + QuidoRS_4_4, + QuidoRS_8_8, + Count + } + + public class CBoardCfg : ComponentCfgBase, Generic.IChildComponentCfg + { + public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(CBoardCfg) })[0]; + public override XmlSerializer GetSerializer() { return Serializer; } + + public IComponentCfgCtrl GetControl() { return new CBoardCfgCtrl(); } + + /// + /// Serialized parameters + /// + public byte ModbusAddress; /// 1..254 + public QuidoVariant Variant; /// QuidoRS_2_16, QuidoRS_4_4 or QuidoRS_8_8 + public int VirtualValvesRangeLo; + public int VirtualValvesRangeHi; + + /// Private parameterless constructor invoked by all other (public) constructors + CBoardCfg() + { + Name = "CB"; + ParentName = "Modbus"; + ModbusAddress = 1; + Variant = QuidoVariant.QuidoRS_2_16; + VirtualValvesRangeLo = 50; + VirtualValvesRangeHi = 59; + } + + public CBoardCfg(IComponentFactory factory) + : this() + { + this.Factory = factory; + } + + public string ToString(int i) + { + return string.Format("name={0}({1}) address={2} variant={3} vvLo={4} vvHi={5}", + Name, + (string.IsNullOrEmpty(ParentName) ? "-" : ParentName), + ModbusAddress, + Variant, + VirtualValvesRangeLo, + VirtualValvesRangeHi); + } + } +} diff --git a/TBF/BenchControl/ControlBoard/Papouch/CBoardCfgCtrl.Designer.cs b/TBF/BenchControl/ControlBoard/Papouch/CBoardCfgCtrl.Designer.cs new file mode 100644 index 000000000..ecb780f9c --- /dev/null +++ b/TBF/BenchControl/ControlBoard/Papouch/CBoardCfgCtrl.Designer.cs @@ -0,0 +1,203 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +namespace TBF.BenchControl.ControlBoard.Papouch +{ + partial class CBoardCfgCtrl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.classNameLabel = new System.Windows.Forms.Label(); + this.nameLabel = new System.Windows.Forms.Label(); + this.nameTextBox = new System.Windows.Forms.TextBox(); + this.vValveRangeLoTextBox = new System.Windows.Forms.TextBox(); + this.vValveRangeLoLabel = new System.Windows.Forms.Label(); + this.vValveRangeHiTextBox = new System.Windows.Forms.TextBox(); + this.vValveRangeHiLabel = new System.Windows.Forms.Label(); + this.parentNameComboBox = new System.Windows.Forms.ComboBox(); + this.modbusAddressTextBox = new System.Windows.Forms.TextBox(); + this.modbusAddressLabel = new System.Windows.Forms.Label(); + this.parentNameLabel = new System.Windows.Forms.Label(); + this.variantComboBox = new System.Windows.Forms.ComboBox(); + this.variantLabel = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // classNameLabel + // + this.classNameLabel.AutoSize = true; + this.classNameLabel.Location = new System.Drawing.Point(175, 26); + this.classNameLabel.Name = "classNameLabel"; + this.classNameLabel.Size = new System.Drawing.Size(83, 13); + this.classNameLabel.TabIndex = 2; + this.classNameLabel.Text = "ComonentName"; + // + // nameLabel + // + this.nameLabel.AutoSize = true; + this.nameLabel.Location = new System.Drawing.Point(42, 60); + this.nameLabel.Name = "nameLabel"; + this.nameLabel.Size = new System.Drawing.Size(35, 13); + this.nameLabel.TabIndex = 3; + this.nameLabel.Text = "Name"; + // + // nameTextBox + // + this.nameTextBox.Enabled = false; + this.nameTextBox.Location = new System.Drawing.Point(178, 57); + this.nameTextBox.Name = "nameTextBox"; + this.nameTextBox.Size = new System.Drawing.Size(130, 20); + this.nameTextBox.TabIndex = 4; + // + // vValveRangeLoTextBox + // + this.vValveRangeLoTextBox.Enabled = false; + this.vValveRangeLoTextBox.Location = new System.Drawing.Point(178, 161); + this.vValveRangeLoTextBox.Name = "vValveRangeLoTextBox"; + this.vValveRangeLoTextBox.Size = new System.Drawing.Size(46, 20); + this.vValveRangeLoTextBox.TabIndex = 6; + // + // vValveRangeLoLabel + // + this.vValveRangeLoLabel.AutoSize = true; + this.vValveRangeLoLabel.Location = new System.Drawing.Point(42, 164); + this.vValveRangeLoLabel.Name = "vValveRangeLoLabel"; + this.vValveRangeLoLabel.Size = new System.Drawing.Size(118, 13); + this.vValveRangeLoLabel.TabIndex = 5; + this.vValveRangeLoLabel.Text = "Virtual valves range Lo:"; + // + // vValveRangeHiTextBox + // + this.vValveRangeHiTextBox.Enabled = false; + this.vValveRangeHiTextBox.Location = new System.Drawing.Point(178, 186); + this.vValveRangeHiTextBox.Name = "vValveRangeHiTextBox"; + this.vValveRangeHiTextBox.Size = new System.Drawing.Size(46, 20); + this.vValveRangeHiTextBox.TabIndex = 8; + // + // vValveRangeHiLabel + // + this.vValveRangeHiLabel.AutoSize = true; + this.vValveRangeHiLabel.Location = new System.Drawing.Point(42, 189); + this.vValveRangeHiLabel.Name = "vValveRangeHiLabel"; + this.vValveRangeHiLabel.Size = new System.Drawing.Size(116, 13); + this.vValveRangeHiLabel.TabIndex = 7; + this.vValveRangeHiLabel.Text = "Virtual valves range Hi:"; + // + // parentNameComboBox + // + this.parentNameComboBox.Enabled = false; + this.parentNameComboBox.FormattingEnabled = true; + this.parentNameComboBox.Location = new System.Drawing.Point(178, 83); + this.parentNameComboBox.Name = "parentNameComboBox"; + this.parentNameComboBox.Size = new System.Drawing.Size(130, 21); + this.parentNameComboBox.TabIndex = 10; + // + // modbusAddressTextBox + // + this.modbusAddressTextBox.Enabled = false; + this.modbusAddressTextBox.Location = new System.Drawing.Point(178, 136); + this.modbusAddressTextBox.Name = "modbusAddressTextBox"; + this.modbusAddressTextBox.Size = new System.Drawing.Size(46, 20); + this.modbusAddressTextBox.TabIndex = 12; + // + // modbusAddressLabel + // + this.modbusAddressLabel.AutoSize = true; + this.modbusAddressLabel.Location = new System.Drawing.Point(42, 140); + this.modbusAddressLabel.Name = "modbusAddressLabel"; + this.modbusAddressLabel.Size = new System.Drawing.Size(86, 13); + this.modbusAddressLabel.TabIndex = 11; + this.modbusAddressLabel.Text = "Modbus Address"; + // + // parentNameLabel + // + this.parentNameLabel.AutoSize = true; + this.parentNameLabel.Location = new System.Drawing.Point(42, 86); + this.parentNameLabel.Name = "parentNameLabel"; + this.parentNameLabel.Size = new System.Drawing.Size(69, 13); + this.parentNameLabel.TabIndex = 9; + this.parentNameLabel.Text = "Parent Name"; + // + // variantComboBox + // + this.variantComboBox.Enabled = false; + this.variantComboBox.FormattingEnabled = true; + this.variantComboBox.Location = new System.Drawing.Point(178, 110); + this.variantComboBox.Name = "variantComboBox"; + this.variantComboBox.Size = new System.Drawing.Size(130, 21); + this.variantComboBox.TabIndex = 14; + // + // variantLabel + // + this.variantLabel.AutoSize = true; + this.variantLabel.Location = new System.Drawing.Point(42, 113); + this.variantLabel.Name = "variantLabel"; + this.variantLabel.Size = new System.Drawing.Size(40, 13); + this.variantLabel.TabIndex = 13; + this.variantLabel.Text = "Variant"; + // + // CBoardCfgCtrl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.variantComboBox); + this.Controls.Add(this.variantLabel); + this.Controls.Add(this.parentNameComboBox); + this.Controls.Add(this.modbusAddressTextBox); + this.Controls.Add(this.modbusAddressLabel); + this.Controls.Add(this.parentNameLabel); + this.Controls.Add(this.vValveRangeHiTextBox); + this.Controls.Add(this.vValveRangeHiLabel); + this.Controls.Add(this.vValveRangeLoTextBox); + this.Controls.Add(this.vValveRangeLoLabel); + this.Controls.Add(this.nameTextBox); + this.Controls.Add(this.nameLabel); + this.Controls.Add(this.classNameLabel); + this.Name = "CBoardCfgCtrl"; + this.Size = new System.Drawing.Size(400, 300); + this.Load += new System.EventHandler(this.ControlBoardCfgCtrl_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label classNameLabel; + private System.Windows.Forms.Label nameLabel; + private System.Windows.Forms.TextBox nameTextBox; + private System.Windows.Forms.TextBox vValveRangeLoTextBox; + private System.Windows.Forms.Label vValveRangeLoLabel; + private System.Windows.Forms.TextBox vValveRangeHiTextBox; + private System.Windows.Forms.Label vValveRangeHiLabel; + private System.Windows.Forms.ComboBox parentNameComboBox; + private System.Windows.Forms.TextBox modbusAddressTextBox; + private System.Windows.Forms.Label modbusAddressLabel; + private System.Windows.Forms.Label parentNameLabel; + private System.Windows.Forms.ComboBox variantComboBox; + private System.Windows.Forms.Label variantLabel; + } +} diff --git a/TBF/BenchControl/ControlBoard/Papouch/CBoardCfgCtrl.cs b/TBF/BenchControl/ControlBoard/Papouch/CBoardCfgCtrl.cs new file mode 100644 index 000000000..8107243f1 --- /dev/null +++ b/TBF/BenchControl/ControlBoard/Papouch/CBoardCfgCtrl.cs @@ -0,0 +1,142 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System; +using System.Windows.Forms; +using Config.Entities; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.ControlBoard.Papouch +{ + public partial class CBoardCfgCtrl : UserControl, IComponentCfgCtrl + { + ComponentParametersDlg parent; + + public bool ShowMore { get { return false; } } + + CBoardCfg config; + public IComponentCfg Config + { + get { return config as IComponentCfg; } + set + { + config = value as CBoardCfg; + Redraw(); + } + } + + public CBoardCfgCtrl() + { + InitializeComponent(); + } + + private void ControlBoardCfgCtrl_Load(object sender, EventArgs e) + { + parent = ParentForm as ComponentParametersDlg; + if (parent == null) return; + + if (parent.TbfComponents != null) + { + foreach (var cmpnt in parent.TbfComponents) + { + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Modbus.Common.Factory) + { + parentNameComboBox.Items.Add(cmpnt.Name); + } + } + } + + for (QuidoVariant v = 0; v < QuidoVariant.Count; v++) variantComboBox.Items.Add(v.ToString()); + + Redraw(); + } + + public void Closing() + { + } + + void Redraw() + { + if (config == null) return; /// Control was not loaded, settings were not changed + + classNameLabel.Text = config.Factory.ClassName; + nameTextBox.Text = config.Name; + parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName; + variantComboBox.Text = config.Variant.ToString(); + modbusAddressTextBox.Text = config.ModbusAddress.ToString(); + vValveRangeLoTextBox.Text = config.VirtualValvesRangeLo.ToString(); + vValveRangeHiTextBox.Text = config.VirtualValvesRangeHi.ToString(); + } + + public void Unlock() + { + nameTextBox.Enabled = true; + parentNameComboBox.Enabled = true; + variantComboBox.Enabled = true; + modbusAddressTextBox.Enabled = true; + vValveRangeLoTextBox.Enabled = true; + vValveRangeHiTextBox.Enabled = true; + } + + /// + /// Verify current user controls for validity. + /// Called when user wants to close/save the configuration. + /// + /// See VerifyFlags + public CfgUpdateFlags VerifyCfg(ref string message) + { + CfgUpdateFlags flags = CfgUpdateFlags.None; + + int dummy; + if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text)) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "Invalid 'Parent Name'"; + } + if (!variantComboBox.Items.Contains(variantComboBox.Text)) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "Invalid 'Variant'"; + } + if (!int.TryParse(modbusAddressTextBox.Text, out dummy) || dummy < 0 || dummy > 255) + { + flags |= CfgUpdateFlags.Error; + message += Environment.NewLine + "'Modbus Address' should be between 0 and 255"; + } + if (!int.TryParse(vValveRangeLoTextBox.Text, out dummy) || dummy < 0 || dummy > 63) + { + message += "Virtual valves range Lo is invalid"; + flags |= CfgUpdateFlags.Error; + } + if (!int.TryParse(vValveRangeHiTextBox.Text, out dummy) || dummy < 0 || dummy > 63) + { + message += "Virtual valves range Hi is invalid"; + flags |= CfgUpdateFlags.Error; + } + + return flags; + } + + /// + /// Save settings to the configuration class. + /// + public CfgUpdateFlags UpdateCfg() + { + CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd; + + if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed + + this.Name = nameTextBox.Text; + config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text; + for (QuidoVariant v = 0; v < QuidoVariant.Count; v++) + { + if (variantComboBox.Text == v.ToString()) { config.Variant = v; break; } + } + config.ModbusAddress = (byte)int.Parse(modbusAddressTextBox.Text); + config.VirtualValvesRangeLo = int.Parse(vValveRangeLoTextBox.Text); + config.VirtualValvesRangeHi = int.Parse(vValveRangeHiTextBox.Text); + + return flags; + } + } +} diff --git a/TBF/BenchControl/ControlBoard/Papouch/CBoardCfgCtrl.resx b/TBF/BenchControl/ControlBoard/Papouch/CBoardCfgCtrl.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TBF/BenchControl/ControlBoard/Papouch/CBoardCfgCtrl.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TBF/BenchControl/ControlBoard/Papouch/CBoardFactory.cs b/TBF/BenchControl/ControlBoard/Papouch/CBoardFactory.cs new file mode 100644 index 000000000..80bd77114 --- /dev/null +++ b/TBF/BenchControl/ControlBoard/Papouch/CBoardFactory.cs @@ -0,0 +1,29 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System.Collections.Generic; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.ControlBoard.Papouch +{ + public class CBoardFactory : IComponentFactory + { + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } + + public void ResetStaticProperties() { CBoard.ResetStaticProperties(); } + + /// Max. number of components of this class in the system + public int MaxCount { get { return 1; } } + + public IComponent DummyComponent() { return new CBoard(); } + + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new CBoard(cfg, components); } + + public IComponentCfg DefaultConfig() { return new CBoardCfg(this); } + + public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) + { + return ComponentCfgBase.CreateFromDbEntity(CBoardCfg.Serializer, component, this); + } + } +} diff --git a/TBF/BenchControl/Danfoss/VLT2800/Pump.cs b/TBF/BenchControl/Danfoss/VLT2800/Pump.cs index 1d1d662bf..a820080ba 100644 --- a/TBF/BenchControl/Danfoss/VLT2800/Pump.cs +++ b/TBF/BenchControl/Danfoss/VLT2800/Pump.cs @@ -1,16 +1,15 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; -using System.Globalization; using System.IO.Ports; using System.Text; using log4net; using Config.Entities; -using TBF.BenchControl.Generic; -using TBF.Boxes; using Dirichlet.Numerics; +using TBF.BenchControl.ControlBoard; +using TBF.BenchControl.Generic; namespace TBF.BenchControl.Danfoss.VLT2800 { @@ -92,7 +91,7 @@ namespace TBF.BenchControl.Danfoss.VLT2800 } - readonly Elde.ControlBoardDev controlBoard; + readonly IControlBoard controlBoard; readonly int bitPosition; /// 0 .. 63 public readonly UInt128 Mask; /// derived from bitPosition in the constructor @@ -122,7 +121,7 @@ namespace TBF.BenchControl.Danfoss.VLT2800 { pumpCfg = cfg as PumpCfg; - controlBoard = (Elde.ControlBoardDev)TbfComponents.FindComponent("CB", components); /// TODO: replace "CB" + controlBoard = TbfComponents.FindComponent("CB", components) as IControlBoard; /// TODO: replace "CB" if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent"); bitPosition = pumpCfg.BitPosition; diff --git a/TBF/BenchControl/Elde/CoverTest/CoverTest.cs b/TBF/BenchControl/Elde/CoverTest/CoverTest.cs index 5aed994d5..476de8f81 100644 --- a/TBF/BenchControl/Elde/CoverTest/CoverTest.cs +++ b/TBF/BenchControl/Elde/CoverTest/CoverTest.cs @@ -1,10 +1,11 @@ /// -/// Copyright (c) 2017 Sensus Metering Systems +/// Copyright (c) 2017-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using Dirichlet.Numerics; using log4net; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.BenchControl.GenericDevices; using TBF.Resources; diff --git a/TBF/BenchControl/Elde/CoverTest/CoverTestCfgCtrl.cs b/TBF/BenchControl/Elde/CoverTest/CoverTestCfgCtrl.cs index 37ad93a0b..04626d1ec 100644 --- a/TBF/BenchControl/Elde/CoverTest/CoverTestCfgCtrl.cs +++ b/TBF/BenchControl/Elde/CoverTest/CoverTestCfgCtrl.cs @@ -39,7 +39,7 @@ namespace TBF.BenchControl.Elde.CoverTest { foreach (var cmpnt in parent.TbfComponents) { - if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.ControlBoardFactory) + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.ControlBoardFactory) { parentNameComboBox.Items.Add(cmpnt.Name); } diff --git a/TBF/BenchControl/Elde/Diverter/Diverter.cs b/TBF/BenchControl/Elde/Diverter/Diverter.cs index 2fbc80510..ebf152cf7 100644 --- a/TBF/BenchControl/Elde/Diverter/Diverter.cs +++ b/TBF/BenchControl/Elde/Diverter/Diverter.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using log4net; using Dirichlet.Numerics; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.BenchControl.Generic; using TBF.Boxes; using TBF.Resources; @@ -69,7 +70,7 @@ namespace TBF.BenchControl.Elde.Diverter { diverterCfg = cfg as DiverterCfg; - controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components); + controlBoard = TbfComponents.FindComponent(cfg.ParentName, components) as ControlBoardDev; if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent"); if (diverterCfg.BitPosition < 0 || diverterCfg.BitPosition >= 64) throw new ArgumentOutOfRangeException("position"); @@ -189,7 +190,7 @@ namespace TBF.BenchControl.Elde.Diverter public void Initialize() { } public void RunDeviceBefore() { - int adcValue = (int)StateMachine.ControlBoard.AnalogInputRaw(diverterCfg.AdcNr, 0); + int adcValue = (int)controlBoard.AnalogInputRaw(diverterCfg.AdcNr, 0); Handlers.OnAdcChanged(this, new CmdResponseArgs(CfgChangeCmd.GetAdc, diverterCfg.BitPosition, adcValue)); } public void RunDeviceAfter() { } diff --git a/TBF/BenchControl/Elde/Diverter/DiverterCfgCtrl.cs b/TBF/BenchControl/Elde/Diverter/DiverterCfgCtrl.cs index 7044ac78a..a36f646f6 100644 --- a/TBF/BenchControl/Elde/Diverter/DiverterCfgCtrl.cs +++ b/TBF/BenchControl/Elde/Diverter/DiverterCfgCtrl.cs @@ -42,7 +42,7 @@ namespace TBF.BenchControl.Elde.Diverter { foreach (var cmpnt in parent.TbfComponents) { - if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.ControlBoardFactory) + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.ControlBoardFactory) { parentNameComboBox.Items.Add(cmpnt.Name); } diff --git a/TBF/BenchControl/Elde/ReadDiverterStateOp.cs b/TBF/BenchControl/Elde/Diverter/ReadDiverterStateOp.cs similarity index 77% rename from TBF/BenchControl/Elde/ReadDiverterStateOp.cs rename to TBF/BenchControl/Elde/Diverter/ReadDiverterStateOp.cs index f23e583c7..6a7677b21 100644 --- a/TBF/BenchControl/Elde/ReadDiverterStateOp.cs +++ b/TBF/BenchControl/Elde/Diverter/ReadDiverterStateOp.cs @@ -5,16 +5,15 @@ using System; using log4net; using TBF.Boxes; -namespace TBF.BenchControl.Elde +namespace TBF.BenchControl.Elde.Diverter { public class ReadDiverterStateOp : IOperation { - private static readonly ILog log = LogManager.GetLogger(typeof(ReadFlowOp)); + private static readonly ILog log = LogManager.GetLogger(typeof(ReadDiverterStateOp)); public override string ToString() { return string.Format("ReadDiverterStateOp(div={0}, delay={1})", div.Name, delay); } /// Set by the constructor readonly GenericDevices.IDiverter div; - readonly ControlBoardDev ctrlBrd; readonly int delay; int startTime; @@ -25,18 +24,17 @@ namespace TBF.BenchControl.Elde /// Flow meter reference /// Reference to the measured flow variable, value is in bar /// Event to be returned by Run() when completed OK - public ReadDiverterStateOp(ControlBoardDev ctrlBrd, GenericDevices.IDiverter div, int delay) + public ReadDiverterStateOp(GenericDevices.IDiverter div, int delay) { - if (ctrlBrd == null || div == null) throw new ArgumentNullException(); - - this.ctrlBrd = ctrlBrd; this.div = div; + if (div == null) throw new ArgumentNullException(); + this.delay = delay; log.Debug(this.ToString()); } - public ReadDiverterStateOp(ControlBoardDev ctrlBrd, GenericDevices.IDiverter div) - : this(ctrlBrd, div, 0) + public ReadDiverterStateOp(GenericDevices.IDiverter div) + : this(div, 0) { } diff --git a/TBF/BenchControl/Elde/Diverter/SwitchDiverterOp.cs b/TBF/BenchControl/Elde/Diverter/SwitchDiverterOp.cs index 676987ad8..e81e3df7a 100644 --- a/TBF/BenchControl/Elde/Diverter/SwitchDiverterOp.cs +++ b/TBF/BenchControl/Elde/Diverter/SwitchDiverterOp.cs @@ -1,7 +1,8 @@ /// -/// Copyright (c) 2017 Sensus Metering Systems +/// Copyright (c) 2017-2020 Sensus Slovensko a.s. /// using System; +using TBF.BenchControl.ControlBoard.Legacy; namespace TBF.BenchControl.Elde.Diverter { diff --git a/TBF/BenchControl/Elde/FlowMeter/FlowMeter.cs b/TBF/BenchControl/Elde/FlowMeter/FlowMeter.cs index 06baf94d6..500fa236a 100644 --- a/TBF/BenchControl/Elde/FlowMeter/FlowMeter.cs +++ b/TBF/BenchControl/Elde/FlowMeter/FlowMeter.cs @@ -1,9 +1,10 @@ /// -/// Copyright (c) 2013-2018 Sensus Slovensko a.s. +/// Copyright (c) 2013-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.Boxes; using TBF.Resources; @@ -114,8 +115,8 @@ namespace TBF.BenchControl.Elde.FlowMeter } - public double ReadFlow() { return controlBoard.ReferenceFlow; } - public double ReadFrequency() { return controlBoard.ReferenceFreq; } + public double ReadFlow() { return controlBoard.RefFlow; } + public double ReadFrequency() { return controlBoard.RefFrequency; } /// /// Events: FlowDone, Error diff --git a/TBF/BenchControl/Elde/FlowMeter/FlowMeterCfgCtrl.cs b/TBF/BenchControl/Elde/FlowMeter/FlowMeterCfgCtrl.cs index e0fede5fd..370037652 100644 --- a/TBF/BenchControl/Elde/FlowMeter/FlowMeterCfgCtrl.cs +++ b/TBF/BenchControl/Elde/FlowMeter/FlowMeterCfgCtrl.cs @@ -40,7 +40,7 @@ namespace TBF.BenchControl.Elde.FlowMeter { foreach (var cmpnt in parent.TbfComponents) { - if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.ControlBoardFactory) + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.ControlBoardFactory) { parentNameComboBox.Items.Add(cmpnt.Name); } diff --git a/TBF/BenchControl/Elde/FlowMeterDewa/FlowMeter.cs b/TBF/BenchControl/Elde/FlowMeterDewa/FlowMeter.cs index 9fdad5ddd..bcb07ba99 100644 --- a/TBF/BenchControl/Elde/FlowMeterDewa/FlowMeter.cs +++ b/TBF/BenchControl/Elde/FlowMeterDewa/FlowMeter.cs @@ -1,11 +1,12 @@ /// -/// Copyright (c) 2019 Sensus Slovensko a.s. +/// Copyright (c) 2019-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; -using TBF.Boxes; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.BenchControl.GenericDevices; +using TBF.Boxes; namespace TBF.BenchControl.Elde.FlowMeterDewa { @@ -43,7 +44,7 @@ namespace TBF.BenchControl.Elde.FlowMeterDewa refFreq[1] = refFreq[0] - refFreq[2] - refFreq[3]; - refPulses[0] = controlBoard.EtPulses(0); + refPulses[0] = controlBoard.RefPulses; refPulses[2] = controlBoard.EtPulses2; refPulses[3] = controlBoard.EtPulses3; refPulses[1] = refPulses[0] - refPulses[2] - refPulses[3]; @@ -132,8 +133,8 @@ namespace TBF.BenchControl.Elde.FlowMeterDewa log.Debug(this.ToString()); } - public double ReadFlow() { return controlBoard.ReferenceFlow; } - public double ReadFrequency() { return controlBoard.ReferenceFreq; } + public double ReadFlow() { return controlBoard.RefFlow; } + public double ReadFrequency() { return controlBoard.RefFrequency; } /// /// Events: FlowDone, Error diff --git a/TBF/BenchControl/Elde/FlowMeterDewa/FlowMeterCfgCtrl.cs b/TBF/BenchControl/Elde/FlowMeterDewa/FlowMeterCfgCtrl.cs index 0801c325f..2dd39ea67 100644 --- a/TBF/BenchControl/Elde/FlowMeterDewa/FlowMeterCfgCtrl.cs +++ b/TBF/BenchControl/Elde/FlowMeterDewa/FlowMeterCfgCtrl.cs @@ -44,7 +44,7 @@ namespace TBF.BenchControl.Elde.FlowMeterDewa { foreach (var cmpnt in parent.TbfComponents) { - if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.ControlBoardFactory) + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.ControlBoardFactory) { parentNameComboBox.Items.Add(cmpnt.Name); } diff --git a/TBF/BenchControl/Elde/FlowMeterTriplet/FlowMeter.cs b/TBF/BenchControl/Elde/FlowMeterTriplet/FlowMeter.cs index 2bd20bf21..f3f2af9be 100644 --- a/TBF/BenchControl/Elde/FlowMeterTriplet/FlowMeter.cs +++ b/TBF/BenchControl/Elde/FlowMeterTriplet/FlowMeter.cs @@ -1,9 +1,10 @@ /// -/// Copyright (c) 2017-2019 Sensus Slovensko a.s. +/// Copyright (c) 2017-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.Boxes; namespace TBF.BenchControl.Elde.FlowMeterTriplet @@ -46,8 +47,8 @@ namespace TBF.BenchControl.Elde.FlowMeterTriplet log.Debug(this.ToString()); } - public double ReadFlow() { return controlBoard.ReferenceFlow; } - public double ReadFrequency() { return controlBoard.ReferenceFreq; } + public double ReadFlow() { return controlBoard.RefFlow; } + public double ReadFrequency() { return controlBoard.RefFrequency; } /// /// Events: FlowDone, Error diff --git a/TBF/BenchControl/Elde/FlowMeterTriplet/FlowMeterCfgCtrl.cs b/TBF/BenchControl/Elde/FlowMeterTriplet/FlowMeterCfgCtrl.cs index 8075b6a16..cf17cbae7 100644 --- a/TBF/BenchControl/Elde/FlowMeterTriplet/FlowMeterCfgCtrl.cs +++ b/TBF/BenchControl/Elde/FlowMeterTriplet/FlowMeterCfgCtrl.cs @@ -39,7 +39,7 @@ namespace TBF.BenchControl.Elde.FlowMeterTriplet { foreach (var cmpnt in parent.TbfComponents) { - if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.ControlBoardFactory) + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.ControlBoardFactory) { parentNameComboBox.Items.Add(cmpnt.Name); } diff --git a/TBF/BenchControl/Elde/FlowMeterTwins/FlowMeter.cs b/TBF/BenchControl/Elde/FlowMeterTwins/FlowMeter.cs index 963a9d1ec..41c4c6ab7 100644 --- a/TBF/BenchControl/Elde/FlowMeterTwins/FlowMeter.cs +++ b/TBF/BenchControl/Elde/FlowMeterTwins/FlowMeter.cs @@ -1,10 +1,11 @@ /// -/// Copyright (c) 2013-2019 Sensus Slovensko a.s. +/// Copyright (c) 2013-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; using TBF.BenchControl; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.Boxes; namespace TBF.BenchControl.Elde.FlowMeterTwins @@ -58,8 +59,8 @@ namespace TBF.BenchControl.Elde.FlowMeterTwins log.Debug(this.ToString()); } - public double ReadFlow() { return controlBoard.ReferenceFlow; } - public double ReadFrequency() { return controlBoard.ReferenceFreq; } + public double ReadFlow() { return controlBoard.RefFlow; } + public double ReadFrequency() { return controlBoard.RefFrequency; } /// /// Events: FlowDone, Error diff --git a/TBF/BenchControl/Elde/FlowMeterTwins/FlowMeterCfgCtrl.cs b/TBF/BenchControl/Elde/FlowMeterTwins/FlowMeterCfgCtrl.cs index ba041c74e..4d628ba52 100644 --- a/TBF/BenchControl/Elde/FlowMeterTwins/FlowMeterCfgCtrl.cs +++ b/TBF/BenchControl/Elde/FlowMeterTwins/FlowMeterCfgCtrl.cs @@ -39,7 +39,7 @@ namespace TBF.BenchControl.Elde.FlowMeterTwins { foreach (var cmpnt in parentDlg.TbfComponents) { - if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.ControlBoardFactory) + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.ControlBoardFactory) { parentNameComboBox.Items.Add(cmpnt.Name); } diff --git a/TBF/BenchControl/Elde/PressureMeter/PressureMeter.cs b/TBF/BenchControl/Elde/PressureMeter/PressureMeter.cs index d6bdf1bde..b127aecfd 100644 --- a/TBF/BenchControl/Elde/PressureMeter/PressureMeter.cs +++ b/TBF/BenchControl/Elde/PressureMeter/PressureMeter.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using log4net; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.BenchControl.Generic; using TBF.Boxes; using TBF.Resources; @@ -86,9 +87,9 @@ namespace TBF.BenchControl.Elde.PressureMeter /// - /// Returns the water pressure + /// Returns the water pressure and convert from kPa to default units /// - /// Pressure in mBar + /// Pressure public float ReadPressure() { double rawPressure = Config.Units.ConvertFrom(Config.Unit.kPa, ControlBoard.Pressure(Idx0)); diff --git a/TBF/BenchControl/Elde/PressureMeter/PressureMeterCfgCtrl.cs b/TBF/BenchControl/Elde/PressureMeter/PressureMeterCfgCtrl.cs index ce14412c4..384ce4cf9 100644 --- a/TBF/BenchControl/Elde/PressureMeter/PressureMeterCfgCtrl.cs +++ b/TBF/BenchControl/Elde/PressureMeter/PressureMeterCfgCtrl.cs @@ -39,7 +39,7 @@ namespace TBF.BenchControl.Elde.PressureMeter { foreach (var cmpnt in parent.TbfComponents) { - if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.ControlBoardFactory) + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.ControlBoardFactory) { parentNameComboBox.Items.Add(cmpnt.Name); } diff --git a/TBF/BenchControl/Elde/PressureMeterInternal/PressureMeter.cs b/TBF/BenchControl/Elde/PressureMeterInternal/PressureMeter.cs index e4eb21a72..c7510c82f 100644 --- a/TBF/BenchControl/Elde/PressureMeterInternal/PressureMeter.cs +++ b/TBF/BenchControl/Elde/PressureMeterInternal/PressureMeter.cs @@ -1,11 +1,10 @@ /// -/// Copyright (c) 2015 Sensus Metering Systems -/// Author: Milan Hanajik +/// Copyright (c) 2015-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; -using TBF.BenchControl.Generic; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.Boxes; using TBF.Resources; @@ -78,6 +77,18 @@ namespace TBF.BenchControl.Elde.PressureMeterInternal } + /// + /// Returns the water pressure and convert from kPa to default units + /// + /// Pressure + public float ReadPressure() + { + double rawPressure = Config.Units.ConvertFrom(Config.Unit.kPa, ControlBoard.Pressure(Idx0)); + double correctedPressure = Config.Formulas.CorrectedValue(rawPressure, Corrections); + return (float)correctedPressure; + } + + /// /// Events: PressureDone, Error /// diff --git a/TBF/BenchControl/Elde/PressureMeterInternal/PressureMeterCfgCtrl.cs b/TBF/BenchControl/Elde/PressureMeterInternal/PressureMeterCfgCtrl.cs index 53833a471..afa0370c6 100644 --- a/TBF/BenchControl/Elde/PressureMeterInternal/PressureMeterCfgCtrl.cs +++ b/TBF/BenchControl/Elde/PressureMeterInternal/PressureMeterCfgCtrl.cs @@ -39,7 +39,7 @@ namespace TBF.BenchControl.Elde.PressureMeterInternal { foreach (var cmpnt in parent.TbfComponents) { - if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.ControlBoardFactory) + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.ControlBoardFactory) { parentNameComboBox.Items.Add(cmpnt.Name); } diff --git a/TBF/BenchControl/Elde/PressureMeterInternal/ReadPressureOp.cs b/TBF/BenchControl/Elde/PressureMeterInternal/ReadPressureOp.cs index 38440bd2e..6f4cd1b90 100644 --- a/TBF/BenchControl/Elde/PressureMeterInternal/ReadPressureOp.cs +++ b/TBF/BenchControl/Elde/PressureMeterInternal/ReadPressureOp.cs @@ -1,6 +1,5 @@ /// -/// Copyright (c) 2015 Sensus Metering Systems -/// Author: Milan Hanajik +/// Copyright (c) 2015-2020 Sensus Slovensko a.s. /// using System; using log4net; @@ -11,27 +10,25 @@ namespace TBF.BenchControl.Elde.PressureMeterInternal public class ReadPressureOp : IOperation { private static readonly ILog log = LogManager.GetLogger(typeof(ReadPressureOp)); - public override string ToString() { return string.Format("ReadPressureOp(.,{0},{1},.)", eventDone, pressureMeterNr); } + public override string ToString() { return string.Format("ReadPressureOp()"); } /// Set by the constructor - readonly ControlBoardDev controlBoardDev; - readonly int pressureMeterNr; + readonly PressureMeter pressureMeter; readonly Event eventDone; - FloatBox pressure; + FloatBox pressureBox; /// /// Events: PressureInDone, PressureOutDone or Error /// /// Pressure meter reference - /// Reference to the measured pressure variable, value is in bar + /// Reference to the measured pressure variable, value is in bar /// Event to be returned by Run() when completed OK - public ReadPressureOp(PressureMeter pressureMeter, ref FloatBox pressure, Event eventDone) + public ReadPressureOp(PressureMeter pressureMeter, ref FloatBox pressureBox, Event eventDone) { if (pressureMeter == null) throw new ArgumentNullException("pressureMeter"); - this.controlBoardDev = pressureMeter.ControlBoard; - this.pressureMeterNr = pressureMeter.Idx0; - this.eventDone = eventDone; - this.pressure = pressure; + this.pressureMeter = pressureMeter; + this.pressureBox = pressureBox; + this.eventDone = eventDone; log.Debug(this.ToString()); } @@ -43,7 +40,7 @@ namespace TBF.BenchControl.Elde.PressureMeterInternal /// Start this operation public void Start() { - pressure.Val = 0.01F * controlBoardDev.Pressure(pressureMeterNr); /// converted from [kPa] to [bar] + pressureBox.Val = pressureMeter.ReadPressure(); } /// Run this operation @@ -52,7 +49,7 @@ namespace TBF.BenchControl.Elde.PressureMeterInternal /// public Event Run() { - pressure.Val = 0.01F * controlBoardDev.Pressure(pressureMeterNr); /// converted from [kPa] to [bar] + pressureBox.Val = pressureMeter.ReadPressure(); return eventDone; } diff --git a/TBF/BenchControl/Elde/PumpWithFM/Pump.cs b/TBF/BenchControl/Elde/PumpWithFM/Pump.cs index 0ef0439fd..dfeebe464 100644 --- a/TBF/BenchControl/Elde/PumpWithFM/Pump.cs +++ b/TBF/BenchControl/Elde/PumpWithFM/Pump.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using Dirichlet.Numerics; using log4net; +using TBF.BenchControl.ControlBoard.Legacy; namespace TBF.BenchControl.Elde.PumpWithFM { diff --git a/TBF/BenchControl/Elde/PumpWithFM/PumpCfgCtrl.cs b/TBF/BenchControl/Elde/PumpWithFM/PumpCfgCtrl.cs index 493de0b78..86cb8fff7 100644 --- a/TBF/BenchControl/Elde/PumpWithFM/PumpCfgCtrl.cs +++ b/TBF/BenchControl/Elde/PumpWithFM/PumpCfgCtrl.cs @@ -39,7 +39,7 @@ namespace TBF.BenchControl.Elde.PumpWithFM { foreach (var cmpnt in parent.TbfComponents) { - if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.ControlBoardFactory) + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.ControlBoardFactory) { parentNameComboBox.Items.Add(cmpnt.Name); } diff --git a/TBF/BenchControl/Elde/RegisterReader/RegisterReader.cs b/TBF/BenchControl/Elde/RegisterReader/RegisterReader.cs index 1af04f3f7..afe480e7d 100644 --- a/TBF/BenchControl/Elde/RegisterReader/RegisterReader.cs +++ b/TBF/BenchControl/Elde/RegisterReader/RegisterReader.cs @@ -1,9 +1,10 @@ /// -/// Copyright (c) 2013-2018 Sensus Slovensko a.s. +/// Copyright (c) 2013-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.Boxes; namespace TBF.BenchControl.Elde.RegisterReader @@ -15,8 +16,8 @@ namespace TBF.BenchControl.Elde.RegisterReader readonly RegisterReaderCfg registerReaderCfg; - public int Position { get { return registerReaderCfg.Position; } } /// 1 .. inf - /// + public int Position { get { return registerReaderCfg.Position; } } /// 1 .. Config.Data.WMsCount + public Config.Entities.RegisterReaderType RegisterReaderType { get { return Config.Entities.RegisterReaderType.Pulses; } } public double PulsesPerLtr { get { return registerReaderCfg.ProcParams.PulsesPerLtr; } } public double LtrsPerPulse { get { return (PulsesPerLtr <= float.Epsilon) ? 1.0 : (1 / PulsesPerLtr); ; } } @@ -29,14 +30,12 @@ namespace TBF.BenchControl.Elde.RegisterReader public double BeginWMState { get { return 0; } } /// Always 0 public double EndWMState { get { return WMVolume; } } /// Derived from WMVolume + int wmPulses; int wmRefPulses; - /// This is to cope with counter overflow - int lastPulses; - bool lastPulsesValid; - readonly ControlBoardDev controlBoard; + readonly TBF.BenchControl.ControlBoard.IControlBoard controlBoard; public RegisterReader() @@ -48,30 +47,14 @@ namespace TBF.BenchControl.Elde.RegisterReader { registerReaderCfg = cfg as RegisterReaderCfg; - controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components); + controlBoard = TbfComponents.FindComponent(cfg.ParentName, components) as TBF.BenchControl.ControlBoard.IControlBoard; if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent"); - Clear(); - /// Prepare data for SendCalibData() control board component method log.Debug(this.ToString()); } - public void Clear() - { - log.DebugFormat("{0}:Clear()", Name); - wmPulses = 0; - wmRefPulses = 0; - lastPulsesValid = false; - } - - public void TestCompleted() - { - log.DebugFormat("{0}:TestCompleted()", Name); - ReadPulses(); - } - /// /// Events: Event.ReadRegisterDone, Event.Error /// @@ -83,40 +66,13 @@ namespace TBF.BenchControl.Elde.RegisterReader private void ReadPulses() { - log.DebugFormat("{0}:ReadPulses() started, lastPulses={1}, lastPulsesValid={2}", Name, lastPulses, lastPulsesValid); - if (!lastPulsesValid) - { - lastPulses = (int)controlBoard.WMeterPulses(Position); - lastPulsesValid = true; - } - else - { - UInt16 lowerWord = controlBoard.WMeterPulses(Position); - int uncorrected = (int)(((uint)lastPulses & 0xFFFF0000) | lowerWord); - if (Math.Abs(uncorrected - lastPulses) <= Int16.MaxValue) - { - lastPulses = uncorrected; - } - else if (Math.Abs(uncorrected + 65536 - lastPulses) <= Int16.MaxValue) - { - lastPulses = uncorrected + 65536; - } - else if (Math.Abs(uncorrected - 65536 - lastPulses) <= Int16.MaxValue) - { - lastPulses = uncorrected - 65536; - } - } - - wmPulses = lastPulses; - wmRefPulses = (int)controlBoard.EtPulses(Position); - - log.DebugFormat("{0}:ReadPulses() completed, wmPulses={1} wmRefPulses={2}", Name, wmPulses, wmRefPulses); + wmPulses = controlBoard.PulsesWM(Position); + wmRefPulses = controlBoard.RefPulsesWM(Position); } /// Start this operation public void Start() { - lastPulsesValid = false; ReadPulses(); } diff --git a/TBF/BenchControl/Elde/RegisterReader/RegisterReaderCfgCtrl.cs b/TBF/BenchControl/Elde/RegisterReader/RegisterReaderCfgCtrl.cs index 30feff706..5f1a1e2de 100644 --- a/TBF/BenchControl/Elde/RegisterReader/RegisterReaderCfgCtrl.cs +++ b/TBF/BenchControl/Elde/RegisterReader/RegisterReaderCfgCtrl.cs @@ -39,7 +39,7 @@ namespace TBF.BenchControl.Elde.RegisterReader { foreach (var cmpnt in parent.TbfComponents) { - if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.ControlBoardFactory) + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.ControlBoardFactory) { parentNameComboBox.Items.Add(cmpnt.Name); } diff --git a/TBF/BenchControl/Elde/RegulValve/ChangeValvePositionOp.cs b/TBF/BenchControl/Elde/RegulValve/ChangeValvePositionOp.cs index 706704197..9f95ffa66 100644 --- a/TBF/BenchControl/Elde/RegulValve/ChangeValvePositionOp.cs +++ b/TBF/BenchControl/Elde/RegulValve/ChangeValvePositionOp.cs @@ -17,7 +17,7 @@ namespace TBF.BenchControl.Elde.RegulValve } /// Set by the constructor - readonly ControlBoardDev controlBoard; + readonly TBF.BenchControl.ControlBoard.Legacy.ControlBoardDev controlBoard; readonly RegulValve regulValve; readonly int regulValveNr; readonly float timePulseSec; @@ -26,18 +26,18 @@ namespace TBF.BenchControl.Elde.RegulValve /// Set required water flow. /// Events: FlowSet, FlowTimeOut /// - /// Control board device - /// Regulation valve component + /// Control board device + /// Regulation valve component /// Lower limit of the position to be achieved /// Upper limit of the position to be achieved /// Timeout in sec. for setting the flow /// Only Elde.Valve flow are used, other flow on the lists are ignored - public ChangeRegulValvePositionOp(ControlBoardDev controlBoard, RegulValve _regulValve, float timePulseSec) + public ChangeRegulValvePositionOp(TBF.BenchControl.ControlBoard.IControlBoard cb, RegulValve rv, float timePulseSec) { - if (controlBoard == null) throw new ArgumentNullException("ctrlBoard"); - this.controlBoard = controlBoard; + controlBoard = cb as TBF.BenchControl.ControlBoard.Legacy.ControlBoardDev; + if (controlBoard == null) throw new ArgumentNullException("ctrlBoard"); - regulValve = _regulValve as RegulValve; + regulValve = rv as RegulValve; if (regulValve == null) throw new ArgumentNullException("regValve is null or not Elde"); regulValveNr = this.regulValve.Idx1; @@ -53,7 +53,7 @@ namespace TBF.BenchControl.Elde.RegulValve log.WarnFormat("RV#={0}, actPos={1}%", regulValveNr, positionPct.ToString("F1")); controlBoard.ValveMove(regulValveNr, - RegulValveMode.PulseWidth, + TBF.BenchControl.ControlBoard.Legacy.RegulValveMode.PulseWidth, new float[2] { timePulseSec, timePulseSec }, regulValve.StableTime); } diff --git a/TBF/BenchControl/Elde/RegulValve/RegulValve.cs b/TBF/BenchControl/Elde/RegulValve/RegulValve.cs index 7bfb62cfd..b49af7ca2 100644 --- a/TBF/BenchControl/Elde/RegulValve/RegulValve.cs +++ b/TBF/BenchControl/Elde/RegulValve/RegulValve.cs @@ -1,9 +1,10 @@ /// -/// Copyright (c) 2013-2019 Sensus Slovensko a.s. +/// Copyright (c) 2013-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.BenchControl.Generic; using TBF.Boxes; diff --git a/TBF/BenchControl/Elde/RegulValve/RegulValveCfgCtrl.cs b/TBF/BenchControl/Elde/RegulValve/RegulValveCfgCtrl.cs index a98dd2222..b397733f7 100644 --- a/TBF/BenchControl/Elde/RegulValve/RegulValveCfgCtrl.cs +++ b/TBF/BenchControl/Elde/RegulValve/RegulValveCfgCtrl.cs @@ -42,7 +42,7 @@ namespace TBF.BenchControl.Elde.RegulValve { foreach (var cmpnt in parent.TbfComponents) { - if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.ControlBoardFactory) + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.ControlBoardFactory) { parentNameComboBox.Items.Add(cmpnt.Name); } diff --git a/TBF/BenchControl/Elde/RegulValve/SetFlowOp.cs b/TBF/BenchControl/Elde/RegulValve/SetFlowOp.cs index 3ebfbbf66..929c88c14 100644 --- a/TBF/BenchControl/Elde/RegulValve/SetFlowOp.cs +++ b/TBF/BenchControl/Elde/RegulValve/SetFlowOp.cs @@ -1,9 +1,10 @@ /// -/// Copyright (c) 2013-2017 Sensus Metering Systems +/// Copyright (c) 2013-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.BenchControl.GenericDevices; using TBF.Boxes; diff --git a/TBF/BenchControl/Elde/RegulValve/SetRegulValvePositionOp.cs b/TBF/BenchControl/Elde/RegulValve/SetRegulValvePositionOp.cs index d4add434a..e524e3228 100644 --- a/TBF/BenchControl/Elde/RegulValve/SetRegulValvePositionOp.cs +++ b/TBF/BenchControl/Elde/RegulValve/SetRegulValvePositionOp.cs @@ -1,9 +1,10 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.BenchControl.GenericDevices; namespace TBF.BenchControl.Elde.RegulValve diff --git a/TBF/BenchControl/Elde/RegulValveCoax/ChangeValvePositionOp.cs b/TBF/BenchControl/Elde/RegulValveCoax/ChangeValvePositionOp.cs index 95d46b5ca..5163f650a 100644 --- a/TBF/BenchControl/Elde/RegulValveCoax/ChangeValvePositionOp.cs +++ b/TBF/BenchControl/Elde/RegulValveCoax/ChangeValvePositionOp.cs @@ -1,9 +1,10 @@ /// -/// Copyright (c) 2017 Sensus Metering Systems +/// Copyright (c) 2017-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.BenchControl.GenericDevices; namespace TBF.BenchControl.Elde.RegulValveCoax diff --git a/TBF/BenchControl/Elde/RegulValveCoax/RegulValve.cs b/TBF/BenchControl/Elde/RegulValveCoax/RegulValve.cs index 8c159faab..b784c61a9 100644 --- a/TBF/BenchControl/Elde/RegulValveCoax/RegulValve.cs +++ b/TBF/BenchControl/Elde/RegulValveCoax/RegulValve.cs @@ -1,9 +1,10 @@ /// -/// Copyright (c) 2017 Sensus Metering Systems +/// Copyright (c) 2017-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.Boxes; namespace TBF.BenchControl.Elde.RegulValveCoax diff --git a/TBF/BenchControl/Elde/RegulValveCoax/RegulValveCfgCtrl.cs b/TBF/BenchControl/Elde/RegulValveCoax/RegulValveCfgCtrl.cs index 1e47bc3c8..f0376c6d0 100644 --- a/TBF/BenchControl/Elde/RegulValveCoax/RegulValveCfgCtrl.cs +++ b/TBF/BenchControl/Elde/RegulValveCoax/RegulValveCfgCtrl.cs @@ -39,7 +39,7 @@ namespace TBF.BenchControl.Elde.RegulValveCoax { foreach (var cmpnt in parent.TbfComponents) { - if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.ControlBoardFactory) + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.ControlBoardFactory) { parentNameComboBox.Items.Add(cmpnt.Name); } diff --git a/TBF/BenchControl/Elde/RegulValveCoax/SetFlowOp.cs b/TBF/BenchControl/Elde/RegulValveCoax/SetFlowOp.cs index aa4697be5..84bdd2414 100644 --- a/TBF/BenchControl/Elde/RegulValveCoax/SetFlowOp.cs +++ b/TBF/BenchControl/Elde/RegulValveCoax/SetFlowOp.cs @@ -1,9 +1,10 @@ /// -/// Copyright (c) 2017-2018 Sensus Slovensko a.s. +/// Copyright (c) 2017-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.BenchControl.GenericDevices; using TBF.Boxes; @@ -172,7 +173,7 @@ namespace TBF.BenchControl.Elde.RegulValveCoax /// Start this operation public void Start() { - double flowMtrFreq = controlBoard.ReferenceFreq; + double flowMtrFreq = controlBoard.RefFrequency; currentReqFlowLo = reqFlowAve; currentReqFlowHi = reqFlowAve; /// @@ -209,7 +210,7 @@ namespace TBF.BenchControl.Elde.RegulValveCoax expireTime = StateMachine.Time + timeout; if (expireTime < 0) expireTime = int.MaxValue; - TestMethods tm = 0; + ControlBoard.Legacy.TestMethods tm = 0; StopDevs sd = 0; // '_regulValve.RegulValveCfg.PidCoef' replaced by a casted operation parameter 'pidCoef' controlBoard.SendCommand(Command.Start, flowMeterNr, int.MaxValue, int.MaxValue, tm, sd); @@ -222,7 +223,7 @@ namespace TBF.BenchControl.Elde.RegulValveCoax public Event Run() { float rvPosition = controlBoard.RValvePosition(regulValveNr); - double flowMtrFreq = controlBoard.ReferenceFreq; + double flowMtrFreq = controlBoard.RefFrequency; double flow = flowMtrFreq * nominalFlow / 2000.0; if (flowMtrFreq != 0) @@ -258,8 +259,8 @@ namespace TBF.BenchControl.Elde.RegulValveCoax expireTime = StateMachine.Time + timeout; if (expireTime < 0) expireTime = int.MaxValue; - TestMethods tm = 0; - StopDevs sd = 0; + ControlBoard.Legacy.TestMethods tm = 0; + StopDevs sd = 0; // '_regulValve.RegulValveCfg.PidCoef' replaced by a casted operation parameter 'pidCoef' controlBoard.SendCommand(Command.Start, flowMeterNr, int.MaxValue, int.MaxValue, tm, sd); log.DebugFormat(" return Event.None"); @@ -475,7 +476,7 @@ namespace TBF.BenchControl.Elde.RegulValveCoax if (leaveMeasurementRunning) return; /// Stop measurement - TestMethods tm = 0; + ControlBoard.Legacy.TestMethods tm = 0; StopDevs sd = StopDevs.RegValveRegulation; controlBoard.SendCommand(Command.Stop, flowMeterNr, 50000, 50000, tm, sd); diff --git a/TBF/BenchControl/Elde/RegulValveCoax/SetRegulValvePositionOp.cs b/TBF/BenchControl/Elde/RegulValveCoax/SetRegulValvePositionOp.cs index cc482019b..4cd7c7db7 100644 --- a/TBF/BenchControl/Elde/RegulValveCoax/SetRegulValvePositionOp.cs +++ b/TBF/BenchControl/Elde/RegulValveCoax/SetRegulValvePositionOp.cs @@ -1,9 +1,10 @@ /// -/// Copyright (c) 2017 Sensus Metering Systems +/// Copyright (c) 2017-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.BenchControl.GenericDevices; namespace TBF.BenchControl.Elde.RegulValveCoax diff --git a/TBF/BenchControl/Elde/RegulValveTandem/ChangeValvePositionOp.cs b/TBF/BenchControl/Elde/RegulValveTandem/ChangeValvePositionOp.cs index 954809a3b..51a866e1e 100644 --- a/TBF/BenchControl/Elde/RegulValveTandem/ChangeValvePositionOp.cs +++ b/TBF/BenchControl/Elde/RegulValveTandem/ChangeValvePositionOp.cs @@ -1,9 +1,10 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.BenchControl.GenericDevices; namespace TBF.BenchControl.Elde.RegulValveTandem diff --git a/TBF/BenchControl/Elde/RegulValveTandem/RegulValveTandem.cs b/TBF/BenchControl/Elde/RegulValveTandem/RegulValveTandem.cs index eb9f194a0..559fdddf6 100644 --- a/TBF/BenchControl/Elde/RegulValveTandem/RegulValveTandem.cs +++ b/TBF/BenchControl/Elde/RegulValveTandem/RegulValveTandem.cs @@ -1,9 +1,10 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.BenchControl.Generic; using TBF.Boxes; diff --git a/TBF/BenchControl/Elde/RegulValveTandem/SetFlowOp.cs b/TBF/BenchControl/Elde/RegulValveTandem/SetFlowOp.cs index 74e06de08..b0ee334e9 100644 --- a/TBF/BenchControl/Elde/RegulValveTandem/SetFlowOp.cs +++ b/TBF/BenchControl/Elde/RegulValveTandem/SetFlowOp.cs @@ -1,9 +1,10 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.BenchControl.GenericDevices; using TBF.Boxes; @@ -177,7 +178,7 @@ namespace TBF.BenchControl.Elde.RegulValveTandem /// Start this operation public void Start() { - double flowMtrFreq = controlBoard.ReferenceFreq; + double flowMtrFreq = controlBoard.RefFrequency; currentReqFlowLo = reqFlowAve; currentReqFlowHi = reqFlowAve; /// @@ -214,7 +215,7 @@ namespace TBF.BenchControl.Elde.RegulValveTandem expireTime = StateMachine.Time + timeout; if (expireTime < 0) expireTime = int.MaxValue; - TestMethods tm = 0; + ControlBoard.Legacy.TestMethods tm = 0; StopDevs sd = 0; // '_regulValve.RegulValveTandemCfg.PidCoef' replaced by a casted operation parameter 'pidCoef' controlBoard.SendCommand(Command.Start, flowMeterNr, int.MaxValue, int.MaxValue, tm, sd); @@ -228,7 +229,7 @@ namespace TBF.BenchControl.Elde.RegulValveTandem { float rvPosition = controlBoard.RValvePosition(regulValveNr); float fixedRVPosition = controlBoard.RValvePosition(fixedRVNr); - double flowMtrFreq = controlBoard.ReferenceFreq; + double flowMtrFreq = controlBoard.RefFrequency; double flow = flowMtrFreq * nominalFlow / 2000.0; if (flowMtrFreq != 0) @@ -368,7 +369,7 @@ namespace TBF.BenchControl.Elde.RegulValveTandem if (leaveMeasurementRunning) return; /// Stop measurement - TestMethods tm = 0; + ControlBoard.Legacy.TestMethods tm = 0; StopDevs sd = StopDevs.RegValveRegulation; controlBoard.SendCommand(Command.Stop, flowMeterNr, 50000, 50000, tm, sd); } diff --git a/TBF/BenchControl/Elde/RegulValveTandem/SetRegulValvePositionOp.cs b/TBF/BenchControl/Elde/RegulValveTandem/SetRegulValvePositionOp.cs index 0292c5b68..05c55c0ca 100644 --- a/TBF/BenchControl/Elde/RegulValveTandem/SetRegulValvePositionOp.cs +++ b/TBF/BenchControl/Elde/RegulValveTandem/SetRegulValvePositionOp.cs @@ -1,9 +1,10 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.BenchControl.GenericDevices; namespace TBF.BenchControl.Elde.RegulValveTandem diff --git a/TBF/BenchControl/Elde/TempMeter/TempMeter.cs b/TBF/BenchControl/Elde/TempMeter/TempMeter.cs index 0c4e97db7..81d51cc3a 100644 --- a/TBF/BenchControl/Elde/TempMeter/TempMeter.cs +++ b/TBF/BenchControl/Elde/TempMeter/TempMeter.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using log4net; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.BenchControl.Generic; using TBF.Boxes; using TBF.Resources; diff --git a/TBF/BenchControl/Elde/TempMeter/TempMeterCfgCtrl.cs b/TBF/BenchControl/Elde/TempMeter/TempMeterCfgCtrl.cs index e683b4260..53963793a 100644 --- a/TBF/BenchControl/Elde/TempMeter/TempMeterCfgCtrl.cs +++ b/TBF/BenchControl/Elde/TempMeter/TempMeterCfgCtrl.cs @@ -42,7 +42,7 @@ namespace TBF.BenchControl.Elde.TempMeter { foreach (var cmpnt in parent.TbfComponents) { - if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.ControlBoardFactory) + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.ControlBoardFactory) { parentNameComboBox.Items.Add(cmpnt.Name); } diff --git a/TBF/BenchControl/Elde/TempMeterInternal/TempMeter.cs b/TBF/BenchControl/Elde/TempMeterInternal/TempMeter.cs index 8c03e0826..c9e585c1e 100644 --- a/TBF/BenchControl/Elde/TempMeterInternal/TempMeter.cs +++ b/TBF/BenchControl/Elde/TempMeterInternal/TempMeter.cs @@ -1,9 +1,10 @@ /// -/// Copyright (c) 2015 Sensus Metering Systems +/// Copyright (c) 2015-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.BenchControl.Generic; using TBF.Boxes; using TBF.Resources; diff --git a/TBF/BenchControl/Elde/TempMeterInternal/TempMeterCfgCtrl.cs b/TBF/BenchControl/Elde/TempMeterInternal/TempMeterCfgCtrl.cs index bd5fcefa7..8405eecfb 100644 --- a/TBF/BenchControl/Elde/TempMeterInternal/TempMeterCfgCtrl.cs +++ b/TBF/BenchControl/Elde/TempMeterInternal/TempMeterCfgCtrl.cs @@ -39,7 +39,7 @@ namespace TBF.BenchControl.Elde.TempMeterInternal { foreach (var cmpnt in parent.TbfComponents) { - if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.ControlBoardFactory) + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.ControlBoardFactory) { parentNameComboBox.Items.Add(cmpnt.Name); } diff --git a/TBF/BenchControl/Elde/TempMeterMeret/TempMeter.cs b/TBF/BenchControl/Elde/TempMeterMeret/TempMeter.cs index 96399347b..52033d275 100644 --- a/TBF/BenchControl/Elde/TempMeterMeret/TempMeter.cs +++ b/TBF/BenchControl/Elde/TempMeterMeret/TempMeter.cs @@ -1,9 +1,10 @@ /// -/// Copyright (c) 2018 Sensus Slovensko a.s. +/// Copyright (c) 2018-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; +using TBF.BenchControl.ControlBoard.Legacy; using TBF.Boxes; using TBF.Resources; @@ -25,7 +26,7 @@ namespace TBF.BenchControl.Elde.TempMeterMeret { tempMtrCfg = cfg as TempMeterCfg; - ControlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components); + ControlBoard = TbfComponents.FindComponent(cfg.ParentName, components) as ControlBoardDev; if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent"); /// Prepare data for SendCalibData() control board component method diff --git a/TBF/BenchControl/GenericDevices/IRegisterReader.cs b/TBF/BenchControl/GenericDevices/IRegisterReader.cs index 51778e675..67005c085 100644 --- a/TBF/BenchControl/GenericDevices/IRegisterReader.cs +++ b/TBF/BenchControl/GenericDevices/IRegisterReader.cs @@ -21,11 +21,6 @@ namespace TBF.BenchControl.GenericDevices double BeginWMState { get; } /// Test begin state of the water meter double EndWMState { get; } /// Test end state of the water meter - void Clear(); /// To be used at the beginning of a test - - void TestCompleted(); /// To be used when the test is completed ... - /// ... for more accurate WMPulses, WMRefPulses calculation - IOperation ReadRegisterOp(); } } diff --git a/TBF/BenchControl/GenericDevices/ITestMethod.cs b/TBF/BenchControl/GenericDevices/ITestMethod.cs index e99556bf9..394413212 100644 --- a/TBF/BenchControl/GenericDevices/ITestMethod.cs +++ b/TBF/BenchControl/GenericDevices/ITestMethod.cs @@ -16,6 +16,13 @@ namespace TBF.BenchControl.GenericDevices /// true when the watermeters can be tested by this method bool CanTest(MetersKind meters); + /// + /// Check capabilities of devces in the output path required for this test method + /// + /// Devices + /// true when capabilities of devices are OK + bool CheckDeviceCaps(Test test, OutputPath devices, out string message); + /// /// Return true when test method requires start/end test transition execution /// diff --git a/TBF/BenchControl/GenericDevices/IValveControl.cs b/TBF/BenchControl/GenericDevices/IValveControl.cs index 4a15b5171..026ca0f77 100644 --- a/TBF/BenchControl/GenericDevices/IValveControl.cs +++ b/TBF/BenchControl/GenericDevices/IValveControl.cs @@ -2,14 +2,24 @@ /// Copyright (c) 2013-2015 Sensus Metering Systems /// using System.Collections.Generic; +using Dirichlet.Numerics; namespace TBF.BenchControl.GenericDevices { public interface IValveControl { /// - /// Open one valve and/or close one valve. - /// Events: RouteDone, Error + /// + /// + /// Valves to be opened as a bit field + /// Valves to be closed as a bit field + /// List of extended valves + /// + UInt128 SetValves(UInt128 valvesToOpen, UInt128 valvesToClose, IList extendedValves); + + /// + /// Open/close one valve. + /// Events: ValvesSet, ValvesBusy, Error /// /// Valve to be opened /// Valve to be closed @@ -17,12 +27,26 @@ namespace TBF.BenchControl.GenericDevices IOperation SetValvesOp(IValve valveToOpen, IValve valveToClose); /// - /// Open and/or close multiple valves. - /// Events: RouteDone, Error - /// + /// Open/close multiple valves. + /// Events: ValvesSet, ValvesBusy, Error + /// /// A list of valves to be opened /// A list of valves to be closed /// Newly created operation instance reference casted to IOperaton IOperation SetValvesOp(IList valvesToOpen, IList valvesToClose); + + /// + /// Open start/stop valve. + /// Events: ValvesSet, ValvesBusy, Error + /// + /// Created operation + IOperation OpenStartValveOp(); + + /// + /// Close start/stop valve. + /// Events: ValvesSet, ValvesBusy, Error + /// + /// Created operation + IOperation CloseStartValveOp(); } } diff --git a/TBF/BenchControl/MettlerToledo/Multi/BalanceCfgCtrl.cs b/TBF/BenchControl/MettlerToledo/Multi/BalanceCfgCtrl.cs index 8697f25f3..fb7ff1da2 100644 --- a/TBF/BenchControl/MettlerToledo/Multi/BalanceCfgCtrl.cs +++ b/TBF/BenchControl/MettlerToledo/Multi/BalanceCfgCtrl.cs @@ -102,7 +102,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi drainValveComboBox.Items.Add("---"); foreach (var cmpnt in parent.TbfComponents) { - if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.Valve.ValveFactory) + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is BuiltIn.Valve.ValveFactory) { drainValveComboBox.Items.Add(cmpnt.Name); } diff --git a/TBF/BenchControl/MettlerToledo/Multi/BalanceDev.cs b/TBF/BenchControl/MettlerToledo/Multi/BalanceDev.cs index d78a7e144..6e12e3ad7 100644 --- a/TBF/BenchControl/MettlerToledo/Multi/BalanceDev.cs +++ b/TBF/BenchControl/MettlerToledo/Multi/BalanceDev.cs @@ -197,7 +197,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi { if (balanceCfg.DebugLevel == DebugMode.Simulate) { - Masses[balanceNr] = TestBenchSim.GetSimMass(balanceNr); + Masses[balanceNr] = 123.456; msrmntState = MsrmntState.Valid; msrmntTimeStamp = StateMachine.Time; return; diff --git a/TBF/BenchControl/MettlerToledo/Standard/BalanceCfgCtrl.cs b/TBF/BenchControl/MettlerToledo/Standard/BalanceCfgCtrl.cs index 7b131f80d..c5869ad3a 100644 --- a/TBF/BenchControl/MettlerToledo/Standard/BalanceCfgCtrl.cs +++ b/TBF/BenchControl/MettlerToledo/Standard/BalanceCfgCtrl.cs @@ -104,7 +104,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard drainValveComboBox.Items.Add("---"); foreach (var cmpnt in parent.TbfComponents) { - if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.Valve.ValveFactory) + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is BuiltIn.Valve.ValveFactory) { drainValveComboBox.Items.Add(cmpnt.Name); } diff --git a/TBF/BenchControl/MettlerToledo/Standard/BalanceDev.cs b/TBF/BenchControl/MettlerToledo/Standard/BalanceDev.cs index 260b1079a..e21654bfb 100644 --- a/TBF/BenchControl/MettlerToledo/Standard/BalanceDev.cs +++ b/TBF/BenchControl/MettlerToledo/Standard/BalanceDev.cs @@ -297,7 +297,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard if (balanceCfg.DebugLevel == DebugMode.Simulate) { - Masses[balanceNr] = TestBenchSim.GetSimMass(balanceNr); + Masses[balanceNr] = 123.456; msrmntState = MsrmntState.Valid; msrmntTimeStamp = StateMachine.Time; return; diff --git a/TBF/BenchControl/MettlerToledo/Standard/BalanceNewDev.cs b/TBF/BenchControl/MettlerToledo/Standard/BalanceNewDev.cs index 9ecd0baef..3d38fee09 100644 --- a/TBF/BenchControl/MettlerToledo/Standard/BalanceNewDev.cs +++ b/TBF/BenchControl/MettlerToledo/Standard/BalanceNewDev.cs @@ -67,7 +67,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard if (balanceCfg.DebugLevel == DebugMode.Simulate) { - mass = TestBenchSim.GetSimMass(balanceNr); + mass = 123.456; Masses[balanceNr] = mass; serialNumber = "1234567890"; msrmntState = MsrmntState.Valid; diff --git a/TBF/BenchControl/MettlerToledo/Standard/BalanceOld.cs b/TBF/BenchControl/MettlerToledo/Standard/BalanceOld.cs index 91e9d427a..48987ce78 100644 --- a/TBF/BenchControl/MettlerToledo/Standard/BalanceOld.cs +++ b/TBF/BenchControl/MettlerToledo/Standard/BalanceOld.cs @@ -65,7 +65,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard if (balanceCfg.DebugLevel == DebugMode.Simulate) { - mass = TestBenchSim.GetSimMass(balanceNr); + mass = 123.456; Masses[balanceNr] = mass; msrmntState = MsrmntState.Valid; msrmntTimeStamp = StateMachine.Time; diff --git a/TBF/BenchControl/MettlerToledo/TankDraining.cs b/TBF/BenchControl/MettlerToledo/TankDraining.cs index 85956655e..a5814659d 100644 --- a/TBF/BenchControl/MettlerToledo/TankDraining.cs +++ b/TBF/BenchControl/MettlerToledo/TankDraining.cs @@ -79,8 +79,8 @@ namespace TBF.BenchControl.MettlerToledo if (drainValve == null) throw new Exception(string.Format("{0} is missing a drain valve", Name)); - openTheDrainValveOp = new Elde.SetValvesOp(StateMachine.ControlBoard, drainValve, null); - closeTheDrainValveOp = new Elde.SetValvesOp(StateMachine.ControlBoard, null, drainValve); + openTheDrainValveOp = new BuiltIn.SetValvesOp(StateMachine.ControlBoard, drainValve, null); + closeTheDrainValveOp = new BuiltIn.SetValvesOp(StateMachine.ControlBoard, null, drainValve); waitTankIsEmptyOp = new WaitTankEmptyOp(this); Various.TankWithLevelMsrmnt.TankCfg tankCfg = tankDrainingCfg as Various.TankWithLevelMsrmnt.TankCfg; diff --git a/TBF/BenchControl/Modbus/Easytherm/Easytherm.cs b/TBF/BenchControl/Modbus/Easytherm/Easytherm.cs index 9572bf3dd..eb349a9dd 100644 --- a/TBF/BenchControl/Modbus/Easytherm/Easytherm.cs +++ b/TBF/BenchControl/Modbus/Easytherm/Easytherm.cs @@ -76,7 +76,7 @@ namespace TBF.BenchControl.Modbus.Easytherm if (easythermCfg.ReservoirNr > 0 && easythermCfg.ReservoirNr <= 3) { - StateMachine.ControlBoard.SetReservoirTemp(easythermCfg.ReservoirNr, (float)actualTemperature); + StateMachine.ControlBoard.UpdateUI("ReservoirTemp", easythermCfg.ReservoirNr, actualTemperature); } } } diff --git a/TBF/BenchControl/Modbus/QuidoRS/QuidoRS.cs b/TBF/BenchControl/Modbus/QuidoRS/QuidoRS.cs index f4592e44c..893c80eef 100644 --- a/TBF/BenchControl/Modbus/QuidoRS/QuidoRS.cs +++ b/TBF/BenchControl/Modbus/QuidoRS/QuidoRS.cs @@ -14,7 +14,7 @@ namespace TBF.BenchControl.Modbus.QuidoRS public class QuidoRS : ComponentBase, IDevice, GenericDevices.IParallelOutput { private static readonly ILog log = LogManager.GetLogger(typeof(QuidoRS)); - public override string ToString() { return string.Format("QuidoRS({0})", Cfg.ToString(1)); } + public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(1)); } readonly QuidoRSCfg quidoRSCfg; readonly GenericDevices.IModbus modbus; diff --git a/TBF/BenchControl/Network/Camera/Roi/Roi.cs b/TBF/BenchControl/Network/Camera/Roi/Roi.cs index 76d223e55..a6bc46278 100644 --- a/TBF/BenchControl/Network/Camera/Roi/Roi.cs +++ b/TBF/BenchControl/Network/Camera/Roi/Roi.cs @@ -181,8 +181,6 @@ namespace TBF.BenchControl.Network.Camera.Roi wmRefPulses = 0; } - public void TestCompleted() { } - public IOperation RoiDetectionOp() { @@ -232,7 +230,7 @@ namespace TBF.BenchControl.Network.Camera.Roi cameraPulses = NetCamera.GetResult(roiHandle, out cameraTime); } - wmRefPulses = StateMachine.ControlBoard.EtPulses(0); + wmRefPulses = StateMachine.ControlBoard.RefPulses; } /// diff --git a/TBF/BenchControl/Network/Camera/RoiForFixedStart/Roi.cs b/TBF/BenchControl/Network/Camera/RoiForFixedStart/Roi.cs index 80479e088..ce7a49e1a 100644 --- a/TBF/BenchControl/Network/Camera/RoiForFixedStart/Roi.cs +++ b/TBF/BenchControl/Network/Camera/RoiForFixedStart/Roi.cs @@ -122,15 +122,9 @@ namespace TBF.BenchControl.Network.Camera.RoiForFixedStart wmRefPulses = 0; } - public void TestCompleted() - { - log.DebugFormat("{0}:TestCompleted()", Name); - ReadPulses(); - } - private void ReadPulses() { - wmRefPulses = (int)StateMachine.ControlBoard.EtPulses(0); + wmRefPulses = StateMachine.ControlBoard.RefPulses; } diff --git a/TBF/BenchControl/Operations/ReadMoreRegistersOp.cs b/TBF/BenchControl/Operations/ReadMoreRegistersOp.cs index b915cd588..81ea0ad04 100644 --- a/TBF/BenchControl/Operations/ReadMoreRegistersOp.cs +++ b/TBF/BenchControl/Operations/ReadMoreRegistersOp.cs @@ -42,7 +42,7 @@ namespace TBF.BenchControl.Operations public void Start() { int oriRefPulses = Sequences.ProcessData.RefPulses; - Sequences.ProcessData.RefPulses = StateMachine.ControlBoard.EtPulses(0); + Sequences.ProcessData.RefPulses = StateMachine.ControlBoard.RefPulses; Sequences.ProcessData.RefPulsesDelta = Sequences.ProcessData.RefPulses - oriRefPulses; for (int i = 0; i < readersCount; i++) @@ -58,7 +58,7 @@ namespace TBF.BenchControl.Operations bool anyError = false; int oriRefPulses = Sequences.ProcessData.RefPulses; - Sequences.ProcessData.RefPulses = StateMachine.ControlBoard.EtPulses(0); + Sequences.ProcessData.RefPulses = StateMachine.ControlBoard.RefPulses; Sequences.ProcessData.RefPulsesDelta = Sequences.ProcessData.RefPulses - oriRefPulses; for (int i = 0; i < readersCount; i++) diff --git a/TBF/BenchControl/RegisterReaders/KPackE/RegisterReader/RegisterReader.cs b/TBF/BenchControl/RegisterReaders/KPackE/RegisterReader/RegisterReader.cs index 121b9e890..6033dd2c7 100644 --- a/TBF/BenchControl/RegisterReaders/KPackE/RegisterReader/RegisterReader.cs +++ b/TBF/BenchControl/RegisterReaders/KPackE/RegisterReader/RegisterReader.cs @@ -15,7 +15,7 @@ namespace TBF.BenchControl.RegisterReaders.KPackE.RegisterReader readonly RegisterReaderCfg registerReaderCfg; readonly Radio.Radio radio; - readonly TBF.BenchControl.Elde.ControlBoardDev controlBoard; + readonly TBF.BenchControl.ControlBoard.Legacy.ControlBoardDev controlBoard; public int Position @@ -90,7 +90,8 @@ namespace TBF.BenchControl.RegisterReaders.KPackE.RegisterReader radio = (Radio.Radio)TbfComponents.FindComponent(cfg.ParentName, components); if (radio == null) throw new Exception(string.Format("Cannot find a parent of {0}", Name)); - controlBoard = StateMachine.ControlBoard; + controlBoard = StateMachine.ControlBoard as TBF.BenchControl.ControlBoard.Legacy.ControlBoardDev; + if (controlBoard == null) throw new Exception("Missing ELDE control board"); Clear(); @@ -106,12 +107,6 @@ namespace TBF.BenchControl.RegisterReaders.KPackE.RegisterReader } - public void TestCompleted() - { - log.DebugFormat("{0}:TestCompleted()", Name); - ReadPulses(); - } - /// /// Events: Event.ReadRegisterDone /// @@ -123,7 +118,7 @@ namespace TBF.BenchControl.RegisterReaders.KPackE.RegisterReader private void ReadPulses() { - wmRefPulses = (controlBoard != null) ? controlBoard.EtPulses(0) : 0; + wmRefPulses = (controlBoard != null) ? controlBoard.RefPulses : 0; } /// Start this operation diff --git a/TBF/BenchControl/RegisterReaders/SerialStream/SerialStream.cs b/TBF/BenchControl/RegisterReaders/SerialStream/SerialStream.cs index 68ddb4282..0f9c84dfd 100644 --- a/TBF/BenchControl/RegisterReaders/SerialStream/SerialStream.cs +++ b/TBF/BenchControl/RegisterReaders/SerialStream/SerialStream.cs @@ -304,11 +304,6 @@ namespace TBF.BenchControl.RegisterReaders.SerialStream ReadPulses(); } - public void TestCompleted() - { - /// TODO: Implement - } - int sampleNr; /// This is to determine when the test start sample should be taken @@ -423,7 +418,7 @@ namespace TBF.BenchControl.RegisterReaders.SerialStream endWMState = volumeLtr; wmVolume = Math.Abs(endWMState - beginWMState); wmPulses = (int)(wmVolume * (double)PulsesPerLtr + 0.5); - wmRefPulses = StateMachine.ControlBoard.EtPulses(0); + wmRefPulses = StateMachine.ControlBoard.RefPulses; wmTestTime = timestampSec - timestampSec0; } diff --git a/TBF/BenchControl/Elde/FixedStartRegisterReader/RRProcedureParams.cs b/TBF/BenchControl/RegisterReaders/StandingStartStop/RRProcedureParams.cs similarity index 97% rename from TBF/BenchControl/Elde/FixedStartRegisterReader/RRProcedureParams.cs rename to TBF/BenchControl/RegisterReaders/StandingStartStop/RRProcedureParams.cs index 13bfcfe08..622731573 100644 --- a/TBF/BenchControl/Elde/FixedStartRegisterReader/RRProcedureParams.cs +++ b/TBF/BenchControl/RegisterReaders/StandingStartStop/RRProcedureParams.cs @@ -9,7 +9,7 @@ using Config.Entities; using TBF.BenchControl.Generic; using TBF.Resources; -namespace TBF.BenchControl.Elde.FixedStartRegisterReader +namespace TBF.BenchControl.RegisterReaders.StandingStartStop { public class RRProcedureParams : ProcedureParamsBase, IParamsProvider, IProcedureParams { diff --git a/TBF/BenchControl/Elde/FixedStartRegisterReader/RegisterReader.cs b/TBF/BenchControl/RegisterReaders/StandingStartStop/RegisterReader.cs similarity index 87% rename from TBF/BenchControl/Elde/FixedStartRegisterReader/RegisterReader.cs rename to TBF/BenchControl/RegisterReaders/StandingStartStop/RegisterReader.cs index b205e7765..a5d552449 100644 --- a/TBF/BenchControl/Elde/FixedStartRegisterReader/RegisterReader.cs +++ b/TBF/BenchControl/RegisterReaders/StandingStartStop/RegisterReader.cs @@ -1,12 +1,12 @@ /// -/// Copyright (c) 2013-2016 Sensus Metering Systems +/// Copyright (c) 2013-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using log4net; using TBF.Boxes; -namespace TBF.BenchControl.Elde.FixedStartRegisterReader +namespace TBF.BenchControl.RegisterReaders.StandingStartStop { public class RegisterReader : ComponentBase, GenericDevices.IRegisterReader, IOperation { @@ -14,7 +14,7 @@ namespace TBF.BenchControl.Elde.FixedStartRegisterReader public override string ToString() { return string.Format("FixedStartRegisterReader({0})", Cfg.ToString(1)); } readonly RegisterReaderCfg registerReaderCfg; - readonly ControlBoardDev controlBoard; + readonly ControlBoard.IControlBoard controlBoard; public int Position @@ -64,7 +64,7 @@ namespace TBF.BenchControl.Elde.FixedStartRegisterReader registerReaderCfg = cfg as RegisterReaderCfg; /// Control board is used to read reference flowmeter pulses - controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components); + controlBoard = TbfComponents.FindComponent(cfg.ParentName, components) as ControlBoard.IControlBoard; if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent"); Clear(); @@ -80,13 +80,6 @@ namespace TBF.BenchControl.Elde.FixedStartRegisterReader wmRefPulses = 0; } - - public void TestCompleted() - { - log.DebugFormat("{0}:TestCompleted()", Name); - ReadPulses(); - } - /// /// Events: Event.ReadRegisterDone /// @@ -98,7 +91,7 @@ namespace TBF.BenchControl.Elde.FixedStartRegisterReader private void ReadPulses() { - wmRefPulses = (int)controlBoard.EtPulses(0); + wmRefPulses = controlBoard.RefPulses; } /// Start this operation diff --git a/TBF/BenchControl/Elde/FixedStartRegisterReader/RegisterReaderCfg.cs b/TBF/BenchControl/RegisterReaders/StandingStartStop/RegisterReaderCfg.cs similarity index 95% rename from TBF/BenchControl/Elde/FixedStartRegisterReader/RegisterReaderCfg.cs rename to TBF/BenchControl/RegisterReaders/StandingStartStop/RegisterReaderCfg.cs index c02480ac6..c50869738 100644 --- a/TBF/BenchControl/Elde/FixedStartRegisterReader/RegisterReaderCfg.cs +++ b/TBF/BenchControl/RegisterReaders/StandingStartStop/RegisterReaderCfg.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; using Config.Entities; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Elde.FixedStartRegisterReader +namespace TBF.BenchControl.RegisterReaders.StandingStartStop { public class RegisterReaderCfg : ComponentCfgBase, Generic.IChildComponentCfg { diff --git a/TBF/BenchControl/Elde/FixedStartRegisterReader/RegisterReaderCfgCtrl.Designer.cs b/TBF/BenchControl/RegisterReaders/StandingStartStop/RegisterReaderCfgCtrl.Designer.cs similarity index 98% rename from TBF/BenchControl/Elde/FixedStartRegisterReader/RegisterReaderCfgCtrl.Designer.cs rename to TBF/BenchControl/RegisterReaders/StandingStartStop/RegisterReaderCfgCtrl.Designer.cs index 52c4a378a..50d4d722e 100644 --- a/TBF/BenchControl/Elde/FixedStartRegisterReader/RegisterReaderCfgCtrl.Designer.cs +++ b/TBF/BenchControl/RegisterReaders/StandingStartStop/RegisterReaderCfgCtrl.Designer.cs @@ -1,7 +1,7 @@ /// /// Copyright (c) 2013-2015 Sensus Metering Systems /// -namespace TBF.BenchControl.Elde.FixedStartRegisterReader +namespace TBF.BenchControl.RegisterReaders.StandingStartStop { partial class RegisterReaderCfgCtrl { diff --git a/TBF/BenchControl/Elde/FixedStartRegisterReader/RegisterReaderCfgCtrl.cs b/TBF/BenchControl/RegisterReaders/StandingStartStop/RegisterReaderCfgCtrl.cs similarity index 91% rename from TBF/BenchControl/Elde/FixedStartRegisterReader/RegisterReaderCfgCtrl.cs rename to TBF/BenchControl/RegisterReaders/StandingStartStop/RegisterReaderCfgCtrl.cs index d1160c691..4817deba0 100644 --- a/TBF/BenchControl/Elde/FixedStartRegisterReader/RegisterReaderCfgCtrl.cs +++ b/TBF/BenchControl/RegisterReaders/StandingStartStop/RegisterReaderCfgCtrl.cs @@ -6,7 +6,7 @@ using System.Windows.Forms; using Config.Entities; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Elde.FixedStartRegisterReader +namespace TBF.BenchControl.RegisterReaders.StandingStartStop { public partial class RegisterReaderCfgCtrl : UserControl, IComponentCfgCtrl { @@ -39,7 +39,7 @@ namespace TBF.BenchControl.Elde.FixedStartRegisterReader { foreach (var cmpnt in parent.TbfComponents) { - if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.ControlBoardFactory) + if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.ControlBoardFactory) { parentNameComboBox.Items.Add(cmpnt.Name); } diff --git a/TBF/BenchControl/RegisterReaders/StandingStartStop/RegisterReaderCfgCtrl.resx b/TBF/BenchControl/RegisterReaders/StandingStartStop/RegisterReaderCfgCtrl.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TBF/BenchControl/RegisterReaders/StandingStartStop/RegisterReaderCfgCtrl.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TBF/BenchControl/Elde/FixedStartRegisterReader/RegisterReaderFactory.cs b/TBF/BenchControl/RegisterReaders/StandingStartStop/RegisterReaderFactory.cs similarity index 93% rename from TBF/BenchControl/Elde/FixedStartRegisterReader/RegisterReaderFactory.cs rename to TBF/BenchControl/RegisterReaders/StandingStartStop/RegisterReaderFactory.cs index 00dde1c89..85c5ce948 100644 --- a/TBF/BenchControl/Elde/FixedStartRegisterReader/RegisterReaderFactory.cs +++ b/TBF/BenchControl/RegisterReaders/StandingStartStop/RegisterReaderFactory.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.Elde.FixedStartRegisterReader +namespace TBF.BenchControl.RegisterReaders.StandingStartStop { public class RegisterReaderFactory : IComponentFactory { diff --git a/TBF/BenchControl/Sequences/MainSeq.cs b/TBF/BenchControl/Sequences/MainSeq.cs index cbdf8e9be..3840d38b7 100644 --- a/TBF/BenchControl/Sequences/MainSeq.cs +++ b/TBF/BenchControl/Sequences/MainSeq.cs @@ -331,7 +331,10 @@ namespace TBF.BenchControl.Sequences /// Procedure selected at this point, a new batch was started /// int newBatchNr = Program.LocalSettings.BatchNr; - StateMachine.ControlBoard.ManualUIAllowed = !StateMachine.Procedure.ManualCtrlDisabled; + if (StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) + { + (StateMachine.ControlBoard as ControlBoard.Legacy.ControlBoardDev).ManualUIAllowed = !StateMachine.Procedure.ManualCtrlDisabled; + } Bridge.Bench2UI(ButtonsEtc.StopBtnEn); /// A new cycle started : Enable STOP button log.FatalFormat("New measurement session started: batch = {0}, procedure = {1}", newBatchNr, StateMachine.Procedure.Name); @@ -658,7 +661,10 @@ namespace TBF.BenchControl.Sequences } if (selection == Selection.Break) { - StateMachine.ControlBoard.ManualUIAllowed = true; + if (StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) + { + (StateMachine.ControlBoard as ControlBoard.Legacy.ControlBoardDev).ManualUIAllowed = true; + } Bridge.Bench2UI(ButtonsEtc.ShowBenchEmpty); Bridge.OnProcedureCompleted(this, new ProcedureCompletedEventArgs(StateMachine.Procedure)); goto select_procedure; @@ -840,6 +846,14 @@ namespace TBF.BenchControl.Sequences StateMachine.LoadTestParams(test); + string errMsg; + if (!testMethod.CheckDeviceCaps(test, outPath, out errMsg)) + { + UiBridge.Bridge.OnError(this, errMsg); + goto select_cycle_or_test; + } + StateMachine.ControlBoard.Devices = outPath; + if ((sensPath != null) && (sensPath.RegisterReaders != null)) { ProcessData.RegisterReaders = sensPath.RegisterReaders; @@ -878,6 +892,7 @@ namespace TBF.BenchControl.Sequences { bool doExecuteTransitionBefore = isOuterLoopMode || (repetNr == 1) || veryFirstTestInTheRestOfCycle; veryFirstTestInTheRestOfCycle = false; + if (testMethod.DoTransitions()) { /// Make a transition before a test and before each test repetition @@ -1006,6 +1021,8 @@ namespace TBF.BenchControl.Sequences { StateMachine.LoadTestParams(dfrrdData.Test); + StateMachine.ControlBoard.Devices = outPath; + if ((sensPath != null) && (sensPath.RegisterReaders != null)) { ProcessData.RegisterReaders = sensPath.RegisterReaders; @@ -1072,6 +1089,14 @@ namespace TBF.BenchControl.Sequences { StateMachine.LoadTestParams(test); + string errMsg; + if (!testMethod.CheckDeviceCaps(test, outPath, out errMsg)) + { + UiBridge.Bridge.OnError(this, errMsg); + goto select_cycle_or_test; + } + StateMachine.ControlBoard.Devices = outPath; + if ((sensPath != null) && (sensPath.RegisterReaders != null)) { ProcessData.RegisterReaders = sensPath.RegisterReaders; @@ -1295,7 +1320,10 @@ namespace TBF.BenchControl.Sequences ProcessData.BatchRslts.Batch.ProcedureName, Program.LocalSettings.BatchNr); - StateMachine.ControlBoard.ManualUIAllowed = true; + if (StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) + { + (StateMachine.ControlBoard as ControlBoard.Legacy.ControlBoardDev).ManualUIAllowed = true; + } Event evacRetv = DoEvacuation(purgeEnd); /// diff --git a/TBF/BenchControl/Sequences/ProcessData.cs b/TBF/BenchControl/Sequences/ProcessData.cs index 7288e1505..9a31bdbd8 100644 --- a/TBF/BenchControl/Sequences/ProcessData.cs +++ b/TBF/BenchControl/Sequences/ProcessData.cs @@ -187,7 +187,7 @@ namespace TBF.BenchControl.Sequences public static double LtrPerRefPulse; /// to calculate the ref.volume public static int RefPulses; public static int RefPulsesDelta; - public static DoubleBox RefFreq = new DoubleBox() { Name = "RefFreq", Format = "F2" }; + public static DoubleBox RefFrequency = new DoubleBox() { Name = "RefFreq", Format = "F2" }; public static DoubleBox RefFlow = new DoubleBox() { Name = "RefFlow", Format = "F2" }; /// [m3/h] public static DoubleBox Mass = new DoubleBox() { Name = "Mass", Format = "F3" }; /// [kg] @@ -211,13 +211,10 @@ namespace TBF.BenchControl.Sequences /// protected void ClearProcessValues() { - for (int i = 0; i < Config.Data.WMsCount; i++) - { - if (RegisterReaders[i] != null) RegisterReaders[i].Clear(); - } + StateMachine.ControlBoard.ClearProcessValues(); RefPulses = 0; - RefFreq.Clear(); + RefFrequency.Clear(); RefFlow.Clear(); Mass.Clear(); StartMass.Clear(); diff --git a/TBF/BenchControl/Sequences/SequenceBase.cs b/TBF/BenchControl/Sequences/SequenceBase.cs index 5516f6888..8b1e2949b 100644 --- a/TBF/BenchControl/Sequences/SequenceBase.cs +++ b/TBF/BenchControl/Sequences/SequenceBase.cs @@ -30,8 +30,6 @@ namespace TBF.BenchControl.Sequences public const int FlowSettingTimeoutSec = 300; /// Flow setting timeout = 5 min. public const int StableMassMsrmntTimeoutSec = 300; /// Stable mass measurement timeout = 5 min. - public const int CountWhenSendingRdDivCmd = 1; /// Passed to cBrd.ReadDiverterTransitionOp() - public const int CountWhenReadingDiv = 3; /// Passed to cBrd.ReadDiverterTransitionOp() ///------------------------------------------------------------ @@ -127,9 +125,9 @@ namespace TBF.BenchControl.Sequences logger.InfoFormat("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11} {12} {13} {14} {15} {16}", DateTime.Now.ToLongTimeString(), Utils.DoubleToStr(RefFlow.Val, 4), /// flow measured by the reference flow meter in m3/h - StateMachine.ControlBoard.TTime.ToString("F3"), /// test time in s - StateMachine.ControlBoard.EtPulses(0), /// reference flow meter pulses count - Formulas.VolumeFromPulses(StateMachine.ControlBoard.EtPulses(0), 1.0f / LtrPerRefPulse).ToString("F3"), /// volume in l + StateMachine.ControlBoard.TestTime.ToString("F3"),/// test time in s + StateMachine.ControlBoard.RefPulses, /// reference flow meter pulses count + Formulas.VolumeFromPulses(StateMachine.ControlBoard.RefPulses, 1.0f / LtrPerRefPulse).ToString("F3"), /// volume in l TempUp, /// water temperature at the beginning of test line in degree C TempDown, /// water temperature at the end of test line in degree C TempDiv, /// water temperature at the diverter in degree C @@ -157,9 +155,9 @@ namespace TBF.BenchControl.Sequences logger.InfoFormat("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11} {12} {13} {14} {15} {16} {17} {18} {19} {20}", DateTime.Now.ToLongTimeString(), Utils.DoubleToStr(RefFlow.Val, 4), - StateMachine.ControlBoard.TTime.ToString("F3"), - StateMachine.ControlBoard.EtPulses(0), - Formulas.VolumeFromPulses(StateMachine.ControlBoard.EtPulses(0), 1.0f / LtrPerRefPulse).ToString("F3"), + StateMachine.ControlBoard.TestTime.ToString("F3"), + StateMachine.ControlBoard.RefPulses, + Formulas.VolumeFromPulses(StateMachine.ControlBoard.RefPulses, 1.0f / LtrPerRefPulse).ToString("F3"), TempUp, TempDown, TempDiv, @@ -781,8 +779,8 @@ namespace TBF.BenchControl.Sequences .AddOperation(checkUiOp) .AddOperation(new MettlerToledo.KeepReadingMassesOp()) .AddOperation(StateMachine.ControlBoard - .SetValvesOp(GenericDevices.ValveBase.Merge(inPath.ValvesOpen, benchPath.ValvesOpen, outPath.ValvesOpen), - GenericDevices.ValveBase.Merge(inPath.ValvesClose, benchPath.ValvesClose, outPath.ValvesClose))) + .SetValvesOp(BuiltIn.ValveBase.Merge(inPath.ValvesOpen, benchPath.ValvesOpen, outPath.ValvesOpen), + BuiltIn.ValveBase.Merge(inPath.ValvesClose, benchPath.ValvesClose, outPath.ValvesClose))) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -801,8 +799,8 @@ namespace TBF.BenchControl.Sequences .AddOperation(checkUiOp) .AddOperation(new MettlerToledo.KeepReadingMassesOp()) .AddOperation(StateMachine.ControlBoard - .SetValvesOp(GenericDevices.ValveBase.Merge(nextInPath.ValvesOpen, nextBenchPath.ValvesOpen, nextOutPath.ValvesOpen), - GenericDevices.ValveBase.Merge(nextInPath.ValvesClose, nextBenchPath.ValvesClose, nextOutPath.ValvesClose))) + .SetValvesOp(BuiltIn.ValveBase.Merge(nextInPath.ValvesOpen, nextBenchPath.ValvesOpen, nextOutPath.ValvesOpen), + BuiltIn.ValveBase.Merge(nextInPath.ValvesClose, nextBenchPath.ValvesClose, nextOutPath.ValvesClose))) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -813,8 +811,11 @@ namespace TBF.BenchControl.Sequences /// 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); + if (StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) + { + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + (StateMachine.ControlBoard as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, nextPidCoef, (nextTolerRed == 0) ? 0 : 1); + } /// Set pump power if (nextInPath.Pump is GenericDevices.IPumpFM) (nextInPath.Pump as GenericDevices.IPumpFM).TurnOn(nextPumpPower); @@ -1042,7 +1043,7 @@ namespace TBF.BenchControl.Sequences State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperation(doNotWait ? regulValve.SetFlowAndMeasureOp(flowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec, 0) - : regulValve.SetFlowOp(flowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) + : StateMachine.ControlBoard.SetFlowOp(test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) .AddOperations(extraOperations) .EnterState(); do diff --git a/TBF/BenchControl/StateMachine.cs b/TBF/BenchControl/StateMachine.cs index 8c8b9a750..ef3303bad 100644 --- a/TBF/BenchControl/StateMachine.cs +++ b/TBF/BenchControl/StateMachine.cs @@ -51,7 +51,7 @@ namespace TBF.BenchControl public static IList TransitionSteps; /// Public components - public static Elde.ControlBoardDev ControlBoard; + public static ControlBoard.IControlBoard ControlBoard; public static GenericDevices.IAmbient Ambient; public static IOperation BenchWaitingOp; public static IOperation BenchErrorOp; @@ -63,8 +63,10 @@ namespace TBF.BenchControl public static GenericDevices.IValve DrainValve3; public static IList MasterValves; /// list of directly controlled valves public static IList CoupledValves; /// list of coupled valves - public static IList ExtendedValves; /// list of extended valves + public static IList ExtendedValves; /// list of extended valves + /// Test method classes fo all test methods + public static Dictionary TestMethod2Class; /// Time and synchronization #if TURA_IPERL || TURA_IPERL_NEW @@ -89,7 +91,7 @@ namespace TBF.BenchControl { get { - return GenericDevices.ValveBase.Merge( + return BuiltIn.ValveBase.Merge( Utils.ValvesOpen((feedingPaths != null && feedingPaths.Count > 0) ? feedingPaths[0] : null), Utils.ValvesOpen((benchPaths != null && benchPaths.Count > 0) ? benchPaths[0] : null), Utils.ValvesOpen((outputPaths != null && outputPaths.Count > 0) ? outputPaths[0] : null) @@ -101,7 +103,7 @@ namespace TBF.BenchControl { get { - return GenericDevices.ValveBase.Merge( + return BuiltIn.ValveBase.Merge( Utils.ValvesClose((feedingPaths != null && feedingPaths.Count > 0) ? feedingPaths[0] : null), Utils.ValvesClose((benchPaths != null && benchPaths.Count > 0) ? benchPaths[0] : null), Utils.ValvesClose((outputPaths != null && outputPaths.Count > 0) ? outputPaths[0] : null) @@ -140,9 +142,20 @@ namespace TBF.BenchControl /// static StateMachine() { + currentTimeSec = 0; + /// devices = new List(); states = new List(); - currentTimeSec = 0; + TestMethod2Class = new Dictionary(); + + ProcessData.IperlHeads = new List(); + SequenceBase.FlowMeters = new List(); + SequenceBase.RegulValves = new List(); + SequenceBase.PumpsWithFM = new List(); + SequenceBase.WaterMeters = new List(); + SequenceBase.Cameras = new List(); + + ProcessData.IperlHeads = new List(); } /// @@ -213,23 +226,17 @@ namespace TBF.BenchControl /// Load the list of components (entities) from the database. /// Then create the components (derived from IComponent). components = BenchControl.TbfComponents.LoadComponentsFromDB(Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config)); - MasterValves = GenericDevices.ValveBase.MasterValves(components); - CoupledValves = GenericDevices.ValveBase.CoupledValves(components); - ExtendedValves = GenericDevices.ValveBase.ExtendedValves(components); + MasterValves = BuiltIn.ValveBase.GetMasterValves(components); + CoupledValves = BuiltIn.ValveBase.CoupledValves(components); + ExtendedValves = BuiltIn.ValveBase.ExtendedValves(components); /// Find all balances (to initialize tank capacities in the control board) /// Find the control board - IList tanks = new List(); - ProcessData.IperlHeads = new List(); - SequenceBase.FlowMeters = new List(); - SequenceBase.RegulValves = new List(); - SequenceBase.PumpsWithFM = new List(); - SequenceBase.WaterMeters = new List(); - SequenceBase.Cameras = new List(); + IList tanks = new List(); UInt128 valvesToInvert = 0; foreach (var cmpnt in components) { - if (cmpnt is Elde.ControlBoardDev) ControlBoard = cmpnt as Elde.ControlBoardDev; + if (cmpnt is TBF.BenchControl.ControlBoard.IControlBoard) ControlBoard = cmpnt as TBF.BenchControl.ControlBoard.IControlBoard; if (cmpnt is IBenchInfo) ProcessData.BenchInfo = cmpnt as IBenchInfo; if (cmpnt is IErrorFlags) ProcessData.ErrorFlagsComp = cmpnt as IErrorFlags; if (cmpnt is IStatisticsMonitoring) ProcessData.StatisticsMonitoringComp = cmpnt as IStatisticsMonitoring; @@ -238,19 +245,20 @@ namespace TBF.BenchControl { ProcessData.OracleDB = cmpnt as Output.DB.SensusOracle.Database; } + + if (cmpnt is ITestMethod) TestMethod2Class.Add(cmpnt.Name, cmpnt.ClassName); + if (cmpnt is TestMethods.iPerlCommunication.iPerlHead.IperlHead) { ProcessData.IperlHeads.Add(cmpnt as TestMethods.iPerlCommunication.iPerlHead.IperlHead); } + if (cmpnt is IFlowMeter) SequenceBase.FlowMeters.Add(cmpnt as IFlowMeter); if ((cmpnt is IRegulValve) && !(cmpnt is BenchControl.Elde.RegulValveTandem.RegulValveTandem)) { SequenceBase.RegulValves.Add(cmpnt as IRegulValve); } - if (cmpnt is IPumpFM && !(cmpnt is Elde.PumpTandem.Pump)) - { - SequenceBase.PumpsWithFM.Add(cmpnt as IPumpFM); - } + if (cmpnt is IPumpFM && !(cmpnt is BuiltIn.PumpTandem.Pump)) SequenceBase.PumpsWithFM.Add(cmpnt as IPumpFM); if (cmpnt is IWaterMeter) SequenceBase.WaterMeters.Add(cmpnt as IWaterMeter); if (cmpnt is ICamera) SequenceBase.Cameras.Add(cmpnt as ICamera); if (cmpnt is GenericDevices.IAmbient) Ambient = cmpnt as GenericDevices.IAmbient; @@ -271,8 +279,8 @@ namespace TBF.BenchControl else if ((tank.ScaleNr == 2) && (Tank3 == null)) Tank3 = tank; } - Elde.Valve.Valve eldeValve = (cmpnt as Elde.Valve.Valve); - if ((eldeValve != null) && eldeValve.Inverted) valvesToInvert |= eldeValve.Mask; + BuiltIn.Valve.Valve plainValve = (cmpnt as BuiltIn.Valve.Valve); + if ((plainValve != null) && plainValve.Inverted) valvesToInvert |= plainValve.Mask; cmpnt.StartChangeHandler(); /// Start handling parameter change events } diff --git a/TBF/BenchControl/TbfComponents.cs b/TBF/BenchControl/TbfComponents.cs index fbdc2c389..de10c27ad 100644 --- a/TBF/BenchControl/TbfComponents.cs +++ b/TBF/BenchControl/TbfComponents.cs @@ -21,7 +21,9 @@ namespace TBF.BenchControl Factories.Add(new DataContainers.Buoyancy.ComponentFactory()); Factories.Add(new DataContainers.Density.ComponentFactory()); Factories.Add(new DataContainers.Evaporation.Factory()); - Factories.Add(new Elde.ControlBoardFactory()); + Factories.Add(new ControlBoard.Legacy.ControlBoardFactory()); + Factories.Add(new ControlBoard.New.CBoardFactory()); + Factories.Add(new ControlBoard.Papouch.CBoardFactory()); Factories.Add(new Elde.CoverTest.Factory()); Factories.Add(new DataEntry.Combined.EntryFormFactory()); Factories.Add(new DataEntry.HeatMeters6.Factory()); @@ -165,12 +167,12 @@ namespace TBF.BenchControl Factories.Add(new Output.Printers.Zapiska.FactoryHeatMeters()); Factories.Add(new Elde.PressureMeter.PressureMeterFactory()); Factories.Add(new Elde.PressureMeterInternal.PressureMeterFactory()); - Factories.Add(new Elde.Pump.PumpFactory()); + Factories.Add(new BuiltIn.Pump.PumpFactory()); Factories.Add(new Danfoss.VLT2800.PumpFactory()); Factories.Add(new Elde.PumpWithFM.PumpFactory()); - Factories.Add(new Elde.PumpTandem.PumpFactory()); + Factories.Add(new BuiltIn.PumpTandem.PumpFactory()); Factories.Add(new Elde.RegisterReader.Factory()); /// 'RegisterReader' - Factories.Add(new Elde.FixedStartRegisterReader.RegisterReaderFactory()); /// 'RegisterReader for standing start/stop' + Factories.Add(new RegisterReaders.StandingStartStop.RegisterReaderFactory()); /// 'RegisterReader for standing start/stop' Factories.Add(new TestMethods.iPerlCommunication.iPerlHead.Factory()); /// 'RegisterReader for iPerl' Factories.Add(new RegisterReaders.SerialStream.Factory()); /// 'RegisterReader for generic serial stream' Factories.Add(new RegisterReaders.KPackE.RegisterReader.Factory()); /// KPackE register reader @@ -181,8 +183,8 @@ namespace TBF.BenchControl Factories.Add(new Elde.TempMeter.TempMeterFactory()); Factories.Add(new Elde.TempMeterInternal.TempMeterFactory()); Factories.Add(new Elde.TempMeterMeret.Factory()); /// Meret temp. meter connected to control board Modbus - Factories.Add(new Elde.Valve.ValveFactory()); - Factories.Add(new Elde.ValveEx.ValveFactory()); + Factories.Add(new BuiltIn.Valve.ValveFactory()); + Factories.Add(new BuiltIn.ValveEx.ValveFactory()); Factories.Add(new Various.ErrorFlags.Factory()); Factories.Add(new Various.StatisticsMonitoring.Factory()); Factories.Add(new Various.TankWithLevelMsrmnt.Factory()); diff --git a/TBF/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs b/TBF/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs index 33d6ab2fd..37270527c 100644 --- a/TBF/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs +++ b/TBF/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs @@ -17,6 +17,40 @@ namespace TBF.BenchControl.TestMethods.Adjustment { private static readonly ILog log = LogManager.GetLogger(typeof(AdjustmentSeq)); + /// + /// Check capabilities of devces in the output path required for this test method + /// + /// Devices + /// true when capabilities of devices are OK + public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) + { + if (!(StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) && + !(StateMachine.ControlBoard is ControlBoard.New.CBoard)) + { + /// Control board does not support this method + message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); + return false; + } + + if (!(devices.FlowMeter is GenericDevices.IFlowMeter)) + { + /// Flow meter is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_flow_meter); + return false; + } + + if (!(devices.RegulValve is GenericDevices.IRegulValve)) + { + /// Regulation valve is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_regulation_valve); + return false; + } + + message = string.Empty; + return true; + } + + System.Windows.Forms.Form modelessDlg; /// delegate void ErrorsFormDlgt(AdjustmentSeq myRef, IList waterMeters); @@ -85,7 +119,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment IList e; /// Events from currently running operations Event retVal = Event.Done; - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; + TBF.BenchControl.ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false); @@ -102,7 +136,10 @@ namespace TBF.BenchControl.TestMethods.Adjustment } } - cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + if (cBrd is ControlBoard.Legacy.ControlBoardDev) + { + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + } IList readTempPressOps = new List(); if (benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp)); @@ -117,11 +154,10 @@ namespace TBF.BenchControl.TestMethods.Adjustment if (heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)); LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h] - int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f); int flowSetTime = 0; /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, totalPulses)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); /// Read pressure and temperature once before calling Bridge.OnTestSelected(...) @@ -223,7 +259,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) + .AddOperation(cBrd.SetFlowOp(test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -342,7 +378,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment .AddOperation(checkUiOp) .AddOperations(readTempPressOps) .AddOperations(measureOperations) - .AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Synchro, test.Qfrom, test.Qto, totalPulses)) + .AddOperation(cBrd.StartTestOp(test)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -369,8 +405,8 @@ namespace TBF.BenchControl.TestMethods.Adjustment case Event.MeasurementCompleted: goto one_test_completed; } - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; + RefFrequency.Val = cBrd.RefFrequency; + RefFlow.Val = cBrd.RefFlow; UpdateAllStatistics(StateMachine.Time); Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); @@ -404,8 +440,8 @@ namespace TBF.BenchControl.TestMethods.Adjustment tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TTime; /// [s] measurement time - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total) + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = 0; tstRslt.MassStart = 0; tstRslt.MassEndRaw = 0; @@ -449,7 +485,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment meterRslt.VolumeEnd = 0; /// liter meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter meterRslt.VolumeRef = meterRslt.PulsesMaster * tstRslt.ConstMaster; /// liter - meterRslt.TestTime = cBrd.ImpulseTime(i + 1); + meterRslt.TestTime = cBrd.PulsesWM(i + 1); meterRslt.Error = Config.Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); meterRslt.Passed = (meterRslt.Error >= test.GetErrLimLo(tstRslt.VolumeCTV, tstRslt.TestTime) + test.Uncertainty) && (meterRslt.Error <= test.GetErrLimHi(tstRslt.VolumeCTV, tstRslt.TestTime) - test.Uncertainty); diff --git a/TBF/BenchControl/TestMethods/Adjustment/TestMethod.cs b/TBF/BenchControl/TestMethods/Adjustment/TestMethod.cs index 831571ec1..5ea9d718a 100644 --- a/TBF/BenchControl/TestMethods/Adjustment/TestMethod.cs +++ b/TBF/BenchControl/TestMethods/Adjustment/TestMethod.cs @@ -12,15 +12,17 @@ namespace TBF.BenchControl.TestMethods.Adjustment public class TestMethod : ComponentBase, GenericDevices.ITestMethod { private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod)); - public override string ToString() { return string.Format("TestMethods.Adjustment({0})", Cfg.ToString(1)); } + public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(1)); } public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return AdjustmentSeq.CheckDeviceCaps(test, devices, out message); + } - public TestMethod() - { - } - + public TestMethod() { } + /// public TestMethod(Generic.IComponentCfg cfg) : base(cfg) { diff --git a/TBF/BenchControl/TestMethods/ChangeFlowDirection/ChangeFlowDirectionSeq.cs b/TBF/BenchControl/TestMethods/ChangeFlowDirection/ChangeFlowDirectionSeq.cs index e144f1e62..ca2736b83 100644 --- a/TBF/BenchControl/TestMethods/ChangeFlowDirection/ChangeFlowDirectionSeq.cs +++ b/TBF/BenchControl/TestMethods/ChangeFlowDirection/ChangeFlowDirectionSeq.cs @@ -40,7 +40,7 @@ namespace TBF.BenchControl.TestMethods.ChangeFlowDirection checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, 0)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); TestStartTime = DateTime.Now; diff --git a/TBF/BenchControl/TestMethods/ChangeFlowDirection/TestMethod.cs b/TBF/BenchControl/TestMethods/ChangeFlowDirection/TestMethod.cs index 54ea84d6c..51f0ef509 100644 --- a/TBF/BenchControl/TestMethods/ChangeFlowDirection/TestMethod.cs +++ b/TBF/BenchControl/TestMethods/ChangeFlowDirection/TestMethod.cs @@ -12,15 +12,19 @@ namespace TBF.BenchControl.TestMethods.ChangeFlowDirection public class TestMethod : ComponentBase, GenericDevices.ITestMethod { private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod)); - public override string ToString() { return string.Format("TestMethods.ChangeFlowDirection({0})", Cfg.ToString(1)); } + public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(1)); } public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + message = string.Format("{0}: CheckDeviceCaps() is not implemented yet", Name); + return false; + } - public TestMethod() - { - } + public TestMethod() { } + /// public TestMethod(Generic.IComponentCfg cfg) : base(cfg) { diff --git a/TBF/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs b/TBF/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs index d139b9d58..8bd7e2dde 100644 --- a/TBF/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs +++ b/TBF/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs @@ -19,6 +19,53 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection const int DetectionBufferSize = 9; const int DetectionKernelSize = 5; + /// + /// Check capabilities of devces in the output path required for this test method + /// + /// Devices + /// true when capabilities of devices are OK + public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) + { + if (!(StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) && + !(StateMachine.ControlBoard is ControlBoard.New.CBoard)) + { + /// Control board does not support this method + message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); + return false; + } + + if (!(devices.Scale is IScale)) + { + /// Scale is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_scale); + return false; + } + + if (!(devices.Diverter is IDiverter)) + { + /// Scale is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_diverter); + return false; + } + + if (!(devices.FlowMeter is IFlowMeter)) + { + /// Flow meter is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_flow_meter); + return false; + } + + if (!(devices.RegulValve is GenericDevices.IRegulValve)) + { + /// Regulation valve is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_regulation_valve); + return false; + } + + message = string.Empty; + return true; + } + public IList Execute(Config.Entities.Test test, int repetitionNr, bool isLastRepetition, CombinedWithDetTestParams testParams, Config.Entities.DebugMode debugLevel) @@ -64,7 +111,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection IList e; /// Events from currently running operations - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; + TBF.BenchControl.ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; int tMass1 = 0; int tMass2 = 0; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state @@ -84,7 +131,10 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection } } - cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + if (cBrd is ControlBoard.Legacy.ControlBoardDev) + { + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + } IList readTempPressOps = new List(); if (benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp)); @@ -143,7 +193,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection while (e.Contains(Event.Busy)); /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, totalPulses)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); TestStartTime = DateTime.Now; Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); @@ -332,7 +382,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection case Event.UiCmdStop: goto stopTest; } - flowsForDetection[0] = cBrd.ReferenceFreq * outPath.FlowMeter.NominalFlow / 2000.0; + flowsForDetection[0] = cBrd.RefFrequency * outPath.FlowMeter.NominalFlow / 2000.0; double diff = RegisterReaders[(test.Part - 1) * 2 + 1].WMPulses - lastWMPulses[(test.Part - 1) * 2 + 1]; pulseFreqsForDetection[0] = diff / (double)(StateMachine.Time - lastTime); lastTime = StateMachine.Time; @@ -449,7 +499,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection .AddOperation(checkUiOp) .AddOperations(readTempPressOps) .AddOperations(measureOperations) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) + .AddOperation(cBrd.SetFlowOp(test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -520,7 +570,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection .AddOperation(checkUiOp) .AddOperations(readTempPressOps) .AddOperations(measureOperations) - .AddOperation(cBrd.StartMeasurementOp(outPath, (Elde.TestMethods.Diverter | Elde.TestMethods.Synchro), qfrom_detected, qto_detected, totalPulses)) + .AddOperation(cBrd.StartTestOp(test, 0, qfrom_detected, qto_detected)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -539,8 +589,12 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection int estimtdEndTime = StateMachine.Time + (int)test.TstTime; /// Read the diverter switch time - switchTimeStart = 0.001f * (float)cBrd.DivTime(0); - log.WarnFormat("Diverter switch time on test start = {0} ms", cBrd.DivTime(0)); + if (StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) + { + ControlBoard.Legacy.ControlBoardDev eldeCB = StateMachine.ControlBoard as ControlBoard.Legacy.ControlBoardDev; + switchTimeStart = 0.001f * (float)eldeCB.DivTime(0); + log.WarnFormat("Diverter switch time on test start = {0} ms", eldeCB.DivTime(0)); + } /// Measurement loop - begin while (true) @@ -624,8 +678,12 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection } /// Read the diverter switch time - switchTimeEnd = 0.001f * (float)cBrd.DivTime(0); - log.WarnFormat("Diverter switch time on test end = {0} ms", cBrd.DivTime(0)); + if (StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) + { + ControlBoard.Legacy.ControlBoardDev eldeCB = StateMachine.ControlBoard as ControlBoard.Legacy.ControlBoardDev; + switchTimeEnd = 0.001f * (float)eldeCB.DivTime(0); + log.WarnFormat("Diverter switch time on test end = {0} ms", eldeCB.DivTime(0)); + } //------------------------------------------------ Bridge.OnActivity(this, Strings.Test_completed); @@ -673,16 +731,16 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TTime; /// [s] measurement time + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; double massOfEvaporatedWater = tstRslt.TimeBtwnMassMsrmnts * outPath.Scale.EvaporationRate(tstRslt.TempDivMean); - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total) + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = StartMass.Val; tstRslt.MassStart = Config.Formulas.CorrectedValue(tstRslt.MassStartRaw, scale.Corrections); tstRslt.MassEndRaw = EndMass.Val; tstRslt.MassEnd = Config.Formulas.CorrectedValue(tstRslt.MassEndRaw, scale.Corrections); tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart + massOfEvaporatedWater) / tstRslt.TestTime; /// [kg/h] - tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * cBrd.EtPulses(0) / tstRslt.TestTime; /// [m3/h] + tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * cBrd.RefPulses / tstRslt.TestTime; /// [m3/h] tstRslt.Buoyancy = Config.Formulas.Buoyancy(); tstRslt.VolumeCTV = 1000 * tstRslt.Buoyancy * (tstRslt.MassEnd - tstRslt.MassStart + massOfEvaporatedWater) / tstRslt.DensityLine; /// [l] commercially true volume if ((outPath.Diverter != null) && (tstRslt.TestTime > float.Epsilon)) @@ -730,7 +788,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection /// Optionally supress pulses from the large water meter meterRslt.PulsesMeter = (isAux == 0 && testParams.SupressTrills) ? 0 : Convert.ToDouble(regReader.WMPulses); meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses); - meterRslt.TestTime = cBrd.TTime; + meterRslt.TestTime = cBrd.TestTime; meterRslt.VolumeStart = 0; meterRslt.VolumeEnd = 0; meterRslt.VolumeRef = tstRslt.VolumeCTV; diff --git a/TBF/BenchControl/TestMethods/CombinedWithDetection/TestMethod.cs b/TBF/BenchControl/TestMethods/CombinedWithDetection/TestMethod.cs index dbe09be67..461685075 100644 --- a/TBF/BenchControl/TestMethods/CombinedWithDetection/TestMethod.cs +++ b/TBF/BenchControl/TestMethods/CombinedWithDetection/TestMethod.cs @@ -12,18 +12,21 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection public class TestMethod : ComponentBase, GenericDevices.ITestMethod { private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod)); - public override string ToString() { return string.Format("TestMethods.CombinedWithDetection({0})", Cfg.ToString(1)); } - - readonly TestMethodCfg testMethodCfg; + public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(1)); } public bool CanTest(MetersKind meters) { return meters == MetersKind.Combined; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return CombinedWithDetectionSeq.CheckDeviceCaps(test, devices, out message); + } - public TestMethod() - { - } - public TestMethod(Generic.IComponentCfg cfg) + readonly TestMethodCfg testMethodCfg; + + public TestMethod() { } + /// + public TestMethod(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/Counter/TestMethod.cs b/TBF/BenchControl/TestMethods/Counter/TestMethod.cs index 7e6171be7..1ac98917d 100644 --- a/TBF/BenchControl/TestMethods/Counter/TestMethod.cs +++ b/TBF/BenchControl/TestMethods/Counter/TestMethod.cs @@ -12,10 +12,15 @@ namespace TBF.BenchControl.TestMethods.Counter public class TestMethod : ComponentBase, GenericDevices.ITestMethod { private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod)); - public override string ToString() { return string.Format("TestMethods.Counter({0})", Cfg.ToString(1)); } + public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(1)); } public bool CanTest(MetersKind meters) { return true; } public bool DoTransitions() { return false; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + message = string.Format("{0}: CheckDeviceCaps() is not implemented yet", Name); + return false; + } /// @@ -32,11 +37,9 @@ namespace TBF.BenchControl.TestMethods.Counter private int counterIdx0; /// 0-based index of this counter - public TestMethod() - { - } - - public TestMethod(Generic.IComponentCfg cfg) + public TestMethod() { } + /// + public TestMethod(Generic.IComponentCfg cfg) : base(cfg) { counterIdx0 = nextCounterIdx++; diff --git a/TBF/BenchControl/TestMethods/DiverterTest/Component.cs b/TBF/BenchControl/TestMethods/DiverterTest/Component.cs index 456804b81..906406695 100644 --- a/TBF/BenchControl/TestMethods/DiverterTest/Component.cs +++ b/TBF/BenchControl/TestMethods/DiverterTest/Component.cs @@ -18,13 +18,16 @@ namespace TBF.BenchControl.TestMethods.DiverterTest public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return DiverterTestSeq.CheckDeviceCaps(test, devices, out message); + } + readonly TestMethodCfg testMethodCfg; - public Component() - { - } - + public Component() { } + /// public Component(Generic.IComponentCfg cfg) : base(cfg) { diff --git a/TBF/BenchControl/TestMethods/DiverterTest/DiverterTestSeq.cs b/TBF/BenchControl/TestMethods/DiverterTest/DiverterTestSeq.cs index 31f8bf7e0..548bdb65a 100644 --- a/TBF/BenchControl/TestMethods/DiverterTest/DiverterTestSeq.cs +++ b/TBF/BenchControl/TestMethods/DiverterTest/DiverterTestSeq.cs @@ -17,6 +17,60 @@ namespace TBF.BenchControl.TestMethods.DiverterTest { private static readonly ILog log = LogManager.GetLogger(typeof(DiverterTestSeq)); + /// + /// Check capabilities of devces in the output path required for this test method + /// + /// Devices + /// true when capabilities of devices are OK + public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) + { + if (!(StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) && + !(StateMachine.ControlBoard is ControlBoard.New.CBoard)) + { + /// Control board does not support this method + message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); + return false; + } + + if (!(devices.Scale is IScale)) + { + /// Scale is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_scale); + return false; + } + + if (test.Volume > devices.Scale.Capacity * Constants.TankFullFactor) + { + /// Scale capacity is not sufficient + message = string.Format("{0}: {1}", test.Name, Strings.Test_volume_exceeds_the_scale_capacity); + return false; + } + + if (!(devices.Diverter is IDiverter)) + { + /// Scale is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_diverter); + return false; + } + + if (!(devices.FlowMeter is IFlowMeter)) + { + /// Flow meter is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_flow_meter); + return false; + } + + if (!(devices.RegulValve is GenericDevices.IRegulValve)) + { + /// Regulation valve is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_regulation_valve); + return false; + } + + message = string.Empty; + return true; + } + /// /// Flying start mass collection method sequence /// @@ -29,12 +83,8 @@ namespace TBF.BenchControl.TestMethods.DiverterTest /// public IList Execute(Config.Entities.Test test, int repetitionNr, bool isLastRepetition, TestParams testParams) { - IScale scale = outPath.Scale as IScale; - if (scale == null) - { - Bridge.OnError(this, Strings.Missing_a_scale); - return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? - } + TBF.BenchControl.ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; + IScale scale = cBrd.Devices.Scale as IScale; int rangeIx = 0; /// Default range, used for non-Elde flowmeters if (outPath.FlowMeter is Elde.FlowMeter.FlowMeter) @@ -57,16 +107,9 @@ namespace TBF.BenchControl.TestMethods.DiverterTest } } - if (test.Volume > scale.Capacity * Constants.TankFullFactor) - { - Bridge.OnError(this, Strings.Test_volume_exceeds_the_scale_capacity); - return new List { Event.ConfigurationError }; - } - IList e; /// Events from currently running operations Event retVal = Event.Done; - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; int tMass1 = 0; int tMass2 = 0; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state @@ -86,7 +129,10 @@ namespace TBF.BenchControl.TestMethods.DiverterTest } } - cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + if (cBrd is ControlBoard.Legacy.ControlBoardDev) + { + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + } IList readTempPressOps = new List(); if(benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp)); @@ -114,7 +160,7 @@ namespace TBF.BenchControl.TestMethods.DiverterTest while (e.Contains(Event.Busy)); /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, null, totalPulses)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, null)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); TestStartTime = DateTime.Now; @@ -259,7 +305,7 @@ namespace TBF.BenchControl.TestMethods.DiverterTest //------------------------------------------------ State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name)) .AddOperation(checkUiOp) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) + .AddOperation(cBrd.SetFlowOp(test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) .AddOperations(readTempPressOps) .EnterState(); do { @@ -457,7 +503,7 @@ namespace TBF.BenchControl.TestMethods.DiverterTest .AddOperations(readTempPressOps) .AddOperations(measureOperations) .AddOperation(processDataLoggingOp) - .AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro, test.Qfrom, test.Qto, totalPulses/ testParams.DivRepetitions)) + .AddOperation(cBrd.StartTestOp(test, testParams.DivRepetitions)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -512,8 +558,8 @@ namespace TBF.BenchControl.TestMethods.DiverterTest } //------------------------------------------------ - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; + RefFrequency.Val = cBrd.RefFrequency; + RefFlow.Val = cBrd.RefFlow; UpdateAllStatistics(StateMachine.Time); @@ -546,13 +592,13 @@ namespace TBF.BenchControl.TestMethods.DiverterTest while (!e.Contains(Event.TimerExpired)); /// Accumulate partial pulses - cumulativeEtPulses[0] += cBrd.EtPulses(0); - cumulativeTestTime[0] += cBrd.TTime; + cumulativeEtPulses[0] += cBrd.RefPulses; + cumulativeTestTime[0] += cBrd.TestTime; for (int i = 1; i <= Config.Data.WMsCount; i++) { - cumulativeEtPulses[i] += cBrd.EtPulses(i); - cumulativeWMPulses[i] += cBrd.WMeterPulses(i); - cumulativeTestTime[i] += cBrd.ImpulseTime(i); + cumulativeEtPulses[i] += cBrd.RefPulsesWM(i); + cumulativeWMPulses[i] += cBrd.PulsesWM(i); + cumulativeTestTime[i] += cBrd.TestTimeWM(i); } } } /// end for ... diverter test loop @@ -566,7 +612,7 @@ namespace TBF.BenchControl.TestMethods.DiverterTest State.Create(string.Format("{0}({1}) : Stopping flow regulation", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(cBrd.StopFlowRegulationOp(outPath)) + .AddOperation(cBrd.StopFlowRegulationOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -607,7 +653,7 @@ namespace TBF.BenchControl.TestMethods.DiverterTest .AddOperation(checkUiOp) .AddOperations(readTempPressOps) .AddOperation(scale.ReadMassOp(ref Mass)) - .AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, false, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr)) + .AddOperation(cBrd.ReadDiverterTransitionOp(false, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr)) .AddOperation(processDataLoggingOp) .AddOperation(new Operations.TimerOp(test.TimeStop2Mass)) .EnterState(); @@ -667,13 +713,13 @@ namespace TBF.BenchControl.TestMethods.DiverterTest /// /// Accumulate partial pulses from the last diverter repetition /// - cumulativeEtPulses[0] += cBrd.EtPulses(0); - cumulativeTestTime[0] += cBrd.TTime; + cumulativeEtPulses[0] += cBrd.RefPulses; + cumulativeTestTime[0] += cBrd.TestTime; for (int i = 1; i <= Config.Data.WMsCount; i++) { - cumulativeEtPulses[i] += cBrd.EtPulses(i); - cumulativeWMPulses[i] += cBrd.WMeterPulses(i); - cumulativeTestTime[i] += cBrd.ImpulseTime(i); + cumulativeEtPulses[i] += cBrd.RefPulsesWM(i); + cumulativeWMPulses[i] += cBrd.PulsesWM(i); + cumulativeTestTime[i] += cBrd.TestTimeWM(i); } /// diff --git a/TBF/BenchControl/TestMethods/Dummy/DummySeq.cs b/TBF/BenchControl/TestMethods/Dummy/DummySeq.cs index 3eae445c8..adc44755d 100644 --- a/TBF/BenchControl/TestMethods/Dummy/DummySeq.cs +++ b/TBF/BenchControl/TestMethods/Dummy/DummySeq.cs @@ -29,7 +29,7 @@ namespace TBF.BenchControl.TestMethods.Dummy checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, 0)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); TestStartTime = DateTime.Now; diff --git a/TBF/BenchControl/TestMethods/Dummy/TestMethod.cs b/TBF/BenchControl/TestMethods/Dummy/TestMethod.cs index c20e763af..e36e3fab3 100644 --- a/TBF/BenchControl/TestMethods/Dummy/TestMethod.cs +++ b/TBF/BenchControl/TestMethods/Dummy/TestMethod.cs @@ -12,16 +12,20 @@ namespace TBF.BenchControl.TestMethods.Dummy public class TestMethod : ComponentBase, GenericDevices.ITestMethod { private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod)); - public override string ToString() { return string.Format("TestMethods.Dummy({0})", Cfg.ToString(1)); } + public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(1)); } public bool CanTest(MetersKind meters) { return true; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + message = string.Format("{0}: CheckDeviceCaps() is not implemented yet", Name); + return false; + } - public TestMethod() - { - } - public TestMethod(Generic.IComponentCfg cfg) + public TestMethod() { } + /// + public TestMethod(Generic.IComponentCfg cfg) : base(cfg) { log.Debug(this.ToString()); diff --git a/TBF/BenchControl/TestMethods/Endurance/Component.cs b/TBF/BenchControl/TestMethods/Endurance/Component.cs index 44df74270..a06c4e183 100644 --- a/TBF/BenchControl/TestMethods/Endurance/Component.cs +++ b/TBF/BenchControl/TestMethods/Endurance/Component.cs @@ -16,16 +16,19 @@ namespace TBF.BenchControl.TestMethods.Endurance return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1)); } - readonly TestMethodCfg testMethodCfg; - public bool CanTest(MetersKind meters) { return true; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return EnduranceSeq.CheckDeviceCaps(test, devices, out message); + } - public Component() - { - } - public Component(Generic.IComponentCfg cfg) + readonly TestMethodCfg testMethodCfg; + + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/Endurance/CycleDlg.cs b/TBF/BenchControl/TestMethods/Endurance/CycleDlg.cs index 9fbd9a880..ec2661dd4 100644 --- a/TBF/BenchControl/TestMethods/Endurance/CycleDlg.cs +++ b/TBF/BenchControl/TestMethods/Endurance/CycleDlg.cs @@ -68,7 +68,7 @@ namespace TBF.BenchControl.TestMethods.Endurance { foreach (var vlv in TbfComponents) { - if (vlv is BenchControl.Elde.Valve.Valve && (vlv as BenchControl.Elde.Valve.Valve).BitPosition == bitNr) + if (vlv is TBF.BenchControl.BuiltIn.Valve.Valve && (vlv as TBF.BenchControl.BuiltIn.Valve.Valve).BitPosition == bitNr) { Valves.Add(vlv as IValve); break; diff --git a/TBF/BenchControl/TestMethods/Endurance/EnduranceSeq.cs b/TBF/BenchControl/TestMethods/Endurance/EnduranceSeq.cs index cb68c16f2..e9ee1d047 100644 --- a/TBF/BenchControl/TestMethods/Endurance/EnduranceSeq.cs +++ b/TBF/BenchControl/TestMethods/Endurance/EnduranceSeq.cs @@ -16,6 +16,38 @@ namespace TBF.BenchControl.TestMethods.Endurance { private static readonly ILog log = LogManager.GetLogger(typeof(EnduranceSeq)); + /// + /// Check capabilities of devces in the output path required for this test method + /// + /// Devices + /// true when capabilities of devices are OK + public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) + { + if (!(StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev)) + { + /// Control board does not support this method + message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); + return false; + } + + if (!(devices.FlowMeter is GenericDevices.IFlowMeter)) + { + /// Flow meter is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_flow_meter); + return false; + } + + if (!(devices.RegulValve is GenericDevices.IRegulValve)) + { + /// Regulation valve is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_regulation_valve); + return false; + } + + message = string.Empty; + return true; + } + /// /// Endurance test sequence /// @@ -30,6 +62,9 @@ namespace TBF.BenchControl.TestMethods.Endurance string enduranceCycleStr, Config.Entities.DebugMode debugLevel) { + ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; + ControlBoard.Legacy.ControlBoardDev eldeCB = cBrd as ControlBoard.Legacy.ControlBoardDev; + int rangeIx = 0; /// Default range, used for non-Elde flowmeters if (outPath.FlowMeter is Elde.FlowMeter.FlowMeter) { @@ -54,7 +89,6 @@ namespace TBF.BenchControl.TestMethods.Endurance IList e; /// Events from currently running operations Event retVal = Event.Done; - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false); @@ -72,7 +106,10 @@ namespace TBF.BenchControl.TestMethods.Endurance } } - cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + if (cBrd is ControlBoard.Legacy.ControlBoardDev) + { + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + } IList readTempPressOps = new List(); if (benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp)); @@ -121,7 +158,7 @@ namespace TBF.BenchControl.TestMethods.Endurance while (e.Contains(Event.Busy)); /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, totalPulses)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); TestStartTime = DateTime.Now; @@ -155,7 +192,7 @@ namespace TBF.BenchControl.TestMethods.Endurance State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) + .AddOperation(cBrd.SetFlowOp(test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -259,7 +296,7 @@ namespace TBF.BenchControl.TestMethods.Endurance .AddOperations(readTempPressOps) .AddOperations(measureOperations) .AddOperation(enduranceDataLoggingOp) - .AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Synchro, test.Qfrom, test.Qto, totalPulses)) + .AddOperation(cBrd.StartTestOp(test)) .AddOperation(processDataLoggingOp) .EnterState(); do { @@ -317,8 +354,8 @@ namespace TBF.BenchControl.TestMethods.Endurance } //------------------------------------------------ - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; + RefFrequency.Val = cBrd.RefFrequency; + RefFlow.Val = cBrd.RefFlow; UpdateAllStatistics(StateMachine.Time); @@ -360,8 +397,8 @@ namespace TBF.BenchControl.TestMethods.Endurance tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TTime; /// [s] measurement time - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total) + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = 0; tstRslt.MassStart = 0; tstRslt.MassEndRaw = 0; @@ -534,12 +571,13 @@ namespace TBF.BenchControl.TestMethods.Endurance cyclePar[2 * stepsCount + 2] = 0; cyclePar[0] = duration / 10; /// - cBrd.CyclePar = cyclePar; + + eldeCB.CyclePar = cyclePar; /// State.Create(string.Format("{0}({1}) : Uploading cycle parameters", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(cBrd.ExecuteCommandOp(Elde.Command.EnduranceCycleParamsUpload, Elde.Command.None, 0)) + .AddOperation(eldeCB.ExecuteCommandOp(ControlBoard.Legacy.Command.EnduranceCycleParamsUpload, ControlBoard.Legacy.Command.None, 0)) .AddOperation(processDataLoggingOp) .AddOperation(enduranceDataLoggingOp) .EnterState(); @@ -548,8 +586,8 @@ namespace TBF.BenchControl.TestMethods.Endurance if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; + RefFrequency.Val = cBrd.RefFrequency; + RefFlow.Val = cBrd.RefFlow; UpdateAllStatistics(StateMachine.Time); } @@ -562,7 +600,7 @@ namespace TBF.BenchControl.TestMethods.Endurance .AddOperation(checkUiOp) .AddOperations(readTempPressOps) .AddOperation(new Operations.TimerOp((int)test.TstTime, Event.TimerExpired)) - .AddOperation(cBrd.ExecuteCommandOp(Elde.Command.EnduranceCycleStart, Elde.Command.EnduranceCycleStop, 0)) + .AddOperation(eldeCB.ExecuteCommandOp(ControlBoard.Legacy.Command.EnduranceCycleStart, ControlBoard.Legacy.Command.EnduranceCycleStop, 0)) .AddOperation(processDataLoggingOp) .AddOperation(enduranceDataLoggingOp) .EnterState(); @@ -587,8 +625,8 @@ namespace TBF.BenchControl.TestMethods.Endurance } //------------------------------------------------ - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; + RefFrequency.Val = cBrd.RefFrequency; + RefFlow.Val = cBrd.RefFlow; UpdateAllStatistics(StateMachine.Time); @@ -616,8 +654,8 @@ namespace TBF.BenchControl.TestMethods.Endurance stopInProgress = true; } - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; + RefFrequency.Val = cBrd.RefFrequency; + RefFlow.Val = cBrd.RefFlow; UpdateAllStatistics(StateMachine.Time); diff --git a/TBF/BenchControl/TestMethods/FixedStart/Compound/Component.cs b/TBF/BenchControl/TestMethods/FixedStart/Compound/Component.cs index ef88056a6..cae70ef40 100644 --- a/TBF/BenchControl/TestMethods/FixedStart/Compound/Component.cs +++ b/TBF/BenchControl/TestMethods/FixedStart/Compound/Component.cs @@ -18,12 +18,14 @@ namespace TBF.BenchControl.TestMethods.FixedStart.Compound public bool CanTest(MetersKind meters) { return meters == MetersKind.Combined; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FixedStartSeq.CheckDeviceCaps(test, devices, out message); + } - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { log.Debug(this.ToString()); diff --git a/TBF/BenchControl/TestMethods/FixedStart/FixedStartSeq.cs b/TBF/BenchControl/TestMethods/FixedStart/FixedStartSeq.cs index 4b5828e50..17c3f29b4 100644 --- a/TBF/BenchControl/TestMethods/FixedStart/FixedStartSeq.cs +++ b/TBF/BenchControl/TestMethods/FixedStart/FixedStartSeq.cs @@ -15,6 +15,40 @@ namespace TBF.BenchControl.TestMethods.FixedStart { private static readonly ILog log = LogManager.GetLogger(typeof(FixedStartSeq)); + /// + /// Check capabilities of devces in the output path required for this test method + /// + /// Devices + /// true when capabilities of devices are OK + public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) + { + if (!(StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) && + !(StateMachine.ControlBoard is ControlBoard.Papouch.CBoard) && + !(StateMachine.ControlBoard is ControlBoard.New.CBoard)) + { + /// Control board does not support this method + message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); + return false; + } + + if (!(devices.FlowMeter is IFlowMeter)) + { + /// Flow meter is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_flow_meter); + return false; + } + + if (!(devices.RegulValve is GenericDevices.IRegulValve)) + { + /// Regulation valve is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_regulation_valve); + return false; + } + + message = string.Empty; + return true; + } + /// /// Fixed start mass collection method sequence /// @@ -54,7 +88,7 @@ namespace TBF.BenchControl.TestMethods.FixedStart IList e; /// Events from currently running operations - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; + TBF.BenchControl.ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, heatMetersTestParams != null); @@ -72,7 +106,10 @@ namespace TBF.BenchControl.TestMethods.FixedStart } } - cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + if (cBrd is ControlBoard.Legacy.ControlBoardDev) + { + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + } IList readTempPressOps = new List(); if (benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp)); @@ -115,7 +152,7 @@ namespace TBF.BenchControl.TestMethods.FixedStart while (e.Contains(Event.Busy)); /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, totalPulses)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); /// @@ -242,7 +279,7 @@ namespace TBF.BenchControl.TestMethods.FixedStart State.Create(string.Format("{0}({1}) : Start valve open", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, false, outPath)) + .AddOperation(cBrd.OpenStartValveOp()) .AddOperation(heatMetersPromptOp) .EnterState(); do { @@ -259,7 +296,7 @@ namespace TBF.BenchControl.TestMethods.FixedStart State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) + .AddOperation(cBrd.SetFlowOp(test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) .AddOperation(heatMetersPromptOp) .EnterState(); do { @@ -359,7 +396,7 @@ namespace TBF.BenchControl.TestMethods.FixedStart State.Create(string.Format("{0}({1}) : Closing the start/stop valve before the fixed start test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, true, outPath)) + .AddOperation(cBrd.CloseStartValveOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -433,11 +470,11 @@ namespace TBF.BenchControl.TestMethods.FixedStart { for (int i = 0; i < Config.Data.HeatMetersCount; i++) { - BenchControl.Elde.FixedStartRegisterReader.RegisterReader volumeRegisterReader = - sensPath.RegisterReaders[2 * i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; + BenchControl.RegisterReaders.StandingStartStop.RegisterReader volumeRegisterReader = + sensPath.RegisterReaders[2 * i] as BenchControl.RegisterReaders.StandingStartStop.RegisterReader; - BenchControl.Elde.FixedStartRegisterReader.RegisterReader energyRegisterReader = - sensPath.RegisterReaders[2 * i + 1] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; + BenchControl.RegisterReaders.StandingStartStop.RegisterReader energyRegisterReader = + sensPath.RegisterReaders[2 * i + 1] as BenchControl.RegisterReaders.StandingStartStop.RegisterReader; if (volumeRegisterReader != null) volumeRegisterReader.BeginWMState = dataEntryCmpnt.WMStartState(i); if (energyRegisterReader != null && dataEntryCmpnt is GenericDevices.IHasHeatMtrStatesForm) @@ -452,8 +489,8 @@ namespace TBF.BenchControl.TestMethods.FixedStart { GenericDevices.IRegisterReader rr = sensPath.RegisterReaders[i]; - if (rr is BenchControl.Elde.FixedStartRegisterReader.RegisterReader) - (rr as BenchControl.Elde.FixedStartRegisterReader.RegisterReader).BeginWMState = dataEntryCmpnt.WMStartState(i); + if (rr is BenchControl.RegisterReaders.StandingStartStop.RegisterReader) + (rr as BenchControl.RegisterReaders.StandingStartStop.RegisterReader).BeginWMState = dataEntryCmpnt.WMStartState(i); if (rr is BenchControl.Network.Camera.RoiForFixedStart.Roi) (rr as BenchControl.Network.Camera.RoiForFixedStart.Roi).BeginWMState = dataEntryCmpnt.WMStartState(i); @@ -497,7 +534,7 @@ namespace TBF.BenchControl.TestMethods.FixedStart State.Create(string.Format("{0}({1}) : Starting the test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Synchro, test.Qfrom, test.Qto, 2 * totalPulses)) + .AddOperation(cBrd.StartTestOp(test)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -511,7 +548,7 @@ namespace TBF.BenchControl.TestMethods.FixedStart State.Create(string.Format("{0}({1}) : Opening the start/stop valve at the beginning of the fixed start test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, false, outPath)) + .AddOperation(cBrd.OpenStartValveOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -558,8 +595,8 @@ namespace TBF.BenchControl.TestMethods.FixedStart Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime)); } - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; + RefFrequency.Val = cBrd.RefFrequency; + RefFlow.Val = cBrd.RefFlow; UpdateAllStatistics(StateMachine.Time); @@ -600,7 +637,7 @@ namespace TBF.BenchControl.TestMethods.FixedStart Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); } - while (cBrd.EtPulses(0) < totalPulses); + while (cBrd.RefPulses < totalPulses); /// Measurement loop - end test_completed: @@ -612,7 +649,7 @@ namespace TBF.BenchControl.TestMethods.FixedStart State.Create(string.Format("{0}({1}) : Closing the start/stop valve at the end of the fixed start test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, true, outPath)) + .AddOperation(cBrd.CloseStartValveOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -624,7 +661,7 @@ namespace TBF.BenchControl.TestMethods.FixedStart State.Create(string.Format("{0}({1}) : Stopping flow regulation", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(cBrd.StopFlowRegulationOp(outPath)) + .AddOperation(cBrd.StopFlowRegulationOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -639,7 +676,7 @@ namespace TBF.BenchControl.TestMethods.FixedStart TestEndTime = DateTime.Now; - int endPulses = cBrd.EtPulses(0); + int endPulses = cBrd.RefPulses; State.Create(string.Format("{0}({1}) : Stopping diverter, gate, etc.", test.Method, test.Name)) @@ -654,7 +691,7 @@ namespace TBF.BenchControl.TestMethods.FixedStart while (!e.Contains(Event.PreviousStopped)); - double flowVolume = 3.6 * LtrPerRefPulse * Convert.ToDouble(endPulses - startPulses) / cBrd.TTime; + double flowVolume = 3.6 * LtrPerRefPulse * Convert.ToDouble(endPulses - startPulses) / cBrd.TestTime; double constMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flowVolume, rangeIx); double volumeCTV = constMasterCorr * Convert.ToDouble(endPulses - startPulses); double refEnergy = Energy.Sum * volumeCTV / VolumeForEnergy.Sum; /// [J]=[J]*[l]/[l] @@ -728,11 +765,11 @@ namespace TBF.BenchControl.TestMethods.FixedStart { for (int i = 0; i < Config.Data.HeatMetersCount; i++) { - BenchControl.Elde.FixedStartRegisterReader.RegisterReader volumeRegisterReader = - sensPath.RegisterReaders[2 * i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; + BenchControl.RegisterReaders.StandingStartStop.RegisterReader volumeRegisterReader = + sensPath.RegisterReaders[2 * i] as BenchControl.RegisterReaders.StandingStartStop.RegisterReader; - BenchControl.Elde.FixedStartRegisterReader.RegisterReader energyRegisterReader = - sensPath.RegisterReaders[2 * i + 1] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; + BenchControl.RegisterReaders.StandingStartStop.RegisterReader energyRegisterReader = + sensPath.RegisterReaders[2 * i + 1] as BenchControl.RegisterReaders.StandingStartStop.RegisterReader; if (volumeRegisterReader != null) volumeRegisterReader.EndWMState = dataEntryCmpnt.WMEndState(i); if (energyRegisterReader != null && dataEntryCmpnt is GenericDevices.IHasHeatMtrStatesForm) @@ -747,8 +784,8 @@ namespace TBF.BenchControl.TestMethods.FixedStart { GenericDevices.IRegisterReader rr = sensPath.RegisterReaders[i]; - if (rr is BenchControl.Elde.FixedStartRegisterReader.RegisterReader) - (rr as BenchControl.Elde.FixedStartRegisterReader.RegisterReader).EndWMState = dataEntryCmpnt.WMEndState(i); + if (rr is BenchControl.RegisterReaders.StandingStartStop.RegisterReader) + (rr as BenchControl.RegisterReaders.StandingStartStop.RegisterReader).EndWMState = dataEntryCmpnt.WMEndState(i); if (rr is BenchControl.Network.Camera.RoiForFixedStart.Roi) (rr as BenchControl.Network.Camera.RoiForFixedStart.Roi).EndWMState = dataEntryCmpnt.WMEndState(i); diff --git a/TBF/BenchControl/TestMethods/FixedStart/HeatMeters/Component.cs b/TBF/BenchControl/TestMethods/FixedStart/HeatMeters/Component.cs index 3e7076a4f..1c80ef22d 100644 --- a/TBF/BenchControl/TestMethods/FixedStart/HeatMeters/Component.cs +++ b/TBF/BenchControl/TestMethods/FixedStart/HeatMeters/Component.cs @@ -16,16 +16,19 @@ namespace TBF.BenchControl.TestMethods.FixedStart.HeatMeters return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1)); } - readonly TestMethodCfg testMethodCfg; - public bool CanTest(MetersKind meters) { return meters == MetersKind.HeatMeter; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FixedStartSeq.CheckDeviceCaps(test, devices, out message); + } - public Component() - { - } - public Component(Generic.IComponentCfg cfg) + readonly TestMethodCfg testMethodCfg; + + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/FixedStart/Single/Component.cs b/TBF/BenchControl/TestMethods/FixedStart/Single/Component.cs index 2b07bed6a..f290382af 100644 --- a/TBF/BenchControl/TestMethods/FixedStart/Single/Component.cs +++ b/TBF/BenchControl/TestMethods/FixedStart/Single/Component.cs @@ -18,12 +18,14 @@ namespace TBF.BenchControl.TestMethods.FixedStart.Single public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FixedStartSeq.CheckDeviceCaps(test, devices, out message); + } - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { log.Debug(this.ToString()); diff --git a/TBF/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs b/TBF/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs index 1ba1c42d8..a15823f8d 100644 --- a/TBF/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs +++ b/TBF/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs @@ -17,6 +17,40 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced { private static readonly ILog log = LogManager.GetLogger(typeof(FixedStartAdvancedSeq)); + /// + /// Check capabilities of devces in the output path required for this test method + /// + /// Devices + /// true when capabilities of devices are OK + public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) + { + if (!(StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) && + !(StateMachine.ControlBoard is ControlBoard.Papouch.CBoard) && + !(StateMachine.ControlBoard is ControlBoard.New.CBoard)) + { + /// Control board does not support this method + message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); + return false; + } + + if (!(devices.FlowMeter is IFlowMeter)) + { + /// Flow meter is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_flow_meter); + return false; + } + + if (!(devices.RegulValve is GenericDevices.IRegulValve)) + { + /// Regulation valve is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_regulation_valve); + return false; + } + + message = string.Empty; + return true; + } + /// /// Flying start mass collection method sequence /// @@ -59,7 +93,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced IList e; /// Events from currently running operations - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; + TBF.BenchControl.ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; int tMass1 = 0; int tMass2 = 0; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state @@ -79,7 +113,10 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced } } - cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + if (cBrd is ControlBoard.Legacy.ControlBoardDev) + { + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + } IList readTempPressOps = new List(); if (benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp)); @@ -121,7 +158,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced while (e.Contains(Event.Busy)); /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, totalPulses)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); TestStartTime = DateTime.Now; @@ -225,7 +262,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced State.Create("FixedStartAdvanced : Setting the flow") .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) + .AddOperation(cBrd.SetFlowOp(test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -253,7 +290,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced State.Create("FixedStartAdvanced : Closing the start/stop valve before the fixed start test") .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, true, outPath)) + .AddOperation(cBrd.CloseStartValveOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -322,8 +359,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced for (int i = 0; i < Config.Data.WMsCount; i++) { - BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader = - sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; + BenchControl.RegisterReaders.StandingStartStop.RegisterReader registerReader = + sensPath.RegisterReaders[i] as BenchControl.RegisterReaders.StandingStartStop.RegisterReader; if (registerReader != null) registerReader.BeginWMState = dataEntryCmpnt.WMStartState(i); } @@ -365,7 +402,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced .AddOperation(checkUiOp) .AddOperations(readTempPressOps) .AddOperations(measureOperations) - .AddOperation(cBrd.StartMeasurementOp(outPath, (Elde.TestMethods.Diverter | Elde.TestMethods.Synchro), test.Qfrom, test.Qto, 2 * totalPulses)) + .AddOperation(cBrd.StartTestOp(test)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -378,7 +415,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced State.Create("FixedStartAdvanced : Opening the start/stop valve at the beginning of the fixed start test") .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, false, outPath)) + .AddOperation(cBrd.OpenStartValveOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -423,14 +460,14 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime)); } - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; + RefFrequency.Val = cBrd.RefFrequency; + RefFlow.Val = cBrd.RefFlow; UpdateAllStatistics(StateMachine.Time); Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); } - while (cBrd.EtPulses(0) < totalPulses); + while (cBrd.RefPulses < totalPulses); /// Measurement loop - end test_completed: @@ -440,7 +477,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced State.Create("FixedStartAdvanced : Closing the start/stop valve at the end of the fixed start test") .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, true, outPath)) + .AddOperation(cBrd.CloseStartValveOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -546,8 +583,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced for (int i = 0; i < Config.Data.WMsCount; i++) { - BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader = - sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; + BenchControl.RegisterReaders.StandingStartStop.RegisterReader registerReader = + sensPath.RegisterReaders[i] as BenchControl.RegisterReaders.StandingStartStop.RegisterReader; if (registerReader != null) registerReader.EndWMState = dataEntryCmpnt.WMEndState(i); } @@ -576,13 +613,13 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TTime; /// [s] measurement time + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total) + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = StartMass.Val; - tstRslt.MassStart = massStart; /// [kg] calculated before displaying 'End state' dialog + tstRslt.MassStart = massStart; /// [kg] calculated before displaying 'End state' dialog tstRslt.MassEndRaw = EndMass.Val; - tstRslt.MassEnd = massEnd; /// [kg] calculated before displaying 'End state' dialog + tstRslt.MassEnd = massEnd; /// [kg] calculated before displaying 'End state' dialog tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart + massOfEvaporatedWater) / tstRslt.TestTime; /// [kg/h] tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; tstRslt.Buoyancy = buoyancy; diff --git a/TBF/BenchControl/TestMethods/FixedStartAdvanced/Single/Component.cs b/TBF/BenchControl/TestMethods/FixedStartAdvanced/Single/Component.cs index ca908d37a..7c1484830 100644 --- a/TBF/BenchControl/TestMethods/FixedStartAdvanced/Single/Component.cs +++ b/TBF/BenchControl/TestMethods/FixedStartAdvanced/Single/Component.cs @@ -12,15 +12,18 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced.Single public class Component : ComponentBase, GenericDevices.ITestMethod { private static readonly ILog log = LogManager.GetLogger(typeof(Component)); - public override string ToString() { return string.Format("TestMethods.FixedStartAdvanced({0})", Cfg.ToString(1)); } + public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(1)); } public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FixedStartAdvancedSeq.CheckDeviceCaps(test, devices, out message); + } - public Component() - { - } + public Component() { } + /// public Component(Generic.IComponentCfg cfg) : base(cfg) { diff --git a/TBF/BenchControl/TestMethods/FixedStartDeferredEval/Compound/Component.cs b/TBF/BenchControl/TestMethods/FixedStartDeferredEval/Compound/Component.cs index f9a32cd39..3e8d944cf 100644 --- a/TBF/BenchControl/TestMethods/FixedStartDeferredEval/Compound/Component.cs +++ b/TBF/BenchControl/TestMethods/FixedStartDeferredEval/Compound/Component.cs @@ -18,11 +18,13 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEval.Compound public bool CanTest(MetersKind meters) { return meters == MetersKind.Combined; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FixedStartDeferredEvalSeq.CheckDeviceCaps(test, devices, out message); + } - public Component() - { - } - + public Component() { } + /// public Component(Generic.IComponentCfg cfg) : base(cfg) { diff --git a/TBF/BenchControl/TestMethods/FixedStartDeferredEval/FixedStartDeferredEvalSeq.cs b/TBF/BenchControl/TestMethods/FixedStartDeferredEval/FixedStartDeferredEvalSeq.cs index f40b6f2f6..42410beb5 100644 --- a/TBF/BenchControl/TestMethods/FixedStartDeferredEval/FixedStartDeferredEvalSeq.cs +++ b/TBF/BenchControl/TestMethods/FixedStartDeferredEval/FixedStartDeferredEvalSeq.cs @@ -18,6 +18,39 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEval { private static readonly ILog log = LogManager.GetLogger(typeof(FixedStartDeferredEvalSeq)); + /// + /// Check capabilities of devces in the output path required for this test method + /// + /// Devices + /// true when capabilities of devices are OK + public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) + { + if (!(StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) && + !(StateMachine.ControlBoard is ControlBoard.New.CBoard)) + { + /// Control board does not support this method + message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); + return false; + } + + if (!(devices.FlowMeter is IFlowMeter)) + { + /// Flow meter is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_flow_meter); + return false; + } + + if (!(devices.RegulValve is GenericDevices.IRegulValve)) + { + /// Regulation valve is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_regulation_valve); + return false; + } + + message = string.Empty; + return true; + } + /// /// Fixed start mass collection method with deferred evaluation of images /// @@ -72,7 +105,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEval IList e; /// Events from currently running operations - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; + TBF.BenchControl.ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, heatMetersTestParams != null); @@ -90,7 +123,10 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEval } } - cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + if (cBrd is ControlBoard.Legacy.ControlBoardDev) + { + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + } IList readTempPressOps = new List(); if (benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp)); @@ -133,7 +169,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEval while (e.Contains(Event.Busy)); /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, totalPulses)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); /// @@ -260,7 +296,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEval State.Create(string.Format("{0}({1}) : Start valve open", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, false, outPath)) + .AddOperation(cBrd.OpenStartValveOp()) .AddOperation(heatMetersPromptOp) .EnterState(); do { @@ -277,7 +313,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEval State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) + .AddOperation(cBrd.SetFlowOp(test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) .AddOperation(heatMetersPromptOp) .EnterState(); do { @@ -377,7 +413,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEval State.Create(string.Format("{0}({1}) : Closing the start/stop valve before the fixed start test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, true, outPath)) + .AddOperation(cBrd.CloseStartValveOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -524,7 +560,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEval State.Create(string.Format("{0}({1}) : Starting the test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Synchro, test.Qfrom, test.Qto, 2 * totalPulses)) + .AddOperation(cBrd.StartTestOp(test)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -538,7 +574,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEval State.Create(string.Format("{0}({1}) : Closing the start/stop valve at the end of the fixed start test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, false, outPath)) + .AddOperation(cBrd.OpenStartValveOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -585,8 +621,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEval Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime)); } - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; + RefFrequency.Val = cBrd.RefFrequency; + RefFlow.Val = cBrd.RefFlow; UpdateAllStatistics(StateMachine.Time); @@ -627,7 +663,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEval Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); } - while (cBrd.EtPulses(0) < totalPulses); + while (cBrd.RefPulses < totalPulses); /// Measurement loop - end test_completed: @@ -637,7 +673,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEval State.Create(string.Format("{0}({1}) : Closing the start/stop valve at the end of the fixed start test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, true, outPath)) + .AddOperation(cBrd.CloseStartValveOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -664,9 +700,9 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEval } while (!e.Contains(Event.TimerExpired)); } - - int endPulses = cBrd.EtPulses(0); + + int endPulses = cBrd.RefPulses; switchTimeEnd = 0.001f * cBrd.ValveOpenCloseTime; log.WarnFormat("Start valve switch time on test end = {0} ms", cBrd.ValveOpenCloseTime); @@ -683,7 +719,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEval while (!e.Contains(Event.PreviousStopped)); - double flowVolume = 3.6 * LtrPerRefPulse * Convert.ToDouble(endPulses - startPulses) / cBrd.TTime; + double flowVolume = 3.6 * LtrPerRefPulse * Convert.ToDouble(endPulses - startPulses) / cBrd.TestTime; double constMasterCorr = outPath.FlowMeter.LtrPerPulseCorrected(flowVolume, rangeIx); double volumeCTV = constMasterCorr * Convert.ToDouble(endPulses - startPulses); if (debugLevel == Config.Entities.DebugMode.Simulate) volumeCTV = test.Volume; diff --git a/TBF/BenchControl/TestMethods/FixedStartDeferredEval/HeatMeters/Component.cs b/TBF/BenchControl/TestMethods/FixedStartDeferredEval/HeatMeters/Component.cs index 1a29d8a2d..1a4c6effe 100644 --- a/TBF/BenchControl/TestMethods/FixedStartDeferredEval/HeatMeters/Component.cs +++ b/TBF/BenchControl/TestMethods/FixedStartDeferredEval/HeatMeters/Component.cs @@ -16,16 +16,19 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEval.HeatMeters return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1)); } - readonly TestMethodCfg testMethodCfg; - public bool CanTest(MetersKind meters) { return meters == MetersKind.HeatMeter; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FixedStartDeferredEvalSeq.CheckDeviceCaps(test, devices, out message); + } - public Component() - { - } - public Component(Generic.IComponentCfg cfg) + readonly TestMethodCfg testMethodCfg; + + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/FixedStartDeferredEval/Single/Component.cs b/TBF/BenchControl/TestMethods/FixedStartDeferredEval/Single/Component.cs index 6b92e4722..ebd79c21a 100644 --- a/TBF/BenchControl/TestMethods/FixedStartDeferredEval/Single/Component.cs +++ b/TBF/BenchControl/TestMethods/FixedStartDeferredEval/Single/Component.cs @@ -18,12 +18,14 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEval.Single public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FixedStartDeferredEvalSeq.CheckDeviceCaps(test, devices, out message); + } - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { log.Debug(this.ToString()); diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/Compound/Component.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/Compound/Component.cs index de591db61..300dea0f3 100644 --- a/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/Compound/Component.cs +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/Compound/Component.cs @@ -18,12 +18,14 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollDeferredEval.Compound public bool CanTest(MetersKind meters) { return meters == MetersKind.Combined; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FixedStartMassCollDeferredEvalSeq.CheckDeviceCaps(test, devices, out message); + } - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { log.Debug(this.ToString()); diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/FixedStartMassCollDeferredEvalSeq.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/FixedStartMassCollDeferredEvalSeq.cs index 7ba1ce705..ab36c9660 100644 --- a/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/FixedStartMassCollDeferredEvalSeq.cs +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/FixedStartMassCollDeferredEvalSeq.cs @@ -18,6 +18,53 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollDeferredEval { private static readonly ILog log = LogManager.GetLogger(typeof(FixedStartMassCollDeferredEvalSeq)); + /// + /// Check capabilities of devces in the output path required for this test method + /// + /// Devices + /// true when capabilities of devices are OK + public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) + { + if (!(StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) && + !(StateMachine.ControlBoard is ControlBoard.New.CBoard)) + { + /// Control board does not support this method + message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); + return false; + } + + if (!(devices.Scale is IScale)) + { + /// Scale is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_scale); + return false; + } + + if (test.Volume > devices.Scale.Capacity * Constants.TankFullFactor) + { + /// Scale capacity is not sufficient + message = string.Format("{0}: {1}", test.Name, Strings.Test_volume_exceeds_the_scale_capacity); + return false; + } + + if (!(devices.FlowMeter is IFlowMeter)) + { + /// Flow meter is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_flow_meter); + return false; + } + + if (!(devices.RegulValve is GenericDevices.IRegulValve)) + { + /// Regulation valve is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_regulation_valve); + return false; + } + + message = string.Empty; + return true; + } + /// /// Fixed start mass collection method with deferred evaluation of images /// @@ -78,15 +125,9 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollDeferredEval new List { Event.ConfigurationError }; } - if (test.Volume >= scale.Capacity * Constants.TankFullFactor) - { - Bridge.OnError(this, Strings.Test_volume_exceeds_the_scale_capacity); - new List { Event.ConfigurationError }; - } - IList e; /// Events from currently running operations - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; + TBF.BenchControl.ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; int tMass1 = 0; int tMass2 = 0; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state @@ -106,7 +147,10 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollDeferredEval } } - cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + if (cBrd is ControlBoard.Legacy.ControlBoardDev) + { + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + } IList readTempPressOps = new List(); if (benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp)); @@ -149,7 +193,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollDeferredEval while (e.Contains(Event.Busy)); /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, totalPulses)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); /// @@ -333,7 +377,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollDeferredEval State.Create(string.Format("{0}({1}) : Start valve open", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, false, outPath)) + .AddOperation(cBrd.OpenStartValveOp()) .AddOperation(heatMetersPromptOp) .EnterState(); do { @@ -350,7 +394,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollDeferredEval State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) + .AddOperation(cBrd.SetFlowOp(test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) .AddOperation(heatMetersPromptOp) .EnterState(); do { @@ -450,7 +494,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollDeferredEval State.Create(string.Format("{0}({1}) : Closing the start/stop valve before the fixed start test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, true, outPath)) + .AddOperation(cBrd.CloseStartValveOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -627,8 +671,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollDeferredEval State.Create(string.Format("{0}({1}) : Starting the test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(cBrd.StartMeasurementOp(outPath, (Elde.TestMethods.Diverter | Elde.TestMethods.Synchro), - test.Qfrom, test.Qto, (2 * totalPulses))) + .AddOperation(cBrd.StartTestOp(test)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -642,7 +685,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollDeferredEval State.Create(string.Format("{0}({1}) : Closing the start/stop valve at the end of the fixed start test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, false, outPath)) + .AddOperation(cBrd.OpenStartValveOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -689,8 +732,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollDeferredEval Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime)); } - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; + RefFrequency.Val = cBrd.RefFrequency; + RefFlow.Val = cBrd.RefFlow; UpdateAllStatistics(StateMachine.Time); @@ -731,7 +774,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollDeferredEval Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); } - while (cBrd.EtPulses(0) < totalPulses); + while (cBrd.RefPulses < totalPulses); /// Measurement loop - end test_completed: @@ -743,7 +786,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollDeferredEval State.Create(string.Format("{0}({1}) : Closing the start/stop valve at the end of the fixed start test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, true, outPath)) + .AddOperation(cBrd.CloseStartValveOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -939,7 +982,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollDeferredEval tstRslt.FlowSetTime = flowSetTime; tstRslt.TestTime = Math.Max(1.0, EndTime - StartTime); /// [s] measurement time, at least 1 to prevent division by zero tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total) + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = StartMass.Val; tstRslt.MassStart = massStart; tstRslt.MassEndRaw = EndMass.Val; diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/HeatMeters/Component.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/HeatMeters/Component.cs index 23833b207..c6506de64 100644 --- a/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/HeatMeters/Component.cs +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/HeatMeters/Component.cs @@ -16,16 +16,19 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollDeferredEval.HeatMeters return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1)); } - readonly TestMethodCfg testMethodCfg; - public bool CanTest(MetersKind meters) { return meters == MetersKind.HeatMeter; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FixedStartMassCollDeferredEvalSeq.CheckDeviceCaps(test, devices, out message); + } - public Component() - { - } - public Component(Generic.IComponentCfg cfg) + readonly TestMethodCfg testMethodCfg; + + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/Single/Component.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/Single/Component.cs index 557caded8..4637138ae 100644 --- a/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/Single/Component.cs +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/Single/Component.cs @@ -18,12 +18,14 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollDeferredEval.Single public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FixedStartMassCollDeferredEvalSeq.CheckDeviceCaps(test, devices, out message); + } - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { log.Debug(this.ToString()); diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollection/Compound/Component.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollection/Compound/Component.cs index 6ead67ea3..5b1ee7cb8 100644 --- a/TBF/BenchControl/TestMethods/FixedStartMassCollection/Compound/Component.cs +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollection/Compound/Component.cs @@ -18,12 +18,14 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection.Compound public bool CanTest(MetersKind meters) { return meters == MetersKind.Combined; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FixedStartMassCollectionSeq.CheckDeviceCaps(test, devices, out message); + } - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { log.Debug(this.ToString()); diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs index 71376585b..7f6ae4adf 100644 --- a/TBF/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs @@ -15,6 +15,53 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection { private static readonly ILog log = LogManager.GetLogger(typeof(FixedStartMassCollectionSeq)); + /// + /// Check capabilities of devces in the output path required for this test method + /// + /// Devices + /// true when capabilities of devices are OK + public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) + { + if (!(StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) && + !(StateMachine.ControlBoard is ControlBoard.New.CBoard)) + { + /// Control board does not support this method + message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); + return false; + } + + if (!(devices.Scale is IScale)) + { + /// Scale is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_scale); + return false; + } + + if (test.Volume > devices.Scale.Capacity * Constants.TankFullFactor) + { + /// Scale capacity is not sufficient + message = string.Format("{0}: {1}", test.Name, Strings.Test_volume_exceeds_the_scale_capacity); + return false; + } + + if (!(devices.FlowMeter is IFlowMeter)) + { + /// Flow meter is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_flow_meter); + return false; + } + + if (!(devices.RegulValve is GenericDevices.IRegulValve)) + { + /// Regulation valve is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_regulation_valve); + return false; + } + + message = string.Empty; + return true; + } + /// /// Fixed start mass collection method sequence /// @@ -31,12 +78,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection HeatMeters.TestParams heatMetersTestParams, Config.Entities.DebugMode debugLevel) { - IScale scale = outPath.Scale as IScale; - if (scale == null) - { - Bridge.OnError(this, Strings.Missing_a_scale); - new List { Event.ConfigurationError }; - } + ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; + IScale scale = cBrd.Devices.Scale as IScale; int rangeIx = 0; /// Default range, used for non-Elde flowmeters if (outPath.FlowMeter is Elde.FlowMeter.FlowMeter) @@ -59,15 +102,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection } } - if (test.Volume >= scale.Capacity * Constants.TankFullFactor) - { - Bridge.OnError(this, Strings.Test_volume_exceeds_the_scale_capacity); - new List { Event.ConfigurationError }; - } - - IList e; /// Events from currently running operations - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; int tMass1 = 0; int tMass2 = 0; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state @@ -87,7 +122,10 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection } } - cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + if (cBrd is ControlBoard.Legacy.ControlBoardDev) + { + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + } IList readTempPressOps = new List(); if (benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp)); @@ -130,7 +168,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection while (e.Contains(Event.Busy)); /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, totalPulses)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); /// @@ -191,7 +229,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection .AddOperations(readTempPressOps) .AddOperation(scale.ReadMassOp(ref Mass)) .AddOperation(heatMetersPromptOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, scale.DrainValve)) + .AddOperation(cBrd.SetValvesOp(null, scale.DrainValve)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -256,7 +294,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection State.Create(string.Format("{0}({1}) : Opening the stop backflow valve", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(benchPath.StopBFValve, null)) + .AddOperation(cBrd.SetValvesOp(benchPath.StopBFValve, null)) .AddOperation(heatMetersPromptOp) .EnterState(); do { @@ -300,7 +338,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection State.Create(string.Format("{0}({1}) : Pump on", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(inPath.Pump, null)) + .AddOperation(cBrd.SetValvesOp(inPath.Pump, null)) .AddOperation(heatMetersPromptOp) .EnterState(); do { @@ -315,7 +353,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection State.Create(string.Format("{0}({1}) : Start valve open", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, false, outPath)) + .AddOperation(cBrd.OpenStartValveOp()) .AddOperation(heatMetersPromptOp) .EnterState(); do { @@ -332,7 +370,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) + .AddOperation(cBrd.SetFlowOp(test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) .AddOperation(heatMetersPromptOp) .EnterState(); do { @@ -432,7 +470,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection State.Create(string.Format("{0}({1}) : Closing the start/stop valve before the fixed start test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, true, outPath)) + .AddOperation(cBrd.CloseStartValveOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -553,11 +591,11 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection { for (int i = 0; i < Config.Data.HeatMetersCount; i++) { - BenchControl.Elde.FixedStartRegisterReader.RegisterReader volumeRegisterReader = - sensPath.RegisterReaders[2 * i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; + BenchControl.RegisterReaders.StandingStartStop.RegisterReader volumeRegisterReader = + sensPath.RegisterReaders[2 * i] as BenchControl.RegisterReaders.StandingStartStop.RegisterReader; - BenchControl.Elde.FixedStartRegisterReader.RegisterReader energyRegisterReader = - sensPath.RegisterReaders[2 * i + 1] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; + BenchControl.RegisterReaders.StandingStartStop.RegisterReader energyRegisterReader = + sensPath.RegisterReaders[2 * i + 1] as BenchControl.RegisterReaders.StandingStartStop.RegisterReader; if (volumeRegisterReader != null) volumeRegisterReader.BeginWMState = dataEntryCmpnt.WMStartState(i); if (energyRegisterReader != null && dataEntryCmpnt is GenericDevices.IHasHeatMtrStatesForm) @@ -572,8 +610,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection { GenericDevices.IRegisterReader rr = sensPath.RegisterReaders[i]; - if (rr is BenchControl.Elde.FixedStartRegisterReader.RegisterReader) - (rr as BenchControl.Elde.FixedStartRegisterReader.RegisterReader).BeginWMState = dataEntryCmpnt.WMStartState(i); + if (rr is BenchControl.RegisterReaders.StandingStartStop.RegisterReader) + (rr as BenchControl.RegisterReaders.StandingStartStop.RegisterReader).BeginWMState = dataEntryCmpnt.WMStartState(i); if (rr is BenchControl.Network.Camera.RoiForFixedStart.Roi) (rr as BenchControl.Network.Camera.RoiForFixedStart.Roi).BeginWMState = dataEntryCmpnt.WMStartState(i); @@ -617,8 +655,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection State.Create(string.Format("{0}({1}) : Starting the test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(cBrd.StartMeasurementOp(outPath, (Elde.TestMethods.Diverter | Elde.TestMethods.FixedStart), - test.Qfrom, test.Qto, 2 * totalPulses)) + .AddOperation(cBrd.StartTestOp(test)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -632,7 +669,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection State.Create(string.Format("{0}({1}) : Opening the start/stop valve at the beginning of the fixed start test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, false, outPath)) + .AddOperation(cBrd.OpenStartValveOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -679,8 +716,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime)); } - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; + RefFrequency.Val = cBrd.RefFrequency; + RefFlow.Val = cBrd.RefFlow; UpdateAllStatistics(StateMachine.Time); @@ -721,7 +758,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); } - while (cBrd.EtPulses(0) < totalPulses); + while (cBrd.RefPulses < totalPulses); /// Measurement loop - end test_completed: @@ -733,7 +770,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection State.Create(string.Format("{0}({1}) : Closing the start/stop valve at the end of the fixed start test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, true, outPath)) + .AddOperation(cBrd.CloseStartValveOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -745,7 +782,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection State.Create(string.Format("{0}({1}) : Stopping flow regulation", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(cBrd.StopFlowRegulationOp(outPath)) + .AddOperation(cBrd.StopFlowRegulationOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -806,7 +843,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection { State.Create(string.Format("{0}({1}) : Open the drain valve", test.Method, test.Name)) .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(scale.DrainValve, null)) + .AddOperation(cBrd.SetValvesOp(scale.DrainValve, null)) .AddOperations(readTempPressOps) .EnterState(); do @@ -907,11 +944,11 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection { for (int i = 0; i < Config.Data.HeatMetersCount; i++) { - BenchControl.Elde.FixedStartRegisterReader.RegisterReader volumeRegisterReader = - sensPath.RegisterReaders[2 * i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; + BenchControl.RegisterReaders.StandingStartStop.RegisterReader volumeRegisterReader = + sensPath.RegisterReaders[2 * i] as BenchControl.RegisterReaders.StandingStartStop.RegisterReader; - BenchControl.Elde.FixedStartRegisterReader.RegisterReader energyRegisterReader = - sensPath.RegisterReaders[2 * i + 1] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; + BenchControl.RegisterReaders.StandingStartStop.RegisterReader energyRegisterReader = + sensPath.RegisterReaders[2 * i + 1] as BenchControl.RegisterReaders.StandingStartStop.RegisterReader; if (volumeRegisterReader != null) volumeRegisterReader.EndWMState = dataEntryCmpnt.WMEndState(i); if (energyRegisterReader != null && dataEntryCmpnt is GenericDevices.IHasHeatMtrStatesForm) @@ -926,8 +963,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection { GenericDevices.IRegisterReader rr = sensPath.RegisterReaders[i]; - if (rr is BenchControl.Elde.FixedStartRegisterReader.RegisterReader) - (rr as BenchControl.Elde.FixedStartRegisterReader.RegisterReader).EndWMState = dataEntryCmpnt.WMEndState(i); + if (rr is BenchControl.RegisterReaders.StandingStartStop.RegisterReader) + (rr as BenchControl.RegisterReaders.StandingStartStop.RegisterReader).EndWMState = dataEntryCmpnt.WMEndState(i); if (rr is BenchControl.Network.Camera.RoiForFixedStart.Roi) (rr as BenchControl.Network.Camera.RoiForFixedStart.Roi).EndWMState = dataEntryCmpnt.WMEndState(i); @@ -986,7 +1023,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection tstRslt.FlowSetTime = flowSetTime; tstRslt.TestTime = Math.Max(1.0, EndTime - StartTime); /// [s] measurement time, at least 1 to prevent division by zero tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total) + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = StartMass.Val; tstRslt.MassStart = massStart; tstRslt.MassEndRaw = EndMass.Val; diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/Component.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/Component.cs index 26d37bdc8..b516a900b 100644 --- a/TBF/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/Component.cs +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/Component.cs @@ -16,16 +16,19 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection.HeatMeters return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1)); } - readonly TestMethodCfg testMethodCfg; - public bool CanTest(MetersKind meters) { return meters == MetersKind.HeatMeter; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FixedStartMassCollectionSeq.CheckDeviceCaps(test, devices, out message); + } - public Component() - { - } - public Component(Generic.IComponentCfg cfg) + readonly TestMethodCfg testMethodCfg; + + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollection/Single/Component.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollection/Single/Component.cs index f6703beea..290f5a2c7 100644 --- a/TBF/BenchControl/TestMethods/FixedStartMassCollection/Single/Component.cs +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollection/Single/Component.cs @@ -18,12 +18,14 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection.Single public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FixedStartMassCollectionSeq.CheckDeviceCaps(test, devices, out message); + } - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { log.Debug(this.ToString()); diff --git a/TBF/BenchControl/TestMethods/FixedStartTankCollection/Compound/Component.cs b/TBF/BenchControl/TestMethods/FixedStartTankCollection/Compound/Component.cs index 3491bbfc7..7b9f2a7c2 100644 --- a/TBF/BenchControl/TestMethods/FixedStartTankCollection/Compound/Component.cs +++ b/TBF/BenchControl/TestMethods/FixedStartTankCollection/Compound/Component.cs @@ -18,14 +18,17 @@ namespace TBF.BenchControl.TestMethods.FixedStartTankCollection.Compound public bool CanTest(MetersKind meters) { return meters == MetersKind.Combined; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FixedStartTankCollectionSeq.CheckDeviceCaps(test, devices, out message); + } + readonly TestMethodCfg testMethodCfg; - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/FixedStartTankCollection/FixedStartTankCollectionSeq.cs b/TBF/BenchControl/TestMethods/FixedStartTankCollection/FixedStartTankCollectionSeq.cs index 9b0a17ef8..908f71d41 100644 --- a/TBF/BenchControl/TestMethods/FixedStartTankCollection/FixedStartTankCollectionSeq.cs +++ b/TBF/BenchControl/TestMethods/FixedStartTankCollection/FixedStartTankCollectionSeq.cs @@ -16,6 +16,53 @@ namespace TBF.BenchControl.TestMethods.FixedStartTankCollection { private static readonly ILog log = LogManager.GetLogger(typeof(FixedStartTankCollectionSeq)); + /// + /// Check capabilities of devces in the output path required for this test method + /// + /// Devices + /// true when capabilities of devices are OK + public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) + { + if (!(StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) && + !(StateMachine.ControlBoard is ControlBoard.New.CBoard)) + { + /// Control board does not support this method + message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); + return false; + } + + if (!(devices.Scale is IVolumeMeter)) + { + /// Volume meter (tank with a level meter) is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_volume_meter); + return false; + } + + if (test.Volume > devices.Scale.Capacity * Constants.TankFullFactor) + { + /// Volume meter capacity is not sufficient + message = string.Format("{0}: {1}", test.Name, Strings.Test_volume_exceeds_the_scale_capacity); + return false; + } + + if (!(devices.FlowMeter is IFlowMeter)) + { + /// Flow meter is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_flow_meter); + return false; + } + + if (!(devices.RegulValve is GenericDevices.IRegulValve)) + { + /// Regulation valve is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_regulation_valve); + return false; + } + + message = string.Empty; + return true; + } + /// /// Fixed start mass collection method sequence /// @@ -61,15 +108,9 @@ namespace TBF.BenchControl.TestMethods.FixedStartTankCollection } } - if (test.Volume >= outPath.Scale.Capacity * Constants.TankFullFactor) - { - Bridge.OnError(this, Strings.Test_volume_exceeds_the_scale_capacity); - new List { Event.ConfigurationError }; - } - IList e; /// Events from currently running operations - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; + TBF.BenchControl.ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false); @@ -87,7 +128,10 @@ namespace TBF.BenchControl.TestMethods.FixedStartTankCollection } } - cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + if (cBrd is ControlBoard.Legacy.ControlBoardDev) + { + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + } IList readTempPressOps = new List(); if (benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp)); @@ -131,7 +175,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartTankCollection while (e.Contains(Event.Busy)); /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, totalPulses)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); @@ -254,7 +298,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartTankCollection State.Create(string.Format("{0}({1}) : Start valve open", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, false, outPath)) + .AddOperation(cBrd.OpenStartValveOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -270,7 +314,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartTankCollection State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) + .AddOperation(cBrd.SetFlowOp(test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -325,7 +369,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartTankCollection State.Create(string.Format("{0}({1}) : Closing the start/stop valve before the fixed start test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, true, outPath)) + .AddOperation(cBrd.CloseStartValveOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -397,8 +441,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartTankCollection { GenericDevices.IRegisterReader rr = sensPath.RegisterReaders[i]; - if (rr is BenchControl.Elde.FixedStartRegisterReader.RegisterReader) - (rr as BenchControl.Elde.FixedStartRegisterReader.RegisterReader).BeginWMState = dataEntryCmpnt.WMStartState(i); + if (rr is BenchControl.RegisterReaders.StandingStartStop.RegisterReader) + (rr as BenchControl.RegisterReaders.StandingStartStop.RegisterReader).BeginWMState = dataEntryCmpnt.WMStartState(i); if (rr is BenchControl.Network.Camera.RoiForFixedStart.Roi) (rr as BenchControl.Network.Camera.RoiForFixedStart.Roi).BeginWMState = dataEntryCmpnt.WMStartState(i); @@ -442,7 +486,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartTankCollection State.Create(string.Format("{0}({1}) : Starting the test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(cBrd.StartMeasurementOp(outPath, (Elde.TestMethods.Diverter | Elde.TestMethods.Synchro), test.Qfrom, test.Qto, (totalPulses * 5 / 4))) + .AddOperation(cBrd.StartTestOp(test)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -456,7 +500,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartTankCollection State.Create(string.Format("{0}({1}) : Opening the start/stop valve at the beginning of the fixed start test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, false, outPath)) + .AddOperation(cBrd.OpenStartValveOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -503,8 +547,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartTankCollection Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime)); } - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; + RefFrequency.Val = cBrd.RefFrequency; + RefFlow.Val = cBrd.RefFlow; UpdateAllStatistics(StateMachine.Time); @@ -526,7 +570,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartTankCollection Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); } - while (cBrd.EtPulses(0) < totalPulses); + while (cBrd.RefPulses < totalPulses); /// Measurement loop - end test_completed: @@ -538,7 +582,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartTankCollection State.Create(string.Format("{0}({1}) : Closing the start/stop valve at the end of the fixed start test", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, true, outPath)) + .AddOperation(cBrd.CloseStartValveOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -657,8 +701,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartTankCollection { GenericDevices.IRegisterReader rr = sensPath.RegisterReaders[i]; - if (rr is BenchControl.Elde.FixedStartRegisterReader.RegisterReader) - (rr as BenchControl.Elde.FixedStartRegisterReader.RegisterReader).EndWMState = dataEntryCmpnt.WMEndState(i); + if (rr is BenchControl.RegisterReaders.StandingStartStop.RegisterReader) + (rr as BenchControl.RegisterReaders.StandingStartStop.RegisterReader).EndWMState = dataEntryCmpnt.WMEndState(i); if (rr is BenchControl.Network.Camera.RoiForFixedStart.Roi) (rr as BenchControl.Network.Camera.RoiForFixedStart.Roi).EndWMState = dataEntryCmpnt.WMEndState(i); @@ -716,8 +760,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartTankCollection tstRslt.FlowSetTime = flowSetTime; tstRslt.TestTime = Math.Max(1.0, EndTime - StartTime); /// [s] measurement time, at least 1 to prevent division by zero - - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total) + + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = 0; tstRslt.MassStart = 0; tstRslt.MassEndRaw = 0; diff --git a/TBF/BenchControl/TestMethods/FixedStartTankCollection/Single/Component.cs b/TBF/BenchControl/TestMethods/FixedStartTankCollection/Single/Component.cs index 42a595afd..7b5b31acb 100644 --- a/TBF/BenchControl/TestMethods/FixedStartTankCollection/Single/Component.cs +++ b/TBF/BenchControl/TestMethods/FixedStartTankCollection/Single/Component.cs @@ -18,14 +18,17 @@ namespace TBF.BenchControl.TestMethods.FixedStartTankCollection.Single public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FixedStartTankCollectionSeq.CheckDeviceCaps(test, devices, out message); + } + readonly TestMethodCfg testMethodCfg; - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/FlyingStart/Compound/Component.cs b/TBF/BenchControl/TestMethods/FlyingStart/Compound/Component.cs index 443e9afd8..6008339cc 100644 --- a/TBF/BenchControl/TestMethods/FlyingStart/Compound/Component.cs +++ b/TBF/BenchControl/TestMethods/FlyingStart/Compound/Component.cs @@ -18,14 +18,17 @@ namespace TBF.BenchControl.TestMethods.FlyingStart.Compound public bool CanTest(MetersKind meters) { return meters == MetersKind.Combined; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FlyingStartSeq.CheckDeviceCaps(test, devices, out message); + } - readonly TestMethodCfg testMethodCfg; + + readonly TestMethodCfg testMethodCfg; - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs b/TBF/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs index 05137d16e..787338f60 100644 --- a/TBF/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs +++ b/TBF/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs @@ -16,6 +16,39 @@ namespace TBF.BenchControl.TestMethods.FlyingStart { private static readonly ILog log = LogManager.GetLogger(typeof(FlyingStartSeq)); + /// + /// Check capabilities of devces in the output path required for this test method + /// + /// Devices + /// true when capabilities of devices are OK + public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) + { + if (!(StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) && + !(StateMachine.ControlBoard is ControlBoard.New.CBoard)) + { + /// Control board does not support this method + message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); + return false; + } + + if (!(devices.FlowMeter is TBF.BenchControl.GenericDevices.IFlowMeter)) + { + /// Flow meter is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_flow_meter); + return false; + } + + if (!(devices.RegulValve is GenericDevices.IRegulValve)) + { + /// Regulation valve is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_regulation_valve); + return false; + } + + message = string.Empty; + return true; + } + /// /// Flying start mass collection method sequence /// @@ -36,6 +69,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart return Simulate(test, repetitionNr, isLastRepetition, compoundTestParams, heatMetersTestParams, debugLevel); } + ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; int rangeIx = 0; /// Default range, used for non-Elde flowmeters if (outPath.FlowMeter is Elde.FlowMeter.FlowMeter) @@ -61,30 +95,32 @@ namespace TBF.BenchControl.TestMethods.FlyingStart IList e; /// Events from currently running operations Event retVal = Event.Done; - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, heatMetersTestParams != null); - int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - if (sensPath != null && sensPath.RegisterReaders != null) + if (cBrd is ControlBoard.Legacy.ControlBoardDev) { - foreach (var rr in sensPath.RegisterReaders) + int[] filters = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + + if (sensPath != null && sensPath.RegisterReaders != null) { - TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; - if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) + foreach (var rr in sensPath.RegisterReaders) { - filters[eldeRR.Position - 1] = eldeRR.Filter; + TBF.BenchControl.Elde.RegisterReader.RegisterReader eldeRR = rr as TBF.BenchControl.Elde.RegisterReader.RegisterReader; + if ((eldeRR != null) && (eldeRR.Position >= 1) && (eldeRR.Position <= 8)) + { + filters[eldeRR.Position - 1] = eldeRR.Filter; + } } } - } - cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + } IList readTempPressOps = new List(); if (benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp)); if (benchPath.TempMtrDown != null) readTempPressOps.Add(benchPath.TempMtrDown.ReadTempOp(ref TempDown)); - if (outPath.TempDiv != null) readTempPressOps.Add(outPath.TempDiv.ReadTempOp(ref TempDiv)); if (benchPath.PressMtrUp != null) readTempPressOps.Add(benchPath.PressMtrUp.ReadPressureOp(ref PressUp)); if (benchPath.PressMtrDown != null) readTempPressOps.Add(benchPath.PressMtrDown.ReadPressureOp(ref PressDown)); if (benchPath.PressMtrDelta != null) readTempPressOps.Add(benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta)); @@ -111,7 +147,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart while (e.Contains(Event.Busy)); /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, totalPulses)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); TestStartTime = DateTime.Now; @@ -174,7 +210,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart State.Create(string.Format("{0}({1}) : Opening the stop backflow valve", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(benchPath.StopBFValve, null)) + .AddOperation(cBrd.SetValvesOp(benchPath.StopBFValve, null)) .AddOperation(heatMetersPromptOp) .EnterState(); do { @@ -214,7 +250,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) + .AddOperation(cBrd.SetFlowOp(test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) .AddOperation(heatMetersPromptOp) .EnterState(); do { @@ -352,7 +388,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart .AddOperation(checkUiOp) .AddOperations(readTempPressOps) .AddOperations(measureOperations) - .AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Synchro, test.Qfrom, test.Qto, totalPulses)) + .AddOperation(cBrd.StartTestOp(test)) .AddOperation(processDataLoggingOp) .EnterState(); do { @@ -409,8 +445,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStart } //------------------------------------------------ - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; + RefFrequency.Val = cBrd.RefFrequency; + RefFlow.Val = cBrd.RefFlow; UpdateAllStatistics(StateMachine.Time); @@ -470,8 +506,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStart tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TTime; /// [s] measurement time - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total) + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = 0; tstRslt.MassStart = 0; tstRslt.MassEndRaw = 0; @@ -655,7 +691,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart if (regReader.WMPulses >= 1) { /// Normal measurement - meterRslt.TestTime = cBrd.ImpulseTime(regReader.Position); + meterRslt.TestTime = cBrd.TestTimeWM(regReader.Position); meterRslt.VolumeRef = meterRslt.PulsesMaster * tstRslt.ConstMaster; /// liter } else @@ -720,7 +756,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart State.Create(string.Format("{0}({1}) : Stopping flow regulation", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(cBrd.StopFlowRegulationOp(outPath)) + .AddOperation(cBrd.StopFlowRegulationOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); diff --git a/TBF/BenchControl/TestMethods/FlyingStart/HeatMeters/Component.cs b/TBF/BenchControl/TestMethods/FlyingStart/HeatMeters/Component.cs index caa955d87..48bfce609 100644 --- a/TBF/BenchControl/TestMethods/FlyingStart/HeatMeters/Component.cs +++ b/TBF/BenchControl/TestMethods/FlyingStart/HeatMeters/Component.cs @@ -18,14 +18,17 @@ namespace TBF.BenchControl.TestMethods.FlyingStart.HeatMeters public bool CanTest(MetersKind meters) { return meters == MetersKind.HeatMeter; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FlyingStartSeq.CheckDeviceCaps(test, devices, out message); + } - readonly TestMethodCfg testMethodCfg; + + readonly TestMethodCfg testMethodCfg; - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/FlyingStart/Single/Component.cs b/TBF/BenchControl/TestMethods/FlyingStart/Single/Component.cs index 83dbc9bd2..7f4e669d9 100644 --- a/TBF/BenchControl/TestMethods/FlyingStart/Single/Component.cs +++ b/TBF/BenchControl/TestMethods/FlyingStart/Single/Component.cs @@ -18,12 +18,14 @@ namespace TBF.BenchControl.TestMethods.FlyingStart.Single public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FlyingStartSeq.CheckDeviceCaps(test, devices, out message); + } - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { log.Debug(this.ToString()); diff --git a/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/Component.cs b/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/Component.cs index 594b625fd..10483f61e 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/Component.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/Component.cs @@ -18,14 +18,17 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl.Compoun public bool CanTest(MetersKind meters) { return meters == MetersKind.Combined; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FlyingStartFirstRepetWithMassCollSeq.CheckDeviceCaps(test, devices, out message); + } - readonly TestMethodCfg testMethodCfg; + + readonly TestMethodCfg testMethodCfg; - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/FlyingStartFirstRepetWithMassCollSeq.cs b/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/FlyingStartFirstRepetWithMassCollSeq.cs index 4f19c90c0..e30de316e 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/FlyingStartFirstRepetWithMassCollSeq.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/FlyingStartFirstRepetWithMassCollSeq.cs @@ -17,6 +17,60 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl { private static readonly ILog log = LogManager.GetLogger(typeof(FlyingStartFirstRepetWithMassCollSeq)); + /// + /// Check capabilities of devces in the output path required for this test method + /// + /// Devices + /// true when capabilities of devices are OK + public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) + { + if (!(StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) && + !(StateMachine.ControlBoard is ControlBoard.New.CBoard)) + { + /// Control board does not support this method + message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); + return false; + } + + if (!(devices.Scale is IScale)) + { + /// Scale is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_scale); + return false; + } + + if (test.Volume > devices.Scale.Capacity * Constants.TankFullFactor) + { + /// Scale capacity is not sufficient + message = string.Format("{0}: {1}", test.Name, Strings.Test_volume_exceeds_the_scale_capacity); + return false; + } + + if (!(devices.Diverter is IDiverter)) + { + /// Scale is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_diverter); + return false; + } + + if (!(devices.FlowMeter is IFlowMeter)) + { + /// Flow meter is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_flow_meter); + return false; + } + + if (!(devices.RegulValve is GenericDevices.IRegulValve)) + { + /// Regulation valve is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_regulation_valve); + return false; + } + + message = string.Empty; + return true; + } + /// /// Flying start mass collection method sequence /// @@ -67,16 +121,10 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl } } - if (test.Volume > scale.Capacity * Constants.TankFullFactor) - { - Bridge.OnError(this, Strings.Test_volume_exceeds_the_scale_capacity); - new List { Event.ConfigurationError }; - } - IList e; /// Events from currently running operations Event retVal = Event.Done; - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; + TBF.BenchControl.ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; int tMass1 = 0; int tMass2 = 0; checkUiOp = new Operations.CheckUIOp(true); @@ -96,7 +144,10 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl } } - cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + if (cBrd is ControlBoard.Legacy.ControlBoardDev) + { + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + } IList readTempPressOps = new List(); if (benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp)); @@ -134,7 +185,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl while (e.Contains(Event.Busy)); /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, totalPulses)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); TestStartTime = DateTime.Now; @@ -299,7 +350,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) + .AddOperation(cBrd.SetFlowOp(test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) .AddOperation(heatMetersPromptOp) .EnterState(); do { @@ -525,9 +576,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl .AddOperations(readTempPressOps) .AddOperations(measureOperations) .AddOperation(processDataLoggingOp) - .AddOperation(cBrd.StartMeasurementOp(outPath, - (repetitionNr == 1) ? (Elde.TestMethods.Diverter | Elde.TestMethods.Synchro) : Elde.TestMethods.Synchro, - test.Qfrom, test.Qto, totalPulses)) + .AddOperation(cBrd.StartTestOp(test, repetitionNr)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -563,7 +612,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl .AddOperations(measureOperations) .AddOperation(readRegistersOp) .AddOperation((repetitionNr == 1) ? scale.ReadMassOp(ref Mass) : null) - .AddOperation((repetitionNr == 1) ? cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, true, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr) : null) + .AddOperation((repetitionNr == 1) ? cBrd.ReadDiverterTransitionOp(true, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr) : null) .AddOperation(queryEnd1) .AddOperation(processDataLoggingOp) .EnterState(); @@ -585,8 +634,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl } //------------------------------------------------ - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; + RefFrequency.Val = cBrd.RefFrequency; + RefFlow.Val = cBrd.RefFlow; UpdateAllStatistics(StateMachine.Time); @@ -623,7 +672,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl State.Create(string.Format("{0}({1}) : Stopping flow regulation", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(cBrd.StopFlowRegulationOp(outPath)) + .AddOperation(cBrd.StopFlowRegulationOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -664,7 +713,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl .AddOperation(checkUiOp) .AddOperations(readTempPressOps) .AddOperation(scale.ReadMassOp(ref Mass)) - .AddOperation((repetitionNr == 1) ? cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, false, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr) : null) + .AddOperation((repetitionNr == 1) ? cBrd.ReadDiverterTransitionOp(false, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr) : null) .AddOperation(processDataLoggingOp) .AddOperation(new Operations.TimerOp(test.TimeStop2Mass)) .EnterState(); @@ -745,10 +794,10 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TTime; /// [s] measurement time + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; double massOfEvaporatedWater = tstRslt.TimeBtwnMassMsrmnts * outPath.Scale.EvaporationRate(tstRslt.TempDivMean); - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total) + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h] /// tstRslt.Buoyancy = Config.Formulas.Buoyancy(); @@ -924,7 +973,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl volumeRslt.VolumeEnd = 0; volumeRslt.VolumeMeter = volumeRslt.PulsesMeter * volumeRegReader.LtrsPerPulse; /// [l] volumeRslt.VolumeRef = volumeRslt.PulsesMaster * tstRslt.ConstMaster; /// [l] - volumeRslt.TestTime = cBrd.ImpulseTime(i + 1); ; /// [s] + volumeRslt.TestTime = cBrd.TestTimeWM(i + 1); /// [s] volumeRslt.Error = Config.Formulas.ErrorFromVolumes(volumeRslt.VolumeMeter, volumeRslt.VolumeRef); volumeRslt.Passed = !heatMetersTestParams.EvaluateVolume || @@ -944,7 +993,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl energyRslt.VolumeEnd = 0; energyRslt.VolumeRef = tstRslt.RefEnergy * (energyRslt.PulsesMaster / tstRslt.PulsesMaster); /// [J] energyRslt.VolumeMeter = energyRslt.PulsesMeter * Config.Units.ConvertFrom(Config.Unit.kWh, energyRegReader.LtrsPerPulse); /// [J] - energyRslt.TestTime = cBrd.ImpulseTime(i + 1); /// [s] + energyRslt.TestTime = cBrd.TestTimeWM(i + 1); /// [s] energyRslt.Error = Config.Formulas.ErrorFromVolumes(energyRslt.VolumeMeter, energyRslt.VolumeRef); energyRslt.Passed = (energyRslt.Error >= heatMetersTestParams.ErrorLimitLo) @@ -1015,12 +1064,12 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl } else { - meterRslt.TestTime = cBrd.ImpulseTime(i + 1); + meterRslt.TestTime = cBrd.TestTimeWM(i + 1); meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses); meterRslt.VolumeStart = 0; - meterRslt.VolumeEnd = 0; + meterRslt.VolumeEnd = 0; meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter - meterRslt.VolumeRef = meterRslt.PulsesMaster * tstRslt.ConstMaster; /// liter + meterRslt.VolumeRef = meterRslt.PulsesMaster * tstRslt.ConstMaster; /// liter } meterRslt.Error = Config.Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); diff --git a/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/Component.cs b/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/Component.cs index 7fe422590..320f4a866 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/Component.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/Component.cs @@ -18,14 +18,17 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl.HeatMet public bool CanTest(MetersKind meters) { return meters == MetersKind.HeatMeter; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FlyingStartFirstRepetWithMassCollSeq.CheckDeviceCaps(test, devices, out message); + } - readonly TestMethodCfg testMethodCfg; + + readonly TestMethodCfg testMethodCfg; - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Single/Component.cs b/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Single/Component.cs index 5743f4006..1ca84899c 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Single/Component.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Single/Component.cs @@ -18,14 +18,17 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl.Single public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FlyingStartFirstRepetWithMassCollSeq.CheckDeviceCaps(test, devices, out message); + } + readonly TestMethodCfg testMethodCfg; - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/Compound/Component.cs b/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/Compound/Component.cs index 92555c696..ee5d0a4fa 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/Compound/Component.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/Compound/Component.cs @@ -19,14 +19,17 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative.Compound public bool CanTest(MetersKind meters) { return meters == MetersKind.Combined; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FlyingStartMassCollComparativeSeq.CheckDeviceCaps(test, devices, out message); + } - readonly TestMethodCfg testMethodCfg; + + readonly TestMethodCfg testMethodCfg; - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/FlyingStartMassCollComparativeSeq.cs b/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/FlyingStartMassCollComparativeSeq.cs index ff9d3a3a8..b03e220e4 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/FlyingStartMassCollComparativeSeq.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/FlyingStartMassCollComparativeSeq.cs @@ -17,6 +17,60 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative { private static readonly ILog log = LogManager.GetLogger(typeof(FlyingStartMassCollComparativeSeq)); + /// + /// Check capabilities of devces in the output path required for this test method + /// + /// Devices + /// true when capabilities of devices are OK + public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) + { + if (!(StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) && + !(StateMachine.ControlBoard is ControlBoard.New.CBoard)) + { + /// Control board does not support this method + message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); + return false; + } + + if (!(devices.Scale is IScale)) + { + /// Scale is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_scale); + return false; + } + + if (test.Volume > devices.Scale.Capacity * Constants.TankFullFactor) + { + /// Scale capacity is not sufficient + message = string.Format("{0}: {1}", test.Name, Strings.Test_volume_exceeds_the_scale_capacity); + return false; + } + + if (!(devices.Diverter is IDiverter)) + { + /// Scale is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_diverter); + return false; + } + + if (!(devices.FlowMeter is IFlowMeter)) + { + /// Flow meter is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_flow_meter); + return false; + } + + if (!(devices.RegulValve is GenericDevices.IRegulValve)) + { + /// Regulation valve is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_regulation_valve); + return false; + } + + message = string.Empty; + return true; + } + /// /// Flying start mass collection method sequence /// @@ -61,13 +115,6 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative } } - if (test.Volume > scale.Capacity * Constants.TankFullFactor) - { - Bridge.OnError(this, Strings.Test_volume_exceeds_the_scale_capacity); - return new List { Event.ConfigurationError }; - } - - string vlvNames = (singleTestParams != null) ? singleTestParams.ValveName : ((compoundTestParams != null) ? compoundTestParams.ValveName : heatMetersTestParams.ValveName); @@ -97,7 +144,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative IList e; /// Events from currently running operations Event retVal = Event.Done; - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; + TBF.BenchControl.ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; int tMass1 = 0; int tMass2 = 0; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state @@ -117,7 +164,10 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative } } - cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + if (cBrd is ControlBoard.Legacy.ControlBoardDev) + { + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + } IList readTempPressOps = new List(); if (benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp)); @@ -149,7 +199,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative while (e.Contains(Event.Busy)); /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, totalPulses)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); TestStartTime = DateTime.Now; @@ -312,7 +362,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) + .AddOperation(cBrd.SetFlowOp(test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) .AddOperation(heatMetersPromptOp) .EnterState(); do { @@ -634,7 +684,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative .AddOperations(readTempPressOps) .AddOperations(measureOperations) .AddOperation(processDataLoggingOp) - .AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro, test.Qfrom, test.Qto, totalPulses)) + .AddOperation(cBrd.StartTestOp(test)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -669,7 +719,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative .AddOperations(measureOperations) .AddOperation(readRegistersOp) .AddOperation(scale.ReadMassOp(ref Mass)) - .AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, true, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr)) + .AddOperation(cBrd.ReadDiverterTransitionOp(true, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr)) .AddOperation(cBrd.QueryMeasurementEndOp()) .AddOperation(processDataLoggingOp) .EnterState(); @@ -691,8 +741,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative } //------------------------------------------------ - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; + RefFrequency.Val = cBrd.RefFrequency; + RefFlow.Val = cBrd.RefFlow; UpdateAllStatistics(StateMachine.Time); @@ -729,7 +779,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative State.Create(string.Format("{0}({1}) : Stopping flow regulation", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(cBrd.StopFlowRegulationOp(outPath)) + .AddOperation(cBrd.StopFlowRegulationOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -768,7 +818,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative .AddOperation(checkUiOp) .AddOperations(readTempPressOps) .AddOperation(scale.ReadMassOp(ref Mass)) - .AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, false, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr)) + .AddOperation(cBrd.ReadDiverterTransitionOp(false, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr)) .AddOperation(new Operations.TimerOp(test.TimeStop2Mass)) .AddOperation(processDataLoggingOp) .EnterState(); @@ -862,10 +912,10 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TTime; /// [s] measurement time + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; double massOfEvaporatedWater = tstRslt.TimeBtwnMassMsrmnts * outPath.Scale.EvaporationRate(tstRslt.TempDivMean); - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total) + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = StartMass.Val; tstRslt.MassStart = StartMass.Val; tstRslt.MassEndRaw = EndMass.Val; @@ -934,7 +984,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative meterRslt.PulsesMeter = (isAux == 0 && compoundTestParams.SupressTrills) ? 0 : Convert.ToDouble(regReader.WMPulses); meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses); - meterRslt.TestTime = cBrd.ImpulseTime(regReader.Position); + meterRslt.TestTime = cBrd.TestTimeWM(regReader.Position); meterRslt.VolumeStart = 0; meterRslt.VolumeEnd = 0; meterRslt.VolumeRef = tstRslt.VolumeCTV; @@ -1007,7 +1057,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative volumeRslt.VolumeEnd = 0; volumeRslt.VolumeMeter = volumeRslt.PulsesMeter * volumeRegReader.LtrsPerPulse; /// [l] volumeRslt.VolumeRef = volumeRslt.PulsesMaster * tstRslt.ConstMaster; /// [l] - volumeRslt.TestTime = cBrd.ImpulseTime(i + 1); /// [s] + volumeRslt.TestTime = cBrd.TestTimeWM(i + 1); /// [s] volumeRslt.Error = Config.Formulas.ErrorFromVolumes(volumeRslt.VolumeMeter, volumeRslt.VolumeRef); volumeRslt.Passed = !heatMetersTestParams.EvaluateVolume || @@ -1027,7 +1077,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative energyRslt.VolumeEnd = 0; energyRslt.VolumeRef = tstRslt.RefEnergy * (energyRslt.PulsesMaster / tstRslt.PulsesMaster); /// [J] energyRslt.VolumeMeter = energyRslt.PulsesMeter * Config.Units.ConvertFrom(Config.Unit.kWh, energyRegReader.LtrsPerPulse); /// [J] - energyRslt.TestTime = cBrd.ImpulseTime(i + 1); /// [s] + energyRslt.TestTime = cBrd.TestTimeWM(i + 1); /// [s] energyRslt.Error = Config.Formulas.ErrorFromVolumes(energyRslt.VolumeMeter, energyRslt.VolumeRef); energyRslt.Passed = (energyRslt.Error >= heatMetersTestParams.ErrorLimitLo) @@ -1119,7 +1169,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative if (regReader.WMPulses >= 1) { /// Normal measurement - meterRslt.TestTime = cBrd.ImpulseTime(regReader.Position); + meterRslt.TestTime = cBrd.TestTimeWM(regReader.Position); meterRslt.VolumeRef = meterRslt.PulsesMaster * tstRslt.ConstMaster; /// liter } else diff --git a/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/HeatMeters/Component.cs b/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/HeatMeters/Component.cs index 2719df740..9b650c1f3 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/HeatMeters/Component.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/HeatMeters/Component.cs @@ -18,14 +18,17 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative.HeatMeters public bool CanTest(MetersKind meters) { return meters == MetersKind.HeatMeter; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FlyingStartMassCollComparativeSeq.CheckDeviceCaps(test, devices, out message); + } - readonly TestMethodCfg testMethodCfg; + + readonly TestMethodCfg testMethodCfg; - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/Single/Component.cs b/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/Single/Component.cs index 8aa2949a3..6216c9153 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/Single/Component.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/Single/Component.cs @@ -18,14 +18,17 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative.Single public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FlyingStartMassCollComparativeSeq.CheckDeviceCaps(test, devices, out message); + } + readonly TestMethodCfg testMethodCfg; - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/Compound/Component.cs b/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/Compound/Component.cs index 5377ae84b..e47145472 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/Compound/Component.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/Compound/Component.cs @@ -18,14 +18,17 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged.Compound public bool CanTest(MetersKind meters) { return meters == MetersKind.Combined; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FlyingStartMassCollProlongedSeq.CheckDeviceCaps(test, devices, out message); + } - readonly TestMethodCfg testMethodCfg; + + readonly TestMethodCfg testMethodCfg; - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/FlyingStartMassCollProlongedSeq.cs b/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/FlyingStartMassCollProlongedSeq.cs index 4124d3bdd..e87b817a6 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/FlyingStartMassCollProlongedSeq.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/FlyingStartMassCollProlongedSeq.cs @@ -15,6 +15,53 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged { private static readonly ILog log = LogManager.GetLogger(typeof(FlyingStartMassCollProlongedSeq)); + /// + /// Check capabilities of devces in the output path required for this test method + /// + /// Devices + /// true when capabilities of devices are OK + public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) + { + if (!(StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) && + !(StateMachine.ControlBoard is ControlBoard.New.CBoard)) + { + /// Control board does not support this method + message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); + return false; + } + + if (!(devices.Scale is IScale)) + { + /// Scale is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_scale); + return false; + } + + if (!(devices.Diverter is IDiverter)) + { + /// Scale is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_diverter); + return false; + } + + if (!(devices.FlowMeter is IFlowMeter)) + { + /// Flow meter is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_flow_meter); + return false; + } + + if (!(devices.RegulValve is GenericDevices.IRegulValve)) + { + /// Regulation valve is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_regulation_valve); + return false; + } + + message = string.Empty; + return true; + } + /// /// Flying start mass collection method sequence /// @@ -36,13 +83,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged return Simulate(test, repetitionNr, isLastRepetition, singleTestParams, compoundTestParams, heatMetersTestParams); } - + ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; IScale scale = outPath.Scale as IScale; - if (scale == null) - { - Bridge.OnError(this, Strings.Missing_a_scale); - new List { Event.ConfigurationError }; - } int rangeIx = 0; /// Default range, used for non-Elde flowmeters if (outPath.FlowMeter is Elde.FlowMeter.FlowMeter) @@ -80,7 +122,6 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged IList e = new List(); /// Events from currently running operations - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; int tMass1 = 0; int tMass2 = 0; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state @@ -100,7 +141,10 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged } } - cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + if (cBrd is ControlBoard.Legacy.ControlBoardDev) + { + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + } IList readTempPressOps = new List(); if (benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp)); @@ -135,7 +179,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged while (e.Contains(Event.Busy)); /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, targetTotalPulses)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); TestStartTime = DateTime.Now; @@ -183,7 +227,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged State.Create(string.Format("{0}({1}) : Open the drain valve", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(scale.DrainValve, null)) + .AddOperation(cBrd.SetValvesOp(scale.DrainValve, null)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -258,7 +302,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged { State.Create(string.Format("{0}({1}) : Opening the stop backflow valve", test.Method, test.Name)) .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(benchPath.StopBFValve, null)) + .AddOperation(cBrd.SetValvesOp(benchPath.StopBFValve, null)) .AddOperations(readTempPressOps) .AddOperation(heatMetersPromptOp) .EnterState(); @@ -297,7 +341,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged //------------------------------------------------ State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name)) .AddOperation(checkUiOp) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) + .AddOperation(cBrd.SetFlowOp(test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) .AddOperations(readTempPressOps) .AddOperation(heatMetersPromptOp) .EnterState(); @@ -451,7 +495,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged State.Create(string.Format("{0}({1}) : Close the drain valve", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, scale.DrainValve)) + .AddOperation(cBrd.SetValvesOp(null, scale.DrainValve)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -523,9 +567,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged .AddOperations(readTempPressOps) .AddOperations(cameraMeasurementOperations) .AddOperation(processDataLoggingOp) - .AddOperation(cBrd.StartProlongedMeasurementOp(outPath, - Elde.TestMethods.Diverter | Elde.TestMethods.Synchro | Elde.TestMethods.MassAndContinue, - test.Qfrom, test.Qto, targetTotalPulses, targetMassPulses)) + .AddOperation(cBrd.StartTestOp(test, targetMassPulses, test.Qfrom, test.Qto)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -570,16 +612,15 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged State.Create(string.Format("{0}({1}) : Reading watermeters", test.Method, test.Name)) .AddOperations(measurementLoopOperations) .AddOperation(readMassOp) - .AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, - true, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr)) - .AddOperation(new TBF.BenchControl.Elde.ReadDiverterStateOp(cBrd, outPath.Diverter)) + .AddOperation(cBrd.ReadDiverterTransitionOp(true, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr)) + .AddOperation(new TBF.BenchControl.Elde.Diverter.ReadDiverterStateOp(cBrd.Devices.Diverter)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } if (e.Contains(Event.MeasurementCompleted)) { retVal = Event.Error; goto stopTest; } - DoInsideMeasurementLoop(heatMetersTestParams, test, repetitionNr, estimtdEndTime); + DoInsideMeasurementLoop(cBrd, heatMetersTestParams, test, repetitionNr, estimtdEndTime); } while (!e.Contains(Event.ToSink) && !e.Contains(Event.Next)); /// Proceed to 2nd part of the measurement loop when diverter turns back to sink /// 'Next' button can be used in Debug version @@ -587,8 +628,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged /// Waiting before the 2nd mass measurement /// bool waitingBeforeEndMassMeasurementCompleted = false; - IOperation readDiverterTransitionOp = cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, - false, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr); + IOperation readDiverterTransitionOp = cBrd.ReadDiverterTransitionOp(false, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr); IOperation stop2MassTimerOp = new Operations.TimerOp(test.TimeStop2Mass); do { State.Create(string.Format("{0}({1}) : Waiting before the 2nd mass measurement", test.Method, test.Name)) @@ -606,7 +646,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } if (e.Contains(Event.MeasurementCompleted)) isMeasurementCompleted = true; waitingBeforeEndMassMeasurementCompleted = (e.Contains(Event.TimerExpired) && e.Contains(Event.BalanceDone)); - DoInsideMeasurementLoop(heatMetersTestParams, test, repetitionNr, estimtdEndTime); + DoInsideMeasurementLoop(cBrd, heatMetersTestParams, test, repetitionNr, estimtdEndTime); } while (!isMeasurementCompleted && !waitingBeforeEndMassMeasurementCompleted); } @@ -655,7 +695,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged } if (e.Contains(Event.MeasurementCompleted)) isMeasurementCompleted = true; measuringEndMassCompleted = e.Contains(Event.BalanceDone); - DoInsideMeasurementLoop(heatMetersTestParams, test, repetitionNr, estimtdEndTime, false); + DoInsideMeasurementLoop(cBrd, heatMetersTestParams, test, repetitionNr, estimtdEndTime, false); } while (!isMeasurementCompleted && !measuringEndMassCompleted); } @@ -687,7 +727,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged /// /// Draining after the 2nd mass measurement enabled, empty the tank /// - IOperation setValvesOp = StateMachine.ControlBoard.SetValvesOp(scale.DrainValve, null); + IOperation setValvesOp = cBrd.SetValvesOp(scale.DrainValve, null); bool openingDrainValveCompleted = false; do { State.Create(string.Format("{0}({1}) : Open the drain valve", test.Method, test.Name)) @@ -704,7 +744,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } if (e.Contains(Event.MeasurementCompleted)) isMeasurementCompleted = true; openingDrainValveCompleted = !e.Contains(Event.ValvesBusy); - DoInsideMeasurementLoop(heatMetersTestParams, test, repetitionNr, estimtdEndTime); + DoInsideMeasurementLoop(cBrd, heatMetersTestParams, test, repetitionNr, estimtdEndTime); } while (!isMeasurementCompleted && !openingDrainValveCompleted); } @@ -735,7 +775,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged e = StateMachine.WaitRunDevsRunOps(); if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } - DoInsideMeasurementLoop(heatMetersTestParams, test, repetitionNr, estimtdEndTime); + DoInsideMeasurementLoop(cBrd, heatMetersTestParams, test, repetitionNr, estimtdEndTime); } while (!e.Contains(Event.MeasurementCompleted) && !e.Contains(Event.Next)); /// Quit the measurement loop when there is Event.MeasurementCompleted /// 'Next' button can be used in Debug version @@ -748,7 +788,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged State.Create(string.Format("{0}({1}) : Stopping flow regulation", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(cBrd.StopFlowRegulationOp(outPath)) + .AddOperation(cBrd.StopFlowRegulationOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -770,7 +810,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged .AddOperation(checkUiOp) .AddOperations(readTempPressOps) .AddOperation(new MettlerToledo.KeepReadingMassesOp()) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose)) + .AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -800,15 +840,19 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters); UpdateTempPressDensAmb(tstRslt); - double totalPulses = Convert.ToDouble(cBrd.EtPulses(0)); - double massPulses = Convert.ToDouble(cBrd.EtPulsesK); + double totalPulses = Convert.ToDouble(cBrd.RefPulses); + double massPulses = totalPulses; + if (StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) + { + massPulses = Convert.ToDouble((StateMachine.ControlBoard as ControlBoard.Legacy.ControlBoardDev).EtPulsesK); + } /// Main results tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TTime; /// [s] measurement time (TODO: or cBrd.ImpulseTime(0) ???) + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time (TODO: or cBrd.ImpulseTime(0) ???) tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; double massOfEvaporatedWater = (double)tstRslt.TimeBtwnMassMsrmnts * outPath.Scale.EvaporationRate(tstRslt.TempDivMean); tstRslt.PulsesMaster = massPulses; /// Pulses of the master flow meter (test total) @@ -880,7 +924,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged meterRslt.PulsesMeter = (isAux == 0 && compoundTestParams.SupressTrills) ? 0 : Convert.ToDouble(regReader.WMPulses); meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses); - meterRslt.TestTime = cBrd.ImpulseTime(regReader.Position); + meterRslt.TestTime = cBrd.TestTimeWM(regReader.Position); meterRslt.VolumeStart = 0; meterRslt.VolumeEnd = 0; meterRslt.VolumeRef = tstRslt.VolumeCTV; @@ -953,7 +997,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged volumeRslt.VolumeEnd = 0; volumeRslt.VolumeMeter = volumeRslt.PulsesMeter * volumeRegReader.LtrsPerPulse; /// [l] volumeRslt.VolumeRef = volumeRslt.PulsesMaster * tstRslt.ConstMaster; /// [l] - volumeRslt.TestTime = cBrd.ImpulseTime(i + 1); /// [s] + volumeRslt.TestTime = cBrd.TestTimeWM(i + 1); /// [s] volumeRslt.Error = Formulas.ErrorFromVolumes(volumeRslt.VolumeMeter, volumeRslt.VolumeRef); volumeRslt.Passed = !heatMetersTestParams.EvaluateVolume || @@ -973,7 +1017,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged energyRslt.VolumeEnd = 0; energyRslt.VolumeRef = tstRslt.RefEnergy * (energyRslt.PulsesMaster / totalPulses); /// [J] energyRslt.VolumeMeter = energyRslt.PulsesMeter * Config.Units.ConvertFrom(Config.Unit.kWh, energyRegReader.LtrsPerPulse); /// [J] - energyRslt.TestTime = cBrd.ImpulseTime(i + 1); /// [s] + energyRslt.TestTime = cBrd.TestTimeWM(i + 1); /// [s] energyRslt.Error = Formulas.ErrorFromVolumes(energyRslt.VolumeMeter, energyRslt.VolumeRef); energyRslt.Passed = (energyRslt.Error >= heatMetersTestParams.ErrorLimitLo) @@ -1045,7 +1089,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged } else { - meterRslt.TestTime = cBrd.ImpulseTime(i + 1); /// TODO: Malo by sa citat z dosky + meterRslt.TestTime = cBrd.TestTimeWM(i + 1); /// TODO: Malo by sa citat z dosky meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses); meterRslt.VolumeStart = 0; /// liter meterRslt.VolumeEnd = 0; /// liter @@ -1129,10 +1173,10 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged /// /// Collection of actions executed inside measurement loop /// - void DoInsideMeasurementLoop(HeatMeters.TestParams heatMetersTestParams, Config.Entities.Test test, int repetitionNr, int estimtdEndTime, bool showRemainingTimeMsg = true) + void DoInsideMeasurementLoop(ControlBoard.IControlBoard cBrd, HeatMeters.TestParams heatMetersTestParams, Config.Entities.Test test, int repetitionNr, int estimtdEndTime, bool showRemainingTimeMsg = true) { - RefFreq.Val = StateMachine.ControlBoard.ReferenceFreq; - RefFlow.Val = StateMachine.ControlBoard.ReferenceFlow; + RefFrequency.Val = cBrd.RefFrequency; + RefFlow.Val = cBrd.RefFlow; UpdateAllStatistics(StateMachine.Time); UpdateEnergy(heatMetersTestParams); diff --git a/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/HeatMeters/Component.cs b/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/HeatMeters/Component.cs index 0c638fda3..bae4b9f26 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/HeatMeters/Component.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/HeatMeters/Component.cs @@ -18,14 +18,17 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged.HeatMeters public bool CanTest(MetersKind meters) { return meters == MetersKind.HeatMeter; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FlyingStartMassCollProlongedSeq.CheckDeviceCaps(test, devices, out message); + } - readonly TestMethodCfg testMethodCfg; + + readonly TestMethodCfg testMethodCfg; - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/Single/Component.cs b/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/Single/Component.cs index 31489d5a4..8a60a0bf2 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/Single/Component.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/Single/Component.cs @@ -18,14 +18,17 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged.Single public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FlyingStartMassCollProlongedSeq.CheckDeviceCaps(test, devices, out message); + } + readonly TestMethodCfg testMethodCfg; - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/FlyingStartMassCollection/Compound/Component.cs b/TBF/BenchControl/TestMethods/FlyingStartMassCollection/Compound/Component.cs index baf473efa..93d4ea27b 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartMassCollection/Compound/Component.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartMassCollection/Compound/Component.cs @@ -19,14 +19,17 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection.Compound public bool CanTest(MetersKind meters) { return meters == MetersKind.Combined; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FlyingStartMassCollectionSeq.CheckDeviceCaps(test, devices, out message); + } - readonly TestMethodCfg testMethodCfg; + + readonly TestMethodCfg testMethodCfg; - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs b/TBF/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs index 6bdd89336..146a7fb8c 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2013-2018 Sensus Slovensko a.s. +/// Copyright (c) 2013-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -17,6 +17,60 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection { private static readonly ILog log = LogManager.GetLogger(typeof(FlyingStartMassCollectionSeq)); + /// + /// Check capabilities of devces in the output path required for this test method + /// + /// Devices + /// true when capabilities of devices are OK + public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) + { + if (!(StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) && + !(StateMachine.ControlBoard is ControlBoard.New.CBoard)) + { + /// Control board does not support this method + message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); + return false; + } + + if (!(devices.Scale is IScale)) + { + /// Scale is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_scale); + return false; + } + + if (test.Volume > devices.Scale.Capacity * Constants.TankFullFactor) + { + /// Scale capacity is not sufficient + message = string.Format("{0}: {1}", test.Name, Strings.Test_volume_exceeds_the_scale_capacity); + return false; + } + + if (!(devices.Diverter is IDiverter)) + { + /// Scale is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_diverter); + return false; + } + + if (!(devices.FlowMeter is IFlowMeter)) + { + /// Flow meter is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_flow_meter); + return false; + } + + if (!(devices.RegulValve is GenericDevices.IRegulValve)) + { + /// Regulation valve is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_regulation_valve); + return false; + } + + message = string.Empty; + return true; + } + /// /// Flying start mass collection method sequence /// @@ -41,17 +95,13 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection return Simulate2(test, repetitionNr, isLastRepetition, compoundTestParams, heatMetersTestParams); } - IScale scale = outPath.Scale as IScale; - if (scale == null) - { - Bridge.OnError(this, Strings.Missing_a_scale); - return new List { Event.ConfigurationError }; /// or Event.UiCmdStop ??? - } + ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; + IScale scale = cBrd.Devices.Scale as IScale; int rangeIx = 0; /// Default range, used for non-Elde flowmeters - if (outPath.FlowMeter is Elde.FlowMeter.FlowMeter) + if (cBrd.Devices.FlowMeter is Elde.FlowMeter.FlowMeter) { - Elde.FlowMeter.FlowMeter eldeFM = outPath.FlowMeter as Elde.FlowMeter.FlowMeter; + Elde.FlowMeter.FlowMeter eldeFM = cBrd.Devices.FlowMeter as Elde.FlowMeter.FlowMeter; rangeIx = -1; /// Indicates invalid range for (int r = 0; r <= 5; r++) { @@ -69,16 +119,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection } } - if (test.Volume > scale.Capacity * Constants.TankFullFactor) - { - Bridge.OnError(this, Strings.Test_volume_exceeds_the_scale_capacity); - return new List { Event.ConfigurationError }; - } - - IList e; /// Events from currently running operations Event retVal = Event.Done; - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; int tMass1 = 0; int tMass2 = 0; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state @@ -98,7 +140,10 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection } } - cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + if (cBrd is ControlBoard.Legacy.ControlBoardDev) + { + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + } IList readTempPressOps = new List(); if(benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp)); @@ -112,7 +157,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection if(heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1)); if(heatMetersPath != null) readTempPressOps.Add(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)); - LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; + LtrPerRefPulse = cBrd.Devices.FlowMeter.LtrPerPulse; int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f); //==================================== @@ -130,7 +175,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection while (e.Contains(Event.Busy)); /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, totalPulses)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); TestStartTime = DateTime.Now; @@ -167,7 +212,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection if (drainTheTank) { #if BERLIN || SENTEC - switch (DrainTheTank(outPath.Scale, readTempPressOps)) + switch (DrainTheTank(scale, readTempPressOps)) { case Event.Error: { retVal = Event.Error; goto stopTest; } case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } @@ -177,7 +222,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection #else State.Create(string.Format("{0}({1}) : Open the drain valve", test.Method, test.Name)) .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(scale.DrainValve, null)) + .AddOperation(cBrd.SetValvesOp(scale.DrainValve, null)) .AddOperations(readTempPressOps) .EnterState(); do { @@ -253,7 +298,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection { State.Create(string.Format("{0}({1}) : Opening the stop backflow valve", test.Method, test.Name)) .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(benchPath.StopBFValve, null)) + .AddOperation(cBrd.SetValvesOp(benchPath.StopBFValve, null)) .AddOperations(readTempPressOps) .AddOperation(heatMetersPromptOp) .EnterState(); @@ -292,7 +337,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection //------------------------------------------------ State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name)) .AddOperation(checkUiOp) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) + .AddOperation(cBrd.SetFlowOp(test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) .AddOperations(readTempPressOps) .AddOperation(heatMetersPromptOp) .EnterState(); @@ -446,7 +491,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection State.Create(string.Format("{0}({1}) : Close the drain valve", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, scale.DrainValve)) + .AddOperation(cBrd.SetValvesOp(null, scale.DrainValve)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -518,7 +563,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection .AddOperations(readTempPressOps) .AddOperations(measureOperations) .AddOperation(processDataLoggingOp) - .AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro, test.Qfrom, test.Qto, totalPulses)) + .AddOperation(cBrd.StartTestOp(test)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -553,7 +598,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection .AddOperations(measureOperations) .AddOperation(readRegistersOp) .AddOperation(scale.ReadMassOp(ref Mass)) - .AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, true, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr)) + .AddOperation(cBrd.ReadDiverterTransitionOp(true, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr)) .AddOperation(cBrd.QueryMeasurementEndOp()) .AddOperation(processDataLoggingOp) .EnterState(); @@ -575,8 +620,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection } //------------------------------------------------ - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; + RefFrequency.Val = cBrd.RefFrequency; + RefFlow.Val = cBrd.RefFlow; UpdateAllStatistics(StateMachine.Time); @@ -613,7 +658,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection State.Create(string.Format("{0}({1}) : Stopping flow regulation", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(cBrd.StopFlowRegulationOp(outPath)) + .AddOperation(cBrd.StopFlowRegulationOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -637,7 +682,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection .AddOperation(checkUiOp) .AddOperations(readTempPressOps) .AddOperation(new MettlerToledo.KeepReadingMassesOp()) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose)) + .AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -656,7 +701,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection .AddOperation(checkUiOp) .AddOperations(readTempPressOps) .AddOperation(scale.ReadMassOp(ref Mass)) - .AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, false, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr)) + .AddOperation(cBrd.ReadDiverterTransitionOp(false, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr)) .AddOperation(processDataLoggingOp) .AddOperation(new Operations.TimerOp(test.TimeStop2Mass)) .EnterState(); @@ -700,7 +745,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection { State.Create(string.Format("{0}({1}) : Open the drain valve", test.Method, test.Name)) .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(scale.DrainValve, null)) + .AddOperation(cBrd.SetValvesOp(scale.DrainValve, null)) .AddOperations(readTempPressOps) .EnterState(); do { @@ -735,10 +780,10 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TTime; /// [s] measurement time + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time tstRslt.TimeBtwnMassMsrmnts = tMass2 - tMass1; double massOfEvaporatedWater = (double)tstRslt.TimeBtwnMassMsrmnts * outPath.Scale.EvaporationRate(tstRslt.TempDivMean); - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total) + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = StartMass.Val; tstRslt.MassStart = Config.Formulas.CorrectedValue(tstRslt.MassStartRaw, scale.Corrections); tstRslt.MassEndRaw = EndMass.Val; @@ -807,7 +852,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection meterRslt.PulsesMeter = (isAux == 0 && compoundTestParams.SupressTrills) ? 0 : Convert.ToDouble(regReader.WMPulses); meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses); - meterRslt.TestTime = cBrd.ImpulseTime(regReader.Position); + meterRslt.TestTime = cBrd.TestTimeWM(regReader.Position); meterRslt.VolumeStart = 0; meterRslt.VolumeEnd = 0; meterRslt.VolumeRef = tstRslt.VolumeCTV; @@ -880,7 +925,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection volumeRslt.VolumeEnd = 0; volumeRslt.VolumeMeter = volumeRslt.PulsesMeter * volumeRegReader.LtrsPerPulse; /// [l] volumeRslt.VolumeRef = volumeRslt.PulsesMaster * tstRslt.ConstMaster; /// [l] - volumeRslt.TestTime = cBrd.ImpulseTime(i + 1); /// [s] + volumeRslt.TestTime = cBrd.TestTimeWM(i + 1); /// [s] volumeRslt.Error = Config.Formulas.ErrorFromVolumes(volumeRslt.VolumeMeter, volumeRslt.VolumeRef); volumeRslt.Passed = !heatMetersTestParams.EvaluateVolume || @@ -900,7 +945,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection energyRslt.VolumeEnd = 0; energyRslt.VolumeRef = tstRslt.RefEnergy * (energyRslt.PulsesMaster / tstRslt.PulsesMaster); /// [J] energyRslt.VolumeMeter = energyRslt.PulsesMeter * Config.Units.ConvertFrom(Config.Unit.kWh, energyRegReader.LtrsPerPulse); /// [J] - energyRslt.TestTime = cBrd.ImpulseTime(i + 1); /// [s] + energyRslt.TestTime = cBrd.TestTimeWM(i + 1); /// [s] energyRslt.Error = Config.Formulas.ErrorFromVolumes(energyRslt.VolumeMeter, energyRslt.VolumeRef); energyRslt.Passed = (energyRslt.Error >= heatMetersTestParams.ErrorLimitLo) @@ -992,7 +1037,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection if (regReader.WMPulses >= 1) { /// Normal measurement - meterRslt.TestTime = cBrd.ImpulseTime(regReader.Position); + meterRslt.TestTime = cBrd.TestTimeWM(regReader.Position); meterRslt.VolumeRef = meterRslt.PulsesMaster * tstRslt.ConstMaster; /// liter } else @@ -1018,7 +1063,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection (BenchInfo != null) ? BenchInfo.TestBenchName : "testbench", inPath.Pump != null ? inPath.Pump.Name : string.Empty, outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty, - scale != null ? scale.Name : string.Empty, + cBrd.Devices.Scale.Name, outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); diff --git a/TBF/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/Component.cs b/TBF/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/Component.cs index 72828b5d8..901d76174 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/Component.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/Component.cs @@ -18,14 +18,17 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection.HeatMeters public bool CanTest(MetersKind meters) { return meters == MetersKind.HeatMeter; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FlyingStartMassCollectionSeq.CheckDeviceCaps(test, devices, out message); + } - readonly TestMethodCfg testMethodCfg; + + readonly TestMethodCfg testMethodCfg; - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/FlyingStartMassCollection/Single/Component.cs b/TBF/BenchControl/TestMethods/FlyingStartMassCollection/Single/Component.cs index e4840c674..0a7f53816 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartMassCollection/Single/Component.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartMassCollection/Single/Component.cs @@ -18,12 +18,14 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection.Single public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FlyingStartMassCollectionSeq.CheckDeviceCaps(test, devices, out message); + } - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { log.Debug(this.ToString()); diff --git a/TBF/BenchControl/TestMethods/FlyingStartTankCollection/Compound/Component.cs b/TBF/BenchControl/TestMethods/FlyingStartTankCollection/Compound/Component.cs index bee14359e..047e868c5 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartTankCollection/Compound/Component.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartTankCollection/Compound/Component.cs @@ -18,14 +18,17 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection.Compound public bool CanTest(MetersKind meters) { return meters == MetersKind.Combined; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FlyingStartTankCollectionSeq.CheckDeviceCaps(test, devices, out message); + } - readonly TestMethodCfg testMethodCfg; + + readonly TestMethodCfg testMethodCfg; - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/FlyingStartTankCollection/FlyingStartTankCollectionSeq.cs b/TBF/BenchControl/TestMethods/FlyingStartTankCollection/FlyingStartTankCollectionSeq.cs index 95328f879..a7631949b 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartTankCollection/FlyingStartTankCollectionSeq.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartTankCollection/FlyingStartTankCollectionSeq.cs @@ -15,6 +15,60 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection { private static readonly ILog log = LogManager.GetLogger(typeof(FlyingStartTankCollectionSeq)); + /// + /// Check capabilities of devces in the output path required for this test method + /// + /// Devices + /// true when capabilities of devices are OK + public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) + { + if (!(StateMachine.ControlBoard is ControlBoard.Legacy.ControlBoardDev) && + !(StateMachine.ControlBoard is ControlBoard.New.CBoard)) + { + /// Control board does not support this method + message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); + return false; + } + + if (!(devices.Scale is IVolumeMeter)) + { + /// Volume meter (tank with a level meter) is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_volume_meter); + return false; + } + + if (test.Volume > devices.Scale.Capacity * Constants.TankFullFactor) + { + /// Volume meter capacity is not sufficient + message = string.Format("{0}: {1}", test.Name, Strings.Test_volume_exceeds_the_scale_capacity); + return false; + } + + if (!(devices.Diverter is IDiverter)) + { + /// Scale is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_diverter); + return false; + } + + if (!(devices.FlowMeter is IFlowMeter)) + { + /// Flow meter is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_flow_meter); + return false; + } + + if (!(devices.RegulValve is GenericDevices.IRegulValve)) + { + /// Regulation valve is missing + message = string.Format("{0}: {1}", test.Name, Strings.Missing_a_regulation_valve); + return false; + } + + message = string.Empty; + return true; + } + /// /// Flying start mass collection method sequence /// @@ -75,7 +129,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection IList e; /// Events from currently running operations Event retVal = Event.Done; - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; + TBF.BenchControl.ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false); @@ -93,7 +147,10 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection } } - cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + if (cBrd is ControlBoard.Legacy.ControlBoardDev) + { + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + } IList readTempPressOps = new List(); if (benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp)); @@ -127,7 +184,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection while (e.Contains(Event.Busy)); /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, totalPulses)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); TestStartTime = DateTime.Now; @@ -231,7 +288,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) + .AddOperation(cBrd.SetFlowOp(test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -326,8 +383,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection .AddOperations(readTempPressOps) .AddOperations(measureOperations) .AddOperation(processDataLoggingOp) - .AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro, - test.Qfrom, test.Qto, totalPulses)) + .AddOperation(cBrd.StartTestOp(test)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -361,7 +417,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection .AddOperations(readTempPressOps) .AddOperations(measureOperations) .AddOperation(readRegistersOp) - .AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, true, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr)) + .AddOperation(cBrd.ReadDiverterTransitionOp(true, DiverterStart, BatchRslts.Batch.BatchNr, test.Name, repetitionNr)) .AddOperation(cBrd.QueryMeasurementEndOp()) .AddOperation(processDataLoggingOp) .EnterState(); @@ -383,8 +439,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection } //------------------------------------------------ - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; + RefFrequency.Val = cBrd.RefFrequency; + RefFlow.Val = cBrd.RefFlow; UpdateAllStatistics(StateMachine.Time); @@ -402,7 +458,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection State.Create(string.Format("{0}({1}) : Stopping flow regulation", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(cBrd.StopFlowRegulationOp(outPath)) + .AddOperation(cBrd.StopFlowRegulationOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -441,7 +497,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection State.Create(string.Format("{0}({1}) : Waiting before the water level measurement", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(cBrd.ReadDiverterTransitionOp(outPath.Diverter, CountWhenSendingRdDivCmd, CountWhenReadingDiv, false, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr)) + .AddOperation(cBrd.ReadDiverterTransitionOp(false, DiverterEnd, BatchRslts.Batch.BatchNr, test.Name, repetitionNr)) .AddOperation(new Operations.TimerOp(test.TimeStop2Mass)) .AddOperation(processDataLoggingOp) .EnterState(); @@ -494,8 +550,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TTime; /// [s] measurement time - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total) + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = 0; tstRslt.MassStart = 0; tstRslt.MassEndRaw = 0; @@ -564,7 +620,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection meterRslt.PulsesMeter = (isAux == 0 && compoundTestParams.SupressTrills) ? 0 : Convert.ToDouble(regReader.WMPulses); meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses); - meterRslt.TestTime = cBrd.ImpulseTime(regReader.Position); + meterRslt.TestTime = cBrd.TestTimeWM(regReader.Position); meterRslt.VolumeStart = 0; meterRslt.VolumeEnd = 0; meterRslt.VolumeRef = tstRslt.VolumeCTV; @@ -678,7 +734,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection if (regReader.WMPulses >= 1) { /// Normal measurement - meterRslt.TestTime = cBrd.ImpulseTime(regReader.Position); + meterRslt.TestTime = cBrd.TestTimeWM(regReader.Position); meterRslt.VolumeRef = meterRslt.PulsesMaster * tstRslt.ConstMaster; /// liter } else diff --git a/TBF/BenchControl/TestMethods/FlyingStartTankCollection/Single/Component.cs b/TBF/BenchControl/TestMethods/FlyingStartTankCollection/Single/Component.cs index 29ebcf894..ff2cd5881 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartTankCollection/Single/Component.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartTankCollection/Single/Component.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2018 Sensus Slovensko a.s. +/// Copyright (c) 2018-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -18,14 +18,17 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection.Single public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + return FlyingStartTankCollectionSeq.CheckDeviceCaps(test, devices, out message); + } + readonly TestMethodCfg testMethodCfg; - public Component() - { - } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/GrabImage/Component.cs b/TBF/BenchControl/TestMethods/GrabImage/Component.cs index 097e66131..ee726e3de 100644 --- a/TBF/BenchControl/TestMethods/GrabImage/Component.cs +++ b/TBF/BenchControl/TestMethods/GrabImage/Component.cs @@ -12,7 +12,7 @@ namespace TBF.BenchControl.TestMethods.GrabImage public class Component : ComponentBase, GenericDevices.ITestMethod { private static readonly ILog log = LogManager.GetLogger(typeof(Component)); - public override string ToString() { return string.Format("TestMethods.GrabImage({0})", Cfg.ToString(1)); } + public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(1)); } public bool CanTest(MetersKind meters) { return true; } public bool DoTransitions() { return false; } @@ -51,10 +51,14 @@ namespace TBF.BenchControl.TestMethods.GrabImage #endregion Configuration Change Handling - public Component() - { - } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + message = string.Format("{0}: CheckDeviceCaps() is not implemented yet", Name); + return false; + } + public Component() { } + /// public Component(Generic.IComponentCfg cfg) : base(cfg) { diff --git a/TBF/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs b/TBF/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs index 60c3189b2..c70959871 100644 --- a/TBF/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs +++ b/TBF/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs @@ -50,7 +50,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest IList e; /// Events from currently running operations Event retVal = Event.Done; - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; + TBF.BenchControl.ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false); @@ -79,7 +79,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest while (e.Contains(Event.Busy)); /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, 1, inPath, benchPath, outPath, sensPath, heatMetersPath, 0)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, 1, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, 1); //------------------------------------------------ @@ -189,7 +189,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest State.Create(string.Format("{0}({1}) : Closing the valve", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, true, outPath)) + .AddOperation(cBrd.CloseStartValveOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); diff --git a/TBF/BenchControl/TestMethods/LeakTest/TestMethod.cs b/TBF/BenchControl/TestMethods/LeakTest/TestMethod.cs index 846317daf..ab048716b 100644 --- a/TBF/BenchControl/TestMethods/LeakTest/TestMethod.cs +++ b/TBF/BenchControl/TestMethods/LeakTest/TestMethod.cs @@ -12,18 +12,22 @@ namespace TBF.BenchControl.TestMethods.LeakTest public class TestMethod : ComponentBase, GenericDevices.ITestMethod { private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod)); - public override string ToString() { return string.Format("TestMethods.LeakTest({0})", Cfg.ToString(1)); } + public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(1)); } public bool CanTest(MetersKind meters) { return true; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + message = string.Format("{0}: CheckDeviceCaps() is not implemented yet", Name); + return false; + } + readonly TestMethodCfg testMethodCfg; - public TestMethod() - { - } - - public TestMethod(Generic.IComponentCfg cfg) + public TestMethod() { } + /// + public TestMethod(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/LiveStream/Component.cs b/TBF/BenchControl/TestMethods/LiveStream/Component.cs index be35884ad..f57ef36ba 100644 --- a/TBF/BenchControl/TestMethods/LiveStream/Component.cs +++ b/TBF/BenchControl/TestMethods/LiveStream/Component.cs @@ -12,18 +12,22 @@ namespace TBF.BenchControl.TestMethods.LiveStream public class Component : ComponentBase, GenericDevices.ITestMethod { private static readonly ILog log = LogManager.GetLogger(typeof(Component)); - public override string ToString() { return string.Format("TestMethods.LiveStream({0})", Cfg.ToString(1)); } + public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(1)); } public bool CanTest(MetersKind meters) { return true; } public bool DoTransitions() { return false; } readonly LiveStreamCfg cfg; - public Component() - { - } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + message = string.Format("{0}: CheckDeviceCaps() is not implemented yet", Name); + return false; + } - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { log.Debug(this.ToString()); diff --git a/TBF/BenchControl/TestMethods/ManualEntry/Component.cs b/TBF/BenchControl/TestMethods/ManualEntry/Component.cs index 7e35b02cd..96035eb21 100644 --- a/TBF/BenchControl/TestMethods/ManualEntry/Component.cs +++ b/TBF/BenchControl/TestMethods/ManualEntry/Component.cs @@ -19,10 +19,15 @@ namespace TBF.BenchControl.TestMethods.ManualEntry public bool CanTest(MetersKind meters) { return true; } public bool DoTransitions() { return false; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + message = string.Format("{0}: CheckDeviceCaps() is not implemented yet", Name); + return false; + } - public Component() { } - - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { myCfg = cfg as ManualEntryCfg; diff --git a/TBF/BenchControl/TestMethods/ManualEntry/ManualEntrySeq.cs b/TBF/BenchControl/TestMethods/ManualEntry/ManualEntrySeq.cs index 30c640bb6..f39a11456 100644 --- a/TBF/BenchControl/TestMethods/ManualEntry/ManualEntrySeq.cs +++ b/TBF/BenchControl/TestMethods/ManualEntry/ManualEntrySeq.cs @@ -42,7 +42,7 @@ namespace TBF.BenchControl.TestMethods.ManualEntry checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, 0)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); diff --git a/TBF/BenchControl/TestMethods/OuterLoop/End/Component.cs b/TBF/BenchControl/TestMethods/OuterLoop/End/Component.cs index c5ff15deb..dd0758f31 100644 --- a/TBF/BenchControl/TestMethods/OuterLoop/End/Component.cs +++ b/TBF/BenchControl/TestMethods/OuterLoop/End/Component.cs @@ -19,11 +19,15 @@ namespace TBF.BenchControl.TestMethods.OuterLoop.End public bool CanTest(MetersKind meters) { return true; } public bool DoTransitions() { return false; } - public Component() - { - } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + message = string.Format("{0}: CheckDeviceCaps() is not implemented yet", Name); + return false; + } - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { log.Debug(this.ToString()); diff --git a/TBF/BenchControl/TestMethods/OuterLoop/Start/Component.cs b/TBF/BenchControl/TestMethods/OuterLoop/Start/Component.cs index 745b7ac69..5a884527b 100644 --- a/TBF/BenchControl/TestMethods/OuterLoop/Start/Component.cs +++ b/TBF/BenchControl/TestMethods/OuterLoop/Start/Component.cs @@ -19,11 +19,15 @@ namespace TBF.BenchControl.TestMethods.OuterLoop.Start public bool CanTest(MetersKind meters) { return true; } public bool DoTransitions() { return false; } - public Component() - { - } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + message = string.Format("{0}: CheckDeviceCaps() is not implemented yet", Name); + return false; + } - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { log.Debug(this.ToString()); diff --git a/TBF/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs b/TBF/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs index f3054031d..f34cafd26 100644 --- a/TBF/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs +++ b/TBF/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs @@ -31,7 +31,7 @@ namespace TBF.BenchControl.TestMethods.PMaxTest { IList e; /// Events from currently running operations Event retVal = Event.Done; - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; + TBF.BenchControl.ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false); @@ -60,7 +60,7 @@ namespace TBF.BenchControl.TestMethods.PMaxTest while (e.Contains(Event.Busy)); /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, 1, inPath, benchPath, outPath, sensPath, heatMetersPath, 0)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, 1, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, 1); TestStartTime = DateTime.Now; diff --git a/TBF/BenchControl/TestMethods/PMaxTest/TestMethod.cs b/TBF/BenchControl/TestMethods/PMaxTest/TestMethod.cs index 91a72c582..8f991b523 100644 --- a/TBF/BenchControl/TestMethods/PMaxTest/TestMethod.cs +++ b/TBF/BenchControl/TestMethods/PMaxTest/TestMethod.cs @@ -19,14 +19,18 @@ namespace TBF.BenchControl.TestMethods.PMaxTest public bool CanTest(MetersKind meters) { return true; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + message = string.Format("{0}: CheckDeviceCaps() is not implemented yet", Name); + return false; + } + readonly TestMethodCfg testMethodCfg; - public TestMethod() - { - } - - public TestMethod(Generic.IComponentCfg cfg) + public TestMethod() { } + /// + public TestMethod(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/PulsesTest/PulsesTestSeq.cs b/TBF/BenchControl/TestMethods/PulsesTest/PulsesTestSeq.cs index e6c94c40f..6531d9e1f 100644 --- a/TBF/BenchControl/TestMethods/PulsesTest/PulsesTestSeq.cs +++ b/TBF/BenchControl/TestMethods/PulsesTest/PulsesTestSeq.cs @@ -80,7 +80,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTest IList e; /// Events from currently running operations Event retVal = Event.Done; - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; + TBF.BenchControl.ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false); @@ -98,7 +98,10 @@ namespace TBF.BenchControl.TestMethods.PulsesTest } } - cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + if (cBrd is ControlBoard.Legacy.ControlBoardDev) + { + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + } IList readTempPressOps = new List(); if (benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp)); @@ -116,7 +119,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTest int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f); /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, totalPulses)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); /// Read pressure and temperature once before calling Bridge.OnTestSelected(...) @@ -218,7 +221,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTest State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) + .AddOperation(cBrd.SetFlowOp(test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -337,7 +340,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTest .AddOperation(checkUiOp) .AddOperations(readTempPressOps) .AddOperations(measureOperations) - .AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Synchro, test.Qfrom, test.Qto, totalPulses)) + .AddOperation(cBrd.StartTestOp(test)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -364,8 +367,8 @@ namespace TBF.BenchControl.TestMethods.PulsesTest case Event.MeasurementCompleted: goto one_test_completed; } - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; + RefFrequency.Val = cBrd.RefFrequency; + RefFlow.Val = cBrd.RefFlow; UpdateAllStatistics(StateMachine.Time); Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); @@ -399,12 +402,12 @@ namespace TBF.BenchControl.TestMethods.PulsesTest tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TTime; /// [s] measurement time - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total) + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) tstRslt.MassStart = 0; tstRslt.MassEnd = 0; - tstRslt.FlowMass = 0; /// [kg/h] - tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * cBrd.EtPulses(0) / tstRslt.TestTime; /// [m3/h] + tstRslt.FlowMass = 0; /// [kg/h] + tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h] tstRslt.Buoyancy = Config.Formulas.Buoyancy(); tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient @@ -442,7 +445,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTest meterRslt.VolumeEnd = 0; /// liter meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter meterRslt.VolumeRef = meterRslt.PulsesMaster * tstRslt.ConstMaster; /// liter - meterRslt.TestTime = cBrd.ImpulseTime(i + 1); + meterRslt.TestTime = cBrd.TestTimeWM(i + 1); meterRslt.Error = 0; meterRslt.Passed = (meterRslt.PulsesMeter >= (double)testParams.MinPulsesCount); meterRslt.TestDone = true; diff --git a/TBF/BenchControl/TestMethods/PulsesTest/TestMethod.cs b/TBF/BenchControl/TestMethods/PulsesTest/TestMethod.cs index 474d615b3..e645c95e1 100644 --- a/TBF/BenchControl/TestMethods/PulsesTest/TestMethod.cs +++ b/TBF/BenchControl/TestMethods/PulsesTest/TestMethod.cs @@ -12,18 +12,22 @@ namespace TBF.BenchControl.TestMethods.PulsesTest public class TestMethod : ComponentBase, GenericDevices.ITestMethod { private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod)); - public override string ToString() { return string.Format("TestMethods.PulsesTest({0})", Cfg.ToString(1)); } + public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(1)); } public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + message = string.Format("{0}: CheckDeviceCaps() is not implemented yet", Name); + return false; + } + readonly TestMethodCfg testMethodCfg; - public TestMethod() - { - } - - public TestMethod(Generic.IComponentCfg cfg) + public TestMethod() { } + /// + public TestMethod(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/PulsesTestManual/PulsesTestManualSeq.cs b/TBF/BenchControl/TestMethods/PulsesTestManual/PulsesTestManualSeq.cs index b88a22996..644879912 100644 --- a/TBF/BenchControl/TestMethods/PulsesTestManual/PulsesTestManualSeq.cs +++ b/TBF/BenchControl/TestMethods/PulsesTestManual/PulsesTestManualSeq.cs @@ -81,7 +81,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTestManual IList e; /// Events from currently running operations Event retVal = Event.Done; - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; + TBF.BenchControl.ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false); @@ -99,7 +99,10 @@ namespace TBF.BenchControl.TestMethods.PulsesTestManual } } - cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + if (cBrd is ControlBoard.Legacy.ControlBoardDev) + { + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + } IList readTempPressOps = new List(); if (benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp)); @@ -130,7 +133,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTestManual while (e.Contains(Event.Busy)); /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, totalPulses)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); TestStartTime = DateTime.Now; @@ -220,7 +223,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTestManual State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) + .AddOperation(cBrd.SetFlowOp(test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -339,7 +342,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTestManual .AddOperation(checkUiOp) .AddOperations(readTempPressOps) .AddOperations(measureOperations) - .AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Synchro, test.Qfrom, test.Qto, totalPulses)) + .AddOperation(cBrd.StartTestOp(test)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); @@ -366,8 +369,8 @@ namespace TBF.BenchControl.TestMethods.PulsesTestManual case Event.MeasurementCompleted: goto one_test_completed; } - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; + RefFrequency.Val = cBrd.RefFrequency; + RefFlow.Val = cBrd.RefFlow; UpdateAllStatistics(StateMachine.Time); Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); @@ -401,12 +404,12 @@ namespace TBF.BenchControl.TestMethods.PulsesTestManual tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TTime; /// [s] measurement time - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total) + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time + tstRslt.PulsesMaster = Convert.ToDouble(cBrd.RefPulses); /// Pulses of the master flow meter (test total) tstRslt.MassStart = 0; tstRslt.MassEnd = 0; - tstRslt.FlowMass = 0; /// [kg/h] - tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * cBrd.EtPulses(0) / tstRslt.TestTime; /// [m3/h] + tstRslt.FlowMass = 0; /// [kg/h] + tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * cBrd.RefPulses / tstRslt.TestTime; /// [m3/h] tstRslt.Buoyancy = Config.Formulas.Buoyancy(); tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter tstRslt.ConstMasterRaw = outPath.FlowMeter.LtrPerPulse; /// Uncorrected master flowmeter coefficient @@ -444,7 +447,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTestManual meterRslt.VolumeEnd = 0; /// liter meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter meterRslt.VolumeRef = meterRslt.PulsesMaster * tstRslt.ConstMaster; /// liter - meterRslt.TestTime = cBrd.ImpulseTime(i + 1); + meterRslt.TestTime = cBrd.TestTimeWM(i + 1); meterRslt.Error = 0; meterRslt.Passed = (modelessDlg as IHasGetPassed).GetPassed(i); meterRslt.TestDone = true; diff --git a/TBF/BenchControl/TestMethods/PulsesTestManual/TestMethod.cs b/TBF/BenchControl/TestMethods/PulsesTestManual/TestMethod.cs index 392009693..51d8b115d 100644 --- a/TBF/BenchControl/TestMethods/PulsesTestManual/TestMethod.cs +++ b/TBF/BenchControl/TestMethods/PulsesTestManual/TestMethod.cs @@ -12,16 +12,20 @@ namespace TBF.BenchControl.TestMethods.PulsesTestManual public class TestMethod : ComponentBase, GenericDevices.ITestMethod { private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod)); - public override string ToString() { return string.Format("TestMethods.PulsesTestManual({0})", Cfg.ToString(1)); } + public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(1)); } public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + message = string.Format("{0}: CheckDeviceCaps() is not implemented yet", Name); + return false; + } - public TestMethod() - { - } - public TestMethod(Generic.IComponentCfg cfg) + public TestMethod() { } + /// + public TestMethod(Generic.IComponentCfg cfg) : base(cfg) { log.Debug(this.ToString()); diff --git a/TBF/BenchControl/TestMethods/Q2CorrectionFromHistory/Component.cs b/TBF/BenchControl/TestMethods/Q2CorrectionFromHistory/Component.cs index bb3618a83..3f5f145a3 100644 --- a/TBF/BenchControl/TestMethods/Q2CorrectionFromHistory/Component.cs +++ b/TBF/BenchControl/TestMethods/Q2CorrectionFromHistory/Component.cs @@ -11,12 +11,15 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory public class Component : ComponentBase, GenericDevices.ISimultTestMethod { private static readonly ILog log = LogManager.GetLogger(typeof(Component)); - public override string ToString() { return string.Format("TestMethods.GrabImage({0})", Cfg.ToString(1)); } + public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(1)); } public bool CanTest(MetersKind meters) { return true; } public bool DoTransitions() { return false; } - - readonly FromHistoryCfg cfg; + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + message = string.Format("{0}: CheckDeviceCaps() is not implemented yet", Name); + return false; + } public bool SimultWithPrevious { get { return false; } } public bool SimultWithNext { get { return false; } } @@ -57,11 +60,11 @@ namespace TBF.BenchControl.TestMethods.Q2CorrectionFromHistory #endregion Configuration Change Handling - public Component() - { - } + readonly FromHistoryCfg cfg; - public Component(Generic.IComponentCfg cfg) + public Component() { } + /// + public Component(Generic.IComponentCfg cfg) : base(cfg) { this.cfg = cfg as FromHistoryCfg; diff --git a/TBF/BenchControl/TestMethods/RoiDetection/RoiDetection.cs b/TBF/BenchControl/TestMethods/RoiDetection/RoiDetection.cs index b099c56f0..8cc3e2713 100644 --- a/TBF/BenchControl/TestMethods/RoiDetection/RoiDetection.cs +++ b/TBF/BenchControl/TestMethods/RoiDetection/RoiDetection.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2017 Sensus Metering Systems +/// Copyright (c) 2017-2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -12,15 +12,19 @@ namespace TBF.BenchControl.TestMethods.RoiDetection public class RoiDetection : ComponentBase, GenericDevices.ITestMethod { private static readonly ILog log = LogManager.GetLogger(typeof(RoiDetection)); - public override string ToString() { return string.Format("TestMethods.RoiDetection({0})", Cfg.ToString(1)); } + public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(1)); } public bool CanTest(MetersKind meters) { return true; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + message = string.Format("{0}: CheckDeviceCaps() is not implemented yet", Name); + return false; + } - public RoiDetection() - { - } + public RoiDetection() { } + /// public RoiDetection(Generic.IComponentCfg cfg) : base(cfg) { diff --git a/TBF/BenchControl/TestMethods/RoiDetection/RoiDetectionSeq.cs b/TBF/BenchControl/TestMethods/RoiDetection/RoiDetectionSeq.cs index 793dd2bfa..8f9935a82 100644 --- a/TBF/BenchControl/TestMethods/RoiDetection/RoiDetectionSeq.cs +++ b/TBF/BenchControl/TestMethods/RoiDetection/RoiDetectionSeq.cs @@ -21,7 +21,7 @@ namespace TBF.BenchControl.TestMethods.RoiDetection { IList e; /// Events from currently running operations Event retVal = Event.Done; - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; + TBF.BenchControl.ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; checkUiOp = new Operations.CheckUIOp(true); processDataLoggingOp = null; @@ -39,7 +39,10 @@ namespace TBF.BenchControl.TestMethods.RoiDetection } } - cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + if (cBrd is ControlBoard.Legacy.ControlBoardDev) + { + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + } IList readTempPressOps = new List(); if (benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp)); @@ -61,7 +64,7 @@ namespace TBF.BenchControl.TestMethods.RoiDetection //==================== // Start the test //==================== - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, totalPulses)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); TestStartTime = DateTime.Now; @@ -145,7 +148,7 @@ namespace TBF.BenchControl.TestMethods.RoiDetection State.Create(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name)) .AddOperation(checkUiOp) .AddOperations(readTempPressOps) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) + .AddOperation(cBrd.SetFlowOp(test.Qfrom, test.Qto, RefFlow, FlowSettingTimeoutSec)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); diff --git a/TBF/BenchControl/TestMethods/SensitivityTest/SensitivityTestSeq.cs b/TBF/BenchControl/TestMethods/SensitivityTest/SensitivityTestSeq.cs index 20e7f64f5..b75170bd7 100644 --- a/TBF/BenchControl/TestMethods/SensitivityTest/SensitivityTestSeq.cs +++ b/TBF/BenchControl/TestMethods/SensitivityTest/SensitivityTestSeq.cs @@ -60,7 +60,7 @@ namespace TBF.BenchControl.TestMethods.SensitivityTest IList e; /// Events from currently running operations Event retVal = Event.Done; - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; + TBF.BenchControl.ControlBoard.IControlBoard cBrd = StateMachine.ControlBoard; checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false); @@ -78,7 +78,10 @@ namespace TBF.BenchControl.TestMethods.SensitivityTest } } - cBrd.SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + if (cBrd is ControlBoard.Legacy.ControlBoardDev) + { + (cBrd as ControlBoard.Legacy.ControlBoardDev).SetFiltersPidShortPulses(filters, outPath.PidCoef, (test.TolerRed == 0) ? 0 : 1); + } IList readTempPressOps = new List(); if (benchPath.TempMtrUp != null) readTempPressOps.Add(benchPath.TempMtrUp.ReadTempOp(ref TempUp)); @@ -139,7 +142,7 @@ namespace TBF.BenchControl.TestMethods.SensitivityTest while (e.Contains(Event.Busy)); /// Start the test, initialize test results - Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath, totalPulses)); + Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, heatMetersPath)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); TestStartTime = DateTime.Now; @@ -305,7 +308,7 @@ namespace TBF.BenchControl.TestMethods.SensitivityTest } /// TODO: !!! The following can only be done for compound meters - flowsForDetection[0] = cBrd.ReferenceFreq * outPath.FlowMeter.NominalFlow / 2000.0f; + flowsForDetection[0] = cBrd.RefFrequency * outPath.FlowMeter.NominalFlow / 2000.0f; for (int i = 0; i < Config.Data.WMsCount; i++) { double diff = (RegisterReaders[i] != null) ? (RegisterReaders[i].WMPulses - lastWMPulses[i]) : 0; @@ -468,8 +471,8 @@ namespace TBF.BenchControl.TestMethods.SensitivityTest tstRslt.StartTime = TestStartTime; tstRslt.EndTime = TestEndTime; tstRslt.FlowSetTime = flowSetTime1 - flowSetTime0; - tstRslt.TestTime = cBrd.TTime; /// [s] measurement time - tstRslt.PulsesMaster = 0; /// Pulses of the master flow meter (test total) + tstRslt.TestTime = cBrd.TestTime; /// [s] measurement time + tstRslt.PulsesMaster = 0; /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = 0; tstRslt.MassStart = 0; tstRslt.MassEndRaw = 0; diff --git a/TBF/BenchControl/TestMethods/SensitivityTest/TestMethod.cs b/TBF/BenchControl/TestMethods/SensitivityTest/TestMethod.cs index 080755ef8..02f990bc4 100644 --- a/TBF/BenchControl/TestMethods/SensitivityTest/TestMethod.cs +++ b/TBF/BenchControl/TestMethods/SensitivityTest/TestMethod.cs @@ -12,18 +12,22 @@ namespace TBF.BenchControl.TestMethods.SensitivityTest public class TestMethod : ComponentBase, GenericDevices.ITestMethod { private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod)); - public override string ToString() { return string.Format("TestMethods.SensitivityTest({0})", Cfg.ToString(1)); } - - readonly TestMethodCfg testMethodCfg; + public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(1)); } public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } public bool DoTransitions() { return true; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + message = string.Format("{0}: CheckDeviceCaps() is not implemented yet", Name); + return false; + } - public TestMethod() - { - } - public TestMethod(Generic.IComponentCfg cfg) + readonly TestMethodCfg testMethodCfg; + + public TestMethod() { } + /// + public TestMethod(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/iPerlCommunication/TestMethod.cs b/TBF/BenchControl/TestMethods/iPerlCommunication/TestMethod.cs index 280332f7f..e0d15fc05 100644 --- a/TBF/BenchControl/TestMethods/iPerlCommunication/TestMethod.cs +++ b/TBF/BenchControl/TestMethods/iPerlCommunication/TestMethod.cs @@ -15,12 +15,16 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod)); protected static readonly ILog rfidDataLogger = LogManager.GetLogger("RfidData"); - public override string ToString() { return string.Format("TestMethods.iPerlCommunication({0})", Cfg.ToString(1)); } + public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(1)); } public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } public bool DoTransitions() { return false; } + public bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + message = string.Format("{0}: CheckDeviceCaps() is not implemented yet", Name); + return false; + } - readonly TestMethodCfg testMethodCfg; public bool SimultWithPrevious { get { return testMethodCfg.TestParams.SimultWithPrevious; } } public bool SimultWithNext { get { return testMethodCfg.TestParams.SimultWithNext; } } @@ -60,11 +64,11 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication #endregion Configuration Change Handling - public TestMethod() - { - } + readonly TestMethodCfg testMethodCfg; - public TestMethod(Generic.IComponentCfg cfg) + public TestMethod() { } + /// + public TestMethod(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; diff --git a/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs b/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs index af9516f17..f80331c39 100644 --- a/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs +++ b/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs @@ -528,11 +528,6 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead ReadPulses(); } - public void TestCompleted() - { - /// TODO: Implement - } - int timeFromStart; /// [s] Time from test start to determine when the test start sample should be taken @@ -734,7 +729,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead endWMState = volumeLtr; wmVolume = Math.Abs(endWMState - beginWMState); wmPulses = (int)(wmVolume * (double)PulsesPerLtr + 0.5); - wmRefPulses = StateMachine.ControlBoard.EtPulses(0); + wmRefPulses = StateMachine.ControlBoard.RefPulses; wmTestTime = timestampSec - timestampSec0; } diff --git a/TBF/BenchControl/Various/TankWithLevelMsrmnt/TankCfgCtrl.cs b/TBF/BenchControl/Various/TankWithLevelMsrmnt/TankCfgCtrl.cs index b134f5175..0618b065d 100644 --- a/TBF/BenchControl/Various/TankWithLevelMsrmnt/TankCfgCtrl.cs +++ b/TBF/BenchControl/Various/TankWithLevelMsrmnt/TankCfgCtrl.cs @@ -47,7 +47,7 @@ namespace TBF.BenchControl.Various.TankWithLevelMsrmnt { IComponentFactory cmpntFact = TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName); - if (cmpntFact is Elde.Valve.ValveFactory) + if (cmpntFact is BuiltIn.Valve.ValveFactory) { drainValveComboBox.Items.Add(cmpnt.Name); drainValve2ComboBox.Items.Add(cmpnt.Name); diff --git a/TBF/Resources/Strings.Designer.cs b/TBF/Resources/Strings.Designer.cs index c66da85cc..586ea4722 100644 --- a/TBF/Resources/Strings.Designer.cs +++ b/TBF/Resources/Strings.Designer.cs @@ -2904,6 +2904,24 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Missing a diverter. + /// + internal static string Missing_a_diverter { + get { + return ResourceManager.GetString("Missing_a_diverter", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Missing a flow meter. + /// + internal static string Missing_a_flow_meter { + get { + return ResourceManager.GetString("Missing_a_flow_meter", resourceCulture); + } + } + /// /// Looks up a localized string similar to Missing a pressure meter. /// @@ -2913,6 +2931,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Missing a regulation valve. + /// + internal static string Missing_a_regulation_valve { + get { + return ResourceManager.GetString("Missing_a_regulation_valve", resourceCulture); + } + } + /// /// Looks up a localized string similar to Missing a scale. /// @@ -2940,6 +2967,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Missing a volume meter. + /// + internal static string Missing_a_volume_meter { + get { + return ResourceManager.GetString("Missing_a_volume_meter", resourceCulture); + } + } + /// /// Looks up a localized string similar to Mode. /// @@ -5604,6 +5640,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Test bench does not suport the selected test method. + /// + internal static string Test_bench_does_not_suport_selected_test_method { + get { + return ResourceManager.GetString("Test_bench_does_not_suport_selected_test_method", resourceCulture); + } + } + /// /// Looks up a localized string similar to Test bench is controlled by this computer. /// diff --git a/TBF/Resources/Strings.resx b/TBF/Resources/Strings.resx index 2b356e69b..90bbc4325 100644 --- a/TBF/Resources/Strings.resx +++ b/TBF/Resources/Strings.resx @@ -2251,4 +2251,19 @@ All day + + Missing a flow meter + + + Test bench does not suport the selected test method + + + Missing a volume meter + + + Missing a regulation valve + + + Missing a diverter + \ No newline at end of file diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index af54434fa..e517576ba 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -162,6 +162,44 @@ AmbientCfgCtrl.cs + + + + UserControl + + + PumpCfgCtrl.cs + + + + + + UserControl + + + PumpCfgCtrl.cs + + + + + + + + UserControl + + + ValveCfgCtrl.cs + + + + + + UserControl + + + ValveCfgCtrl.cs + + Form @@ -184,6 +222,47 @@ ComponentCfgCtrl.cs + + + + UserControl + + + CBoardCfgCtrl.cs + + + + + + UserControl + + + ControlBoardCfgCtrl.cs + + + + + + + + + + + + + + + + + + + + UserControl + + + CBoardCfgCtrl.cs + + @@ -538,6 +617,7 @@ + @@ -567,10 +647,6 @@ - - - - @@ -583,9 +659,6 @@ - - - @@ -600,15 +673,6 @@ - - - - UserControl - - - ValveCfgCtrl.cs - - @@ -1126,6 +1190,16 @@ + + + + UserControl + + + RegisterReaderCfgCtrl.cs + + + @@ -1719,16 +1793,6 @@ EntryFormCfgCtrl.cs - - - - UserControl - - - RegisterReaderCfgCtrl.cs - - - @@ -1738,15 +1802,6 @@ FlowMeterCfgCtrl.cs - - - - UserControl - - - PumpCfgCtrl.cs - - @@ -1772,8 +1827,6 @@ - - UserControl @@ -1786,26 +1839,13 @@ FlowMeterCfgCtrl.cs - - - - UserControl PressureMeterCfgCtrl.cs - - - - UserControl - - - PumpCfgCtrl.cs - - @@ -1842,16 +1882,9 @@ - - - UserControl - - - ValveCfgCtrl.cs - Form @@ -1874,7 +1907,6 @@ - @@ -1948,15 +1980,6 @@ True Strings.zh-CN.resx - - - - UserControl - - - ControlBoardCfgCtrl.cs - - @@ -1975,9 +1998,6 @@ - - - @@ -1995,7 +2015,6 @@ - @@ -2555,6 +2574,18 @@ AmbientCfgCtrl.cs + + PumpCfgCtrl.cs + + + PumpCfgCtrl.cs + + + ValveCfgCtrl.cs + + + ValveCfgCtrl.cs + ComponentParametersDlg.cs @@ -2564,6 +2595,15 @@ ComponentCfgCtrl.cs + + CBoardCfgCtrl.cs + + + ControlBoardCfgCtrl.cs + + + CBoardCfgCtrl.cs + PumpCfgCtrl.cs @@ -2792,9 +2832,6 @@ DiverterCfgCtrl.cs - - RegisterReaderCfgCtrl.cs - FlowMeterCfgCtrl.cs @@ -2813,15 +2850,9 @@ PressureMeterCfgCtrl.cs - - PumpCfgCtrl.cs - PumpCfgCtrl.cs - - PumpCfgCtrl.cs - RegisterReaderCfgCtrl.cs @@ -2840,12 +2871,6 @@ TempMeterCfgCtrl.cs - - ValveCfgCtrl.cs - - - ValveCfgCtrl.cs - MultimeterCfgCtrl.cs @@ -2987,6 +3012,9 @@ SerialStreamCfgCtrl.cs + + RegisterReaderCfgCtrl.cs + WMErrorsForm.cs @@ -3168,9 +3196,6 @@ ResXFileCodeGenerator Strings.zh-CN.Designer.cs - - ControlBoardCfgCtrl.cs - ResXFileCodeGenerator Resources.Designer.cs @@ -3578,7 +3603,9 @@ Users - + + +