118 lines
2.4 KiB
C#
118 lines
2.4 KiB
C#
///
|
|
/// Copyright (c) 2016 Sensus Metering Systems
|
|
///
|
|
using System;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Xml.Serialization;
|
|
using Config.Entities;
|
|
using TBF.BenchControl.Generic;
|
|
using TBF.Resources;
|
|
|
|
namespace TBF.BenchControl.TestMethods.Endurance
|
|
{
|
|
public class TestParams : TestParamsBase, IParamsProvider, ITestParams
|
|
{
|
|
public bool BooleanParam; /// Main meter readings are ignored during test (suitable for small flows)
|
|
|
|
public override void InitializeAll()
|
|
{
|
|
BooleanParam = 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 (BooleanParam ? Strings.yes : Strings.no);
|
|
default: return string.Empty;
|
|
}
|
|
}
|
|
|
|
public void UpdateParam(int i, string strValue)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0: BooleanParam = 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;
|
|
}
|
|
|
|
void CopyContentTo(TestParams prms)
|
|
{
|
|
prms.BooleanParam = this.BooleanParam;
|
|
}
|
|
|
|
public IParamsProvider Clone()
|
|
{
|
|
TestParams pars = new TestParams();
|
|
CopyContentTo(pars);
|
|
return pars;
|
|
}
|
|
|
|
public override void UpdateTestParams(ComponentTest dbEntity)
|
|
{
|
|
if (dbEntity == null) return;
|
|
try
|
|
{
|
|
TestParams tmp = (TestParams)(new XmlSerializer(typeof(TestParams)))
|
|
.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 TestParams()
|
|
{
|
|
}
|
|
|
|
public TestParams(bool initialize)
|
|
{
|
|
if (initialize) InitializeAll();
|
|
}
|
|
|
|
public TestParams(ComponentTest testParamsEntity, string componentName, Test test)
|
|
{
|
|
this.testParamsEntity = testParamsEntity;
|
|
this.componentName = componentName;
|
|
this.test = test;
|
|
}
|
|
}
|
|
}
|