136 lines
3.7 KiB
C#
136 lines
3.7 KiB
C#
///
|
|
/// Copyright (c) 2019 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Xml.Serialization;
|
|
using Config.Entities;
|
|
using TBF.BenchControl.Generic;
|
|
|
|
namespace TBF.BenchControl.Various.ErrorFlags
|
|
{
|
|
public class ErrorsCfg : ComponentCfgBase, IComponentCfg, Config.Entities.IParamsProvider
|
|
{
|
|
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ErrorsCfg) })[0];
|
|
public override XmlSerializer GetSerializer() { return Serializer; }
|
|
|
|
public IComponentCfgCtrl GetControl() { return new Configs.ParamsProvider.ComponentCfgCtrl(this, null); }
|
|
|
|
///
|
|
/// Serialized parameters
|
|
///
|
|
public string Q3Names;
|
|
public string Q2Names;
|
|
public string Q1Names;
|
|
|
|
/// <summary> Test parameters </summary>
|
|
[XmlIgnore]
|
|
public TestParams TestParams;
|
|
public override IParamsProvider GetRuntimeTestParamsProvider() { return TestParams; }
|
|
public override IParamsProvider CreateTestParamsProvider() { return new TestParams(true); }
|
|
|
|
/// Private parameterless constructor invoked by all other (public) constructors
|
|
ErrorsCfg()
|
|
{
|
|
TestParams = new TestParams(true);
|
|
}
|
|
|
|
public ErrorsCfg(string name, IComponentFactory factory)
|
|
: this()
|
|
{
|
|
Name = name;
|
|
ParentName = string.Empty;
|
|
Factory = factory;
|
|
InitializeAll();
|
|
}
|
|
|
|
public string ComponentName { get { return Name; } }
|
|
|
|
public void InitializeAll()
|
|
{
|
|
Q3Names = "Q3";
|
|
Q2Names = "Q2";
|
|
Q1Names = "Q1";
|
|
}
|
|
|
|
string[] paramNames = new string[]
|
|
{
|
|
"1st test name for E15,E16 (Q3)",
|
|
"2nd test name for E15,E16 (Q2)",
|
|
"3rd test name for E15,E16 (Q1)",
|
|
};
|
|
public string ParamName(int i) { return paramNames[i]; }
|
|
public int ParamsCount() { return paramNames.Length; }
|
|
|
|
public IList<string> ParamValues(int i)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
public string ToString(int i)
|
|
{
|
|
if (i == -1)
|
|
{
|
|
return string.Format("{0}", Name);
|
|
}
|
|
|
|
switch (i)
|
|
{
|
|
case 0: return Q3Names;
|
|
case 1: return Q2Names;
|
|
case 2: return Q1Names;
|
|
default: return string.Empty;
|
|
}
|
|
}
|
|
|
|
public CfgUpdateFlags UpdateParam(int i, string strValue)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0: Q3Names = strValue; return CfgUpdateFlags.RestartRqrd;
|
|
case 1: Q1Names = strValue; return CfgUpdateFlags.RestartRqrd;
|
|
case 2: Q1Names = strValue; return CfgUpdateFlags.RestartRqrd;
|
|
default: return CfgUpdateFlags.None;
|
|
}
|
|
}
|
|
|
|
public bool ValidateParam(int i, string strValue, out string message)
|
|
{
|
|
message = string.Empty;
|
|
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
case 1:
|
|
case 2:
|
|
return true;
|
|
default:
|
|
message = "Invalid index";
|
|
return false;
|
|
}
|
|
|
|
//message = ParamName(i) + " is invalid";
|
|
//return false;
|
|
}
|
|
|
|
void CopyContentTo(ErrorsCfg prms)
|
|
{
|
|
prms.Q3Names = this.Q3Names;
|
|
prms.Q2Names = this.Q2Names;
|
|
prms.Q1Names = this.Q1Names;
|
|
}
|
|
|
|
public Config.Entities.IParamsProvider Clone()
|
|
{
|
|
ErrorsCfg pars = new ErrorsCfg();
|
|
CopyContentTo(pars);
|
|
return pars;
|
|
}
|
|
|
|
public bool UpdateEmbeddedDbEntity()
|
|
{
|
|
return true; /// =OK, do nothing
|
|
}
|
|
}
|
|
}
|