tbf/TestBenchFramework/BenchControl/TestMethods/LeakTest/LeakTestParams.cs
Milan Hanajik b07c7c5c9d PMaxTest and LeakTest methods implemented, added to the project
Order of two new test wizard dialog exchanged
Pressure Selection wizard dialog added
2015-02-19 15:54:55 +01:00

115 lines
2.6 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.LeakTest
{
public class LeakTestParams : TestParamsBase, IParamsProvider, ITestParams
{
public float PressureLo; /// Presure range low limit in bar
public float PressureHi; /// Presure range high limit in bar
public int Duration; /// Duration of the test in [s]
public override void InitializeAll()
{
PressureLo = 1.0f;
PressureHi = 2.0f;
Duration = 10;
}
string[] paramNames = new string[]
{
Strings.PressureLo_bar,
Strings.PressureHi_bar,
Strings.Duration_s,
};
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 PressureLo.ToString();
case 1: return PressureHi.ToString();
case 2: return Duration.ToString();
default: return string.Empty;
}
}
public void UpdateParam(int i, string strValue)
{
switch (i)
{
case 0: PressureLo = Utils.ParseUFloat(strValue); return;
case 1: PressureHi = Utils.ParseSFloat(strValue); return;
case 2: Duration = 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 1:
if (Utils.TryParseUFloat(strValue, out dummy)) return true;
break;
case 2:
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
{
LeakTestParams tmp = (LeakTestParams)(new XmlSerializer(typeof(LeakTestParams)))
.Deserialize(new StringReader(dbEntity.Parameters));
testParamsEntity = dbEntity;
componentName = dbEntity.CmpntName;
test = dbEntity.Test;
PressureLo = tmp.PressureLo;
PressureHi = tmp.PressureHi;
Duration = tmp.Duration;
}
catch
{
}
}
/// <summary>
/// Parameterless constructor initializes the parameters
/// </summary>
public LeakTestParams()
{
}
public LeakTestParams(Entities.ComponentTest testParamsEntity, string componentName, Entities.Test test)
{
this.testParamsEntity = testParamsEntity;
this.componentName = componentName;
this.test = test;
}
}
}