Outer loop logic added, TODO: (1) Begin-block and End-block test methods, (2) support in test method sequences

This commit is contained in:
Milan Hanajik 2016-12-10 11:30:57 +01:00
parent 20c7b07cb9
commit f3b178473c
23 changed files with 142 additions and 53 deletions

View File

@ -168,5 +168,10 @@ namespace TBF.BenchControl
OK,
TimerBusy,
SetOutputsDone,
/// Outer loop control
OuterLoopStart,
OuterLoopNext,
OuterLoopEnd,
}
}

View File

@ -30,7 +30,9 @@ namespace TBF.BenchControl.GenericDevices
/// Execute the test method
/// </summary>
/// <param name="test"></param>
/// <param name="outerLoopMode">false = normal eecution, true = Run the test only once and use 'outerLoopCounter'</param>
/// <param name="outerLoopCounter">External test repeats counter</param>
/// <returns>Event(s) indicating the result of execution</returns>
IList<Event> Execute(Test test);
IList<Event> Execute(Test test, bool outerLoopMode, int outerLoopCounter);
}
}

View File

@ -476,8 +476,6 @@ namespace TBF.BenchControl.Sequences
if (selection == Selection.Cycle)
{
float TimeEstimateTotal; /// Time estimate of the selected cycle or test
float TimeEstimateBeginRpts; /// Time estimate at the beginning of all repetitions of the current tests
float TimeEstimateOneTest; /// Time estimate of the current test (one repetition)
TimeEstimateTotal = 0;
for (int i = simultWithPurgingCount; i < StateMachine.Tests.Count - simultWithEvacuationCount; i++)
@ -500,10 +498,13 @@ namespace TBF.BenchControl.Sequences
}
}
TimeEstimateBeginRpts = 0;
for (int i = simultWithPurgingCount; i < StateMachine.Tests.Count - simultWithEvacuationCount; i++)
int currentTestIx = simultWithPurgingCount;
int outerLoopStartIx = currentTestIx;
bool outerLoopMode = false;
int outerLoopCounter = 0;
do
{
Test test = StateMachine.Tests[i];
Test test = StateMachine.Tests[currentTestIx];
/// Fetch the test paths and transitions
string errorMsg;
@ -522,7 +523,6 @@ namespace TBF.BenchControl.Sequences
StartMass.Format = outPath.Balance.Format;
EndMass.Format = outPath.Balance.Format;
TimeEstimateOneTest = test.TstTime + 10.0f;
//--------------------------------------------------------------
ITestMethod testMethodSequence = TbfComponents.FindComponent(test.Method) as ITestMethod;
if (testMethodSequence != null && testMethodSequence.CanTest(StateMachine.Procedure.MetersKind))
@ -538,21 +538,58 @@ namespace TBF.BenchControl.Sequences
}
}
e = testMethodSequence.Execute(test);
e = testMethodSequence.Execute(test, outerLoopMode, outerLoopCounter);
if (e.Contains(Event.ConfigurationError)) goto select_cycle_or_test;
if (e.Contains(Event.Error)) goto error;
if (e.Contains(Event.OpArgumentError)) goto config_error;
if (e.Contains(Event.UiCmdStop)) goto stop_within_cycle;
if (e.Contains(Event.ConfigurationError))
{
outerLoopMode = false;
outerLoopCounter = 0;
goto select_cycle_or_test;
}
else if (e.Contains(Event.Error))
{
outerLoopMode = false;
outerLoopCounter = 0;
goto error;
}
else if (e.Contains(Event.OpArgumentError))
{
outerLoopMode = false;
outerLoopCounter = 0;
goto config_error;
}
else if (e.Contains(Event.UiCmdStop))
{
outerLoopMode = false;
outerLoopCounter = 0;
goto stop_within_cycle;
}
else if (e.Contains(Event.OuterLoopStart))
{
outerLoopMode = true;
outerLoopCounter = 1;
outerLoopStartIx = currentTestIx;
}
else if (e.Contains(Event.OuterLoopNext))
{
outerLoopCounter++;
currentTestIx = outerLoopStartIx;
}
else if (e.Contains(Event.OuterLoopEnd))
{
outerLoopMode = false;
outerLoopCounter = 0;
}
}
else
{
UiBridge.Bridge.OnError(this, string.Format("{0} cannot be used", test.Method));
UiBridge.Bridge.OnError(this, string.Format(Strings.Method_0_cannot_be_used, test.Method));
goto select_cycle_or_test;
}
TimeEstimateBeginRpts += (test.Repeats * TimeEstimateOneTest);
currentTestIx++;
}
while (currentTestIx < StateMachine.Tests.Count - simultWithEvacuationCount);
}
else if (selection == Selection.RestOfCycle)
{
@ -576,8 +613,6 @@ namespace TBF.BenchControl.Sequences
float TimeEstimateTotal; /// Time estimate of the selected cycle or test
float TimeEstimateBeginRpts; /// Time estimate at the beginning of all repetitions of the current tests
float TimeEstimateOneTest; /// Time estimate of the current test (one repetition)
TimeEstimateTotal = 0;
for (int i = selsctedTestIx; i < StateMachine.Tests.Count - simultWithEvacuationCount; i++)
@ -600,10 +635,13 @@ namespace TBF.BenchControl.Sequences
}
}
TimeEstimateBeginRpts = 0;
for (int i = selsctedTestIx; i < StateMachine.Tests.Count - simultWithEvacuationCount; i++)
int currentTestIx = selsctedTestIx;
int outerLoopStartIx = currentTestIx;
bool outerLoopMode = false;
int outerLoopCounter = 0;
do
{
Test test = StateMachine.Tests[i];
Test test = StateMachine.Tests[currentTestIx];
/// Fetch the test paths and transitions
string errorMsg;
@ -622,7 +660,6 @@ namespace TBF.BenchControl.Sequences
StartMass.Format = outPath.Balance.Format;
EndMass.Format = outPath.Balance.Format;
TimeEstimateOneTest = test.TstTime + 10.0f;
//--------------------------------------------------------------
ITestMethod testMethodSequence = TbfComponents.FindComponent(test.Method) as ITestMethod;
if (testMethodSequence != null && testMethodSequence.CanTest(StateMachine.Procedure.MetersKind))
@ -638,12 +675,48 @@ namespace TBF.BenchControl.Sequences
}
}
e = testMethodSequence.Execute(test);
e = testMethodSequence.Execute(test, outerLoopMode, outerLoopCounter);
if (e.Contains(Event.ConfigurationError)) goto select_cycle_or_test;
if (e.Contains(Event.Error)) goto error;
if (e.Contains(Event.OpArgumentError)) goto config_error;
if (e.Contains(Event.UiCmdStop)) goto stop_within_cycle;
if (e.Contains(Event.ConfigurationError))
{
outerLoopMode = false;
outerLoopCounter = 0;
goto select_cycle_or_test;
}
else if (e.Contains(Event.Error))
{
outerLoopMode = false;
outerLoopCounter = 0;
goto error;
}
else if (e.Contains(Event.OpArgumentError))
{
outerLoopMode = false;
outerLoopCounter = 0;
goto config_error;
}
else if (e.Contains(Event.UiCmdStop))
{
outerLoopMode = false;
outerLoopCounter = 0;
goto stop_within_cycle;
}
else if (e.Contains(Event.OuterLoopStart))
{
outerLoopMode = true;
outerLoopCounter = 1;
outerLoopStartIx = currentTestIx;
}
else if (e.Contains(Event.OuterLoopNext))
{
outerLoopCounter++;
currentTestIx = outerLoopStartIx;
}
else if (e.Contains(Event.OuterLoopEnd))
{
outerLoopMode = false;
outerLoopCounter = 0;
}
}
else
{
@ -651,8 +724,9 @@ namespace TBF.BenchControl.Sequences
goto select_cycle_or_test;
}
TimeEstimateBeginRpts += (test.Repeats * TimeEstimateOneTest);
currentTestIx++;
}
while (currentTestIx < StateMachine.Tests.Count - simultWithEvacuationCount);
}
else /// if (selection == Selection.Test)
{
@ -680,10 +754,6 @@ namespace TBF.BenchControl.Sequences
StartMass.Format = outPath.Balance.Format;
EndMass.Format = outPath.Balance.Format;
float TimeEstimateTotal = test.Repeats * (test.TstTime + 10.0f);
float TimeEstimateOneTest = test.TstTime + 10.0f;
float TimeEstimateBeginRpts = 0;
ITestMethod testMethodSequence = TbfComponents.FindComponent(test.Method) as ITestMethod;
if (testMethodSequence != null && testMethodSequence.CanTest(StateMachine.Procedure.MetersKind))
{
@ -698,7 +768,7 @@ namespace TBF.BenchControl.Sequences
}
}
e = testMethodSequence.Execute(test);
e = testMethodSequence.Execute(test, false, 0);
if (e.Contains(Event.Error)) goto error;
if (e.Contains(Event.OpArgumentError)) goto config_error;

View File

@ -28,7 +28,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test)
public IList<Event> Execute(Test test, bool outerLoopMode, int outerLoopCounter)
{
return (new AdjustmentSeq()).Execute(test, DebugLevel);
}

View File

@ -28,7 +28,7 @@ namespace TBF.BenchControl.TestMethods.CameraRoiDetection
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test)
public IList<Event> Execute(Test test, bool outerLoopMode, int outerLoopCounter)
{
return (new RoiDetectionSeq()).Execute(test);
}

View File

@ -31,7 +31,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test)
public IList<Event> Execute(Test test, bool outerLoopMode, int outerLoopCounter)
{
return (new CombinedWithDetectionSeq()).Execute(test, testMethodCfg.TestParams, DebugLevel);
}

View File

@ -33,7 +33,7 @@ namespace TBF.BenchControl.TestMethods.Endurance
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test)
public IList<Event> Execute(Test test, bool outerLoopMode, int outerLoopCounter)
{
return (new EnduranceSeq()).Execute(test, testMethodCfg.Cycle, DebugLevel);
}

View File

@ -28,7 +28,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced.Single
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test)
public IList<Event> Execute(Test test, bool outerLoopMode, int outerLoopCounter)
{
return (new FixedStartAdvancedSeq()).Execute(test);
}

View File

@ -30,7 +30,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection.Compound
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test)
public IList<Event> Execute(Test test, bool outerLoopMode, int outerLoopCounter)
{
return (new FixedStartMassCollectionSeq()).Execute(test, true, null);
}

View File

@ -33,7 +33,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection.HeatMeters
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test)
public IList<Event> Execute(Test test, bool outerLoopMode, int outerLoopCounter)
{
return (new FixedStartMassCollectionSeq()).Execute(test, false, testMethodCfg.TestParams);
}

View File

@ -30,7 +30,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection.Single
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test)
public IList<Event> Execute(Test test, bool outerLoopMode, int outerLoopCounter)
{
return (new FixedStartMassCollectionSeq()).Execute(test, false, null);
}

View File

@ -33,7 +33,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart.Compound
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test)
public IList<Event> Execute(Test test, bool outerLoopMode, int outerLoopCounter)
{
return (new FlyingStartSeq()).Execute(test, testMethodCfg.TestParams, null, DebugLevel);
}

View File

@ -33,7 +33,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart.HeatMeters
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test)
public IList<Event> Execute(Test test, bool outerLoopMode, int outerLoopCounter)
{
return (new FlyingStartSeq()).Execute(test, null, testMethodCfg.TestParams, DebugLevel);
}

View File

@ -30,7 +30,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart.Single
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test)
public IList<Event> Execute(Test test, bool outerLoopMode, int outerLoopCounter)
{
return (new FlyingStartSeq()).Execute(test, null, null, DebugLevel);
}

View File

@ -34,7 +34,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection.Compound
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test)
public IList<Event> Execute(Test test, bool outerLoopMode, int outerLoopCounter)
{
return (new FlyingStartMassCollectionSeq()).Execute(test, testMethodCfg.TestParams, null, DebugLevel);
}

View File

@ -33,7 +33,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection.HeatMeters
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test)
public IList<Event> Execute(Test test, bool outerLoopMode, int outerLoopCounter)
{
return (new FlyingStartMassCollectionSeq()).Execute(test, null, testMethodCfg.TestParams, DebugLevel);
}

View File

@ -30,7 +30,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection.Single
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test)
public IList<Event> Execute(Test test, bool outerLoopMode, int outerLoopCounter)
{
return (new FlyingStartMassCollectionSeq()).Execute(test, null, null, DebugLevel);
}

View File

@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
@ -31,7 +31,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test)
public IList<Event> Execute(Test test, bool outerLoopMode, int outerLoopCounter)
{
return (new LeakTestSeq()).Execute(test, testMethodCfg.TestParams);
}

View File

@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
@ -31,7 +31,7 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test)
public IList<Event> Execute(Test test, bool outerLoopMode, int outerLoopCounter)
{
return (new PMaxTestSeq()).Execute(test, testMethodCfg.TestParams);
}

View File

@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
@ -28,7 +28,7 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
log.Debug(this.ToString());
}
public IList<Event> Execute(Test test)
public IList<Event> Execute(Test test, bool outerLoopMode, int outerLoopCounter)
{
return (new ReferenceFlowmeterCalibrationSeq()).Execute(test);
}

View File

@ -1,5 +1,5 @@
///
/// Copyright (c) 2015 Sensus Metering Systems
/// Copyright (c) 2015-2016 Sensus Metering Systems
/// Author: Milan Hanajík
///
using System;
@ -99,7 +99,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
public void RunDeviceAfter() { }
public void StopDevice() { }
public IList<Event> Execute(Test test)
public IList<Event> Execute(Test test, bool outerLoopMode, int outerLoopCounter)
{
return (new iPerlCommunicationSeq()).Execute(test, testMethodCfg, testMethodCfg.TestParams);
}

View File

@ -2013,6 +2013,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Method {0} cannot be used.
/// </summary>
internal static string Method_0_cannot_be_used {
get {
return ResourceManager.GetString("Method_0_cannot_be_used", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Test method.
/// </summary>

View File

@ -1612,4 +1612,7 @@
<data name="Wait_please" xml:space="preserve">
<value>Wait please</value>
</data>
<data name="Method_0_cannot_be_used" xml:space="preserve">
<value>Method {0} cannot be used</value>
</data>
</root>