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

View File

@ -1,7 +1,6 @@
- zdruzeny: vysledky na process obrazovke sa opakuju 3x
- s/n sa nedostalo do vysledkov
- oprava process obrazovky
- zdruzeny: ignorovanie pulzov z velkeho vodomera
BUGS HI High importance

View File

@ -2,6 +2,8 @@
using System.Windows.Forms;
using TBF.Resources;
#pragma warning disable 162 /// Disables 'Unreachable code detected' warning
namespace TBF.BenchControl.DataEntry.Munich
{
public partial class CycleBeginningForm : Form, GenericDevices.IHasCompleted

View File

@ -2,6 +2,8 @@
using System.Windows.Forms;
using TBF.Resources;
#pragma warning disable 162 /// Disables 'Unreachable code detected' warning
namespace TBF.BenchControl.DataEntry.Munich
{
public partial class CycleEndForm : Form, GenericDevices.IHasCompleted

View File

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

View File

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

View File

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

View File

@ -11,11 +11,23 @@ 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)

View File

@ -13,8 +13,8 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
public float RelativeQfrom; /// Tested flow low range related to the detected flow
public float RelativeQto; /// Tested flow high range related to the detected flow
public float RateOfChange; /// Each step is calculated as (TargetQfrom - Qfrom) * RateOfChange, text form is displayed in % (*100)
public float DetectionThreshold;/// Drop of frequency for the detection, text form is displayed in % (*100)
public int SupressTrills;
public float DetectionThreshold; /// Drop of frequency for the detection, text form is displayed in % (*100)
public bool SupressTrills; /// Main meter readings are ignored during test (suitable for small flows)
public override void InitializeAll()
{
@ -23,8 +23,10 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
RelativeQto = -0.2f;
RateOfChange = 0.05f;
DetectionThreshold = 0.25f;
SupressTrills = false;
}
string[] paramNames = new string[]
{
Strings.TargetQ,
@ -46,7 +48,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
case 2: return RelativeQto.ToString();
case 3: return (100.0f * RateOfChange).ToString();
case 4: return (100.0f * DetectionThreshold).ToString();
case 5: return SupressTrills.ToString();
case 5: return (SupressTrills ? Strings.yes : Strings.no);
default: return string.Empty;
}
}
@ -60,7 +62,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
case 2: RelativeQto = Utils.ParseSFloat(strValue); return;
case 3: RateOfChange = Utils.ParseUFloat(strValue) / 100.0f; return;
case 4: DetectionThreshold = Utils.ParseUFloat(strValue) / 100.0f; return;
case 5: SupressTrills = int.Parse(strValue); return;
case 5: SupressTrills = strValue.Equals(Strings.yes); return;
default: return;
}
}
@ -70,7 +72,6 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
message = string.Empty;
float dummy;
int idummy;
switch (i)
{
case 0:
@ -83,7 +84,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
if (Utils.TryParseSFloat(strValue, out dummy)) return true;
break;
case 5:
if (int.TryParse(strValue, out idummy)) return true;
if (strValue.Equals(Strings.yes) || strValue.Equals(Strings.no)) return true;
break;
default:
message = "Invalid index";

View File

@ -517,7 +517,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
///
/// Optionally supress pulses from the large water meter
///
if (testParams.SupressTrills > 0)
if (testParams.SupressTrills)
{
WMPulses[0] = 0;
tstRslt.Meters[0].PulsesMeter = 0;

View File

@ -437,6 +437,7 @@
</Compile>
<Compile Include="BenchControl\TestMethods\CameraRoiDetection\RoiDetectionFactory.cs" />
<Compile Include="BenchControl\TestMethods\CombinedMeters\CombinedMetersSeq.cs" />
<Compile Include="BenchControl\TestMethods\CombinedMeters\CombinedTestParams.cs" />
<Compile Include="BenchControl\TestMethods\CombinedMeters\TestMethod.cs" />
<Compile Include="BenchControl\TestMethods\CombinedMeters\TestMethodCfg.cs" />
<Compile Include="BenchControl\TestMethods\CombinedMeters\TestMethodCfgCtrl.cs">