Initial commit almost identical to SVN-repo rev.340
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Elde.Valve
|
||||
{
|
||||
public class ValveCfg : ComponentCfgBase, IChildComponentCfg
|
||||
{
|
||||
public int BitPosition; /// Bit-position
|
||||
public string CoupledToName; /// Name of the coupled valve or null
|
||||
public bool Invert; /// The coupled valve has inverted position
|
||||
public int LagOpening; /// Delay (referred to the master valve) when opening this valve in [s]
|
||||
public int LagClosing; /// Delay (referred to the master valve) when closing this valve in [s]
|
||||
/// Negative values of delays mean an earlier function of the coupled valve.
|
||||
|
||||
/// Parameterless constructor
|
||||
public ValveCfg()
|
||||
{
|
||||
}
|
||||
/// Constructor 1
|
||||
public ValveCfg(IComponentFactory factory, string name, string parentName, int bitPosition, string coupledToName, bool invert, int lagOpening, int lagClosing)
|
||||
: base(factory, name, parentName)
|
||||
{
|
||||
this.BitPosition = bitPosition;
|
||||
this.CoupledToName = coupledToName;
|
||||
this.Invert = invert;
|
||||
this.LagOpening = lagOpening;
|
||||
this.LagClosing = lagClosing;
|
||||
}
|
||||
/// Constructor 2 without CoupledTo valve
|
||||
public ValveCfg(IComponentFactory factory, string name, string parentName, int bitPosition)
|
||||
: this(factory, name, parentName, bitPosition, null, false, 0, 0)
|
||||
{
|
||||
}
|
||||
|
||||
public IComponentCfg Clone()
|
||||
{
|
||||
return new ValveCfg(Factory, Name, ParentName, BitPosition, CoupledToName, Invert, LagOpening, LagClosing);
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("bit={0}, coupledTo={1}, invert={2}, lagOpen={3}, lagClose={4}",
|
||||
BitPosition, CoupledToName, (Invert ? "yes" : "no"), LagOpening, LagClosing);
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
ValveCfg config = (ValveCfg)(new XmlSerializer(typeof(ValveCfg))).Deserialize(reader);
|
||||
config.InitCfgBaseFromEntity(component, factory);
|
||||
return config;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user