53 lines
1.3 KiB
C#
53 lines
1.3 KiB
C#
|
|
using System.IO;
|
|||
|
|
using System.Xml.Serialization;
|
|||
|
|
using TBF.BenchControl.Generic;
|
|||
|
|
|
|||
|
|
namespace TBF.BenchControl.Elde.Pump
|
|||
|
|
{
|
|||
|
|
public class PumpCfg : ComponentCfgBase, IChildComponentCfg
|
|||
|
|
{
|
|||
|
|
public int BitPosition;
|
|||
|
|
|
|||
|
|
/// Parameterless constructor
|
|||
|
|
public PumpCfg()
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// Constructor
|
|||
|
|
public PumpCfg(IComponentFactory factory, string name, string parentName, int bitPosition)
|
|||
|
|
: base(factory, name, parentName)
|
|||
|
|
{
|
|||
|
|
this.BitPosition = bitPosition;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public IComponentCfg Clone()
|
|||
|
|
{
|
|||
|
|
return new PumpCfg(Factory, Name, ParentName, BitPosition);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string ToString(int i)
|
|||
|
|
{
|
|||
|
|
return string.Format("bit={0}", BitPosition);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
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 component, IComponentFactory factory)
|
|||
|
|
{
|
|||
|
|
using (var reader = new StringReader(component.Parameters))
|
|||
|
|
{
|
|||
|
|
PumpCfg config = (PumpCfg)(new XmlSerializer(typeof(PumpCfg))).Deserialize(reader);
|
|||
|
|
config.InitCfgBaseFromEntity(component, factory);
|
|||
|
|
return config;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|