79 lines
2.3 KiB
C#
79 lines
2.3 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Xml.Serialization;
|
|
using TBF.BenchControl.Generic;
|
|
|
|
namespace TBF.BenchControl.Elde.TempMeter
|
|
{
|
|
public class TempMeterCfg : ComponentCfgBase, IChildComponentCfg
|
|
{
|
|
public int Position; /// 0..7
|
|
|
|
public float A1;
|
|
public float A2;
|
|
public float A3;
|
|
public float A4;
|
|
public float A5;
|
|
|
|
/// Parameterless constructor
|
|
public TempMeterCfg()
|
|
{
|
|
}
|
|
/// <summary>
|
|
/// Temperature meter configuration parameters
|
|
/// </summary>
|
|
/// <param name="name">Temperature meter name</param>
|
|
/// <param name="index">Position on the control board 0..7</param>
|
|
/// <param name="a1">A1</param>
|
|
/// <param name="a2">A2</param>
|
|
/// <param name="a3">A3</param>
|
|
/// <param name="a4">A4</param>
|
|
/// <param name="a5">A5</param>
|
|
public TempMeterCfg(IComponentFactory factory, string name, string parentName, int index, float a1, float a2, float a3, float a4, float a5)
|
|
: base(factory, name, parentName)
|
|
{
|
|
if (index < 0 || index > 7) throw new ArgumentOutOfRangeException("position");
|
|
this.Position = index;
|
|
|
|
this.A1 = a1;
|
|
this.A2 = a2;
|
|
this.A3 = a3;
|
|
this.A4 = a4;
|
|
this.A5 = a5;
|
|
}
|
|
public TempMeterCfg(IComponentFactory factory, string name, string parentName, int index)
|
|
: this(factory, name, parentName, index, -21.0116f, 0.0017727f, 0.00000000068422f, -7.40415E-16f, 0)
|
|
{
|
|
}
|
|
|
|
public IComponentCfg Clone()
|
|
{
|
|
return new TempMeterCfg(Factory, Name, ParentName, Position, A1, A2, A3, A4, A5);
|
|
}
|
|
|
|
public string ToString(int i)
|
|
{
|
|
return string.Format("index={0}, A1={1}, A2={2}, A3={3}, A4={4}, A5={5}", Position, A1, A2, A3, A4, A5);
|
|
}
|
|
|
|
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))
|
|
{
|
|
TempMeterCfg config = (TempMeterCfg)(new XmlSerializer(typeof(TempMeterCfg))).Deserialize(reader);
|
|
config.InitCfgBaseFromEntity(component, factory);
|
|
return config;
|
|
}
|
|
}
|
|
}
|
|
}
|