diff --git a/TBF/BenchControl/Dummy/Balance/Component.cs b/TBF/BenchControl/Dummy/Balance/Component.cs index 590c8b95f..88330fd0b 100644 --- a/TBF/BenchControl/Dummy/Balance/Component.cs +++ b/TBF/BenchControl/Dummy/Balance/Component.cs @@ -40,9 +40,8 @@ namespace TBF.BenchControl.Dummy.Balance public float BuoyancyPress { get { return 1.013f; } } public float BuoyancyHumi { get { return 50.0f; } } - public IOperation TaringOp(ref Boxes.DoubleBox tara) + public IOperation ZeroOp() { - tara.Val = 0; return this; } diff --git a/TBF/BenchControl/Elde/ControlBoardDev.cs b/TBF/BenchControl/Elde/ControlBoardDev.cs index 36c79039c..ae23fe82f 100644 --- a/TBF/BenchControl/Elde/ControlBoardDev.cs +++ b/TBF/BenchControl/Elde/ControlBoardDev.cs @@ -110,11 +110,11 @@ namespace TBF.BenchControl.Elde public byte MeretProtocol = 0; // Array length is the reference flowmeters count plus one -#if DN100 || FUZHOU_150 || FUZHOU_300 || IZRAEL_200 || SLM_150 || SENTEC || CEVAK_200 +#if DN100 || FUZHOU_150 || FUZHOU_300 || IZRAEL_200 || SENTEC || CEVAK_200 public uint[,] RegValveCalib = new uint[8,2] {{100,500},{100,500},{100,500},{100,500},{100,500},{100,500},{100,500},{100,500}}; public byte[] MeretRS485Address = new byte[4]; public float[] EtCalib = new float[6] { 1, 1, 1, 1, 1, 1 }; -#elif PUCHONG_200 || GENESIS || BERLIN || GELSENWASSER || PETERSBURG_200 || RUM_MOB +#elif PUCHONG_200 || GENESIS || BERLIN || GELSENWASSER || PETERSBURG_200 || RUM_MOB || SLM_150 public uint[,] RegValveCalib = new uint[16, 2] { {100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500}, {100,500} }; public byte[] MeretRS485Address = new byte[4]; diff --git a/TBF/BenchControl/GenericDevices/IScale.cs b/TBF/BenchControl/GenericDevices/IScale.cs index 0ffb3b39c..bd5c87d87 100644 --- a/TBF/BenchControl/GenericDevices/IScale.cs +++ b/TBF/BenchControl/GenericDevices/IScale.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2013-2018 Sensus Slovensko a.s. +/// Copyright (c) 2013-2020 Sensus Slovensko a.s. /// using TBF.Boxes; @@ -17,9 +17,8 @@ namespace TBF.BenchControl.GenericDevices /// /// Events: BalanceDone, Error /// - /// Reference to a variable for 'tara' in kg - /// TaringOp instance reference casted to IOperaton - IOperation TaringOp(ref DoubleBox tara); + /// ZeroOp instance reference casted to IOperaton + IOperation ZeroOp(); /// /// Events: BalanceDone, Error diff --git a/TBF/BenchControl/MettlerToledo/Multi/BalanceDev.cs b/TBF/BenchControl/MettlerToledo/Multi/BalanceDev.cs index d78a7e144..d6e6eb9d4 100644 --- a/TBF/BenchControl/MettlerToledo/Multi/BalanceDev.cs +++ b/TBF/BenchControl/MettlerToledo/Multi/BalanceDev.cs @@ -197,7 +197,7 @@ namespace TBF.BenchControl.MettlerToledo.Multi { if (balanceCfg.DebugLevel == DebugMode.Simulate) { - Masses[balanceNr] = TestBenchSim.GetSimMass(balanceNr); + Masses[balanceNr] = 123.456; msrmntState = MsrmntState.Valid; msrmntTimeStamp = StateMachine.Time; return; @@ -297,16 +297,26 @@ namespace TBF.BenchControl.MettlerToledo.Multi public void StopDevice2() { } + /// /// Events: BalanceDone, Error /// - /// Reference to a variable for 'tara' in kg - /// TaringOp instance reference casted to IOperaton - public IOperation TaringOp(ref DoubleBox tara) + /// ZeroOp reference + public IOperation ZeroOp() { - return new TaringOp(this, ref tara); + return new ZeroOp(this); } + /// + /// Events: BalanceDone, Error + /// + /// Reference to a variable for 'tara' in kg + /// TaringOp reference + public IOperation TaringOp(ref DoubleBox tara) + { + return new TaringOp(this, ref tara); + } + /// /// Events: BalanceDone, Error /// diff --git a/TBF/BenchControl/MettlerToledo/Multi/ZeroOp.cs b/TBF/BenchControl/MettlerToledo/Multi/ZeroOp.cs new file mode 100644 index 000000000..2cd83ae03 --- /dev/null +++ b/TBF/BenchControl/MettlerToledo/Multi/ZeroOp.cs @@ -0,0 +1,68 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System; +using log4net; + +namespace TBF.BenchControl.MettlerToledo.Multi +{ + public class ZeroOp : IOperation + { + private static readonly ILog log = LogManager.GetLogger(typeof(ZeroOp)); + public override string ToString() { return string.Format("ZeroOp(.,.)"); } + + bool done; + + /// Set by the constructor + BalanceDev balanceDev; + + /// + /// Events: BalanceDone, Error + /// + /// Balance device instance + public ZeroOp(BalanceDev balanceDev) + { + if (balanceDev == null) throw new ArgumentNullException("balanceDev"); + this.balanceDev = balanceDev; + log.Debug(this.ToString()); + } + + /// Start this operation + public void Start() + { + done = true; + } + + /// Run this operation + /// + /// Event.None + /// Event.BalanceDone + /// Event.Error . . . . . Current.Tick == null + /// + public Event Run() + { + if (done) return Event.BalanceDone; /// Zero has been done already + + if (balanceDev.MsrmntState == MsrmntState.Busy) return Event.Busy; + + if (balanceDev.MsrmntState == MsrmntState.Overload) + { + done = true; + return Event.BalanceOverload; + } + + if (balanceDev.MsrmntState == MsrmntState.Valid) + { + done = true; + return Event.BalanceDone; /// Zero completed + } + + return Event.Busy; + } + + /// Stop this operation + public void Stop() + { + } + } +} diff --git a/TBF/BenchControl/MettlerToledo/Standard/BalanceDev.cs b/TBF/BenchControl/MettlerToledo/Standard/BalanceDev.cs index 260b1079a..02889d5b4 100644 --- a/TBF/BenchControl/MettlerToledo/Standard/BalanceDev.cs +++ b/TBF/BenchControl/MettlerToledo/Standard/BalanceDev.cs @@ -78,9 +78,8 @@ namespace TBF.BenchControl.MettlerToledo.Standard public string Format { get { return balanceCfg.Format; } } - public BalanceDev() - { - } + + public BalanceDev() { } /// /// Constructor @@ -297,7 +296,7 @@ namespace TBF.BenchControl.MettlerToledo.Standard if (balanceCfg.DebugLevel == DebugMode.Simulate) { - Masses[balanceNr] = TestBenchSim.GetSimMass(balanceNr); + Masses[balanceNr] = 123.456; msrmntState = MsrmntState.Valid; msrmntTimeStamp = StateMachine.Time; return; @@ -513,13 +512,22 @@ namespace TBF.BenchControl.MettlerToledo.Standard /// /// Events: BalanceDone, Error /// - /// Reference to a variable for 'tara' in kg - /// TaringOp instance reference casted to IOperaton - public IOperation TaringOp(ref DoubleBox tara) + /// ZeroOp reference + public IOperation ZeroOp() { - return new TaringOp(this, ref tara); + return new ZeroOp(this); } + /// + /// Events: BalanceDone, Error + /// + /// Reference to a variable for 'tara' in kg + /// TaringOp reference + public IOperation TaringOp(ref DoubleBox tara) + { + return new TaringOp(this, ref tara); + } + /// /// Events: BalanceDone, Error /// diff --git a/TBF/BenchControl/MettlerToledo/Standard/ZeroOp.cs b/TBF/BenchControl/MettlerToledo/Standard/ZeroOp.cs new file mode 100644 index 000000000..7d44fc472 --- /dev/null +++ b/TBF/BenchControl/MettlerToledo/Standard/ZeroOp.cs @@ -0,0 +1,74 @@ +/// +/// Copyright (c) 2020 Sensus Slovensko a.s. +/// +using System; +using log4net; + +namespace TBF.BenchControl.MettlerToledo.Standard +{ + public class ZeroOp : IOperation + { + private static readonly ILog log = LogManager.GetLogger(typeof(ZeroOp)); + public override string ToString() { return string.Format("ZeroOp(.,.)"); } + + bool done; + + /// Set by the constructor + BalanceDev balanceDev; + + /// + /// Events: BalanceDone, Error + /// + /// Balance device instance + /// Reference to variable for 'tara' in kg + public ZeroOp(BalanceDev balanceDev) + { + if (balanceDev == null) throw new ArgumentNullException("balanceDev"); + this.balanceDev = balanceDev; + + log.Debug(this.ToString()); + } + + /// Start this operation + public void Start() + { + log.DebugFormat("{0} - Start()", balanceDev.Name); + done = false; + balanceDev.ZeroWhenStable(); + } + + /// Run this operation + /// + /// Event.None + /// Event.BalanceDone + /// Event.Error . . . . . Current.Tick == null + /// + public Event Run() + { + if (done) return Event.BalanceDone; /// Zeroing has been done already + + if (balanceDev.MsrmntState == MsrmntState.Busy) return Event.Busy; + + if (balanceDev.MsrmntState == MsrmntState.Overload) + { + done = true; + return Event.BalanceOverload; + } + + if (balanceDev.MsrmntState == MsrmntState.Valid) + { + done = true; + return Event.BalanceDone; /// Zeroing completed + } + + balanceDev.ZeroWhenStable(); /// Failed -> repeat zeroing + return Event.Busy; + } + + /// Stop this operation + public void Stop() + { + log.DebugFormat("{0} - Stop()", balanceDev.Name); + } + } +} diff --git a/TBF/BenchControl/Sequences/MainSeq.cs b/TBF/BenchControl/Sequences/MainSeq.cs index cbdf8e9be..88bd8715f 100644 --- a/TBF/BenchControl/Sequences/MainSeq.cs +++ b/TBF/BenchControl/Sequences/MainSeq.cs @@ -132,13 +132,10 @@ namespace TBF.BenchControl.Sequences Bridge.OnActivity(this, Strings.Resetting_scales); Bridge.Bench2UI(ButtonsEtc.StopBtnEn); /// Resetting scales -> Enable STOP button - DoubleBox tara1 = new DoubleBox(0); - DoubleBox tara2 = new DoubleBox(0); - DoubleBox tara3 = new DoubleBox(0); State.Create("MainSeq : Reset scales").AddOperation(checkUiOp) - .AddOperation((StateMachine.Tank1 is IScale) ? (StateMachine.Tank1 as IScale).TaringOp(ref tara1) : null) - .AddOperation((StateMachine.Tank2 is IScale) ? (StateMachine.Tank2 as IScale).TaringOp(ref tara2) : null) - .AddOperation((StateMachine.Tank3 is IScale) ? (StateMachine.Tank3 as IScale).TaringOp(ref tara3) : null) + .AddOperation((StateMachine.Tank1 is IScale) ? (StateMachine.Tank1 as IScale).ZeroOp() : null) + .AddOperation((StateMachine.Tank2 is IScale) ? (StateMachine.Tank2 as IScale).ZeroOp() : null) + .AddOperation((StateMachine.Tank3 is IScale) ? (StateMachine.Tank3 as IScale).ZeroOp() : null) .EnterState(); do { diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index 008e427ac..a710a3cb2 100644 --- a/TBF/Properties/AssemblyInfo.cs +++ b/TBF/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.26.1510.0")] -[assembly: AssemblyFileVersion("2.26.1510.0")] +[assembly: AssemblyVersion("2.26.1511.0")] +[assembly: AssemblyFileVersion("2.26.1511.0")] diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index af54434fa..95888e5b8 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -680,6 +680,7 @@ + @@ -699,6 +700,7 @@ +