53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
|
|
using System.IO;
|
|||
|
|
using System.Xml.Serialization;
|
|||
|
|
using TBF.BenchControl.Generic;
|
|||
|
|
|
|||
|
|
namespace TBF.BenchControl.Elde
|
|||
|
|
{
|
|||
|
|
public class ControlBoardCfg : ComponentCfgBase, IComponentCfg
|
|||
|
|
{
|
|||
|
|
public int ComPortNr;
|
|||
|
|
|
|||
|
|
/// Parameterless constructor
|
|||
|
|
public ControlBoardCfg()
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
/// Constructor
|
|||
|
|
public ControlBoardCfg(IComponentFactory factory, string name, int comPortNr)
|
|||
|
|
: base(factory, name)
|
|||
|
|
{
|
|||
|
|
this.ComPortNr = comPortNr;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public IComponentCfg Clone()
|
|||
|
|
{
|
|||
|
|
return new ControlBoardCfg(Factory, Name, ComPortNr);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string ToString(int i)
|
|||
|
|
{
|
|||
|
|
return string.Format("COM{0}", ComPortNr);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public TBF.Entities.Component CreateDbEntity()
|
|||
|
|
{
|
|||
|
|
using (var writer = new StringWriter())
|
|||
|
|
{
|
|||
|
|
(new XmlSerializer(GetType())).Serialize(writer, this);
|
|||
|
|
return Entities.Component.CreateFromCfg(Name, Factory.ClassName, ParentName, ItemNr, DebugLevel, LogLevel, writer.ToString());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static IComponentCfg CreateFromDbEntity(Entities.Component tbfComponent, IComponentFactory factory)
|
|||
|
|
{
|
|||
|
|
using (var reader = new StringReader(tbfComponent.Parameters))
|
|||
|
|
{
|
|||
|
|
ControlBoardCfg config = (ControlBoardCfg)(new XmlSerializer(typeof(ControlBoardCfg))).Deserialize(reader);
|
|||
|
|
config.Name = tbfComponent.Name;
|
|||
|
|
config.InitCfgBaseFromEntity(tbfComponent, factory);
|
|||
|
|
return config;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|