diff --git a/TestBenchFramework/BenchControl/Dummy/Balance/Component.cs b/TestBenchFramework/BenchControl/Dummy/Balance/Component.cs index e74bece5f..aadd342bf 100644 --- a/TestBenchFramework/BenchControl/Dummy/Balance/Component.cs +++ b/TestBenchFramework/BenchControl/Dummy/Balance/Component.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2016 Sensus Metering Systems +/// Copyright (c) 2016-2017 Sensus Metering Systems /// using System; using System.Collections.Generic; @@ -28,6 +28,7 @@ namespace TBF.BenchControl.Dummy.Balance public int BalanceNr { get { return 0; } } public double Capacity { get { return 10000.0; } } + public GenericDevices.IValve DrainValve { get { return null; } } public bool IsEmpty(double mass) { return true; } public bool IsEmpty() { return true; } public string Format { get { return "F3"; } } diff --git a/TestBenchFramework/BenchControl/GenericDevices/IBalance.cs b/TestBenchFramework/BenchControl/GenericDevices/IBalance.cs index 3744caaf3..f27cfffa3 100644 --- a/TestBenchFramework/BenchControl/GenericDevices/IBalance.cs +++ b/TestBenchFramework/BenchControl/GenericDevices/IBalance.cs @@ -22,6 +22,11 @@ namespace TBF.BenchControl.GenericDevices /// double Capacity { get; } + /// + /// Water tank drain valve or 'null' + /// + IValve DrainValve { get; } + /// /// Returns true if tank s empty, mass is less then some threshold /// diff --git a/TestBenchFramework/BenchControl/GenericDevices/ITankDraining.cs b/TestBenchFramework/BenchControl/GenericDevices/ITankDraining.cs index 854a1144a..94ba57f89 100644 --- a/TestBenchFramework/BenchControl/GenericDevices/ITankDraining.cs +++ b/TestBenchFramework/BenchControl/GenericDevices/ITankDraining.cs @@ -10,6 +10,7 @@ namespace TBF.BenchControl.GenericDevices { public interface ITankDraining : ISequenceCondition { + IValve DrainValve { get; } bool IsEmpty(); } } diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Multi/BalanceDev.cs b/TestBenchFramework/BenchControl/MettlerToledo/Multi/BalanceDev.cs index 8612d6c6e..b50913dd0 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Multi/BalanceDev.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Multi/BalanceDev.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2015-2016 Sensus Metering Systems +/// Copyright (c) 2015-2017 Sensus Metering Systems /// using System; using System.Collections.Generic; @@ -19,7 +19,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi /// /// Implemented and tested on 15.10.2013 by Milan Hanajik /// - public class BalanceDev : ComponentBase, IDevice, GenericDevices.IBalance + public class BalanceDev : TankDraining, IDevice, GenericDevices.IBalance { /// /// Info: StartMassMeasurement() and "Balnce response = .., Mass = ..." diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceDev.cs b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceDev.cs index 0816fc839..99feebe55 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceDev.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceDev.cs @@ -30,8 +30,6 @@ namespace TBF.BenchControl.MettlerToledo.Standard protected readonly BalanceCfg balanceCfg; - GenericDevices.IValve drainValve; - /// /// Enumeration of balances via static fields and methods /// @@ -99,14 +97,12 @@ namespace TBF.BenchControl.MettlerToledo.Standard Balances[nextBalanceIdx - 1] = this; } - drainValve = TbfComponents.FindComponent(balanceCfg.DrainValve) as GenericDevices.IValve; - log.Debug(this.ToString()); } public void Initialize() { - base.Initalize(drainValve); + base.Initalize(); msrmntState = MsrmntState.Failed; /// Data not valid yet @@ -121,12 +117,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard log.FatalFormat("Successfully initialized device {0}", ToString()); } - public override string GetName() - { - return Name; - } - - public override bool IsEmpty() + public bool IsEmpty() { return (this.mass <= balanceCfg.Empty); } diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceNewDev.cs b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceNewDev.cs index dca2635f4..b8c32ce34 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceNewDev.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceNewDev.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2017 Sensus Metering Systems /// Author: Milan Hanajik /// using System; diff --git a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceOld.cs b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceOld.cs index 5e78bcb0f..26149f15f 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceOld.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/Standard/BalanceOld.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2016 Sensus Metering Systems +/// Copyright (c) 2016-2017 Sensus Metering Systems /// using System; using System.Collections.Generic; diff --git a/TestBenchFramework/BenchControl/MettlerToledo/TankDraining.cs b/TestBenchFramework/BenchControl/MettlerToledo/TankDraining.cs index 8312ee619..6cf744ed3 100644 --- a/TestBenchFramework/BenchControl/MettlerToledo/TankDraining.cs +++ b/TestBenchFramework/BenchControl/MettlerToledo/TankDraining.cs @@ -30,6 +30,8 @@ namespace TBF.BenchControl.MettlerToledo readonly GenericDevices.ITankDrainingCfg tankDrainingCfg; private IValve drainValve; + public GenericDevices.IValve DrainValve { get { return drainValve; } } + private IOperation openDrainValveOp; private IOperation closeDrainValveOp; @@ -51,9 +53,9 @@ namespace TBF.BenchControl.MettlerToledo CreateConditions(true); } - protected void Initalize(IValve drainValve) + protected void Initalize() { - this.drainValve = drainValve; + drainValve = TbfComponents.FindComponent(tankDrainingCfg.DrainValve) as IValve; openDrainValveOp = new Elde.SetValvesOp(StateMachine.ControlBoard, drainValve, null); closeDrainValveOp = new Elde.SetValvesOp(StateMachine.ControlBoard, null, drainValve); } diff --git a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs index fdbe0f8a1..4196e006a 100644 --- a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs +++ b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs @@ -127,9 +127,9 @@ namespace TBF.BenchControl.Sequences State startNew = State.Create("MainSeq : Emptying tanks") .AddOperation(checkUiOp); IList allEmptyingValves = new List(); - if (StateMachine.EmptyTankValve1 != null) allEmptyingValves.Add(StateMachine.EmptyTankValve1); - if (StateMachine.EmptyTankValve2 != null) allEmptyingValves.Add(StateMachine.EmptyTankValve2); - if (StateMachine.EmptyTankValve3 != null) allEmptyingValves.Add(StateMachine.EmptyTankValve3); + if (StateMachine.DrainValve1 != null) allEmptyingValves.Add(StateMachine.DrainValve1); + if (StateMachine.DrainValve2 != null) allEmptyingValves.Add(StateMachine.DrainValve2); + if (StateMachine.DrainValve3 != null) allEmptyingValves.Add(StateMachine.DrainValve3); // Determine the tank emptying time (the maximum for all balances) int balanceEmptyTime = 0; @@ -1126,9 +1126,9 @@ namespace TBF.BenchControl.Sequences ButtonsEtc.SensitivityTestBtnEn | ((Cameras.Count > 0) ? ButtonsEtc.CalibrationBtnEn : 0) | ButtonsEtc.Break)) | - (((StateMachine.Balance1 != null) && (StateMachine.EmptyTankValve1 != null) && !emptying1) ? ButtonsEtc.EmptyTankBtn1En : 0) | - (((StateMachine.Balance2 != null) && (StateMachine.EmptyTankValve2 != null) && !emptying2) ? ButtonsEtc.EmptyTankBtn2En : 0) | - (((StateMachine.Balance3 != null) && (StateMachine.EmptyTankValve3 != null) && !emptying3) ? ButtonsEtc.EmptyTankBtn3En : 0)); + (((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)); selection = Selection.None; State.Create("MainSeq : Select an activity") @@ -1171,9 +1171,9 @@ namespace TBF.BenchControl.Sequences if (emptying1 || emptying2 || emptying3) { IList valvesClose = new List(); - if (emptying1) valvesClose.Add(StateMachine.EmptyTankValve1); - if (emptying2) valvesClose.Add(StateMachine.EmptyTankValve2); - if (emptying3) valvesClose.Add(StateMachine.EmptyTankValve3); + if (emptying1) valvesClose.Add(StateMachine.DrainValve1); + if (emptying2) valvesClose.Add(StateMachine.DrainValve2); + if (emptying3) valvesClose.Add(StateMachine.DrainValve3); State.Create("MainSeq : Close emptying valve(s)") .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, valvesClose)) @@ -1193,7 +1193,7 @@ namespace TBF.BenchControl.Sequences (emptying2 ? 0 : ButtonsEtc.EmptyTankBtn2En) | (emptying3 ? 0 : ButtonsEtc.EmptyTankBtn3En)); State.Create("MainSeq : Open tank 1") - .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.EmptyTankValve1, null)) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DrainValve1, null)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); } while (!e.Contains(Event.ValvesSet)); @@ -1207,7 +1207,7 @@ namespace TBF.BenchControl.Sequences (emptying1 ? 0 : ButtonsEtc.EmptyTankBtn1En) | (emptying3 ? 0 : ButtonsEtc.EmptyTankBtn3En)); State.Create("MainSeq : Open tank 2") - .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.EmptyTankValve2, null)) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DrainValve2, null)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); } while (!e.Contains(Event.ValvesSet)); @@ -1221,7 +1221,7 @@ namespace TBF.BenchControl.Sequences (emptying1 ? 0 : ButtonsEtc.EmptyTankBtn1En) | (emptying2 ? 0 : ButtonsEtc.EmptyTankBtn2En)); State.Create("MainSeq : Open tank 3") - .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.EmptyTankValve3, null)) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DrainValve3, null)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); } while (!e.Contains(Event.ValvesSet)); @@ -1229,7 +1229,7 @@ namespace TBF.BenchControl.Sequences else if (selection == Selection.CloseTank1) { State.Create("MainSeq : Close tank 1") - .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.EmptyTankValve1)) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.DrainValve1)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); } while (!e.Contains(Event.ValvesSet)); @@ -1238,7 +1238,7 @@ namespace TBF.BenchControl.Sequences else if (selection == Selection.CloseTank2) { State.Create("MainSeq : Close tank 2") - .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.EmptyTankValve2)) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.DrainValve2)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); } while (!e.Contains(Event.ValvesSet)); @@ -1247,7 +1247,7 @@ namespace TBF.BenchControl.Sequences else if (selection == Selection.CloseTank3) { State.Create("MainSeq : Close tank 3") - .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.EmptyTankValve3)) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, StateMachine.DrainValve3)) .EnterState(); do { e = StateMachine.WaitRunDevsRunOps(); } while (!e.Contains(Event.ValvesSet)); diff --git a/TestBenchFramework/BenchControl/State.cs b/TestBenchFramework/BenchControl/State.cs index 4a2c8a239..6dae50740 100644 --- a/TestBenchFramework/BenchControl/State.cs +++ b/TestBenchFramework/BenchControl/State.cs @@ -11,9 +11,9 @@ namespace TBF.BenchControl public class State { /// - /// DEBUG: all state changes and all operations - /// INFO: all state changes and operations that returned evnt != Event.None - /// WARN: only state changes + /// DEBUG: operation.Start(), operation.Stop() + /// INFO: operation.Run() when returned event != Event.None + /// WARN: EnterState() only state changes /// private static readonly ILog log = LogManager.GetLogger(typeof(State)); public override string ToString() { return Name + (Label==null ? "" : ", label=" + Label); } @@ -193,9 +193,13 @@ namespace TBF.BenchControl Event evnt = operation.Run(); if (evnt != Event.None) { - log.DebugFormat("Operation {0} returned {1}", operation, evnt); + log.InfoFormat("Operation {0}.Run() returned {1}", operation, evnt); events.Add(evnt); } + else + { + log.DebugFormat("Operation {0}.Run() returned {1}", operation, evnt); + } } LastEvents = events; @@ -209,7 +213,7 @@ namespace TBF.BenchControl { foreach (IOperation operation in currentState.Operations) { - log.InfoFormat("stopping {0}", operation); + log.DebugFormat("stopping {0}", operation); operation.Stop(); } } @@ -226,7 +230,7 @@ namespace TBF.BenchControl { if (!newState.Operations.Contains(operation)) { - log.InfoFormat("stopping {0}", operation); + log.DebugFormat("stopping {0}", operation); operation.Stop(); } } @@ -238,7 +242,7 @@ namespace TBF.BenchControl { if (!previousState.Operations.Contains(operation)) { - log.InfoFormat("starting {0}", operation); + log.DebugFormat("starting {0}", operation); operation.Start(); } } diff --git a/TestBenchFramework/BenchControl/StateMachine.cs b/TestBenchFramework/BenchControl/StateMachine.cs index 90d170f66..9cf2f8334 100644 --- a/TestBenchFramework/BenchControl/StateMachine.cs +++ b/TestBenchFramework/BenchControl/StateMachine.cs @@ -48,9 +48,9 @@ namespace TBF.BenchControl public static GenericDevices.IBalance Balance1; public static GenericDevices.IBalance Balance2; public static GenericDevices.IBalance Balance3; - public static GenericDevices.IValve EmptyTankValve1; - public static GenericDevices.IValve EmptyTankValve2; - public static GenericDevices.IValve EmptyTankValve3; + public static GenericDevices.IValve DrainValve1; + public static GenericDevices.IValve DrainValve2; + public static GenericDevices.IValve DrainValve3; public static IList MasterValves; /// list of directly controlled valves public static IList CoupledValves; /// list of coupled valves public static IList ExtendedValves; /// list of extended valves @@ -235,9 +235,9 @@ namespace TBF.BenchControl IBalance balance = cmpnt as IBalance; balances.Add(balance); - if (balance.BalanceNr == 0) Balance1 = balance; - else if (balance.BalanceNr == 1) Balance2 = balance; - else if (balance.BalanceNr == 2) Balance3 = balance; + if (balance.BalanceNr == 0) Balance1 = balance; + else if (balance.BalanceNr == 1) Balance2 = balance; + else if (balance.BalanceNr == 2) Balance3 = balance; } Elde.Valve.Valve eldeValve = (cmpnt as Elde.Valve.Valve); @@ -291,7 +291,10 @@ namespace TBF.BenchControl CurrentlyInitializedDeviceName = "---"; - /// Propagate debug levels from parents to children when necessary + /// + /// (1) Propagate debug levels from parents to children when necessary + /// (2) Set drain valves DrainValve1, DrainValve2 and DrainValve3 + /// foreach (var cmpnt in components) { if (cmpnt.Cfg is IChildComponentCfg && !string.IsNullOrEmpty(cmpnt.Cfg.ParentName) && @@ -302,6 +305,30 @@ namespace TBF.BenchControl if (par.Cfg.Name.Equals(cmpnt.Cfg.ParentName)) { cmpnt.Cfg.DebugLevel = par.Cfg.DebugLevel; break; } } } + + if (cmpnt is IBalance) + { + IBalance balance = cmpnt as IBalance; + + if (balance.BalanceNr == 0) + { + DrainValve1 = balance.DrainValve; + log.WarnFormat("InitializeBoardEtc() ... Scale1={0} Draining valve1={1}", + balance.Name, (DrainValve1 != null) ? DrainValve1.Name : "---"); + } + else if (balance.BalanceNr == 1) + { + DrainValve2 = balance.DrainValve; + log.WarnFormat("InitializeBoardEtc() ... Scale2={0} Draining valve2={1}", + balance.Name, (DrainValve2 != null) ? DrainValve2.Name : "---"); + } + else if (balance.BalanceNr == 2) + { + DrainValve3 = balance.DrainValve; + log.WarnFormat("InitializeBoardEtc() ... Scale3={0} Draining valve3={1}", + balance.Name, (DrainValve3 != null) ? DrainValve3.Name : "---"); + } + } } if (anyComponentIsInSimulMode) @@ -348,23 +375,6 @@ namespace TBF.BenchControl #if HEAT_METERS heatMetersPaths = session.QueryOver().OrderBy(x => x.ItemNr).Asc.List(); #endif - - // Automatic detection of empty tank valves - foreach (var opath in outputPaths) - { - if ((EmptyTankValve1 == null) && (Balance1 != null) && (opath.Balance == Balance1.Cfg.Name)) - { - EmptyTankValve1 = TbfComponents.FindComponent(opath.EmptyTankValve) as IValve; - } - if ((EmptyTankValve2 == null) && (Balance2 != null) && (opath.Balance == Balance2.Cfg.Name)) - { - EmptyTankValve2 = TbfComponents.FindComponent(opath.EmptyTankValve) as IValve; - } - if ((EmptyTankValve3 == null) && (Balance3 != null) && (opath.Balance == Balance3.Cfg.Name)) - { - EmptyTankValve3 = TbfComponents.FindComponent(opath.EmptyTankValve) as IValve; - } - } if (loadPathsOnly) return; diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index 6523c8e42..8c67e2faf 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.515.1")] -[assembly: AssemblyFileVersion("2.12.515.1")] +[assembly: AssemblyVersion("2.12.517.1")] +[assembly: AssemblyFileVersion("2.12.517.1")]