Changes in MainSeq, Procedure, BenchControlPanel, TestProgressControls, etc., ver. 2.26.1583

This commit is contained in:
Milan Hanajik
2021-01-25 13:01:59 +01:00
parent c403f9345f
commit b2df02dd1b
18 changed files with 307 additions and 293 deletions
+96 -124
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -106,7 +106,6 @@ namespace TBF.BenchControl.Sequences
Selection selection;
string selectedTestName;
#if !DEBUG
Bridge.OnActivity(this, Strings.Starting_system);
WaitForOkButton();
SetValvesToDefaultState();
@@ -159,7 +158,6 @@ namespace TBF.BenchControl.Sequences
if (e.Contains(Event.UiCmdStop)) goto stop;
}
while (!e.Contains(Event.BalanceDone));
#endif
select_procedure:
@@ -701,29 +699,40 @@ namespace TBF.BenchControl.Sequences
IList<DeferredTestEvaluationData> deferredData = new List<DeferredTestEvaluationData>();
bool veryFirstTestInTheRestOfCycle = true;
int selsctedTestIx = simultWithPurgingCount; /// Applies when selection == Selection.Cycle
int repetNr = 1;
int selsctedTestIx = -1; ///= undefined
///
if (selection == Selection.RestOfCycle) /// ... otherwise
{
Test slctdTest = TBF.BenchControl.StateMachine.Procedure.GetTest(selectedTestName, out selsctedTestIx, out repetNr);
if (slctdTest == null || (selsctedTestIx < simultWithPurgingCount)
|| (selsctedTestIx >= StateMachine.Tests.Count - simultWithEvacuationCount))
{
if (selection == Selection.RestOfCycle) /// ... otherwise
{
for (int i = 0; i < StateMachine.TestInstances.Length; i++)
{
if (selectedTestName == StateMachine.TestInstances[i].Name)
{
selsctedTestIx = i;
break;
}
}
if ((selsctedTestIx < simultWithPurgingCount) ||
(selsctedTestIx >= StateMachine.TestInstances.Length - simultWithEvacuationCount))
{
/// Invalid test selection
UiBridge.Bridge.OnError(this, string.Format("No test specified"));
goto select_cycle_or_test;
}
}
UiBridge.Bridge.OnError(this, string.Format("No test specified"));
goto select_cycle_or_test;
}
}
else
{
selsctedTestIx = simultWithPurgingCount; /// Applies when selection == Selection.Cycle
}
float TimeEstimateTotal = 0; /// Time estimate of the selected cycle or test
for (int i = selsctedTestIx; i < StateMachine.Tests.Count - simultWithEvacuationCount; i++)
for (int i = selsctedTestIx; i < StateMachine.TestInstances.Length - simultWithEvacuationCount; i++)
{
Test test = StateMachine.Tests[i];
Test test = StateMachine.TestInstances[i].Test;
TimeEstimateTotal += (test.Repeats * (test.TstTime + 10.0f));
TimeEstimateTotal += (test.TstTime + 10.0f);
/// Try to fetch all test paths and transitions
/// to detect configuration errors as early as possible.
@@ -743,19 +752,16 @@ namespace TBF.BenchControl.Sequences
}
int currentTestIx = selsctedTestIx;
bool isOuterLoopMode = false;
int outerLoopStartIx = -1; /// This is to identify program errors
int outerLoopRepeats = 0;
while (currentTestIx < StateMachine.Tests.Count - simultWithEvacuationCount)
while (currentTestIx < StateMachine.TestInstances.Length - simultWithEvacuationCount)
{
Test nextTest = (currentTestIx + 1 < StateMachine.Tests.Count - simultWithEvacuationCount)
? StateMachine.Tests[currentTestIx + 1]
: null;
TestInstance nextTest = (currentTestIx + 1 < StateMachine.TestInstances.Length - simultWithEvacuationCount)
? StateMachine.TestInstances[currentTestIx + 1]
: null;
Test nextHydroTest = null;
for (int i = currentTestIx + 1; i < StateMachine.Tests.Count - simultWithEvacuationCount; i++)
for (int i = currentTestIx + 1; i < StateMachine.TestInstances.Length - simultWithEvacuationCount; i++)
{
Test tst = StateMachine.Tests[i];
Test tst = StateMachine.TestInstances[i].Test;
if (tst != null)
{
ITestMethod tm = TbfComponents.FindComponent(tst.Method) as ITestMethod;
@@ -803,12 +809,10 @@ namespace TBF.BenchControl.Sequences
}
/// Fetch paths and transitions of this test
Test test = StateMachine.Tests[currentTestIx];
TBF.BenchControl.Generic.IComponent testMethodComp = TbfComponents.FindComponent(test.Method);
TestInstance testInst = StateMachine.TestInstances[currentTestIx];
TBF.BenchControl.Generic.IComponent testMethodComp = TbfComponents.FindComponent(testInst.Test.Method);
string errorMsg;
if (!(testMethodComp is TBF.BenchControl.TestMethods.OuterLoop.Start.Component) &&
!(testMethodComp is TBF.BenchControl.TestMethods.OuterLoop.End.Component) &&
!StateMachine.GetPaths(test, (StateMachine.Procedure.MetersKind == MetersKind.HeatMeter),
if (!StateMachine.GetPaths(testInst.Test, (StateMachine.Procedure.MetersKind == MetersKind.HeatMeter),
out inPath, out benchPath, out outPath, out sensPath,
out heatMetersPath,
out transitionBefore, out transitionBetween, out transitionAfter,
@@ -830,12 +834,7 @@ namespace TBF.BenchControl.Sequences
ITestMethod testMethod = testMethodComp as ITestMethod;
if (testMethod != null && testMethod.CanTest(StateMachine.Procedure.MetersKind))
{
if (isOuterLoopMode && (outerLoopRepeats != test.Repeats) && !(testMethod is TestMethods.OuterLoop.End.Component))
{
goto config_error;
}
StateMachine.LoadTestParams(test);
StateMachine.LoadTestParams(testInst.Test);
if ((sensPath != null) && (sensPath.RegisterReaders != null))
{
@@ -866,119 +865,80 @@ namespace TBF.BenchControl.Sequences
int timeEstTransBetween = testMethod.DoTransitions() ? GetTransitionTimeEst(transitionBetween) : 1;
int timeEstTransAfter = testMethod.DoTransitions() ? GetTransitionTimeEst(transitionAfter) : 1;
TestProgressEventArgs.SetEstimatedTimes(new int[] { 1, timeEstTransBefore, 1, 30, 0, Convert.ToInt32(test.TstTime) + 15, timeEstTransAfter, 0 });
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetNr, Config.Entities.Progress.JustStarted));
TestProgressEventArgs.SetEstimatedTimes(new int[] { 1, timeEstTransBefore, 1, 30, 0, Convert.ToInt32(testInst.Test.TstTime) + 15, timeEstTransAfter, 0 });
Bridge.OnTestProgress(this, new TestProgressEventArgs(testInst.Test, testInst.Repetition, Config.Entities.Progress.JustStarted));
bool currentTestFinished = true;
bool doOneMoreRepetition = false;
do
bool doExecuteTransitionBefore = (currentTestIx == simultWithPurgingCount) || (testInst.Test != StateMachine.TestInstances[currentTestIx - 1].Test) || veryFirstTestInTheRestOfCycle;
bool isLastRepetition = (currentTestIx == StateMachine.TestInstances.Length - simultWithEvacuationCount - 1) || (testInst.Test != StateMachine.TestInstances[currentTestIx + 1].Test);
veryFirstTestInTheRestOfCycle = false;
if (testMethod.DoTransitions())
{
bool doExecuteTransitionBefore = isOuterLoopMode || (repetNr == 1) || veryFirstTestInTheRestOfCycle;
veryFirstTestInTheRestOfCycle = false;
if (testMethod.DoTransitions())
{
/// Make a transition before a test and before each test repetition
rsltTransBefore = Transition(doExecuteTransitionBefore ? transitionBefore : null, TransitionContext.BeforeTest); /// Transition or SetRoute - start of test
log.InfoFormat("Test {0}: Transition({1}, BeforeTest) returned {2}", test.Name, (transitionBefore == null ? "null" : transitionBefore.Name), rsltTransBefore);
}
if (rsltTransBefore != Event.Done) break;
log.InfoFormat("Test {0}: Execute(., {1}, {2})", test.Name, repetNr, isOuterLoopMode || repetNr == test.Repeats);
e = testMethod.Execute(test, repetNr, isOuterLoopMode || repetNr == test.Repeats);
if (e.Contains(Event.MakeSecondPass) && testMethod is ITestMethodWith2ndPass)
{
deferredData.Add(new DeferredTestEvaluationData(test, repetNr, (testMethod as ITestMethodWith2ndPass).IntermediateData));
}
currentTestFinished = (rsltTransBefore == Event.Done && !e.Contains(Event.Error)
&& !e.Contains(Event.ConfigurationError)
&& !e.Contains(Event.OpArgumentError)
&& !e.Contains(Event.UiCmdStop));
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetNr, currentTestFinished ? Config.Entities.Progress.Completed
: Config.Entities.Progress.Aborted));
if (e.Contains(Event.OuterLoopStart)) break; /// Do not repeat OuterLoopStart test in this loop
if (currentTestFinished && !isOuterLoopMode) repetNr++;
doOneMoreRepetition = currentTestFinished && !isOuterLoopMode && (repetNr <= test.Repeats);
if (testMethod.DoTransitions() && doOneMoreRepetition)
{
/// Make a transition between two test repetitions
rsltTransBetween = Transition(transitionBetween, TransitionContext.BetweenTests); /// Transition or SetRoute - start of test
log.InfoFormat("Test {0}: Transition({1}, BetweenTests) returned {2}", test.Name, (transitionBetween == null ? "null" : transitionBetween.Name), rsltTransBetween);
}
/// Make a transition before a test and before each test repetition
rsltTransBefore = Transition(doExecuteTransitionBefore ? transitionBefore : null, TransitionContext.BeforeTest); /// Transition or SetRoute - start of test
log.InfoFormat("Test {0}: Transition({1}, BeforeTest) returned {2}", testInst.Name, (transitionBefore == null ? "null" : transitionBefore.Name), rsltTransBefore);
}
while ((rsltTransBetween == Event.Done) && doOneMoreRepetition);
if (rsltTransBefore != Event.Done) break;
if (currentTestFinished && !isOuterLoopMode && repetNr > test.Repeats) repetNr = 1; /// Reset repetNr
log.InfoFormat("Test {0}: Execute(., {1}, {2})", testInst.Name, testInst.Repetition, isLastRepetition);
e = testMethod.Execute(testInst.Test, testInst.Repetition, isLastRepetition);
if (e.Contains(Event.MakeSecondPass) && testMethod is ITestMethodWith2ndPass)
{
deferredData.Add(new DeferredTestEvaluationData(testInst.Test, testInst.Repetition, (testMethod as ITestMethodWith2ndPass).IntermediateData));
}
currentTestFinished = (rsltTransBefore == Event.Done && !e.Contains(Event.Error)
&& !e.Contains(Event.ConfigurationError)
&& !e.Contains(Event.OpArgumentError)
&& !e.Contains(Event.UiCmdStop));
Bridge.OnTestProgress(this, new TestProgressEventArgs(testInst.Test, testInst.Repetition, currentTestFinished ? Config.Entities.Progress.Completed
: Config.Entities.Progress.Aborted));
if (testMethod.DoTransitions() && !e.Contains(Event.RecoverableError))
{
/// Make a transition after the last test repetition
TransitionContext endContext =
!currentTestFinished ? TransitionContext.Stop
: ((nextTransitionBefore != null) && (nextTransitionBefore.Name.ToLower().Contains("fastflow"))) ? TransitionContext.AfterTestWithOverlap
: TransitionContext.AfterTest;
rsltTransAfter = Transition(transitionAfter, endContext); /// Transition or SetRoute - end of test
log.InfoFormat("Test {0}: Transition({1}, {2}) returned {3}", test.Name, (transitionAfter == null ? "null" : transitionAfter.Name), endContext, rsltTransAfter);
if (currentTestFinished && !isLastRepetition)
{
/// Make a transition between two test repetitions
rsltTransBetween = Transition(transitionBetween, TransitionContext.BetweenTests); /// Transition or SetRoute - start of test
log.InfoFormat("Test {0}: Transition({1}, BetweenTests) returned {2}", testInst.Name, (transitionBetween == null ? "null" : transitionBetween.Name), rsltTransBetween);
}
else
{
/// Make a transition after the last test repetition
TransitionContext endContext =
!currentTestFinished ? TransitionContext.Stop
: ((nextTransitionBefore != null) && (nextTransitionBefore.Name.ToLower().Contains("fastflow"))) ? TransitionContext.AfterTestWithOverlap
: TransitionContext.AfterTest;
rsltTransAfter = Transition(transitionAfter, endContext); /// Transition or SetRoute - end of test
log.InfoFormat("Test {0}: Transition({1}, {2}) returned {3}", testInst.Name, (transitionAfter == null ? "null" : transitionAfter.Name), endContext, rsltTransAfter);
}
}
}
if (rsltTransBefore == Event.Error || rsltTransBetween == Event.Error|| e.Contains(Event.Error))
{
isOuterLoopMode = false;
goto error;
}
else if (e.Contains(Event.ConfigurationError))
{
isOuterLoopMode = false;
goto select_cycle_or_test; /// OR goto config_error; ???
}
else if (e.Contains(Event.OpArgumentError))
{
isOuterLoopMode = false;
goto config_error;
}
else if (rsltTransBefore == Event.UiCmdStop || e.Contains(Event.UiCmdStop) || e.Contains(Event.RecoverableError))
{
isOuterLoopMode = false;
goto stop_within_cycle;
}
else if (e.Contains(Event.OuterLoopStart))
{
if (isOuterLoopMode)
{
goto config_error;
}
isOuterLoopMode = true;
outerLoopRepeats = (nextTest != null) ? nextTest.Repeats : 1;
repetNr = 1;
outerLoopStartIx = currentTestIx;
}
else if (e.Contains(Event.OuterLoopEnd))
{
if (!isOuterLoopMode)
{
goto config_error;
}
else if (++repetNr <= outerLoopRepeats)
{
currentTestIx = outerLoopStartIx;
}
else
{
isOuterLoopMode = false;
repetNr = 1; /// Reset repetNr
}
}
}
else
{
UiBridge.Bridge.OnError(this, string.Format(Strings.Method_0_cannot_be_used, test.Method));
UiBridge.Bridge.OnError(this, string.Format(Strings.Method_0_cannot_be_used, testInst.Test.Method));
goto select_cycle_or_test;
}
@@ -1035,15 +995,27 @@ namespace TBF.BenchControl.Sequences
/// selection == Selection.Test or Selection.Q1 or Selection.Q2 or Selection.Q3
/// Single test will be executed
int repetNr;
int testIx;
Test test = TBF.BenchControl.StateMachine.Procedure.GetTest(selectedTestName, out testIx, out repetNr);
if (test == null)
int testIx = -1; ///= undefined
///
for (int i = 0; i < StateMachine.TestInstances.Length; i++)
{
if (selectedTestName == StateMachine.TestInstances[i].Name)
{
testIx = i;
break;
}
}
if (testIx < 0)
{
/// Invalid test selection
UiBridge.Bridge.OnError(this, string.Format("No test specified"));
goto select_cycle_or_test;
}
Test test = StateMachine.TestInstances[testIx].Test;
int repetNr = StateMachine.TestInstances[testIx].Repetition;
/// Fetch the test paths and transitions
string errorMsg;
TBF.BenchControl.Generic.IComponent testMethodComp = TbfComponents.FindComponent(test.Method);
+8 -8
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2020 Sensus Slovensko a.s.
/// Copyright (c) 2020-2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -700,15 +700,15 @@ namespace TBF.BenchControl.Sequences
simultWithPurgingTests.Clear();
simultWithPurgingParams.Clear();
///
foreach (var test in StateMachine.Tests)
foreach (var ti in StateMachine.TestInstances)
{
Generic.IComponent testMethodComp = TbfComponents.FindComponent(test.Method);
Generic.IComponent testMethodComp = TbfComponents.FindComponent(ti.Test.Method);
if (testMethodComp == null) break;
testMethodComp.Cfg.LoadTestParamsFromDB(test);
testMethodComp.Cfg.LoadTestParamsFromDB(ti.Test);
ISimultTestMethod simultTest = testMethodComp as ISimultTestMethod;
MetersPath sensPath = StateMachine.GetMetersPath(test);
MetersPath sensPath = StateMachine.GetMetersPath(ti.Test);
if (simultTest == null || !simultTest.SimultWithPrevious || sensPath == null) break;
@@ -721,7 +721,7 @@ namespace TBF.BenchControl.Sequences
break;
}
simultWithPurgingTests.Add(test);
simultWithPurgingTests.Add(ti.Test);
simultWithPurgingParams.Add(testMethodComp.Cfg.GetRuntimeTestParamsProvider().Clone() as Generic.ITestParams);
simultWithPurgingCount++;
}
@@ -734,9 +734,9 @@ namespace TBF.BenchControl.Sequences
simultWithEvacuationTests.Clear();
simultWithEvacuationParams.Clear();
///
for (int i = StateMachine.Tests.Count - 1; i >= simultWithPurgingCount; i--)
for (int i = StateMachine.TestInstances.Length - 1; i >= simultWithPurgingCount; i--)
{
var test = StateMachine.Tests[i];
var test = StateMachine.TestInstances[i].Test;
Generic.IComponent testMethodComp = TbfComponents.FindComponent(test.Method);
if (testMethodComp == null) break;
+2 -2
View File
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -1775,7 +1775,7 @@ namespace TBF.BenchControl.Sequences
/// <returns>Test result</returns>
protected void MakeSimulatedHeatMeters(Config.Entities.Test test, int repetitionNr, int part, float errorPct, double energy, float energyErrLimLo, float energyErrLimHi, bool evaluateVolume)
{
string fullTestName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
string fullTestName = Common.Utils.GetTestName(test.Name, test.Repeats, repetitionNr);
Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(fullTestName, part);