55 lines
1.4 KiB
C#
55 lines
1.4 KiB
C#
using System.IO;
|
|
using System.IO.Ports;
|
|
using System.Xml.Serialization;
|
|
using TBF.BenchControl.Generic;
|
|
|
|
namespace TBF.BenchControl.Cameras.CameraRoi
|
|
{
|
|
public class CameraRoiCfg : ComponentCfgBase, IChildComponentCfg
|
|
{
|
|
public int RoiNr; /// ROI number 1..4
|
|
|
|
/// Parameterless constructor
|
|
public CameraRoiCfg()
|
|
{
|
|
}
|
|
|
|
/// Constructor
|
|
public CameraRoiCfg(IComponentFactory factory, string name, string parentName, int roiNr)
|
|
: base(factory, name, parentName)
|
|
{
|
|
this.RoiNr = roiNr;
|
|
}
|
|
|
|
public IComponentCfg Clone()
|
|
{
|
|
return new CameraRoiCfg(Factory, Name, ParentName, RoiNr);
|
|
}
|
|
|
|
public string ToString(int i)
|
|
{
|
|
return string.Format("roi{0}, parent={1}", RoiNr, ParentName);
|
|
}
|
|
|
|
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))
|
|
{
|
|
CameraRoiCfg config = (CameraRoiCfg)(new XmlSerializer(typeof(CameraRoiCfg))).Deserialize(reader);
|
|
config.InitCfgBaseFromEntity(component, factory);
|
|
return config;
|
|
}
|
|
}
|
|
}
|
|
}
|