From ed606701c03a1f557d3e104cadf5c994b4d86f21 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Mon, 15 Nov 2021 16:09:41 +0100 Subject: [PATCH] TestMethods.Evacuation added, ProcessData.FillState updated by SequenceBase.Transition(), ver. 2.27.1813, Statistics v. 2.27.1800 --- Common/Enums.cs | 11 +++ Statistics/Properties/AssemblyInfo.cs | 4 +- TBF/Properties/AssemblyInfo.cs | 4 +- TBF/Rig/Sequences/MainSeq.cs | 10 +- TBF/Rig/Sequences/MainSeqUtils.cs | 23 ++--- TBF/Rig/Sequences/ProcessData.cs | 9 ++ TBF/Rig/Sequences/SequenceBase.cs | 25 ++--- TBF/Rig/TbfComponents.cs | 1 + TBF/Rig/TestMethods/Evacuation/Component.cs | 40 ++++++++ .../TestMethods/Evacuation/EvacuationSeq.cs | 95 +++++++++++++++++++ TBF/Rig/TestMethods/Evacuation/Factory.cs | 25 +++++ TBF/TBF.csproj | 3 + 12 files changed, 221 insertions(+), 29 deletions(-) create mode 100644 TBF/Rig/TestMethods/Evacuation/Component.cs create mode 100644 TBF/Rig/TestMethods/Evacuation/EvacuationSeq.cs create mode 100644 TBF/Rig/TestMethods/Evacuation/Factory.cs diff --git a/Common/Enums.cs b/Common/Enums.cs index 76a1de453..57b93e606 100644 --- a/Common/Enums.cs +++ b/Common/Enums.cs @@ -377,6 +377,17 @@ namespace Common Count } + /// + /// State of water filled in the test bench. + /// + public enum FillState + { + Unknown, /// Test bench fill state is unknown + Empty, /// Test bench is empty, no water + Full, /// Test bench is full of water + Count + } + public enum MeretProtocol { [Description("")] Undefined, diff --git a/Statistics/Properties/AssemblyInfo.cs b/Statistics/Properties/AssemblyInfo.cs index fb25ccb17..1d0fd3357 100644 --- a/Statistics/Properties/AssemblyInfo.cs +++ b/Statistics/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.25.1427.0")] -[assembly: AssemblyFileVersion("2.25.1427.0")] +[assembly: AssemblyVersion("2.27.1800.0")] +[assembly: AssemblyFileVersion("2.27.1800.0")] diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index ecf6a3fe6..af11dcad0 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.27.1807.0")] -[assembly: AssemblyFileVersion("2.27.1807.0")] +[assembly: AssemblyVersion("2.27.1813.0")] +[assembly: AssemblyFileVersion("2.27.1813.0")] diff --git a/TBF/Rig/Sequences/MainSeq.cs b/TBF/Rig/Sequences/MainSeq.cs index 6ec9b1751..c0aaeeb5e 100644 --- a/TBF/Rig/Sequences/MainSeq.cs +++ b/TBF/Rig/Sequences/MainSeq.cs @@ -131,7 +131,7 @@ namespace TBF.Rig.Sequences /// public MainSeq() { - benchFilled = false; + FillState = FillState.Unknown; simultWithPurgingCount = 0; simultWithPurgingCfg = null; @@ -497,7 +497,10 @@ namespace TBF.Rig.Sequences { goto assume_bench_filled; } - else if ((selection == Selection.Cycle && benchFilled) || (selection == Selection.RestoreBatch) || (selection == Selection.RestoreAndFixBatch) || (selection == Selection.RestoreInterruptedSession)) + else if ((selection == Selection.Cycle && FillState == FillState.Full) || + (selection == Selection.RestoreBatch) || + (selection == Selection.RestoreAndFixBatch) || + (selection == Selection.RestoreInterruptedSession)) { /// /// Always ask a question in case of a restored batch @@ -588,7 +591,7 @@ namespace TBF.Rig.Sequences assume_bench_filled: - benchFilled = true; + FillState = FillState.Full; Bridge.Bench2UI(ButtonsEtc.ShowBenchFilled); if ((selection == Selection.Cycle) || (selection == Selection.RestoreBatch) || (selection == Selection.RestoreAndFixBatch)) @@ -704,6 +707,7 @@ namespace TBF.Rig.Sequences if (selection == Selection.PurgeBegin) goto fill_the_bench; if (selection == Selection.PurgeEnd) { + FillState = FillState.Unknown; /// Enfoce evacuation switch (DoEvacuation(purgeEnd)) { case Event.Error: goto error; diff --git a/TBF/Rig/Sequences/MainSeqUtils.cs b/TBF/Rig/Sequences/MainSeqUtils.cs index 24612b936..fd9026889 100644 --- a/TBF/Rig/Sequences/MainSeqUtils.cs +++ b/TBF/Rig/Sequences/MainSeqUtils.cs @@ -811,20 +811,21 @@ namespace TBF.Rig.Sequences } //-------------------------------------------------------- - benchFilled = false; /// because evacuation sequence started - /// - switch (Transition(purgeEnd, TransitionContext.PurgeEnd)) + if (FillState != FillState.Empty) { - case Event.Error: - if (simultWithEvacuationCount > 0) CloseCommunicationForm(); - return Event.Error; + switch (Transition(purgeEnd, TransitionContext.PurgeEnd)) + { + case Event.Error: + if (simultWithEvacuationCount > 0) CloseCommunicationForm(); + return Event.Error; - case Event.UiCmdStop: - if (simultWithEvacuationCount > 0) CloseCommunicationForm(); - return Event.UiCmdStop; + case Event.UiCmdStop: + if (simultWithEvacuationCount > 0) CloseCommunicationForm(); + return Event.UiCmdStop; - default: - break; + default: + break; + } } if (simultWithEvacuationCount > 0) diff --git a/TBF/Rig/Sequences/ProcessData.cs b/TBF/Rig/Sequences/ProcessData.cs index 3b116f828..6119147ab 100644 --- a/TBF/Rig/Sequences/ProcessData.cs +++ b/TBF/Rig/Sequences/ProcessData.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using log4net; +using Common; using TBF.Rig.GenericDevices; using TBF.Boxes; @@ -43,6 +44,13 @@ namespace TBF.Rig.Sequences public static IList RawTestInfos; /// Incomplete raw test infos from Oracle DB public static Results.Output.SensusTestInfo[] CompleteTestInfos; /// Complete TBF test infos obtained as a best mathch + /// + /// State of water filled in the test bench. + /// Updated by Transition(sequence, context) + /// when context == TransitionContext.PurgeBegin + /// or context == TransitionContext.PurgeEnd + /// + public static FillState FillState; static ProcessData() { @@ -54,6 +62,7 @@ namespace TBF.Rig.Sequences IsQ2PreCorrectionCalculated = false; CalculatedQ2PreCorrectionLR = 0; CalculatedQ2PreCorrectionRL = 0; + FillState = FillState.Unknown; } /// diff --git a/TBF/Rig/Sequences/SequenceBase.cs b/TBF/Rig/Sequences/SequenceBase.cs index 4a845fb15..860ac507a 100644 --- a/TBF/Rig/Sequences/SequenceBase.cs +++ b/TBF/Rig/Sequences/SequenceBase.cs @@ -547,15 +547,16 @@ namespace TBF.Rig.Sequences case TransitionContext.BetweenTests: message = Strings.Between_tests_sequence_i_n; break; case TransitionContext.AfterTestWithOverlap: - case TransitionContext.AfterTest: - message = Strings.Test_stop_sequence_i_n; - break; + case TransitionContext.AfterTest: message = Strings.Test_stop_sequence_i_n; break; case TransitionContext.PurgeEnd: message = Strings.Emptying_i_n; break; case TransitionContext.Stop: message = Strings.Test_stop_sequence_i_n; break; default: message = "Transition"; break; } + if (context == TransitionContext.PurgeBegin && FillState != FillState.Full) FillState = FillState.Unknown; + if (context == TransitionContext.PurgeEnd && FillState != FillState.Empty) FillState = FillState.Unknown; + if (transitionSequence == null) { /// @@ -569,11 +570,9 @@ namespace TBF.Rig.Sequences State.Create("SequenceBase : Transition : TestEnd - Default action") .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen, - StateMachine.DefaultValvesClose)) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose)) .EnterState(); - do - { + do { e = StateMachine.WaitRunDevsRunOps(); if (TestAndLogUiCmdStop(e)) return Event.UiCmdStop; } @@ -829,10 +828,14 @@ namespace TBF.Rig.Sequences if (errorFlag) return Event.Error; - else if (stopFlag) - return Event.UiCmdStop; - else - return Event.Done; + else if (stopFlag) + return Event.UiCmdStop; + else + { + if (context == TransitionContext.PurgeBegin) FillState = FillState.Full; + if (context == TransitionContext.PurgeEnd) FillState = FillState.Empty; + return Event.Done; + } } diff --git a/TBF/Rig/TbfComponents.cs b/TBF/Rig/TbfComponents.cs index 86f350742..cbaff843a 100644 --- a/TBF/Rig/TbfComponents.cs +++ b/TBF/Rig/TbfComponents.cs @@ -63,6 +63,7 @@ namespace TBF.Rig Factories.Add(new TestMethods.DiverterTest.Factory()); Factories.Add(new TestMethods.Dummy.Factory()); Factories.Add(new TestMethods.Endurance.Factory()); + Factories.Add(new TestMethods.Evacuation.Factory()); Factories.Add(new TestMethods.FixedStart.Single.Factory()); Factories.Add(new TestMethods.FixedStart.Compound.Factory()); Factories.Add(new TestMethods.FixedStart.HeatMeters.Factory()); diff --git a/TBF/Rig/TestMethods/Evacuation/Component.cs b/TBF/Rig/TestMethods/Evacuation/Component.cs new file mode 100644 index 000000000..c33d2bd19 --- /dev/null +++ b/TBF/Rig/TestMethods/Evacuation/Component.cs @@ -0,0 +1,40 @@ +/// +/// Copyright (c) 2021 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using log4net; +using Common; +using Config.Entities; + +namespace TBF.Rig.TestMethods.Evacuation +{ + public class Component : ComponentBase, GenericDevices.ITestMethod + { + private static readonly ILog log = LogManager.GetLogger(typeof(Component)); + public override string ToString() + { + return string.Format("{0}({1})", GetType().Namespace.Substring(8), Cfg.ToString(1)); + } + + public bool CanTest(MetersKind meters) { return true; } + public bool DoTransitions() { return false; } + + public Component() { } + + public Component(Generic.IComponentCfg cfg) + : base(cfg) + { + } + + public override void Initialize() + { + log.FatalFormat("{0} initialized: {1}", Name, this); + } + + public IList Execute(Test test, int repetNr, bool isLastRepetition) + { + return (new EvacuationSeq()).Execute(test, repetNr, isLastRepetition, DebugLevel); + } + } +} diff --git a/TBF/Rig/TestMethods/Evacuation/EvacuationSeq.cs b/TBF/Rig/TestMethods/Evacuation/EvacuationSeq.cs new file mode 100644 index 000000000..5770ee05e --- /dev/null +++ b/TBF/Rig/TestMethods/Evacuation/EvacuationSeq.cs @@ -0,0 +1,95 @@ +/// +/// Copyright (c) 2021 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using System.Linq; +using Common; +using log4net; +using TBF.Resources; +using TBF.UiBridge; +using Config.Entities; + +namespace TBF.Rig.TestMethods.Evacuation +{ + public class EvacuationSeq : Sequences.SequenceBase + { + private static readonly ILog log = LogManager.GetLogger(typeof(EvacuationSeq)); + + /// + /// Fixed start mass collection method sequence + /// + /// Test entity + /// + /// Event.Done . . . . . . . OK + /// Event.MakeSecondPass . . OK, 2nd pass (=evaluation) required + /// Event.UiCmdStop . . . . Stopped by the user using the on-screen button STOP + /// Event.OpArgumentError . Target flow is out of range + /// Event.Error . . . . . . Unspecified error + /// + public IList Execute(Config.Entities.Test test, int repetitionNr, bool isLastRepetition, + DebugMode debugLevel) + { + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Test_in_progress); + //------------------------------------------------ + + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.JustStarted)); + + TransitionSequence purgeEnd = StateMachine.TransitionSequences + .FirstOrDefault(x => x.Name == StateMachine.Procedure.TransitionEnd); + + TestStartTime = DateTime.Now; + Event retVal = (purgeEnd != null) ? Transition(purgeEnd, TransitionContext.PurgeEnd) : Event.OK; + bool passed = (retVal == Event.Done); + TestEndTime = DateTime.Now; + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Test_completed); + //------------------------------------------------ + + /// + /// Populate TestResult data entity with data + /// + string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); + Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part); + + if (tstRslt != null) + { + Results.Utils.GetCounterStates(tstRslt, Program.LocalSettings.Counters); + UpdateTempPressDensAmb(tstRslt); + + /// Main results + tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName; + tstRslt.StartTime = TestStartTime; + tstRslt.EndTime = TestEndTime; + tstRslt.TestTime = Math.Max(1.0, EndTime - StartTime); /// [s] measurement time, at least 1 to prevent division by zero + tstRslt.TestDone = passed; + tstRslt.ErrorFlags = 0; + tstRslt.InfoFlags = 0; + + /// + /// Single meters + /// + for (int i = 0; i < BatchRslts.WMPositionsCount; i++) + { + Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, CompoundMeterId.Single); + GenericDevices.IRegReader regReader = sensPath.RegisterReaders[i]; + + if (meterRslt != null && regReader != null) + { + meterRslt.TestDone = passed; + meterRslt.Passed = passed; + } + } + + /// Update results + Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName, tstRslt)); + } + + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Progress.TransitionAfter)); + + return new List { retVal }; + } + } +} diff --git a/TBF/Rig/TestMethods/Evacuation/Factory.cs b/TBF/Rig/TestMethods/Evacuation/Factory.cs new file mode 100644 index 000000000..b125f564d --- /dev/null +++ b/TBF/Rig/TestMethods/Evacuation/Factory.cs @@ -0,0 +1,25 @@ +/// +/// Copyright (c) 2021 Sensus Slovensko a.s. +/// +using System.Collections.Generic; +using TBF.Rig.Generic; +using TBF.Rig.Configs.NameOnly; + +namespace TBF.Rig.TestMethods.Evacuation +{ + public class Factory : IComponentFactory + { + public string ClassName { get { return GetType().Namespace.Substring(8); } } + + public IComponent DummyComponent() { return new Component(); } + + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Component(cfg); } + + public IComponentCfg DefaultConfig() { return new TestMethodCfg(GetType().Namespace.Substring(20), this); } + + public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) + { + return ComponentCfgBase.CreateFromDbEntity(TestMethodCfg.Serializer, component, this); + } + } +} diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index f10cdc40e..c7029f696 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -1332,6 +1332,9 @@ Component + + +