FlyingStartCollectionMethod test parameters bool Evaluate and bool Publish added, ver.1.5.90.

This commit is contained in:
Milan Hanajik
2015-08-22 06:24:00 +02:00
parent 46b17fddc8
commit f75138eced
8 changed files with 153 additions and 6 deletions
@@ -26,7 +26,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
/// Event.OpArgumentError . Target flow is out of range
/// Event.Error . . . . . . Unspecified error
/// </returns>
public IList<Event> Execute(Entities.Test test)
public IList<Event> Execute(Entities.Test test, TestParams testParams)
{
Elde.ControlBoardDev cBrd = StateMachine.ControlBoard;
@@ -60,6 +60,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
/// Start the test, initialize test results
Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, totalPulses));
Entities.TestResult tstRslt = new Entities.TestResult(test, repetitionNr, Entities.MetersKind.Single);
tstRslt.DoNotEvaluate = !testParams.Evaluate;
tstRslt.DoNotPublish = !testParams.Publish;
int flowSetTime0 = StateMachine.Time;
@@ -1,5 +1,6 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Author: Milan Hanajík
///
using System;
using System.Collections.Generic;
@@ -13,8 +14,10 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod));
public override string ToString() { return string.Format("TestMethods.FlyingStartCollectionMethod({0})", Cfg.ToString(1)); }
public bool Evaluate { get { return true; } }
public bool Publish { get { return true; } }
readonly TestMethodCfg testMethodCfg;
public bool Evaluate { get { return testMethodCfg.TestParams.Evaluate; } }
public bool Publish { get { return testMethodCfg.TestParams.Publish; } }
public bool CanTest(Entities.MetersKind meters) { return meters == Entities.MetersKind.Single; }
public TestMethod()
@@ -24,12 +27,13 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
public TestMethod(TestMethodCfg cfg)
: base(cfg)
{
testMethodCfg = cfg;
log.Debug(this.ToString());
}
public IList<Event> Execute(Entities.Test test)
{
return (new FlyingStartCollectionMethodSeq()).Execute(test);
return (new FlyingStartCollectionMethodSeq()).Execute(test, testMethodCfg.TestParams);
}
}
}
@@ -14,6 +14,17 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
public IComponent GetComponent(IList<IComponent> components) { return new TestMethod(this); }
public IComponentCfgCtrl GetControl() { return new TestMethodCfgCtrl(); }
/// <summary> Test parameters </summary>
[XmlIgnore]
public TestParams TestParams;
public override IParamsProvider GetTestParams() { return TestParams; }
public override IParamsProvider CreateTestParams(Entities.Test test)
{
TestParams testParams = new TestParams();
testParams.UpdateTestParams(Name, test);
return testParams;
}
/// Private parameterless constructor invoked by all other (public) constructors
TestMethodCfg()
{
@@ -0,0 +1,105 @@
///
/// Copyright (c) 2015 Sensus Metering Systems
/// Author: Milan Hanajík
///
using System;
using System.IO;
using System.Xml.Serialization;
using TBF.BenchControl.Generic;
using TBF.Resources;
namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
{
public class TestParams : TestParamsBase, IParamsProvider, ITestParams
{
public bool Evaluate; /// Evaluate this test for passed/failed final result
public bool Publish; /// Publish this test in results (screen, printed, file, DB)
public override void InitializeAll()
{
Evaluate = false;
}
string[] paramNames = new string[]
{
Strings.Evaluate,
Strings.Publish,
};
public override string ParamName(int i) { return paramNames[i]; }
public override int ParamsCount() { return paramNames.Length; }
public override string ToString(int i)
{
switch (i)
{
case 0: return (Evaluate ? Strings.yes : Strings.no);
case 1: return (Publish ? Strings.yes : Strings.no);
default: return string.Empty;
}
}
public void UpdateParam(int i, string strValue)
{
switch (i)
{
case 0: Evaluate = strValue.Equals(Strings.yes); return;
case 1: Publish = strValue.Equals(Strings.yes); return;
default: return;
}
}
public bool ValidateParam(int i, string strValue, out string message)
{
message = string.Empty;
float dummy;
switch (i)
{
case 0:
case 1:
if (strValue.Equals(Strings.yes) || strValue.Equals(Strings.no)) return true;
break;
default:
message = "Invalid index";
return false;
}
message = ParamName(i) + " is invalid";
return false;
}
public override void UpdateTestParams(Entities.ComponentTest dbEntity)
{
if (dbEntity == null) return;
try
{
TestParams tmp = (TestParams)(new XmlSerializer(typeof(TestParams)))
.Deserialize(new StringReader(dbEntity.Parameters));
testParamsEntity = dbEntity;
componentName = dbEntity.CmpntName;
test = dbEntity.Test;
Evaluate = tmp.Evaluate;
}
catch
{
}
}
/// <summary>
/// Parameterless constructor initializes the parameters
/// </summary>
public TestParams()
{
}
public TestParams(Entities.ComponentTest testParamsEntity, string componentName, Entities.Test test)
{
this.testParamsEntity = testParamsEntity;
this.componentName = componentName;
this.test = test;
}
}
}