- all components, componentCfg-s and parameter providers use base classes - less boilerplate code, simpler access to test/procedure parameters from code - CreateTestParams(test), CreateProcedureParams(procedure) methods added - TestBenchSim class is made static, it is not inheritted by any device anymore
137 lines
3.9 KiB
C#
137 lines
3.9 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Xml.Serialization;
|
|
using TBF.BenchControl.Generic;
|
|
using TBF.Resources;
|
|
|
|
namespace TBF.BenchControl.TestMethods.CombinedWithDetection
|
|
{
|
|
public class CombinedWithDetTestParams : TestParamsBase, IParamsProvider, ITestParams
|
|
{
|
|
public float TargetQ; /// Target=terminal flow durning detection when increasing or decreasing the flow
|
|
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 override void InitializeAll()
|
|
{
|
|
TargetQ = 3.0f;
|
|
RelativeQfrom = -0.4f;
|
|
RelativeQto = -0.2f;
|
|
RateOfChange = 0.05f;
|
|
DetectionThreshold = 0.25f;
|
|
}
|
|
|
|
string[] paramNames = new string[]
|
|
{
|
|
Strings.TargetQ,
|
|
Strings.RelativeQfrom,
|
|
Strings.RelativeQto,
|
|
Strings.RateOfChangePct,
|
|
Strings.DetectionThresholdPct,
|
|
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 TargetQ.ToString();
|
|
case 1: return RelativeQfrom.ToString();
|
|
case 2: return RelativeQto.ToString();
|
|
case 3: return (100.0f * RateOfChange).ToString();
|
|
case 4: return (100.0f * DetectionThreshold).ToString();
|
|
case 5: return SupressTrills.ToString();
|
|
default: return string.Empty;
|
|
}
|
|
}
|
|
|
|
public void UpdateParam(int i, string strValue)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0: TargetQ = Utils.ParseUFloat(strValue); return;
|
|
case 1: RelativeQfrom = Utils.ParseSFloat(strValue); return;
|
|
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;
|
|
default: return;
|
|
}
|
|
}
|
|
|
|
public bool ValidateParam(int i, string strValue, out string message)
|
|
{
|
|
message = string.Empty;
|
|
|
|
float dummy;
|
|
int idummy;
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
case 3:
|
|
case 4:
|
|
if (Utils.TryParseUFloat(strValue, out dummy)) return true;
|
|
break;
|
|
case 1:
|
|
case 2:
|
|
if (Utils.TryParseSFloat(strValue, out dummy)) return true;
|
|
break;
|
|
case 5:
|
|
if (int.TryParse(strValue, out idummy)) 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
|
|
{
|
|
CombinedWithDetTestParams tmp = (CombinedWithDetTestParams)(new XmlSerializer(typeof(CombinedWithDetTestParams)))
|
|
.Deserialize(new StringReader(dbEntity.Parameters));
|
|
|
|
testParamsEntity = dbEntity;
|
|
componentName = dbEntity.CmpntName;
|
|
test = dbEntity.Test;
|
|
|
|
TargetQ = tmp.TargetQ;
|
|
RelativeQfrom = tmp.RelativeQfrom;
|
|
RelativeQto = tmp.RelativeQto;
|
|
RateOfChange = tmp.RateOfChange;
|
|
DetectionThreshold = tmp.DetectionThreshold;
|
|
SupressTrills = tmp.SupressTrills;
|
|
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Parameterless constructor initializes the parameters
|
|
/// </summary>
|
|
public CombinedWithDetTestParams()
|
|
{
|
|
}
|
|
|
|
public CombinedWithDetTestParams(Entities.ComponentTest testParamsEntity, string componentName, Entities.Test test)
|
|
{
|
|
this.testParamsEntity = testParamsEntity;
|
|
this.componentName = componentName;
|
|
this.test = test;
|
|
}
|
|
}
|
|
}
|