2021-06-29 10:42:34 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Copyright (c) 2021 Sensus Slovensko a.s.
|
|
|
|
|
|
///
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Xml.Serialization;
|
2021-09-23 09:46:40 +00:00
|
|
|
|
using Common;
|
2021-06-29 10:42:34 +00:00
|
|
|
|
using Config.Entities;
|
|
|
|
|
|
using TBF.BenchControl.Generic;
|
|
|
|
|
|
|
|
|
|
|
|
namespace TBF.BenchControl.RegisterReaders.DataStream.Reader
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Holds information identifying the test bench - serializable configuration.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class ReaderCfg : ComponentCfgBase, Generic.IChildComponentCfg, Config.Entities.IParamsProvider
|
|
|
|
|
|
{
|
|
|
|
|
|
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ReaderCfg) })[0];
|
|
|
|
|
|
public override XmlSerializer GetSerializer() { return Serializer; }
|
|
|
|
|
|
|
2021-08-29 11:01:34 +00:00
|
|
|
|
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities)
|
2021-06-29 10:42:34 +00:00
|
|
|
|
{
|
|
|
|
|
|
IList<string> parents = new List<string>();
|
|
|
|
|
|
parents.Add("MefImport");
|
|
|
|
|
|
|
|
|
|
|
|
return new Configs.ParamsProvider.ComponentCfgCtrl(this, parents);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Serialized parameters
|
|
|
|
|
|
///
|
|
|
|
|
|
public int Position;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Private parameterless constructor invoked by all other (public) constructors
|
|
|
|
|
|
ReaderCfg() {}
|
|
|
|
|
|
|
|
|
|
|
|
public ReaderCfg(IComponentFactory factory)
|
|
|
|
|
|
: this()
|
|
|
|
|
|
{
|
|
|
|
|
|
Factory = factory;
|
|
|
|
|
|
Name = "Reader";
|
|
|
|
|
|
ParentName = "MefImport";
|
|
|
|
|
|
InitializeAll();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string ComponentName { get { return Name; } }
|
|
|
|
|
|
|
|
|
|
|
|
public void InitializeAll()
|
|
|
|
|
|
{
|
|
|
|
|
|
Position = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string[] paramNames = new string[]
|
|
|
|
|
|
{
|
|
|
|
|
|
"Position",
|
|
|
|
|
|
};
|
|
|
|
|
|
public string ParamName(int i) { return paramNames[i]; }
|
|
|
|
|
|
public int ParamsCount() { return paramNames.Length; }
|
|
|
|
|
|
|
2021-07-28 11:31:18 +00:00
|
|
|
|
public ICollection<string> ParamValues(int i)
|
2021-06-29 10:42:34 +00:00
|
|
|
|
{
|
|
|
|
|
|
switch (i)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
IList<string> retv = new List<string>();
|
2021-09-19 20:04:16 +00:00
|
|
|
|
for (int j = 1; j <= TBF.Data.WMsCount; j++) retv.Add(j.ToString());
|
2021-06-29 10:42:34 +00:00
|
|
|
|
return retv;
|
|
|
|
|
|
default:
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string ToString(int i)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (i)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
return Position.ToString();
|
|
|
|
|
|
default:
|
|
|
|
|
|
return string.Format("{0}: Position = {1}", Name, Position);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public CfgUpdateFlags UpdateParam(int i, string strValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (i)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
Position = int.Parse(strValue);
|
|
|
|
|
|
return CfgUpdateFlags.RestartRqrd;
|
|
|
|
|
|
default:
|
|
|
|
|
|
return CfgUpdateFlags.None;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool ValidateParam(int i, string strValue, out string message)
|
|
|
|
|
|
{
|
|
|
|
|
|
message = string.Empty;
|
|
|
|
|
|
int idummy;
|
|
|
|
|
|
|
|
|
|
|
|
switch (i)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
2021-09-19 20:04:16 +00:00
|
|
|
|
if (int.TryParse(strValue, out idummy) && idummy > 0 && idummy <= TBF.Data.WMsCount) return true;
|
2021-06-29 10:42:34 +00:00
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
message = "Invalid index";
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
message = ParamName(i) + " is invalid";
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CopyContentTo(ReaderCfg prms)
|
|
|
|
|
|
{
|
|
|
|
|
|
prms.Position = this.Position;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Config.Entities.IParamsProvider Clone()
|
|
|
|
|
|
{
|
|
|
|
|
|
ReaderCfg pars = new ReaderCfg();
|
|
|
|
|
|
CopyContentTo(pars);
|
|
|
|
|
|
return pars;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool UpdateEmbeddedDbEntity()
|
|
|
|
|
|
{
|
|
|
|
|
|
return true; /// =OK, do nothing
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|