TestMethods.Evacuation added, ProcessData.FillState updated by SequenceBase.Transition(), ver. 2.27.1813, Statistics v. 2.27.1800

This commit is contained in:
Milan Hanajik 2021-11-15 16:09:41 +01:00
parent 1d152afd6c
commit ed606701c0
12 changed files with 221 additions and 29 deletions

View File

@ -377,6 +377,17 @@ namespace Common
Count
}
/// <summary>
/// State of water filled in the test bench.
/// </summary>
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>")] Undefined,

View File

@ -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")]

View File

@ -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")]

View File

@ -131,7 +131,7 @@ namespace TBF.Rig.Sequences
/// </summary>
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;

View File

@ -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)

View File

@ -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<Results.Output.SensusTestInfo> RawTestInfos; /// Incomplete raw test infos from Oracle DB
public static Results.Output.SensusTestInfo[] CompleteTestInfos; /// Complete TBF test infos obtained as a best mathch
/// <summary>
/// State of water filled in the test bench.
/// Updated by Transition(sequence, context)
/// when context == TransitionContext.PurgeBegin
/// or context == TransitionContext.PurgeEnd
/// </summary>
public static FillState FillState;
static ProcessData()
{
@ -54,6 +62,7 @@ namespace TBF.Rig.Sequences
IsQ2PreCorrectionCalculated = false;
CalculatedQ2PreCorrectionLR = 0;
CalculatedQ2PreCorrectionRL = 0;
FillState = FillState.Unknown;
}
/// <summary>

View File

@ -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;
}
}

View File

@ -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());

View File

@ -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<Event> Execute(Test test, int repetNr, bool isLastRepetition)
{
return (new EvacuationSeq()).Execute(test, repetNr, isLastRepetition, DebugLevel);
}
}
}

View File

@ -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));
/// <summary>
/// Fixed start mass collection method sequence
/// </summary>
/// <param name="test">Test entity</param>
/// <returns>
/// 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
/// </returns>
public IList<Event> 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<TransitionSequence>(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<Event> { retVal };
}
}
}

View File

@ -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<IComponent> 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);
}
}
}

View File

@ -1332,6 +1332,9 @@
<Compile Include="Rig\TestMethods\Endurance\CycleStepsCtrl.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Rig\TestMethods\Evacuation\Component.cs" />
<Compile Include="Rig\TestMethods\Evacuation\Factory.cs" />
<Compile Include="Rig\TestMethods\Evacuation\EvacuationSeq.cs" />
<Compile Include="Rig\TestMethods\FixedStartAdvanced\FixedStartAdvancedSeq.cs" />
<Compile Include="Rig\TestMethods\FixedStartAdvanced\Single\Component.cs" />
<Compile Include="Rig\TestMethods\FixedStartAdvanced\Single\Factory.cs" />