137 lines
3.3 KiB
C#
137 lines
3.3 KiB
C#
///
|
|
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
|
///
|
|
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 kPa
|
|
public float PressureHi; /// Presure range high limit in kPa
|
|
public int DurationPMax; /// Duration of PMax test in [s]
|
|
public int DurationLeak; /// Duration of Leak test in [s]
|
|
|
|
public override void InitializeAll()
|
|
{
|
|
PressureLo = 500.0f; /// kPa
|
|
PressureHi = 600.0f; /// kPa
|
|
DurationPMax = 10;
|
|
DurationLeak = 60;
|
|
}
|
|
|
|
|
|
string[] paramNames = new string[]
|
|
{
|
|
Strings.PressureLo_bar,
|
|
Strings.PressureHi_bar,
|
|
Strings.Duration_PMax_s,
|
|
Strings.Duration_Leak_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 / 100.0f).ToString(); /// Saved in kPa, UI in bar
|
|
case 1: return (PressureHi / 100.0f).ToString(); /// Saved in kPa, UI in bar
|
|
case 2: return DurationPMax.ToString();
|
|
case 3: return DurationLeak.ToString();
|
|
default: return string.Empty;
|
|
}
|
|
}
|
|
|
|
public void UpdateParam(int i, string strValue)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0: PressureLo = 100.0f * Utils.ParseUFloat(strValue); return; /// Saved in kPa, UI in bar
|
|
case 1: PressureHi = 100.0f * Utils.ParseSFloat(strValue); return; /// Saved in kPa, UI in bar
|
|
case 2: DurationPMax = int.Parse(strValue); return;
|
|
case 3: DurationLeak = 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:
|
|
case 3:
|
|
if (int.TryParse(strValue, out iDummy)) return true;
|
|
break;
|
|
default:
|
|
message = "Invalid index";
|
|
return false;
|
|
}
|
|
|
|
message = ParamName(i) + " is invalid";
|
|
return false;
|
|
}
|
|
|
|
void CopyContentTo(LeakTestParams prms)
|
|
{
|
|
prms.PressureLo = this.PressureLo;
|
|
prms.PressureHi = this.PressureHi;
|
|
prms.DurationPMax = this.DurationPMax;
|
|
prms.DurationLeak = this.DurationLeak;
|
|
}
|
|
|
|
public IParamsProvider Clone()
|
|
{
|
|
LeakTestParams pars = new LeakTestParams();
|
|
CopyContentTo(pars);
|
|
return pars;
|
|
}
|
|
|
|
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;
|
|
|
|
tmp.CopyContentTo(this);
|
|
}
|
|
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;
|
|
}
|
|
}
|
|
}
|