63 lines
2.1 KiB
C#
63 lines
2.1 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Xml.Serialization;
|
|
using TBF.BenchControl.Generic;
|
|
|
|
namespace TBF.BenchControl.Elde.FlowMeterTwins
|
|
{
|
|
public class FlowMeterCfg : ComponentCfgBase, Generic.IChildComponentCfg
|
|
{
|
|
public float NominalFlow; /// Nominal flow in m3/h at output frequency 2000 Hz
|
|
public string FlowMeter1; /// Name of the flow meter 1 component
|
|
public string FlowMeter2; /// Name of the flow meter 2 component
|
|
|
|
/// Parameterless constructor
|
|
public FlowMeterCfg()
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Flow meter configuration parameters
|
|
/// </summary>
|
|
/// <param name="name">Flow meter name</param>
|
|
/// <param name="parentName">Parent component name</param>
|
|
/// <param name="nominalFlow">Nominal flow/param>
|
|
public FlowMeterCfg(IComponentFactory factory, string name, string parentName, float nominalFlow, string flowMeter1, string flowMeter2)
|
|
: base(factory, name, parentName)
|
|
{
|
|
this.NominalFlow = nominalFlow;
|
|
this.FlowMeter1 = flowMeter1;
|
|
this.FlowMeter2 = flowMeter2;
|
|
}
|
|
|
|
public IComponentCfg Clone()
|
|
{
|
|
return new FlowMeterCfg(Factory, Name, ParentName, NominalFlow, FlowMeter1, FlowMeter2);
|
|
}
|
|
|
|
public string ToString(int i)
|
|
{
|
|
return string.Format("nominalFlow={0}, flowmeter#1={1}, flowmeter#2={2}", NominalFlow, FlowMeter1, FlowMeter2);
|
|
}
|
|
|
|
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))
|
|
{
|
|
FlowMeterCfg config = (FlowMeterCfg)(new XmlSerializer(typeof(FlowMeterCfg))).Deserialize(reader);
|
|
config.InitCfgBaseFromEntity(component, factory);
|
|
return config;
|
|
}
|
|
}
|
|
}
|
|
}
|