CombinedMeters and CombinedWithDetection support SupressTrils bool parameter

Warnings 'Unreachable code' supressed in DataEntries
This commit is contained in:
Milan Hanajik
2015-01-14 05:33:51 +01:00
parent 5a4df5593a
commit 1c3c90e171
10 changed files with 142 additions and 16 deletions
@@ -23,7 +23,7 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
/// 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, CombinedTestParams testParams)
{
Elde.ControlBoardDev cBrd = StateMachine.ControlBoard;
@@ -258,7 +258,7 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
/// Measurement loop - end
test_completed:
State.Create("FlyingStartCollectionMethod : Waiting before mass measurement")
State.Create("CombinedMeters : Waiting before mass measurement")
.AddOperation(checkUiOp)
.AddOperation(benchPath.TempIn.ReadTempOp(ref tempIn))
.AddOperation(benchPath.TempOut.ReadTempOp(ref tempOut))
@@ -304,6 +304,15 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
Bridge.OnActivity(this, Strings.Test_completed);
//------------------------------------------------
///
/// Optionally supress pulses from the large water meter
///
if (testParams.SupressTrills)
{
WMPulses[0] = 0;
tstRslt.Meters[0].PulsesMeter = 0;
}
///
/// Populate TestRasult data entity with data
///
@@ -0,0 +1,97 @@
using System;
using System.IO;
using System.Text;
using System.Xml.Serialization;
using TBF.BenchControl.Generic;
using TBF.Resources;
namespace TBF.BenchControl.TestMethods.CombinedMeters
{
public class CombinedTestParams : TestParamsBase, IParamsProvider, ITestParams
{
public bool SupressTrills; /// Main meter readings are ignored during test (suitable for small flows)
public override void InitializeAll()
{
SupressTrills = false;
}
string[] paramNames = new string[]
{
Strings.SupressWMTrills,
};
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 (SupressTrills ? Strings.yes : Strings.no);
default: return string.Empty;
}
}
public void UpdateParam(int i, string strValue)
{
switch (i)
{
case 0: SupressTrills = strValue.Equals(Strings.yes); return;
default: return;
}
}
public bool ValidateParam(int i, string strValue, out string message)
{
message = string.Empty;
switch (i)
{
case 0:
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
{
CombinedTestParams tmp = (CombinedTestParams)(new XmlSerializer(typeof(CombinedTestParams)))
.Deserialize(new StringReader(dbEntity.Parameters));
testParamsEntity = dbEntity;
componentName = dbEntity.CmpntName;
test = dbEntity.Test;
SupressTrills = tmp.SupressTrills;
}
catch
{
}
}
/// <summary>
/// Parameterless constructor initializes the parameters
/// </summary>
public CombinedTestParams()
{
}
public CombinedTestParams(Entities.ComponentTest testParamsEntity, string componentName, Entities.Test test)
{
this.testParamsEntity = testParamsEntity;
this.componentName = componentName;
this.test = test;
}
}
}
@@ -10,15 +10,18 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod));
public override string ToString() { return string.Format("TestMethods.CombinedMeters({0})", Cfg.ToString(1)); }
readonly TestMethodCfg testMethodCfg;
public TestMethod(TestMethodCfg cfg)
: base(cfg)
{
testMethodCfg = cfg;
log.Debug(this.ToString());
}
public IList<Event> Execute(Entities.Test test)
{
return (new CombinedMetersSeq()).Execute(test);
return (new CombinedMetersSeq()).Execute(test, testMethodCfg.TestParams);
}
}
}
@@ -11,12 +11,24 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
public IComponent GetComponent(IList<IComponent> components) { return new TestMethod(this); }
public IComponentCfgCtrl GetControl() { return new TestMethodCfgCtrl(); }
/// <summary> Test parameters </summary>
[XmlIgnore]
public CombinedTestParams TestParams;
public override IParamsProvider GetTestParams() { return TestParams; }
public override IParamsProvider CreateTestParams(Entities.Test test)
{
CombinedTestParams testParams = new CombinedTestParams();
testParams.UpdateTestParams(Name, test);
return testParams;
}
/// Private parameterless constructor invoked by all other (public) constructors
TestMethodCfg()
{
Name = "CombinedMeters";
ParentName = string.Empty;
}
TestParams = new CombinedTestParams();
}
public TestMethodCfg(IComponentFactory factory)
: this()