Methods CreateDbEntity and CreateFromDbEntity moved from XyzCfg to ComponentCfgBase, factories modified accordingly.
This commit is contained in:
@@ -14,44 +14,22 @@ namespace TBF.BenchControl.Cameras.IdcCamera
|
||||
/// Parameterless constructor
|
||||
public IdcCameraCfg()
|
||||
{
|
||||
}
|
||||
Name = "Idc";
|
||||
ParentName = string.Empty;
|
||||
ComPortNr = 20;
|
||||
BaudRate = 57600;
|
||||
BrightnessCam = 0.5f;
|
||||
}
|
||||
|
||||
/// Constructor
|
||||
public IdcCameraCfg(IComponentFactory factory, string name, int comPortNr, int baudRate, float brightnessCam)
|
||||
: base(factory, name)
|
||||
{
|
||||
this.ComPortNr = comPortNr;
|
||||
this.BaudRate = baudRate;
|
||||
this.BrightnessCam = brightnessCam;
|
||||
}
|
||||
|
||||
public IComponentCfg Clone()
|
||||
{
|
||||
return new IdcCameraCfg(Factory, Name, ComPortNr, BaudRate, BrightnessCam);
|
||||
}
|
||||
public IdcCameraCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("COM{0}, {1}Bd, brightness={2}%", ComPortNr, BaudRate, (int)(100.0f * BrightnessCam));
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
IdcCameraCfg config = (IdcCameraCfg)(new XmlSerializer(typeof(IdcCameraCfg))).Deserialize(reader);
|
||||
config.InitCfgBaseFromEntity(component, factory);
|
||||
return config;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user