diff --git a/TBF/Rig/TbfComponents.cs b/TBF/Rig/TbfComponents.cs index 8ccd02219..be118230f 100644 --- a/TBF/Rig/TbfComponents.cs +++ b/TBF/Rig/TbfComponents.cs @@ -129,6 +129,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..f78a44f08 --- /dev/null +++ b/TBF/Rig/TestMethods/Evacuation/Component.cs @@ -0,0 +1,45 @@ +/// +/// 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 bool CheckDeviceCaps(Test test, OutputPath devices, out string message) + { + message = string.Empty; + return true; + } + + 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..acdd78ae3 --- /dev/null +++ b/TBF/Rig/TestMethods/Evacuation/Factory.cs @@ -0,0 +1,26 @@ +/// +/// 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 override string ToString() { return ClassName; } + + 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 ca1f00944..0ccc8c025 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -1186,6 +1186,9 @@ Component + + +