From d420128b4ba97f1a916259ef341018f01d5ddc7c Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Tue, 28 Mar 2017 23:47:32 +0200 Subject: [PATCH] Draining modified, in BERLIN done always before flow setting, ver. 2.12.518 --- Config/Entities/OutputPath.cs | 4 +- Config/Entities/Test.cs | 6 +- Config/Entities/TestResult.cs | 2 +- Config/Mappings/OutputPathMap.cs | 3 +- Config/Mappings/TestMap.cs | 3 +- Config/Properties/AssemblyInfo.cs | 4 +- .../BenchControl/Dummy/Balance/Component.cs | 4 +- .../GenericDevices/{IBalance.cs => IScale.cs} | 6 +- .../{IBalance2.cs => IScale2.cs} | 2 +- .../{IBalanceCfg.cs => IScaleCfg.cs} | 4 +- .../MettlerToledo/Multi/BalanceCfg.cs | 2 +- .../MettlerToledo/Multi/BalanceDev.cs | 4 +- .../MettlerToledo/Standard/BalanceCfg.cs | 2 +- .../MettlerToledo/Standard/BalanceDev.cs | 4 +- .../MettlerToledo/Standard/BalanceNewDev.cs | 2 +- .../MettlerToledo/Standard/BalanceOld.cs | 2 +- .../BenchControl/Operations/CheckUIOp.cs | 6 +- TestBenchFramework/BenchControl/OutputPath.cs | 12 +- .../BenchControl/Sequences/MainSeq.cs | 134 +++--- .../BenchControl/Sequences/SequenceBase.cs | 46 +- .../BenchControl/StateMachine.cs | 40 +- .../TestMethods/Adjustment/AdjustmentSeq.cs | 2 +- .../CombinedWithDetectionSeq.cs | 18 +- .../TestMethods/Endurance/EnduranceSeq.cs | 2 +- .../FixedStartAdvancedSeq.cs | 455 +++++++++--------- .../FixedStartMassCollectionSeq.cs | 154 +++--- .../TestMethods/FlyingStart/FlyingStartSeq.cs | 2 +- .../FlyingStartMassCollectionSeq.cs | 63 ++- .../TestMethods/LeakTest/LeakTestSeq.cs | 2 +- .../TestMethods/PMaxTest/PMaxTestSeq.cs | 2 +- .../ReferenceFlowmeterCalibrationSeq.cs | 20 +- TestBenchFramework/MetrologyDlg.cs | 2 +- TestBenchFramework/ProcedureDlg.cs | 6 +- TestBenchFramework/Properties/AssemblyInfo.cs | 4 +- .../Screens/ProcessTabPageCtrl24.cs | 2 +- .../Screens/ProcessTabPageCtrl48.cs | 2 +- .../Screens/ProcessTabPageCtrl6.cs | 2 +- TestBenchFramework/TBF.csproj | 6 +- TestBenchFramework/UiBridge/Enums.cs | 14 +- .../UiControls/BenchControlPanel.cs | 16 +- .../UiControls/MetrologyDlgBalanceTab.cs | 2 +- .../UiControls/PathsOutputCtrl.cs | 8 +- 42 files changed, 553 insertions(+), 523 deletions(-) rename TestBenchFramework/BenchControl/GenericDevices/{IBalance.cs => IScale.cs} (95%) rename TestBenchFramework/BenchControl/GenericDevices/{IBalance2.cs => IScale2.cs} (88%) rename TestBenchFramework/BenchControl/GenericDevices/{IBalanceCfg.cs => IScaleCfg.cs} (89%) diff --git a/Config/Entities/OutputPath.cs b/Config/Entities/OutputPath.cs index e2e635463..3aa7c84f8 100644 --- a/Config/Entities/OutputPath.cs +++ b/Config/Entities/OutputPath.cs @@ -19,7 +19,7 @@ namespace Config.Entities public virtual string StartValve { get; set; } public virtual string Diverter { get; set; } public virtual string TempDiv { get; set; } - public virtual string Balance { get; set; } + public virtual string Scale { get; set; } public virtual string EmptyTankValve { get; set; } /// Valves @@ -54,7 +54,7 @@ namespace Config.Entities result.StartValve = StartValve; result.Diverter = Diverter; result.TempDiv = TempDiv; - result.Balance = Balance; + result.Scale = Scale; result.EmptyTankValve = EmptyTankValve; result.ValvesOpen = ValvesOpen; result.ValvesClose = ValvesClose; diff --git a/Config/Entities/Test.cs b/Config/Entities/Test.cs index 1e4d44bc9..8300a0346 100644 --- a/Config/Entities/Test.cs +++ b/Config/Entities/Test.cs @@ -28,7 +28,7 @@ namespace Config.Entities public virtual float ErrLimHi { get; set; } /// in [%] (usually > 0) public virtual float Uncertainty { get; set; } /// int [%] makes error limits tighter: 0 <= Uncertainty <= abs(ErrLimXx) public virtual int Repeats { get; set; } - public virtual bool Emptying { get; set; } + public virtual bool Draining { get; set; } public virtual bool Zeroing { get; set; } public virtual float PumpPower { get; set; } /// Power of the pump in [%] in the range 0 .. 100.0f, use values 0% and 100% for non-FM pumps public virtual int MassRepeats { get; set; } /// Number of mass. measurements at the beginning/end of test, 0 = default (=5) @@ -68,7 +68,7 @@ namespace Config.Entities Publish = (sbyte)Config.Entities.Publish.Always; Evaluate = true; Repeats = 1; - Emptying = false; + Draining = false; Zeroing = false; ErrLimLo = -2.0f; /// [%] lower error limit ErrLimHi = 2.0f; /// [%] upper error limit @@ -109,7 +109,7 @@ namespace Config.Entities result.Volume = Volume; result.TstTime = TstTime; result.Repeats = Repeats; - result.Emptying = Emptying; + result.Draining = Draining; result.Zeroing = Zeroing; result.PumpPower = PumpPower; result.MassRepeats = MassRepeats; diff --git a/Config/Entities/TestResult.cs b/Config/Entities/TestResult.cs index 6b029e0c5..895cad2f6 100644 --- a/Config/Entities/TestResult.cs +++ b/Config/Entities/TestResult.cs @@ -153,7 +153,7 @@ namespace Config.Entities Volume = test.Volume; TstTime = test.TstTime; Repeats = test.Repeats; - Emptying = test.Emptying; + Emptying = test.Draining; Zeroing = test.Zeroing; PumpPower = PumpPower; Time2MassMsrmt = test.TimeStop2Mass; diff --git a/Config/Mappings/OutputPathMap.cs b/Config/Mappings/OutputPathMap.cs index 4f7bdf250..1e7ebbe14 100644 --- a/Config/Mappings/OutputPathMap.cs +++ b/Config/Mappings/OutputPathMap.cs @@ -21,7 +21,8 @@ namespace Config.Mappings Map(x => x.StartValve); Map(x => x.Diverter); Map(x => x.TempDiv); - Map(x => x.Balance); + Map(x => x.Scale) + .Column("Balance"); Map(x => x.EmptyTankValve); Map(x => x.ValvesOpen) .CustomType("StringClob") diff --git a/Config/Mappings/TestMap.cs b/Config/Mappings/TestMap.cs index 01c5794be..de1fe037b 100644 --- a/Config/Mappings/TestMap.cs +++ b/Config/Mappings/TestMap.cs @@ -22,7 +22,8 @@ namespace Config.Mappings Map(x => x.Volume); Map(x => x.TstTime); Map(x => x.Repeats); - Map(x => x.Emptying); + Map(x => x.Draining) + .Column("Emptying"); Map(x => x.Zeroing); Map(x => x.PumpPower); Map(x => x.MassRepeats); diff --git a/Config/Properties/AssemblyInfo.cs b/Config/Properties/AssemblyInfo.cs index aebfa538c..0695aa1ea 100644 --- a/Config/Properties/AssemblyInfo.cs +++ b/Config/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.12.499.0")] -[assembly: AssemblyFileVersion("2.12.499.0")] +[assembly: AssemblyVersion("2.12.518.0")] +[assembly: AssemblyFileVersion("2.12.518.0")] diff --git a/TestBenchFramework/BenchControl/Dummy/Balance/Component.cs b/TestBenchFramework/BenchControl/Dummy/Balance/Component.cs index 6ec6b14dc..c1e594b18 100644 --- a/TestBenchFramework/BenchControl/Dummy/Balance/Component.cs +++ b/TestBenchFramework/BenchControl/Dummy/Balance/Component.cs @@ -8,7 +8,7 @@ using Config.Entities; namespace TBF.BenchControl.Dummy.Balance { - public class Component : ComponentBase, GenericDevices.IBalance, IOperation + public class Component : ComponentBase, GenericDevices.IScale, IOperation { private static readonly ILog log = LogManager.GetLogger(typeof(Component)); public override string ToString() @@ -26,7 +26,7 @@ namespace TBF.BenchControl.Dummy.Balance log.Debug(this.ToString()); } - public int BalanceNr { get { return 0; } } + public int ScaleNr { get { return 0; } } public double Capacity { get { return 10000.0; } } public GenericDevices.IValve DrainValve { get { return null; } } public bool IsEmpty(double mass) { return true; } diff --git a/TestBenchFramework/BenchControl/GenericDevices/IBalance.cs b/TestBenchFramework/BenchControl/GenericDevices/IScale.cs similarity index 95% rename from TestBenchFramework/BenchControl/GenericDevices/IBalance.cs rename to TestBenchFramework/BenchControl/GenericDevices/IScale.cs index b43c6ed01..9deeb01b0 100644 --- a/TestBenchFramework/BenchControl/GenericDevices/IBalance.cs +++ b/TestBenchFramework/BenchControl/GenericDevices/IScale.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2017 Sensus Metering Systems /// using System.Collections.Generic; using TBF.BenchControl.Generic; @@ -10,12 +10,12 @@ namespace TBF.BenchControl.GenericDevices /// /// Basic balance functions /// - public interface IBalance : IComponent + public interface IScale : IComponent { /// /// Balance number: 0-based index required for communication with the Elde component /// - int BalanceNr { get; } + int ScaleNr { get; } /// /// Balance water tank capacity in kg or ltr diff --git a/TestBenchFramework/BenchControl/GenericDevices/IBalance2.cs b/TestBenchFramework/BenchControl/GenericDevices/IScale2.cs similarity index 88% rename from TestBenchFramework/BenchControl/GenericDevices/IBalance2.cs rename to TestBenchFramework/BenchControl/GenericDevices/IScale2.cs index 17459392c..5937a7629 100644 --- a/TestBenchFramework/BenchControl/GenericDevices/IBalance2.cs +++ b/TestBenchFramework/BenchControl/GenericDevices/IScale2.cs @@ -5,7 +5,7 @@ using TBF.BenchControl.Generic; namespace TBF.BenchControl.GenericDevices { - public interface IBalance2 : IBalance, IComponent + public interface IScale2 : IScale, IComponent { /// /// Events: Done, Error diff --git a/TestBenchFramework/BenchControl/GenericDevices/IBalanceCfg.cs b/TestBenchFramework/BenchControl/GenericDevices/IScaleCfg.cs similarity index 89% rename from TestBenchFramework/BenchControl/GenericDevices/IBalanceCfg.cs rename to TestBenchFramework/BenchControl/GenericDevices/IScaleCfg.cs index 1b432e52a..8288aa0e0 100644 --- a/TestBenchFramework/BenchControl/GenericDevices/IBalanceCfg.cs +++ b/TestBenchFramework/BenchControl/GenericDevices/IScaleCfg.cs @@ -1,12 +1,12 @@ /// -/// Copyright (c) 2013-2016 Sensus Metering Systems +/// Copyright (c) 2013-2017 Sensus Metering Systems /// using System; using TBF.BenchControl.Generic; namespace TBF.BenchControl.GenericDevices { - public interface IBalanceCfg : IComponentCfg + public interface IScaleCfg : IComponentCfg { /// /// Parameters displayed in Metrology tab page diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Multi/BalanceCfg.cs b/TestBenchFramework/BenchControl/MettlerToledo/Multi/BalanceCfg.cs index 9b7ff94b0..53f570a48 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Multi/BalanceCfg.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Multi/BalanceCfg.cs @@ -10,7 +10,7 @@ using TBF.BenchControl.Generic; namespace TBF.BenchControl.MettlerToledo.Multi { - public class BalanceCfg : ComponentCfgBase, GenericDevices.IBalanceCfg, GenericDevices.ICalibInfoCfg + public class BalanceCfg : ComponentCfgBase, GenericDevices.IScaleCfg, GenericDevices.ICalibInfoCfg { public IComponentCfgCtrl GetControl() { return new BalanceCfgCtrl(); } diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Multi/BalanceDev.cs b/TestBenchFramework/BenchControl/MettlerToledo/Multi/BalanceDev.cs index c4213ec56..2fbeebf4c 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Multi/BalanceDev.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Multi/BalanceDev.cs @@ -19,7 +19,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi /// /// Implemented and tested on 15.10.2013 by Milan Hanajik /// - public class BalanceDev : TankDraining, IDevice, GenericDevices.IBalance + public class BalanceDev : TankDraining, IDevice, GenericDevices.IScale { /// /// Info: StartMassMeasurement() and "Balnce response = .., Mass = ..." @@ -48,7 +48,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi protected static SerialPort serialPort; protected static StringBuilder stringBuilder; - public int BalanceNr { get { return balanceNr; } } + public int ScaleNr { get { return balanceNr; } } public int IdNr { get { return balanceCfg.IdNr; } } public double Capacity { get { return balanceCfg.Capacity; } } public double Resolution { get { return balanceCfg.Resolution; } } diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceCfg.cs b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceCfg.cs index c0cf8c181..531235e2b 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceCfg.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceCfg.cs @@ -10,7 +10,7 @@ using TBF.BenchControl.Generic; namespace TBF.BenchControl.MettlerToledo.Standard { - public class BalanceCfg : ComponentCfgBase, GenericDevices.IBalanceCfg, GenericDevices.ICalibInfoCfg, GenericDevices.ITankDrainingCfg + public class BalanceCfg : ComponentCfgBase, GenericDevices.IScaleCfg, GenericDevices.ICalibInfoCfg, GenericDevices.ITankDrainingCfg { public IComponentCfgCtrl GetControl() { return new BalanceCfgCtrl(); } diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceDev.cs b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceDev.cs index 33cf05b59..ccfc8ec2a 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceDev.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceDev.cs @@ -19,7 +19,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard /// /// Implemented and tested on 15.10.2013 by Milan Hanajik /// - public class BalanceDev : TankDraining, IDevice, GenericDevices.IBalance + public class BalanceDev : TankDraining, IDevice, GenericDevices.IScale { /// /// Info: StartMassMeasurement() and "Balnce response = .., Mass = ..." @@ -47,7 +47,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard protected SerialPort serialPort; protected StringBuilder stringBuilder; - public int BalanceNr { get { return balanceNr; } } + public int ScaleNr { get { return balanceNr; } } public double Capacity { get { return balanceCfg.Capacity; } } public int EmptyTimeSec { get { return balanceCfg.DrainTimeSec; } } diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceNewDev.cs b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceNewDev.cs index b8c32ce34..c9e002b5b 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceNewDev.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceNewDev.cs @@ -19,7 +19,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard /// /// Implemented and tested on 15.10.2013 by Milan Hanajik /// - public class BalanceNewDev : BalanceDev, IDevice, GenericDevices.IBalance2 + public class BalanceNewDev : BalanceDev, IDevice, GenericDevices.IScale2 { /// /// Info: StartMassMeasurement() and "Balnce response = .., Mass = ..." diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceOld.cs b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceOld.cs index 26149f15f..91e9d427a 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceOld.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceOld.cs @@ -18,7 +18,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard /// /// Implemented and tested on 15.10.2013 by Milan Hanajik /// - public class BalanceOld : BalanceDev, IDevice, GenericDevices.IBalance + public class BalanceOld : BalanceDev, IDevice, GenericDevices.IScale { /// /// Info: StartMassMeasurement() and "Balnce response = .., Mass = ..." diff --git a/TestBenchFramework/BenchControl/Operations/CheckUIOp.cs b/TestBenchFramework/BenchControl/Operations/CheckUIOp.cs index fa4f9002e..41c879532 100644 --- a/TestBenchFramework/BenchControl/Operations/CheckUIOp.cs +++ b/TestBenchFramework/BenchControl/Operations/CheckUIOp.cs @@ -85,9 +85,9 @@ namespace TBF.BenchControl.Operations case UI2BenchCmd.Stop: return Event.UiCmdStop; case UI2BenchCmd.PurgeBegin: return Event.UiCmdPurgeBegin; case UI2BenchCmd.PurgeEnd: return Event.UiCmdPurgeEnd; - case UI2BenchCmd.EmptyTank1: return Event.UiCmdEmptyTank1; - case UI2BenchCmd.EmptyTank2: return Event.UiCmdEmptyTank2; - case UI2BenchCmd.EmptyTank3: return Event.UiCmdEmptyTank3; + case UI2BenchCmd.DrainTank1: return Event.UiCmdEmptyTank1; + case UI2BenchCmd.DrainTank2: return Event.UiCmdEmptyTank2; + case UI2BenchCmd.DrainTank3: return Event.UiCmdEmptyTank3; case UI2BenchCmd.Break: return Event.UiCmdBreak; case UI2BenchCmd.ResetResults: return Event.UiCmdResetResults; case UI2BenchCmd.AcceptResults: return Event.UiCmdAcceptResults; diff --git a/TestBenchFramework/BenchControl/OutputPath.cs b/TestBenchFramework/BenchControl/OutputPath.cs index 62d24b4d7..1dfe201aa 100644 --- a/TestBenchFramework/BenchControl/OutputPath.cs +++ b/TestBenchFramework/BenchControl/OutputPath.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2017 Sensus Metering Systems /// using System.Collections.Generic; using TBF.BenchControl.GenericDevices; @@ -18,8 +18,8 @@ namespace TBF.BenchControl public IValve StartValve; public IDiverter Diverter; public ITempMeter TempDiv; - public IBalance Balance; - public IValve EmptyTankValve; + public IScale Scale; + public IValve DrainValve; public IList ValvesOpen; public IList ValvesClose; @@ -44,8 +44,8 @@ namespace TBF.BenchControl StartValve = (IValve)TbfComponents.FindComponent(entity.StartValve, components); Diverter = (IDiverter)TbfComponents.FindComponent(entity.Diverter, components); TempDiv = (ITempMeter)TbfComponents.FindComponent(entity.TempDiv, components); - Balance = (IBalance)TbfComponents.FindComponent(entity.Balance, components); - EmptyTankValve = (IValve)TbfComponents.FindComponent(entity.EmptyTankValve, components); + Scale = (IScale)TbfComponents.FindComponent(entity.Scale, components); + DrainValve = (IValve)TbfComponents.FindComponent(entity.EmptyTankValve, components); string[] vOpen = entity.ValvesOpen.Split(new char[] { ';' }); ValvesOpen = new List(); @@ -63,7 +63,7 @@ namespace TBF.BenchControl (RegulValve != null) ? RegulValve.Name : "---", (FlowMeter != null) ? FlowMeter.Name : "---", (Diverter != null) ? Diverter.Name : "---", - (Balance != null) ? Balance.Name : "---"); + (Scale != null) ? Scale.Name : "---"); } } } diff --git a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs index 4196e006a..ac88c8c5e 100644 --- a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs +++ b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs @@ -126,29 +126,29 @@ namespace TBF.BenchControl.Sequences IntBox remainingTime = new IntBox(); State startNew = State.Create("MainSeq : Emptying tanks") .AddOperation(checkUiOp); - IList allEmptyingValves = new List(); - if (StateMachine.DrainValve1 != null) allEmptyingValves.Add(StateMachine.DrainValve1); - if (StateMachine.DrainValve2 != null) allEmptyingValves.Add(StateMachine.DrainValve2); - if (StateMachine.DrainValve3 != null) allEmptyingValves.Add(StateMachine.DrainValve3); + IList allDrainValves = new List(); + if (StateMachine.DrainValve1 != null) allDrainValves.Add(StateMachine.DrainValve1); + if (StateMachine.DrainValve2 != null) allDrainValves.Add(StateMachine.DrainValve2); + if (StateMachine.DrainValve3 != null) allDrainValves.Add(StateMachine.DrainValve3); // Determine the tank emptying time (the maximum for all balances) - int balanceEmptyTime = 0; - if (StateMachine.Balance1 != null && StateMachine.Balance1.EmptyTimeSec > balanceEmptyTime) + int scaleDrainTime = 0; + if (StateMachine.Scale1 != null && StateMachine.Scale1.EmptyTimeSec > scaleDrainTime) { - balanceEmptyTime = StateMachine.Balance1.EmptyTimeSec; + scaleDrainTime = StateMachine.Scale1.EmptyTimeSec; } - if (StateMachine.Balance2 != null && StateMachine.Balance2.EmptyTimeSec > balanceEmptyTime) + if (StateMachine.Scale2 != null && StateMachine.Scale2.EmptyTimeSec > scaleDrainTime) { - balanceEmptyTime = StateMachine.Balance2.EmptyTimeSec; + scaleDrainTime = StateMachine.Scale2.EmptyTimeSec; } - if (StateMachine.Balance3 != null && StateMachine.Balance3.EmptyTimeSec > balanceEmptyTime) + if (StateMachine.Scale3 != null && StateMachine.Scale3.EmptyTimeSec > scaleDrainTime) { - balanceEmptyTime = StateMachine.Balance3.EmptyTimeSec; + scaleDrainTime = StateMachine.Scale3.EmptyTimeSec; } - if (balanceEmptyTime > 0) + if (scaleDrainTime > 0) { - startNew.AddOperation(new TimerOp(balanceEmptyTime, remainingTime)) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(allEmptyingValves, null)); + startNew.AddOperation(new TimerOp(scaleDrainTime, remainingTime)) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(allDrainValves, null)); } startNew.EnterState(); @@ -177,7 +177,7 @@ namespace TBF.BenchControl.Sequences //-------------------------------------------------------------------------------------------- State stopEmptying = State.Create("MainSeq : Stop emptying of water tanks") .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, allEmptyingValves)) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, allDrainValves)) .EnterState(); do { @@ -190,9 +190,9 @@ namespace TBF.BenchControl.Sequences //-------------------------------------------------------------------------------------------- State taraAll = State.Create("MainSeq : Reset all balances").AddOperation(checkUiOp); DoubleBox tara = new DoubleBox(0); - if (StateMachine.Balance1 != null) taraAll.AddOperation(StateMachine.Balance1.TaringOp(ref tara)); - if (StateMachine.Balance2 != null) taraAll.AddOperation(StateMachine.Balance2.TaringOp(ref tara)); - if (StateMachine.Balance3 != null) taraAll.AddOperation(StateMachine.Balance3.TaringOp(ref tara)); + if (StateMachine.Scale1 != null) taraAll.AddOperation(StateMachine.Scale1.TaringOp(ref tara)); + if (StateMachine.Scale2 != null) taraAll.AddOperation(StateMachine.Scale2.TaringOp(ref tara)); + if (StateMachine.Scale3 != null) taraAll.AddOperation(StateMachine.Scale3.TaringOp(ref tara)); taraAll.EnterState(); do { @@ -516,9 +516,9 @@ namespace TBF.BenchControl.Sequences } /// Update format for the water mass - Mass.Format = outPath.Balance.Format; - StartMass.Format = outPath.Balance.Format; - EndMass.Format = outPath.Balance.Format; + Mass.Format = outPath.Scale.Format; + StartMass.Format = outPath.Scale.Format; + EndMass.Format = outPath.Scale.Format; //-------------------------------------------------------------- ITestMethod testMethodSequence = TbfComponents.FindComponent(test.Method) as ITestMethod; @@ -658,9 +658,9 @@ namespace TBF.BenchControl.Sequences } /// Update format for the water mass - Mass.Format = outPath.Balance.Format; - StartMass.Format = outPath.Balance.Format; - EndMass.Format = outPath.Balance.Format; + Mass.Format = outPath.Scale.Format; + StartMass.Format = outPath.Scale.Format; + EndMass.Format = outPath.Scale.Format; //-------------------------------------------------------------- ITestMethod testMethodSequence = TbfComponents.FindComponent(test.Method) as ITestMethod; @@ -754,9 +754,9 @@ namespace TBF.BenchControl.Sequences } /// Update format for the water mass - Mass.Format = outPath.Balance.Format; - StartMass.Format = outPath.Balance.Format; - EndMass.Format = outPath.Balance.Format; + Mass.Format = outPath.Scale.Format; + StartMass.Format = outPath.Scale.Format; + EndMass.Format = outPath.Scale.Format; ITestMethod testMethodSequence = TbfComponents.FindComponent(test.Method) as ITestMethod; if (testMethodSequence != null && testMethodSequence.CanTest(StateMachine.Procedure.MetersKind)) @@ -1046,9 +1046,9 @@ namespace TBF.BenchControl.Sequences { /// Handled inside MakeSelection() None, - EmptyTank1, - EmptyTank2, - EmptyTank3, + DrainTank1, + DrainTank2, + DrainTank3, CloseTank1, CloseTank2, CloseTank3, @@ -1086,9 +1086,9 @@ namespace TBF.BenchControl.Sequences private Selection MakeSelection(MKSelContext context) { /// Tank emptying valves states - bool emptying1 = false; - bool emptying2 = false; - bool emptying3 = false; + bool draining1 = false; + bool draining2 = false; + bool draining3 = false; /// Measured masses to control emptying DoubleBox mass1 = new DoubleBox(); @@ -1101,7 +1101,7 @@ namespace TBF.BenchControl.Sequences while (true) { /// Display an appropriate activity message - if (emptying1 || emptying2 || emptying3) + if (draining1 || draining2 || draining3) { Bridge.OnActivity(this, Strings.Emptying_tank); } @@ -1118,7 +1118,7 @@ namespace TBF.BenchControl.Sequences Bridge.Bench2UI(((context == MKSelContext.ProcedureNotSelected) ? ButtonsEtc.ProcedureCmbBoxEn : 0) | ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn | - ((emptying1 || emptying2 || emptying3) ? 0 : + ((draining1 || draining2 || draining3) ? 0 : (ButtonsEtc.StartCycleBtnEn | ButtonsEtc.StartTestBtnsEn | ButtonsEtc.PurgeBeginBtnEn | @@ -1126,16 +1126,16 @@ namespace TBF.BenchControl.Sequences ButtonsEtc.SensitivityTestBtnEn | ((Cameras.Count > 0) ? ButtonsEtc.CalibrationBtnEn : 0) | ButtonsEtc.Break)) | - (((StateMachine.Balance1 != null) && (StateMachine.DrainValve1 != null) && !emptying1) ? ButtonsEtc.EmptyTankBtn1En : 0) | - (((StateMachine.Balance2 != null) && (StateMachine.DrainValve2 != null) && !emptying2) ? ButtonsEtc.EmptyTankBtn2En : 0) | - (((StateMachine.Balance3 != null) && (StateMachine.DrainValve3 != null) && !emptying3) ? ButtonsEtc.EmptyTankBtn3En : 0)); + (((StateMachine.Scale1 != null) && (StateMachine.DrainValve1 != null) && !draining1) ? ButtonsEtc.DrainTankBtn1En : 0) | + (((StateMachine.Scale2 != null) && (StateMachine.DrainValve2 != null) && !draining2) ? ButtonsEtc.DrainTankBtn2En : 0) | + (((StateMachine.Scale3 != null) && (StateMachine.DrainValve3 != null) && !draining3) ? ButtonsEtc.DrainTankBtn3En : 0)); selection = Selection.None; State.Create("MainSeq : Select an activity") .AddOperation(checkUiOp) - .AddOperation((StateMachine.Balance1 != null) ? StateMachine.Balance1.ReadMassOp(ref mass1) : null) - .AddOperation((StateMachine.Balance2 != null) ? StateMachine.Balance2.ReadMassOp(ref mass2) : null) - .AddOperation((StateMachine.Balance3 != null) ? StateMachine.Balance3.ReadMassOp(ref mass3) : null) + .AddOperation((StateMachine.Scale1 != null) ? StateMachine.Scale1.ReadMassOp(ref mass1) : null) + .AddOperation((StateMachine.Scale2 != null) ? StateMachine.Scale2.ReadMassOp(ref mass2) : null) + .AddOperation((StateMachine.Scale3 != null) ? StateMachine.Scale3.ReadMassOp(ref mass3) : null) .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) .EnterState(); do @@ -1144,12 +1144,12 @@ namespace TBF.BenchControl.Sequences if (e.Contains(Event.Error)) goto error; else if (e.Contains(Event.UiCmdStop)) selection = Selection.Stop; else if (e.Contains(Event.UiCmdCameraTest)) selection = Selection.CameraTest; - else if (e.Contains(Event.UiCmdEmptyTank1)) selection = Selection.EmptyTank1; - else if (e.Contains(Event.UiCmdEmptyTank2)) selection = Selection.EmptyTank2; - else if (e.Contains(Event.UiCmdEmptyTank3)) selection = Selection.EmptyTank3; - else if (emptying1 && StateMachine.Balance1.IsEmpty(mass1.Val)) selection = Selection.CloseTank1; - else if (emptying2 && StateMachine.Balance2.IsEmpty(mass2.Val)) selection = Selection.CloseTank2; - else if (emptying3 && StateMachine.Balance3.IsEmpty(mass3.Val)) selection = Selection.CloseTank3; + else if (e.Contains(Event.UiCmdEmptyTank1)) selection = Selection.DrainTank1; + else if (e.Contains(Event.UiCmdEmptyTank2)) selection = Selection.DrainTank2; + else if (e.Contains(Event.UiCmdEmptyTank3)) selection = Selection.DrainTank3; + else if (draining1 && StateMachine.Scale1.IsEmpty(mass1.Val)) selection = Selection.CloseTank1; + else if (draining2 && StateMachine.Scale2.IsEmpty(mass2.Val)) selection = Selection.CloseTank2; + else if (draining3 && StateMachine.Scale3.IsEmpty(mass3.Val)) selection = Selection.CloseTank3; else if (e.Contains(Event.UiCmdPurgeBegin)) return Selection.PurgeBegin; /// Value used to branch the code later on else if (e.Contains(Event.UiCmdPurgeEnd)) return Selection.PurgeEnd; else if (e.Contains(Event.UiCmdBreak) && context == MKSelContext.InsideProcedure) return Selection.Break; @@ -1168,58 +1168,58 @@ namespace TBF.BenchControl.Sequences } else if (selection == Selection.Stop) { - if (emptying1 || emptying2 || emptying3) + if (draining1 || draining2 || draining3) { IList valvesClose = new List(); - if (emptying1) valvesClose.Add(StateMachine.DrainValve1); - if (emptying2) valvesClose.Add(StateMachine.DrainValve2); - if (emptying3) valvesClose.Add(StateMachine.DrainValve3); + if (draining1) valvesClose.Add(StateMachine.DrainValve1); + if (draining2) valvesClose.Add(StateMachine.DrainValve2); + if (draining3) valvesClose.Add(StateMachine.DrainValve3); State.Create("MainSeq : Close emptying valve(s)") .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, valvesClose)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); } while (!e.Contains(Event.ValvesSet)); - emptying1 = emptying2 = emptying3 = false; + draining1 = draining2 = draining3 = false; } selection = Selection.None; } - else if ((selection == Selection.EmptyTank1) && !emptying1) + else if ((selection == Selection.DrainTank1) && !draining1) { - emptying1 = true; + draining1 = true; Bridge.OnActivity(this, Strings.Emptying_tank); Bridge.Bench2UI(((context == MKSelContext.ProcedureNotSelected) ? ButtonsEtc.ProcedureCmbBoxEn : 0) | ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn | - (emptying2 ? 0 : ButtonsEtc.EmptyTankBtn2En) | - (emptying3 ? 0 : ButtonsEtc.EmptyTankBtn3En)); + (draining2 ? 0 : ButtonsEtc.DrainTankBtn2En) | + (draining3 ? 0 : ButtonsEtc.DrainTankBtn3En)); State.Create("MainSeq : Open tank 1") .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DrainValve1, null)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); } while (!e.Contains(Event.ValvesSet)); } - else if ((selection == Selection.EmptyTank2) && !emptying2) + else if ((selection == Selection.DrainTank2) && !draining2) { - emptying2 = true; + draining2 = true; Bridge.OnActivity(this, Strings.Emptying_tank); Bridge.Bench2UI(((context == MKSelContext.ProcedureNotSelected) ? ButtonsEtc.ProcedureCmbBoxEn : 0) | ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn | - (emptying1 ? 0 : ButtonsEtc.EmptyTankBtn1En) | - (emptying3 ? 0 : ButtonsEtc.EmptyTankBtn3En)); + (draining1 ? 0 : ButtonsEtc.DrainTankBtn1En) | + (draining3 ? 0 : ButtonsEtc.DrainTankBtn3En)); State.Create("MainSeq : Open tank 2") .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DrainValve2, null)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); } while (!e.Contains(Event.ValvesSet)); } - else if ((selection == Selection.EmptyTank3) && !emptying3) + else if ((selection == Selection.DrainTank3) && !draining3) { - emptying3 = true; + draining3 = true; Bridge.OnActivity(this, Strings.Emptying_tank); Bridge.Bench2UI(((context == MKSelContext.ProcedureNotSelected) ? ButtonsEtc.ProcedureCmbBoxEn : 0) | ButtonsEtc.TestCmbBoxEn | ButtonsEtc.StopBtnEn | - (emptying1 ? 0 : ButtonsEtc.EmptyTankBtn1En) | - (emptying2 ? 0 : ButtonsEtc.EmptyTankBtn2En)); + (draining1 ? 0 : ButtonsEtc.DrainTankBtn1En) | + (draining2 ? 0 : ButtonsEtc.DrainTankBtn2En)); State.Create("MainSeq : Open tank 3") .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DrainValve3, null)) .EnterState(); @@ -1233,7 +1233,7 @@ namespace TBF.BenchControl.Sequences .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); } while (!e.Contains(Event.ValvesSet)); - emptying1 = false; + draining1 = false; } else if (selection == Selection.CloseTank2) { @@ -1242,7 +1242,7 @@ namespace TBF.BenchControl.Sequences .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); } while (!e.Contains(Event.ValvesSet)); - emptying2 = false; + draining2 = false; } else if (selection == Selection.CloseTank3) { @@ -1251,7 +1251,7 @@ namespace TBF.BenchControl.Sequences .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); } while (!e.Contains(Event.ValvesSet)); - emptying3 = false; + draining3 = false; } } diff --git a/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs b/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs index f82c6c936..5ef38cbc9 100644 --- a/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs +++ b/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs @@ -171,39 +171,39 @@ namespace TBF.BenchControl.Sequences } - protected Event EmptyTheTank(IValve emptyTankValve, IBalance balance) + protected Event DrainTheTank(IValve drainValve, IScale scale) { - return EmptyTheTank(emptyTankValve, balance, new List()); + return DrainTheTank(drainValve, scale, new List()); } - protected Event EmptyTheTank(IValve emptyTankValve, IBalance balance, IOperation extraOperation) + protected Event DrainTheTank(IValve drainValve, IScale scale, IOperation extraOperation) { IList extraOperations = new List(); extraOperations.Add(extraOperation); - return EmptyTheTank(emptyTankValve, balance, extraOperations); + return DrainTheTank(drainValve, scale, extraOperations); } /// /// Empties the tank: opens the emptying valve and measures the weight. /// - /// Valve to empty the tank - /// Balance underneath the tank + /// Valve to empty the tank + /// Balance underneath the tank /// Event.Done or Event.Error - protected Event EmptyTheTank(IValve emptyTankValve, IBalance balance, IList extraOperations) + protected Event DrainTheTank(IValve drainValve, IScale scale, IList extraOperations) { bool stopped = false; - //------------------------------------------------ + //------------------------------------------------------------ Bridge.OnActivity(this, TBF.Resources.Strings.Emptying_tank); - //------------------------------------------------ + //------------------------------------------------------------ IList e; Bridge.Bench2UI(ButtonsEtc.StopBtnEn); - State.Create("SequenceBase : Opening the emptying valve") + State.Create("SequenceBase : Drain valve opened") .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(emptyTankValve, null)) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(drainValve, null)) .AddOperations(extraOperations) .EnterState(); do @@ -214,9 +214,9 @@ namespace TBF.BenchControl.Sequences do { - State.Create("SequenceBase : Emptying the tank") + State.Create("SequenceBase : Draining the tank") .AddOperation(checkUiOp) - .AddOperation(balance.ReadMassOp(ref Mass)) + .AddOperation(scale.ReadMassOp(ref Mass)) .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) .AddOperations(extraOperations) .EnterState(); @@ -236,16 +236,16 @@ namespace TBF.BenchControl.Sequences if (stopped) break; } - while (!balance.IsEmpty(Mass.Val)); + while (!scale.IsEmpty(Mass.Val)); // // Quit emptying // - State.Create("SequenceBase : Closing the emptying valve") + State.Create("SequenceBase : Drain valve closed") .AddOperation(checkUiOp) - .AddOperation(balance.ReadMassOp(ref Mass)) + .AddOperation(scale.ReadMassOp(ref Mass)) .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, emptyTankValve)) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, drainValve)) .AddOperations(extraOperations) .EnterState(); do @@ -259,7 +259,7 @@ namespace TBF.BenchControl.Sequences State.Create("SequenceBase : Updating the weight") .AddOperation(checkUiOp) - .AddOperation(balance.ReadMassOp(ref Mass)) + .AddOperation(scale.ReadMassOp(ref Mass)) .AddOperation(new Operations.TimerOp(5)) .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) .AddOperations(extraOperations) @@ -720,7 +720,7 @@ namespace TBF.BenchControl.Sequences .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2)) .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1)) .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)) - .AddOperation(realTest ? outPath.Balance.ReadMassOp(ref Mass) : null) + .AddOperation(realTest ? outPath.Scale.ReadMassOp(ref Mass) : null) .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) .AddOperation((StateMachine.Ambient != null) ? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) @@ -774,7 +774,7 @@ namespace TBF.BenchControl.Sequences sb.Append(";"); sb.Append("0"); sb.Append(";"); sb.Append(outPath.FlowMeter.Idx1); sb.Append(";"); sb.Append(" "); - sb.Append(";"); if (outPath.Balance != null) sb.Append(outPath.Balance.Name); + sb.Append(";"); if (outPath.Scale != null) sb.Append(outPath.Scale.Name); sb.Append(";"); sb.Append(tstRslt.AmbTempMean); sb.Append(";"); sb.Append(Units.ConvertTo(Unit.mbar, tstRslt.AmbPressMean).ToString("F0")); /// [mbar] sb.Append(";"); sb.Append(tstRslt.AmbHumiMean); /// [%] @@ -1084,7 +1084,7 @@ namespace TBF.BenchControl.Sequences (BenchInfo != null) ? BenchInfo.TestBenchName : "testbench", inPath.Pump != null ? inPath.Pump.Name : string.Empty, outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty, - outPath.Balance != null ? outPath.Balance.Name : string.Empty, + outPath.Scale != null ? outPath.Scale.Name : string.Empty, outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); } @@ -1208,7 +1208,7 @@ namespace TBF.BenchControl.Sequences (BenchInfo != null) ? BenchInfo.TestBenchName : "testbench", inPath.Pump != null ? inPath.Pump.Name : string.Empty, outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty, - outPath.Balance != null ? outPath.Balance.Name : string.Empty, + outPath.Scale != null ? outPath.Scale.Name : string.Empty, outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); } @@ -1335,7 +1335,7 @@ namespace TBF.BenchControl.Sequences (BenchInfo != null) ? BenchInfo.TestBenchName : "testbench", inPath.Pump != null ? inPath.Pump.Name : string.Empty, outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty, - outPath.Balance != null ? outPath.Balance.Name : string.Empty, + outPath.Scale != null ? outPath.Scale.Name : string.Empty, outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); } diff --git a/TestBenchFramework/BenchControl/StateMachine.cs b/TestBenchFramework/BenchControl/StateMachine.cs index 9cf2f8334..78d6a21f3 100644 --- a/TestBenchFramework/BenchControl/StateMachine.cs +++ b/TestBenchFramework/BenchControl/StateMachine.cs @@ -45,9 +45,9 @@ namespace TBF.BenchControl /// Public components public static Elde.ControlBoardDev ControlBoard; public static GenericDevices.IAmbient Ambient; - public static GenericDevices.IBalance Balance1; - public static GenericDevices.IBalance Balance2; - public static GenericDevices.IBalance Balance3; + public static GenericDevices.IScale Scale1; + public static GenericDevices.IScale Scale2; + public static GenericDevices.IScale Scale3; public static GenericDevices.IValve DrainValve1; public static GenericDevices.IValve DrainValve2; public static GenericDevices.IValve DrainValve3; @@ -85,8 +85,8 @@ namespace TBF.BenchControl { return GenericDevices.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) + Utils.ValvesOpen((benchPaths != null && benchPaths.Count > 0) ? benchPaths[0] : null), + Utils.ValvesOpen((outputPaths != null && outputPaths.Count > 0) ? outputPaths[0] : null) ); } } @@ -97,8 +97,8 @@ namespace TBF.BenchControl { return GenericDevices.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) + Utils.ValvesClose((benchPaths != null && benchPaths.Count > 0) ? benchPaths[0] : null), + Utils.ValvesClose((outputPaths != null && outputPaths.Count > 0) ? outputPaths[0] : null) ); } } @@ -210,7 +210,7 @@ namespace TBF.BenchControl /// Find all balances (to initialize tank capacities in the control board) /// Find the control board - IList balances = new List(); + IList balances = new List(); SequenceBase.FlowMeters = new List(); SequenceBase.RegulValves = new List(); SequenceBase.PumpsWithFM = new List(); @@ -230,14 +230,14 @@ namespace TBF.BenchControl 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; - if (cmpnt is IBalance) + if (cmpnt is IScale) { - IBalance balance = cmpnt as IBalance; - balances.Add(balance); + IScale scale = cmpnt as IScale; + balances.Add(scale); - if (balance.BalanceNr == 0) Balance1 = balance; - else if (balance.BalanceNr == 1) Balance2 = balance; - else if (balance.BalanceNr == 2) Balance3 = balance; + if (scale.ScaleNr == 0) Scale1 = scale; + else if (scale.ScaleNr == 1) Scale2 = scale; + else if (scale.ScaleNr == 2) Scale3 = scale; } Elde.Valve.Valve eldeValve = (cmpnt as Elde.Valve.Valve); @@ -306,23 +306,23 @@ namespace TBF.BenchControl } } - if (cmpnt is IBalance) + if (cmpnt is IScale) { - IBalance balance = cmpnt as IBalance; + IScale balance = cmpnt as IScale; - if (balance.BalanceNr == 0) + if (balance.ScaleNr == 0) { DrainValve1 = balance.DrainValve; log.WarnFormat("InitializeBoardEtc() ... Scale1={0} Draining valve1={1}", balance.Name, (DrainValve1 != null) ? DrainValve1.Name : "---"); } - else if (balance.BalanceNr == 1) + else if (balance.ScaleNr == 1) { DrainValve2 = balance.DrainValve; log.WarnFormat("InitializeBoardEtc() ... Scale2={0} Draining valve2={1}", balance.Name, (DrainValve2 != null) ? DrainValve2.Name : "---"); } - else if (balance.BalanceNr == 2) + else if (balance.ScaleNr == 2) { DrainValve3 = balance.DrainValve; log.WarnFormat("InitializeBoardEtc() ... Scale3={0} Draining valve3={1}", @@ -505,7 +505,7 @@ namespace TBF.BenchControl if (tr.Name == test.TransitionAfter) transitionAfter = tr; } - if (pout.Balance == null) + if (pout.Scale == null) { errorMsg = string.Format("No balance specified in path {0}", test.OutputPath); return false; diff --git a/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs b/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs index 82ce02f28..9ba3499c7 100644 --- a/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs @@ -383,7 +383,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment (BenchInfo != null) ? BenchInfo.TestBenchName : "testbench", inPath.Pump != null ? inPath.Pump.Name : string.Empty, outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty, - outPath.Balance != null ? outPath.Balance.Name : string.Empty, + outPath.Scale != null ? outPath.Scale.Name : string.Empty, outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs index ec948e38f..1c7105099 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs @@ -141,12 +141,12 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection Qrise = 0; Qfall = 0; - if (!test.Emptying) /// Do not skip emptying if test.Emptying==true + if (!test.Draining) /// Do not skip emptying if test.Emptying==true { //-------------------------------- State.Create("CombinedWithDetection : Get the mass of water in the tank") .AddOperation(checkUiOp) - .AddOperation(outPath.Balance.ReadMassOp(ref Mass)) + .AddOperation(outPath.Scale.ReadMassOp(ref Mass)) .EnterState(); do { @@ -157,14 +157,14 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection while (!e.Contains(Event.BalanceDone)); double estimatedEndMass = Mass.Val + test.Volume; - if (estimatedEndMass < outPath.Balance.Capacity * Constants.TankFullFactor) + if (estimatedEndMass < outPath.Scale.Capacity * Constants.TankFullFactor) { goto switching_flow_detection; /// Enough room in the tank -> skip emptying } } // Empty the water tank - switch (EmptyTheTank(outPath.EmptyTankValve, outPath.Balance)) + switch (DrainTheTank(outPath.DrainValve, outPath.Scale)) { case Event.Error: goto error; case Event.UiCmdStop: goto stopTest; @@ -463,7 +463,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection State.Create(Strings.Measure_the_mass) .AddOperation(checkUiOp) .AddOperations(measureOperations) - .AddOperation(outPath.Balance.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod)) + .AddOperation(outPath.Scale.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod)) .EnterState(); do { @@ -548,7 +548,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection //------------------------------------------------ State.Create(Strings.Measure_the_mass) .AddOperation(checkUiOp) - .AddOperation(outPath.Balance.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod)) + .AddOperation(outPath.Scale.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod)) .EnterState(); do { @@ -656,9 +656,9 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection tstRslt.TestTime = cBrd.TTime; /// [s] measurement time tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = StartMass.Val; - tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections); + tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Scale.Corrections); tstRslt.MassEndRaw = EndMass.Val; - tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections); + tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Scale.Corrections); tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; /// [kg/h] tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * cBrd.EtPulses(0) / tstRslt.TestTime; /// [m3/h] tstRslt.VolumeCTV = 1001.03 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3] @@ -729,7 +729,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection (BenchInfo != null) ? BenchInfo.TestBenchName : "testbench", inPath.Pump != null ? inPath.Pump.Name : string.Empty, outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty, - outPath.Balance != null ? outPath.Balance.Name : string.Empty, + outPath.Scale != null ? outPath.Scale.Name : string.Empty, outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); diff --git a/TestBenchFramework/BenchControl/TestMethods/Endurance/EnduranceSeq.cs b/TestBenchFramework/BenchControl/TestMethods/Endurance/EnduranceSeq.cs index d6144b9d1..2d9e3b5f2 100644 --- a/TestBenchFramework/BenchControl/TestMethods/Endurance/EnduranceSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/Endurance/EnduranceSeq.cs @@ -424,7 +424,7 @@ namespace TBF.BenchControl.TestMethods.Endurance (BenchInfo != null) ? BenchInfo.TestBenchName : "testbench", inPath.Pump != null ? inPath.Pump.Name : string.Empty, outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty, - outPath.Balance != null ? outPath.Balance.Name : string.Empty, + outPath.Scale != null ? outPath.Scale.Name : string.Empty, outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs index 694ce3442..24f5a1216 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs @@ -30,33 +30,33 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced { Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; - IList e = new List(); /// Events from currently running operations - Event retVal = Event.Done; - checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state + IList e = new List(); /// Events from currently running operations + Event retVal = Event.Done; + checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state - LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h] + LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h] - /// Notes: - /// float timeHr = volumeLtr / (1000.0f * targetFlow); - /// float timeSec = 3600.0f * timeHr; - /// int refPulses = (int)(timeSec * (2000.0f * targetFlow / pOut.FlowMeter.NominalFlow)); - int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f); + /// Notes: + /// float timeHr = volumeLtr / (1000.0f * targetFlow); + /// float timeSec = 3600.0f * timeHr; + /// int refPulses = (int)(timeSec * (2000.0f * targetFlow / pOut.FlowMeter.NominalFlow)); + int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f); - processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false); + processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false); - int repetitionNr = outerLoopMode ? outerLoopCounter : 1; /// First test: repetitionNr=1 + int repetitionNr = outerLoopMode ? outerLoopCounter : 1; /// First test: repetitionNr=1 //==================================== // Transition or SetRoute - Start //==================================== switch (Transition(transitionBefore, TransitionContext.BeforeTest)) { - case Event.Error: { retVal = Event.Error; goto stopTest; } - case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } + case Event.Error: { retVal = Event.Error; goto stopTest; } + case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } } //==================================== - loop: + loop: /// Start the test, initialize test results Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, totalPulses)); string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); @@ -65,12 +65,49 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.JustStarted)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - int flowSetTime0 = StateMachine.Time; + if (!test.Draining) + { + /// + /// Measure the weight in case there is no unconditional draining + /// + State.Create("FixedStartAdvanced : Measuring the mass of water in the tank") + .AddOperation(checkUiOp) + .AddOperation(outPath.Scale.ReadMassOp(ref Mass)) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.BalanceDone)); + } + /// + /// Skip draining in case there is enough room in the tank + /// + if (test.Draining || (Mass.Val + test.Volume >= outPath.Scale.Capacity * Constants.TankFullFactor)) + { + /// + /// Drain the water tank + /// + switch (DrainTheTank(outPath.DrainValve, outPath.Scale)) + { + case Event.Error: { retVal = Event.Error; goto stopTest; } + case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } + } + } + //------------------------------------------------ Bridge.OnActivity(this, Strings.Setting_the_flow); //------------------------------------------------ + + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + int flowSetTime0 = StateMachine.Time; + if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower); State.Create("FixedStartAdvanced : Waiting 5 sec") @@ -83,7 +120,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } } while (!e.Contains(Event.TimerExpired)); @@ -98,68 +135,32 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } } while (!e.Contains(Event.ValvesSet)); - if (!test.Emptying) /// If condition met => skip measuring and force emptying - { - /// - /// Measure the weight and skip emptying if there is enough room in the tank - /// - State.Create("FixedStartAdvanced : Measuring the mass of water in the tank") - .AddOperation(checkUiOp) - .AddOperation(outPath.Balance.ReadMassOp(ref Mass)) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - - if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.BalanceDone)); + set_flow: - double estimatedEndMass = Mass.Val + test.Volume; - if (estimatedEndMass < outPath.Balance.Capacity * Constants.TankFullFactor) - { - goto set_flow; /// Enough room in the tank -> skip emptying - } - } - - /// - /// Empty the water tank - /// - switch (EmptyTheTank(outPath.EmptyTankValve, outPath.Balance)) - { - case Event.Error: { retVal = Event.Error; goto stopTest; } - case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } - } - - set_flow: - - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Setting_the_flow); - //------------------------------------------------ + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Setting_the_flow); + //------------------------------------------------ if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower); State.Create("FixedStartAdvanced : Starting the pump") - .AddOperation(checkUiOp) + .AddOperation(checkUiOp) .AddOperation(cBrd.SetValvesOp(inPath.Pump, null)) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.ValvesSet)); + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.ValvesSet)); - //-------------------------------- + //-------------------------------- State.Create("FixedStartAdvanced : Setting the flow") .AddOperation(checkUiOp) .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, outPath.PidCoef, RefFlow, 600)) /// timeout = 10 min. @@ -170,8 +171,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; } - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } + if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } if (e.Contains(Event.RegulValveTimeOut)) { Bridge.OnError(this, Strings.Timeout); @@ -182,27 +183,27 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced } while (!e.Contains(Event.FlowReached)); - flow_set: + flow_set: int flowSetTime = StateMachine.Time - flowSetTime0; - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Stopping_flow_for_the_fixed_start); - //------------------------------------------------ - State.Create("FixedStartAdvanced : Closing the start/stop valve before the fixed start test") - .AddOperation(checkUiOp) + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Stopping_flow_for_the_fixed_start); + //------------------------------------------------ + State.Create("FixedStartAdvanced : Closing the start/stop valve before the fixed start test") + .AddOperation(checkUiOp) .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, outPath.StartValve)) .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } } while (!e.Contains(Event.ValvesSet)); - int time = StateMachine.Time; - double currentFlow = RefFlow.Val; + int time = StateMachine.Time; + double currentFlow = RefFlow.Val; /// @@ -236,120 +237,120 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced - /// - /// Enter watermeter begin states here - /// + /// + /// Enter watermeter begin states here + /// GenericDevices.IHasWMStatesForm dataEntryCmpnt = TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IHasWMStatesForm; - if (dataEntryCmpnt != null) - { + if (dataEntryCmpnt != null) + { Bridge.OnActivity(this, Strings.Enter_water_meter_data); - State.Create("FixedStartAdvanced : Enter begin-state") - .AddOperation((dataEntryCmpnt as GenericDevices.IHasWMStatesForm).ShowTestStartFormOp()) - .AddOperation(checkUiOp) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.ModelessFormClosed)); + State.Create("FixedStartAdvanced : Enter begin-state") + .AddOperation((dataEntryCmpnt as GenericDevices.IHasWMStatesForm).ShowTestStartFormOp()) + .AddOperation(checkUiOp) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.ModelessFormClosed)); - for (int i = 0; i < Config.Data.WMsCount; i++) - { + for (int i = 0; i < Config.Data.WMsCount; i++) + { BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader = - sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; + sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; if (registerReader != null) registerReader.BeginWMState = dataEntryCmpnt.WMStartState(i); - } - } + } + } - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Measuring_the_weight); - //------------------------------------------------ + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Measuring_the_weight); + //------------------------------------------------ State.Create("FixedStartAdvanced : Measuring the start mass") .AddOperation(checkUiOp) .AddOperations(measureOperations) .AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp)) - .AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown)) - .AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv)) - .AddOperation(benchPath.PressMtrUp.ReadPressureOp(ref PressUp)) - .AddOperation(benchPath.PressMtrDown.ReadPressureOp(ref PressDown)) + .AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown)) + .AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv)) + .AddOperation(benchPath.PressMtrUp.ReadPressureOp(ref PressUp)) + .AddOperation(benchPath.PressMtrDown.ReadPressureOp(ref PressDown)) .AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta)) .AddOperation((StateMachine.Ambient != null) - ? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null) - .AddOperation(outPath.Balance.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod)) - .AddOperation(cBrd.UpdateTankWeightOp()) - .AddOperation(processDataLoggingOp) - .EnterState(); + ? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null) + .AddOperation(outPath.Scale.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod)) + .AddOperation(cBrd.UpdateTankWeightOp()) + .AddOperation(processDataLoggingOp) + .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.Error)) { retVal = Event.Error; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } } while (!e.Contains(Event.BalanceDone)); - TestStartTime = DateTime.Now; - Mass.Val = StartMass.Val; + TestStartTime = DateTime.Now; + Mass.Val = StartMass.Val; - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Test_in_progress); - //------------------------------------------------ + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Test_in_progress); + //------------------------------------------------ State.Create("FixedStartAdvanced : Starting the test") .AddOperation(checkUiOp) - .AddOperations(measureOperations) - .AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro, + .AddOperations(measureOperations) + .AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro, test.Qfrom, test.Qto, 2 * totalPulses, (float)test.TolerRed)) .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.Error)) { retVal = Event.Error; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } } while (!e.Contains(Event.MeasurementStarted)); - State.Create("FixedStartAdvanced : Opening the start/stop valve at the beginning of the fixed start test") - .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(outPath.StartValve, null)) - .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } - } - while (!e.Contains(Event.ValvesSet)); + State.Create("FixedStartAdvanced : Opening the start/stop valve at the beginning of the fixed start test") + .AddOperation(checkUiOp) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(outPath.StartValve, null)) + .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + } + while (!e.Contains(Event.ValvesSet)); /// Measurement loop - preparation - readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders); - queryEnd1 = cBrd.QueryMeasurementEndOp(); + readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders); + queryEnd1 = cBrd.QueryMeasurementEndOp(); queryEnd2 = cBrd.QueryMeasurementEndOp(); - ClearAllStatistics(); + ClearAllStatistics(); int estimtdEndTime = StateMachine.Time + (int)test.TstTime; - /// Measurement loop - begin - do - { - //-------------------------------- - switch (ReadRegistersTempPressAmbient(measureOperations, true)) - { - case Event.Error: - retVal = Event.Error; - goto stopTest; + /// Measurement loop - begin + do + { + //-------------------------------- + switch (ReadRegistersTempPressAmbient(measureOperations, true)) + { + case Event.Error: + retVal = Event.Error; + goto stopTest; - case Event.UiCmdStop: - retVal = Event.UiCmdStop; - goto stopTest; + case Event.UiCmdStop: + retVal = Event.UiCmdStop; + goto stopTest; - case Event.MeasurementCompleted: - goto test_completed; - } + case Event.MeasurementCompleted: + goto test_completed; + } int remainingTime = Math.Max(estimtdEndTime - StateMachine.Time, 0); if (remainingTime > 60) @@ -362,28 +363,28 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced } RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; + RefFlow.Val = cBrd.ReferenceFlow; UpdateAllStatistics(); 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); - /// Measurement loop - end + while (cBrd.EtPulses(0) < totalPulses); + /// Measurement loop - end - test_completed: + test_completed: - State.Create("FixedStartAdvanced : Closing the start/stop valve at the end of the fixed start test") - .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, outPath.StartValve)) - .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } - } - while (e.Contains(Event.ValvesBusy)); + State.Create("FixedStartAdvanced : Closing the start/stop valve at the end of the fixed start test") + .AddOperation(checkUiOp) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, outPath.StartValve)) + .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + } + while (e.Contains(Event.ValvesBusy)); State.Create("FixedStartAdvanced : Waiting before 2nd mass measurement") @@ -396,7 +397,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced .AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta)) .AddOperation((StateMachine.Ambient != null) ? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null) - .AddOperation(outPath.Balance.ReadMassOp(ref Mass)) + .AddOperation(outPath.Scale.ReadMassOp(ref Mass)) .AddOperation(cBrd.UpdateTankWeightOp()) .AddOperation(processDataLoggingOp) .AddOperation(new Operations.TimerOp(test.TimeStop2Mass)) @@ -405,7 +406,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced { e = StateMachine.WaitRunDevsRunOps(); if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } } while (!e.Contains(Event.TimerExpired)); @@ -423,7 +424,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced .AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta)) .AddOperation((StateMachine.Ambient != null) ? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null) - .AddOperation(outPath.Balance.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod)) + .AddOperation(outPath.Scale.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod)) .AddOperation(cBrd.UpdateTankWeightOp()) .AddOperation(processDataLoggingOp) .EnterState(); @@ -431,7 +432,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced { e = StateMachine.WaitRunDevsRunOps(); if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } } while (!e.Contains(Event.BalanceDone)); /// @@ -439,56 +440,56 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced State.Create("FixedStartAdvanced : Stopping diverter, gate, etc.") - .AddOperation(checkUiOp) - .AddOperation(cBrd.StopPreviousOp()) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.PreviousStopped)); + .AddOperation(checkUiOp) + .AddOperation(cBrd.StopPreviousOp()) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.PreviousStopped)); - double massStart = Formulas.CorrectedValue(StartMass.Val, outPath.Balance.Corrections); - double massEnd = Formulas.CorrectedValue(EndMass.Val, outPath.Balance.Corrections); + double massStart = Formulas.CorrectedValue(StartMass.Val, outPath.Scale.Corrections); + double massEnd = Formulas.CorrectedValue(EndMass.Val, outPath.Scale.Corrections); double densityOut = Formulas.WaterDensityFromTemp(TempDownStat.Average); double volumeCTV = 1.00103f * 1000.0f * (massEnd - massStart) / densityOut; - /// - /// Enter watermeter end states here - /// - if (dataEntryCmpnt != null) - { + /// + /// Enter watermeter end states here + /// + if (dataEntryCmpnt != null) + { Bridge.OnActivity(this, Strings.Enter_water_meter_data); - State.Create("FixedStartAdvanced : Enter end-state") + State.Create("FixedStartAdvanced : Enter end-state") .AddOperation(dataEntryCmpnt.ShowTestEndFormOp(volumeCTV, test.ErrLimLo + test.Uncertainty, test.ErrLimHi - test.Uncertainty)) - .AddOperation(checkUiOp) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.ModelessFormClosed)); + .AddOperation(checkUiOp) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.ModelessFormClosed)); - for (int i = 0; i < Config.Data.WMsCount; i++) - { + for (int i = 0; i < Config.Data.WMsCount; i++) + { BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader = - sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; + sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; if (registerReader != null) registerReader.EndWMState = dataEntryCmpnt.WMEndState(i); - } - } + } + } //------------------------------------------------ Bridge.OnActivity(this, Strings.Test_completed); //------------------------------------------------ - /// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results + /// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest; /// @@ -544,48 +545,48 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced tstRslt.TempDivEnd = (float)TempDivStat.Last; tstRslt.TempDivMin = (float)TempDivStat.Min; tstRslt.TempDivMax = (float)TempDivStat.Max; - tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempUpMean); /// [kg/m3] + tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempUpMean); /// [kg/m3] tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempDownMean); /// [kg/m3] tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivMean); /// [kg/m3] /// Main results - tstRslt.StartTime = TestStartTime; - tstRslt.EndTime = TestEndTime; - tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TTime; /// [s] measurement time + 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.MassStartRaw = StartMass.Val; - 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.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; /// [kg/h] - tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; - tstRslt.VolumeCTV = volumeCTV; /// [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.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; /// [kg/h] + tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; + tstRslt.VolumeCTV = volumeCTV; /// [kg] calculated before displaying 'End state' dialog tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter - tstRslt.ConstMaster = LtrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter - tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); + tstRslt.ConstMaster = LtrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter + tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); tstRslt.FlowMin = (float)((tstRslt.VolumeMaster != 0) ? (RefFlowStat.Min * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : RefFlowStat.Min); tstRslt.FlowMax = (float)((tstRslt.VolumeMaster != 0) ? (RefFlowStat.Max * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : RefFlowStat.Max); - for (int i = 0; i < BatchRslts.WMPositionsCount; i++) - { - if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue; + for (int i = 0; i < BatchRslts.WMPositionsCount; i++) + { + if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue; - Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single); + Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single); GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[i]; if (meterRslt != null && regReader != null) { meterRslt.PulsesPerLiter = 1.0f; - meterRslt.VolumeStart = regReader.BeginWMState; - meterRslt.VolumeEnd = regReader.EndWMState; - meterRslt.VolumeMeter = meterRslt.VolumeEnd - meterRslt.VolumeStart; - meterRslt.VolumeRef = tstRslt.VolumeCTV; /// liter - meterRslt.PulsesMeter = meterRslt.VolumeMeter; + meterRslt.VolumeStart = regReader.BeginWMState; + meterRslt.VolumeEnd = regReader.EndWMState; + meterRslt.VolumeMeter = meterRslt.VolumeEnd - meterRslt.VolumeStart; + meterRslt.VolumeRef = tstRslt.VolumeCTV; /// liter + meterRslt.PulsesMeter = meterRslt.VolumeMeter; meterRslt.PulsesMaster = tstRslt.PulsesMaster; - meterRslt.TestTime = tstRslt.TestTime; - meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); + meterRslt.TestTime = tstRslt.TestTime; + meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty) && (meterRslt.Error <= test.ErrLimHi - test.Uncertainty); meterRslt.TestDone = true; @@ -598,7 +599,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced (BenchInfo != null) ? BenchInfo.TestBenchName : "testbench", inPath.Pump != null ? inPath.Pump.Name : string.Empty, outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty, - outPath.Balance != null ? outPath.Balance.Name : string.Empty, + outPath.Scale != null ? outPath.Scale.Name : string.Empty, outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); @@ -631,7 +632,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced do { e = StateMachine.WaitRunDevsRunOps(); - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } } while (!e.Contains(Event.PreviousStopped)); @@ -639,7 +640,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced /// Prevent overwriting 'retVal' in case it was set to non-default value earlier switch (Transition(transitionAfter, (retVal == Event.Done) ? TransitionContext.AfterTest : TransitionContext.Stop)) { - case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; } + case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; } case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; } } diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs index b6b54a5d8..75a9ebe92 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs @@ -49,6 +49,15 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection int repetitionNr = outerLoopMode ? outerLoopCounter : 1; /// First test: repetitionNr=1 + + if (test.Volume >= outPath.Scale.Capacity * Constants.TankFullFactor) + { + Bridge.OnError(this, Strings.Test_volume_exceeds_the_scale_capacity); + retVal = Event.UiCmdStop; + goto stopTestWOTransitionAfter; + } + + //==================================== // Transition or SetRoute - Start //==================================== @@ -68,45 +77,84 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.JustStarted)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - int flowSetTime0 = StateMachine.Time; - - - if (test.Volume >= outPath.Balance.Capacity * Constants.TankFullFactor) - { - Bridge.OnError(this, Strings.Test_volume_exceeds_the_scale_capacity); - retVal = Event.Error; - goto stopTest; - } - - /// /// Optionally display prompt to emerge temperature meters to appropriate baths for heat meters test /// IOperation heatMetersPromptOp = null; if (heatMetersTestParams != null && !string.IsNullOrEmpty(heatMetersTestParams.Prompt)) { - heatMetersPromptOp = new Operations.MessageBoxOp(heatMetersTestParams.Prompt); + /// Make sure the CycleBeginForm is closed + if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest; + + heatMetersPromptOp = new Operations.MessageBoxOp(heatMetersTestParams.Prompt); } + + + if (!test.Draining) + { + /// + /// Measure the weight in case there is no unconditional draining + /// + State.Create("FixedStartMassCollection : Measuring the mass of water in the tank") + .AddOperation(checkUiOp) + .AddOperation(outPath.Scale.ReadMassOp(ref Mass)) + .AddOperation(heatMetersPromptOp) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.JustStarted)); + + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.BalanceDone)); + } + /// + /// Skip draining in case there is enough room in the tank + /// + if (test.Draining || (Mass.Val + test.Volume >= outPath.Scale.Capacity * Constants.TankFullFactor)) + { + /// + /// Drain the water tank + /// + switch (DrainTheTank(outPath.DrainValve, outPath.Scale, heatMetersPromptOp)) + { + case Event.Error: { retVal = Event.Error; goto stopTest; } + case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } + } + } + /// + /// Make sure the drain valve is closed + /// + State.Create("FixedStartMassCollection : Make sure the drain valve is closed") + .AddOperation(checkUiOp) + .AddOperation(outPath.Scale.ReadMassOp(ref Mass)) + .AddOperation(heatMetersPromptOp) + .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, outPath.DrainValve)) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.JustStarted)); + + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.ValvesSet) || !e.Contains(Event.BalanceDone)); + + + //------------------------------------------------ Bridge.OnActivity(this, Strings.Starting_the_pump); //------------------------------------------------ - if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower); - State.Create("FixedStartMassCollection : Waiting before starting the pump") - .AddOperation(checkUiOp) - .AddOperation(new Operations.TimerOp(5)) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + int flowSetTime0 = StateMachine.Time; - if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.TimerExpired)); + if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower); /// State.Create("FixedStartMassCollection : Starting the pump") .AddOperation(checkUiOp) @@ -128,44 +176,6 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection while (e.Contains(Event.ValvesBusy) || !e.Contains(Event.AllPositionsReached)); - if (!test.Emptying) /// If condition met => skip measuring and force emptying - { - /// - /// Measure the weight and skip emptying if there is enough room in the tank - /// - State.Create("FixedStartMassCollection : Measuring the mass of water in the tank") - .AddOperation(checkUiOp) - .AddOperation(outPath.Balance.ReadMassOp(ref Mass)) - .AddOperation(heatMetersPromptOp) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - - if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } - if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.BalanceDone)); - - double estimatedEndMass = Mass.Val + test.Volume; - if (estimatedEndMass < outPath.Balance.Capacity * Constants.TankFullFactor) - { - goto set_flow; /// Enough room in the tank -> skip emptying - } - } - - /// - /// Empty the water tank - /// - switch (EmptyTheTank(outPath.EmptyTankValve, outPath.Balance, heatMetersPromptOp)) - { - case Event.Error: { retVal = Event.Error; goto stopTest; } - case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } - } - - set_flow: if (debugLevel == Config.Entities.DebugMode.Simulate) goto flow_set; @@ -402,7 +412,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)) .AddOperation((StateMachine.Ambient != null) ? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null) - .AddOperation(outPath.Balance.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod)) + .AddOperation(outPath.Scale.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod)) .AddOperation(cBrd.UpdateTankWeightOp()) .AddOperation(processDataLoggingOp) .EnterState(); @@ -587,7 +597,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)) .AddOperation((StateMachine.Ambient != null) ? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null) - .AddOperation(outPath.Balance.ReadMassOp(ref Mass)) + .AddOperation(outPath.Scale.ReadMassOp(ref Mass)) .AddOperation(cBrd.UpdateTankWeightOp()) .AddOperation(processDataLoggingOp) .AddOperation(new Operations.TimerOp(test.TimeStop2Mass)) @@ -618,7 +628,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)) .AddOperation((StateMachine.Ambient != null) ? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null) - .AddOperation(outPath.Balance.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod)) + .AddOperation(outPath.Scale.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod)) .AddOperation(cBrd.UpdateTankWeightOp()) .AddOperation(processDataLoggingOp) .EnterState(); @@ -645,8 +655,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection while (!e.Contains(Event.PreviousStopped)); - double massStart = Formulas.CorrectedValue(StartMass.Val, outPath.Balance.Corrections); - double massEnd = Formulas.CorrectedValue(EndMass.Val, outPath.Balance.Corrections); + double massStart = Formulas.CorrectedValue(StartMass.Val, outPath.Scale.Corrections); + double massEnd = Formulas.CorrectedValue(EndMass.Val, outPath.Scale.Corrections); double densityOut = Formulas.WaterDensityFromTemp(TempDownStat.Average); /// [kg/m3] double volumeCTV = 1001.03 * (massEnd - massStart) / densityOut; double refEnergy = Energy.Sum * volumeCTV / VolumeForEnergy.Sum; /// [J]=[J]*[l]/[l] @@ -942,7 +952,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection (BenchInfo != null) ? BenchInfo.TestBenchName : "testbench", inPath.Pump != null ? inPath.Pump.Name : string.Empty, outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty, - outPath.Balance != null ? outPath.Balance.Name : string.Empty, + outPath.Scale != null ? outPath.Scale.Name : string.Empty, outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); @@ -982,10 +992,12 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection /// Prevent overwriting 'retVal' in case it was set to non-default value earlier switch (Transition(transitionAfter, (retVal == Event.Done) ? TransitionContext.AfterTest : TransitionContext.Stop)) { - case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; } + case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; } case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; } } + stopTestWOTransitionAfter: + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Completed)); /// Create a list with one item 'retVal' (default is Event.Done) and return it diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs index e02fdac8e..1b013f03e 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs @@ -614,7 +614,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart (BenchInfo != null) ? BenchInfo.TestBenchName : "testbench", inPath.Pump != null ? inPath.Pump.Name : string.Empty, outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty, - outPath.Balance != null ? outPath.Balance.Name : string.Empty, + outPath.Scale != null ? outPath.Scale.Name : string.Empty, outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs index f9c69f6c0..1317a5f75 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs @@ -102,7 +102,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection int repetitionNr = outerLoopMode ? outerLoopCounter : 1; /// First test: repetitionNr = 1 - if (test.Volume >= outPath.Balance.Capacity * Constants.TankFullFactor) + if (test.Volume >= outPath.Scale.Capacity * Constants.TankFullFactor) { Bridge.OnError(this, Strings.Test_volume_exceeds_the_scale_capacity); retVal = Event.UiCmdStop; @@ -127,22 +127,21 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection TestStartTime = DateTime.Now; TestProgressEventArgs.SetEstimatedTimes(new int[] { 1, 1, 1, 30, Convert.ToInt32(test.TstTime) + 15, 0, 0 }); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.JustStarted)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - int flowSetTime0 = StateMachine.Time; + //------------------------------------------------ Bridge.OnActivity(this, Strings.Checking_tank_capacity); //------------------------------------------------ - bool emptyTheTank = test.Emptying; + bool drainTheTank = test.Draining; - if (!emptyTheTank) /// If condition met => skip measuring and force emptying + if (!drainTheTank) /// If condition met => skip measuring and force emptying { /// /// Measure the weight and skip emptying if there is enough room in the tank /// State.Create("FlyingStartMassCollection : Checking available tank capacity") .AddOperation(checkUiOp) - .AddOperation(outPath.Balance.ReadMassOp(ref Mass)) + .AddOperation(outPath.Scale.ReadMassOp(ref Mass)) .EnterState(); do { @@ -153,27 +152,38 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection while (!e.Contains(Event.BalanceDone)); double estimatedEndMass = Mass.Val + test.Volume; - if (estimatedEndMass >= outPath.Balance.Capacity * Constants.TankFullFactor) + if (estimatedEndMass >= outPath.Scale.Capacity * Constants.TankFullFactor) { - emptyTheTank = true; + drainTheTank = true; } } /// - if (emptyTheTank) + if (drainTheTank) { +#if BERLIN + switch (DrainTheTank(outPath.DrainValve, outPath.Scale)) + { + case Event.Error: { retVal = Event.Error; goto stopTest; } + case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } + } + + drainTheTank = false; +#else State.Create("FlyingStartMassCollection : Opening the emptying valve") .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(outPath.EmptyTankValve, null)) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(outPath.DrainValve, null)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } } while (!e.Contains(Event.ValvesSet)); +#endif } + /// /// Optionally display prompt to emerge temperature meters to appropriate baths for heat meters test /// @@ -186,10 +196,15 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection heatMetersPromptOp = new Operations.MessageBoxOp(heatMetersTestParams.Prompt); } + //------------------------------------------------ Bridge.OnActivity(this, Strings.Starting_the_pump); //------------------------------------------------ - if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower); + + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + int flowSetTime0 = StateMachine.Time; + + if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower); /// State.Create("FlyingStartMassCollection : Starting the pump") .AddOperation(checkUiOp) @@ -384,8 +399,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection foreach (var camera in cameras) measureOperations.Add(camera.MeasurementOp()); - - if (emptyTheTank) + if (drainTheTank) { //------------------------------------------------ Bridge.OnActivity(this, Strings.Closing_the_tank); @@ -402,15 +416,16 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection extraOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1)); extraOps.Add(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)); } - switch (EmptyTheTank(outPath.EmptyTankValve, outPath.Balance, extraOps)) + switch (DrainTheTank(outPath.DrainValve, outPath.Scale, extraOps)) { - case Event.Error: { retVal = Event.Error; goto stopTest; } + case Event.Error: { retVal = Event.Error; goto stopTest; } case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } } - emptyTheTank = false; + drainTheTank = false; } + if (test.TimeFlow2Mass > 0) { State.Create("FlyingStartMassCollection : Waiting before 1st mass measurement") @@ -456,7 +471,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)) .AddOperation((StateMachine.Ambient != null) ? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null) - .AddOperation(outPath.Balance.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod)) + .AddOperation(outPath.Scale.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod)) .AddOperation(cBrd.UpdateTankWeightOp()) .AddOperation(processDataLoggingOp) .EnterState(); @@ -535,7 +550,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2)) .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1)) .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)) - .AddOperation(outPath.Balance.ReadMassOp(ref Mass)) + .AddOperation(outPath.Scale.ReadMassOp(ref Mass)) .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) .AddOperation((StateMachine.Ambient != null) ? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) @@ -625,7 +640,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)) .AddOperation((StateMachine.Ambient != null) ? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null) - .AddOperation(outPath.Balance.ReadMassOp(ref Mass)) + .AddOperation(outPath.Scale.ReadMassOp(ref Mass)) .AddOperation(cBrd.UpdateTankWeightOp()) .AddOperation(processDataLoggingOp) .AddOperation(new Operations.TimerOp(test.TimeStop2Mass)) @@ -657,7 +672,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)) .AddOperation((StateMachine.Ambient != null) ? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null) - .AddOperation(outPath.Balance.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod)) + .AddOperation(outPath.Scale.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod)) .AddOperation(cBrd.UpdateTankWeightOp()) .AddOperation(processDataLoggingOp) .EnterState(); @@ -746,9 +761,9 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection tstRslt.TestTime = cBrd.TTime; /// [s] measurement time tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = StartMass.Val; - tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections); + tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Scale.Corrections); tstRslt.MassEndRaw = EndMass.Val; - tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections); + tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Scale.Corrections); tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; /// [kg/h] tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h] tstRslt.VolumeCTV = 1001.03 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3] @@ -942,7 +957,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, - outPath.Balance != null ? outPath.Balance.Name : string.Empty, + outPath.Scale != null ? outPath.Scale.Name : string.Empty, outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); diff --git a/TestBenchFramework/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs b/TestBenchFramework/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs index 715ac8f5b..609fff6f6 100644 --- a/TestBenchFramework/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs @@ -401,7 +401,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest (BenchInfo != null) ? BenchInfo.TestBenchName : "testbench", inPath.Pump != null ? inPath.Pump.Name : string.Empty, outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty, - outPath.Balance != null ? outPath.Balance.Name : string.Empty, + outPath.Scale != null ? outPath.Scale.Name : string.Empty, outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); diff --git a/TestBenchFramework/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs b/TestBenchFramework/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs index 56cf9995d..49bed63a9 100644 --- a/TestBenchFramework/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs @@ -312,7 +312,7 @@ namespace TBF.BenchControl.TestMethods.PMaxTest (BenchInfo != null) ? BenchInfo.TestBenchName : "testbench", inPath.Pump != null ? inPath.Pump.Name : string.Empty, outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty, - outPath.Balance != null ? outPath.Balance.Name : string.Empty, + outPath.Scale != null ? outPath.Scale.Name : string.Empty, outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); diff --git a/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs b/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs index 3de99344c..e2ed788ea 100644 --- a/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/ReferenceFlowmeterCalibrationSeq.cs @@ -103,14 +103,14 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration while (!e.Contains(Event.ValvesSet)); - if (!test.Emptying) /// If condition met => skip measuring and force emptying + if (!test.Draining) /// If condition met => skip measuring and force emptying { /// /// Measure the weight and skip emptying if there is enough room in the tank /// State.Create("ReferenceFlowmeterCalibration : Measuring the mass of water in the tank") .AddOperation(checkUiOp) - .AddOperation(outPath.Balance.ReadMassOp(ref Mass)) + .AddOperation(outPath.Scale.ReadMassOp(ref Mass)) .EnterState(); do { @@ -124,7 +124,7 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration while (!e.Contains(Event.BalanceDone)); double estimatedEndMass = Mass.Val + test.Volume; - if (estimatedEndMass < outPath.Balance.Capacity * Constants.TankFullFactor) + if (estimatedEndMass < outPath.Scale.Capacity * Constants.TankFullFactor) { goto set_flow; /// Enough room in the tank -> skip emptying } @@ -133,7 +133,7 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration /// /// Empty the water tank /// - switch (EmptyTheTank(outPath.EmptyTankValve, outPath.Balance)) + switch (DrainTheTank(outPath.DrainValve, outPath.Scale)) { case Event.Error: { retVal = Event.Error; goto stopTest; } case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } @@ -182,7 +182,7 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration .AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta)) .AddOperation((StateMachine.Ambient != null) ? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null) - .AddOperation(outPath.Balance.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod)) + .AddOperation(outPath.Scale.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod)) .AddOperation(cBrd.UpdateTankWeightOp()) .AddOperation(processDataLoggingOp) .EnterState(); @@ -251,7 +251,7 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration .AddOperation(readRegistersOp) .AddOperation((StateMachine.Ambient != null) ? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null) - .AddOperation(outPath.Balance.ReadMassOp(ref Mass)) + .AddOperation(outPath.Scale.ReadMassOp(ref Mass)) .AddOperation(cBrd.UpdateTankWeightOp()) .AddOperation(processDataLoggingOp) .AddOperation(new Operations.TimerOp(test.TimeStop2Mass)) @@ -277,7 +277,7 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration .AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta)) .AddOperation((StateMachine.Ambient != null) ? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null) - .AddOperation(outPath.Balance.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod)) + .AddOperation(outPath.Scale.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod)) .AddOperation(cBrd.UpdateTankWeightOp()) .AddOperation(processDataLoggingOp) .EnterState(); @@ -362,9 +362,9 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration tstRslt.TestTime = cBrd.TTime; /// [s] measurement time tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total) tstRslt.MassStartRaw = StartMass.Val; - tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections); + tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Scale.Corrections); tstRslt.MassEndRaw = EndMass.Val; - tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections); + tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Scale.Corrections); tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; /// [kg/h] tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h] tstRslt.VolumeCTV = 1001.03 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3] @@ -388,7 +388,7 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration (BenchInfo != null) ? BenchInfo.TestBenchName : "testbench", inPath.Pump != null ? inPath.Pump.Name : string.Empty, outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty, - outPath.Balance != null ? outPath.Balance.Name : string.Empty, + outPath.Scale != null ? outPath.Scale.Name : string.Empty, outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); diff --git a/TestBenchFramework/MetrologyDlg.cs b/TestBenchFramework/MetrologyDlg.cs index 44a524d98..b5524756d 100644 --- a/TestBenchFramework/MetrologyDlg.cs +++ b/TestBenchFramework/MetrologyDlg.cs @@ -79,7 +79,7 @@ namespace TBF TabPage tabPage = new TabPage(" " + cmpnt.Name + " "); MetrologyDlgBalanceTab uiControl = new MetrologyDlgBalanceTab(); uiControl.MeterEntity = cmpnt; - uiControl.BalanceCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.GenericDevices.IBalanceCfg; + uiControl.BalanceCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.GenericDevices.IScaleCfg; uiControl.Dock = DockStyle.Fill; tabPage.Tag = uiControl; tabPage.Controls.Add(uiControl); diff --git a/TestBenchFramework/ProcedureDlg.cs b/TestBenchFramework/ProcedureDlg.cs index ce246ec46..f6b2bef06 100644 --- a/TestBenchFramework/ProcedureDlg.cs +++ b/TestBenchFramework/ProcedureDlg.cs @@ -906,7 +906,7 @@ namespace TBF lviMetrlg1.SubItems.Add(test.Volume.ToString()); lviMetrlg1.SubItems.Add(test.TstTime.ToString()); lviMetrlg1.SubItems.Add(test.Repeats.ToString()); - lviMetrlg1.SubItems.Add(test.Emptying ? Strings.yes : Strings.no); + lviMetrlg1.SubItems.Add(test.Draining ? Strings.yes : Strings.no); //lviMetrlg1.SubItems.Add(test.Zeroing ? Strings.yes : Strings.no); lviMetrlg1.SubItems.Add((test.Method != null) ? test.Method.ToString() : string.Empty); @@ -984,8 +984,8 @@ namespace TBF int itmp; if (int.TryParse(lvi.SubItems[(int)MtrlgyClmn.Repeats].Text, out itmp)) entity.Repeats = itmp; - if (lvi.SubItems[(int)MtrlgyClmn.Emptying].Text.Equals(Strings.yes)) entity.Emptying = true; - else if (lvi.SubItems[(int)MtrlgyClmn.Emptying].Text.Equals(Strings.no)) entity.Emptying = false; + if (lvi.SubItems[(int)MtrlgyClmn.Emptying].Text.Equals(Strings.yes)) entity.Draining = true; + else if (lvi.SubItems[(int)MtrlgyClmn.Emptying].Text.Equals(Strings.no)) entity.Draining = false; if (methodCBox.Items.Contains(lvi.SubItems[(int)MtrlgyClmn.Method].Text)) diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index 8c67e2faf..059239885 100644 --- a/TestBenchFramework/Properties/AssemblyInfo.cs +++ b/TestBenchFramework/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.12.517.1")] -[assembly: AssemblyFileVersion("2.12.517.1")] +[assembly: AssemblyVersion("2.12.518.1")] +[assembly: AssemblyFileVersion("2.12.518.1")] diff --git a/TestBenchFramework/Screens/ProcessTabPageCtrl24.cs b/TestBenchFramework/Screens/ProcessTabPageCtrl24.cs index 4fb807737..619c365a2 100644 --- a/TestBenchFramework/Screens/ProcessTabPageCtrl24.cs +++ b/TestBenchFramework/Screens/ProcessTabPageCtrl24.cs @@ -396,7 +396,7 @@ namespace TBF.Screens if (args.OutputPath.TempDiv != null) tDivCmpntLabel.Text = args.OutputPath.TempDiv.Name; if (args.OutputPath.FlowMeter != null) refFlowCmpntLabel.Text = args.OutputPath.FlowMeter.Name; if (args.OutputPath.RegulValve != null) regValveCmpntLabel.Text = args.OutputPath.RegulValve.Name; - if (args.OutputPath.Balance != null) scaleCmpntLabel.Text = args.OutputPath.Balance.Name; + if (args.OutputPath.Scale != null) scaleCmpntLabel.Text = args.OutputPath.Scale.Name; for (int i = 0; i < textBoxesCount; i++) { diff --git a/TestBenchFramework/Screens/ProcessTabPageCtrl48.cs b/TestBenchFramework/Screens/ProcessTabPageCtrl48.cs index cbfa3c3b8..b6f958219 100644 --- a/TestBenchFramework/Screens/ProcessTabPageCtrl48.cs +++ b/TestBenchFramework/Screens/ProcessTabPageCtrl48.cs @@ -425,7 +425,7 @@ namespace TBF.Screens if (args.OutputPath.TempDiv != null) tDivCmpntLabel.Text = args.OutputPath.TempDiv.Name; if (args.OutputPath.FlowMeter != null) refFlowCmpntLabel.Text = args.OutputPath.FlowMeter.Name; if (args.OutputPath.RegulValve != null) regValveCmpntLabel.Text = args.OutputPath.RegulValve.Name; - if (args.OutputPath.Balance != null) scaleCmpntLabel.Text = args.OutputPath.Balance.Name; + if (args.OutputPath.Scale != null) scaleCmpntLabel.Text = args.OutputPath.Scale.Name; for (int i = 0; i < textBoxesCount; i++) { diff --git a/TestBenchFramework/Screens/ProcessTabPageCtrl6.cs b/TestBenchFramework/Screens/ProcessTabPageCtrl6.cs index 31033ce10..c45f5299b 100644 --- a/TestBenchFramework/Screens/ProcessTabPageCtrl6.cs +++ b/TestBenchFramework/Screens/ProcessTabPageCtrl6.cs @@ -412,7 +412,7 @@ namespace TBF.Screens if (args.OutputPath.TempDiv != null) tDivCmpntLabel.Text = args.OutputPath.TempDiv.Name; if (args.OutputPath.FlowMeter != null) refFlowCmpntLabel.Text = args.OutputPath.FlowMeter.Name; if (args.OutputPath.RegulValve != null) regValveCmpntLabel.Text = args.OutputPath.RegulValve.Name; - if (args.OutputPath.Balance != null) scaleCmpntLabel.Text = args.OutputPath.Balance.Name; + if (args.OutputPath.Scale != null) scaleCmpntLabel.Text = args.OutputPath.Scale.Name; sensor1Label.Text = (args.MetersPath.RegisterReaders[0] == null) ? "" : args.MetersPath.RegisterReaders[0].Cfg.Name; if (Config.Data.WMsCount >= 2) diff --git a/TestBenchFramework/TBF.csproj b/TestBenchFramework/TBF.csproj index 678414330..414d94a1c 100644 --- a/TestBenchFramework/TBF.csproj +++ b/TestBenchFramework/TBF.csproj @@ -445,7 +445,7 @@ ValveCfgCtrl.cs - + @@ -1350,8 +1350,8 @@ - - + + diff --git a/TestBenchFramework/UiBridge/Enums.cs b/TestBenchFramework/UiBridge/Enums.cs index 2a826cc0f..a7b665220 100644 --- a/TestBenchFramework/UiBridge/Enums.cs +++ b/TestBenchFramework/UiBridge/Enums.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2017 Sensus Metering Systems /// namespace TBF.UiBridge { @@ -15,9 +15,9 @@ namespace TBF.UiBridge Stop, PurgeBegin, PurgeEnd, - EmptyTank1, - EmptyTank2, - EmptyTank3, + DrainTank1, + DrainTank2, + DrainTank3, Break, ResetResults, AcceptResults, @@ -40,9 +40,9 @@ namespace TBF.UiBridge StartCycleBtnEn = 0x10, PurgeBeginBtnEn = 0x20, PurgeEndBtnEn = 0x40, - EmptyTankBtn1En = 0x80, - EmptyTankBtn2En = 0x100, - EmptyTankBtn3En = 0x200, + DrainTankBtn1En = 0x80, + DrainTankBtn2En = 0x100, + DrainTankBtn3En = 0x200, Break = 0x400, ResetResultsBtnEn = 0x800, AcceptResultsBtnEn = 0x1000, diff --git a/TestBenchFramework/UiControls/BenchControlPanel.cs b/TestBenchFramework/UiControls/BenchControlPanel.cs index 2e8a457f7..4b7bbf390 100644 --- a/TestBenchFramework/UiControls/BenchControlPanel.cs +++ b/TestBenchFramework/UiControls/BenchControlPanel.cs @@ -199,9 +199,9 @@ namespace TBF.UiControls private void stopBtn_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.Stop); } private void purgeBeginBtn_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.PurgeBegin); } private void purgeEndBtn_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.PurgeEnd); } - private void emptyTank1Btn_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.EmptyTank1); } - private void emptyTank2Btn_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.EmptyTank2); } - private void emptyTank3Btn_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.EmptyTank3); } + private void emptyTank1Btn_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.DrainTank1); } + private void emptyTank2Btn_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.DrainTank2); } + private void emptyTank3Btn_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.DrainTank3); } private void breakBtn_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.Break); } private void resetResultsBtn_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.ResetResults); } private void acceptResultsBtn_Click(object sender, EventArgs e) { Bridge.Ui2Bench(UI2BenchCmd.AcceptResults); } @@ -228,8 +228,8 @@ namespace TBF.UiControls case '5': if (startCycleBtn.Enabled) { Bridge.Ui2Bench(UI2BenchCmd.StartCycle); } return true; case '6': if (purgeBeginBtn.Enabled) { Bridge.Ui2Bench(UI2BenchCmd.PurgeBegin); } return true; case '7': if (purgeEndBtn.Enabled) { Bridge.Ui2Bench(UI2BenchCmd.PurgeEnd); } return true; - case '8': if (emptyTank1Btn.Enabled) { Bridge.Ui2Bench(UI2BenchCmd.EmptyTank1); } return true; - case '9': if (emptyTank2Btn.Enabled) { Bridge.Ui2Bench(UI2BenchCmd.EmptyTank2); } return true; + case '8': if (emptyTank1Btn.Enabled) { Bridge.Ui2Bench(UI2BenchCmd.DrainTank1); } return true; + case '9': if (emptyTank2Btn.Enabled) { Bridge.Ui2Bench(UI2BenchCmd.DrainTank2); } return true; default: return false; } @@ -286,13 +286,13 @@ namespace TBF.UiControls purgeEndBtn.Enabled = ((args.Flags & ButtonsEtc.PurgeEndBtnEn) != 0); purgeEndBtn.BackColor = purgeEndBtn.Enabled ? colorPurgeEn : colorPurgeDis; - emptyTank1Btn.Enabled = ((args.Flags & ButtonsEtc.EmptyTankBtn1En) != 0); + emptyTank1Btn.Enabled = ((args.Flags & ButtonsEtc.DrainTankBtn1En) != 0); emptyTank1Btn.BackColor = emptyTank1Btn.Enabled ? colorEmptyEn : colorEmptyDis; - emptyTank2Btn.Enabled = ((args.Flags & ButtonsEtc.EmptyTankBtn2En) != 0); + emptyTank2Btn.Enabled = ((args.Flags & ButtonsEtc.DrainTankBtn2En) != 0); emptyTank2Btn.BackColor = emptyTank2Btn.Enabled ? colorEmptyEn : colorEmptyDis; - emptyTank3Btn.Enabled = ((args.Flags & ButtonsEtc.EmptyTankBtn3En) != 0); + emptyTank3Btn.Enabled = ((args.Flags & ButtonsEtc.DrainTankBtn3En) != 0); emptyTank3Btn.BackColor = emptyTank3Btn.Enabled ? colorEmptyEn : colorEmptyDis; resetResultsBtn.Enabled = ((args.Flags & ButtonsEtc.ResetResultsBtnEn) != 0); diff --git a/TestBenchFramework/UiControls/MetrologyDlgBalanceTab.cs b/TestBenchFramework/UiControls/MetrologyDlgBalanceTab.cs index 4adcb0b3d..7a5f72f27 100644 --- a/TestBenchFramework/UiControls/MetrologyDlgBalanceTab.cs +++ b/TestBenchFramework/UiControls/MetrologyDlgBalanceTab.cs @@ -29,7 +29,7 @@ namespace TBF.UiControls /// /// Balance configuration (with buoyancy parameters) /// - public BenchControl.GenericDevices.IBalanceCfg BalanceCfg; + public BenchControl.GenericDevices.IScaleCfg BalanceCfg; /// /// A list of 'measurement-correction' pairs to be deleted from the database on OK. diff --git a/TestBenchFramework/UiControls/PathsOutputCtrl.cs b/TestBenchFramework/UiControls/PathsOutputCtrl.cs index 4c392b7ca..6d4110e22 100644 --- a/TestBenchFramework/UiControls/PathsOutputCtrl.cs +++ b/TestBenchFramework/UiControls/PathsOutputCtrl.cs @@ -104,7 +104,7 @@ namespace TBF.UiControls if (cmpnt is IRegulValve) regulValveComboBox.Items.Add(cmpnt.Cfg.Name); if (cmpnt is IFlowMeter) flowMeterComboBox.Items.Add(cmpnt.Cfg.Name); if (cmpnt is IDiverter) diverterComboBox.Items.Add(cmpnt.Cfg.Name); - if (cmpnt is IBalance) balanceComboBox.Items.Add(cmpnt.Cfg.Name); + if (cmpnt is IScale) balanceComboBox.Items.Add(cmpnt.Cfg.Name); if (cmpnt is ITempMeter) tempMeterDivComboBox.Items.Add(cmpnt.Cfg.Name); if (cmpnt is IValve && (cmpnt as IValve).CoupledTo == null) { @@ -207,8 +207,8 @@ namespace TBF.UiControls lvi.SubItems.Add((path.StartValve != null) ? path.StartValve.Cfg.Name : "---"); lvi.SubItems.Add((path.Diverter != null) ? path.Diverter.Cfg.Name : "---"); lvi.SubItems.Add((path.TempDiv != null) ? path.TempDiv.Cfg.Name : "---"); - lvi.SubItems.Add((path.Balance != null) ? path.Balance.Cfg.Name : "---"); - lvi.SubItems.Add((path.EmptyTankValve != null) ? path.EmptyTankValve.Cfg.Name : "---"); + lvi.SubItems.Add((path.Scale != null) ? path.Scale.Cfg.Name : "---"); + lvi.SubItems.Add((path.DrainValve != null) ? path.DrainValve.Cfg.Name : "---"); foreach (var valve in parent.Valves) { @@ -261,7 +261,7 @@ namespace TBF.UiControls entity.StartValve = lvi.SubItems[(int)Column.StartValve].Text.Equals("---") ? null : lvi.SubItems[(int)Column.StartValve].Text; entity.Diverter = lvi.SubItems[(int)Column.Div].Text.Equals("---") ? null : lvi.SubItems[(int)Column.Div].Text; entity.TempDiv = lvi.SubItems[(int)Column.Tdiv].Text.Equals("---") ? null : lvi.SubItems[(int)Column.Tdiv].Text; - entity.Balance = lvi.SubItems[(int)Column.Scale].Text.Equals("---") ? null : lvi.SubItems[(int)Column.Scale].Text; + entity.Scale = lvi.SubItems[(int)Column.Scale].Text.Equals("---") ? null : lvi.SubItems[(int)Column.Scale].Text; entity.EmptyTankValve = lvi.SubItems[(int)Column.DrainValve].Text.Equals("---") ? null : lvi.SubItems[(int)Column.DrainValve].Text; string valvesOpen = string.Empty;