Methods CreateDbEntity and CreateFromDbEntity moved from XyzCfg to ComponentCfgBase, factories modified accordingly.
This commit is contained in:
@@ -11,42 +11,20 @@ namespace TBF.BenchControl.Elde
|
||||
/// Parameterless constructor
|
||||
public ControlBoardCfg()
|
||||
{
|
||||
}
|
||||
/// Constructor
|
||||
public ControlBoardCfg(IComponentFactory factory, string name, int comPortNr)
|
||||
: base(factory, name)
|
||||
{
|
||||
this.ComPortNr = comPortNr;
|
||||
Name = "CB";
|
||||
ParentName = string.Empty;
|
||||
ComPortNr = 1;
|
||||
}
|
||||
|
||||
public IComponentCfg Clone()
|
||||
{
|
||||
return new ControlBoardCfg(Factory, Name, ComPortNr);
|
||||
}
|
||||
public ControlBoardCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("COM{0}", ComPortNr);
|
||||
}
|
||||
|
||||
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 tbfComponent, IComponentFactory factory)
|
||||
{
|
||||
using (var reader = new StringReader(tbfComponent.Parameters))
|
||||
{
|
||||
ControlBoardCfg config = (ControlBoardCfg)(new XmlSerializer(typeof(ControlBoardCfg))).Deserialize(reader);
|
||||
config.Name = tbfComponent.Name;
|
||||
config.InitCfgBaseFromEntity(tbfComponent, factory);
|
||||
return config;
|
||||
}
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("Name={0}, ComPortNr={1}", Name, ComPortNr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace TBF.BenchControl.Elde
|
||||
|
||||
public IComponentCfg DefaultConfig(IList<Entities.Component> components)
|
||||
{
|
||||
return new ControlBoardCfg(this, "CB", 1);
|
||||
return new ControlBoardCfg(this);
|
||||
}
|
||||
|
||||
public IComponentCfgCtrl CreateCfgCtrl()
|
||||
@@ -32,7 +32,7 @@ namespace TBF.BenchControl.Elde
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Entities.Component component)
|
||||
{
|
||||
return Elde.ControlBoardCfg.CreateFromDbEntity(component, this);
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(Elde.ControlBoardCfg), component, this);
|
||||
}
|
||||
|
||||
public void ResetStaticProperties() { ControlBoardDev.ResetStaticProperties(); }
|
||||
|
||||
@@ -11,41 +11,22 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
/// Parameterless constructor
|
||||
public DiverterCfg()
|
||||
{
|
||||
}
|
||||
/// Constructor
|
||||
public DiverterCfg(IComponentFactory factory, string name, string parentName, int bitPosition)
|
||||
: base(factory, name, parentName)
|
||||
{
|
||||
this.BitPosition = bitPosition;
|
||||
}
|
||||
Name = "Div";
|
||||
ParentName = "CB";
|
||||
BitPosition = 0;
|
||||
}
|
||||
|
||||
public IComponentCfg Clone()
|
||||
{
|
||||
return new DiverterCfg(Factory, Name, ParentName, BitPosition);
|
||||
}
|
||||
public DiverterCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("bit={0}", BitPosition);
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
DiverterCfg config = (DiverterCfg)(new XmlSerializer(typeof(DiverterCfg))).Deserialize(reader);
|
||||
config.InitCfgBaseFromEntity(component, factory);
|
||||
return config;
|
||||
}
|
||||
return string.Format("Name={0}, Parent={1}, Bit={2}",
|
||||
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
|
||||
BitPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
|
||||
public IComponentCfg DefaultConfig(IList<Entities.Component> components)
|
||||
{
|
||||
return new DiverterCfg(this, "Diverter", "CB", 0);
|
||||
return new DiverterCfg(this);
|
||||
}
|
||||
|
||||
public IComponentCfgCtrl CreateCfgCtrl()
|
||||
@@ -34,7 +34,7 @@ namespace TBF.BenchControl.Elde.Diverter
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Entities.Component component)
|
||||
{
|
||||
return DiverterCfg.CreateFromDbEntity(component, this);
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(DiverterCfg), component, this);
|
||||
}
|
||||
|
||||
public void ResetStaticProperties() { Diverter.ResetStaticProperties(); }
|
||||
|
||||
+11
-34
@@ -10,44 +10,21 @@ namespace TBF.BenchControl.Elde.FixedStartRegisterReader
|
||||
/// Parameterless constructor
|
||||
public RegisterReaderCfg()
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Regulation valve configuration parameters
|
||||
/// </summary>
|
||||
/// <param name="name">Regulation valve name</param>
|
||||
/// <param name="position">Position on the control board 1 .. nrWaterMeters</param>
|
||||
public RegisterReaderCfg(IComponentFactory factory, string name, string parentName)
|
||||
: base(factory, name, parentName)
|
||||
{
|
||||
}
|
||||
Name = "DummyRR";
|
||||
ParentName = "CB";
|
||||
}
|
||||
|
||||
public IComponentCfg Clone()
|
||||
{
|
||||
return new RegisterReaderCfg(Factory, Name, ParentName);
|
||||
}
|
||||
public RegisterReaderCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return "<nothing to configure>";
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
RegisterReaderCfg config = (RegisterReaderCfg)(new XmlSerializer(typeof(RegisterReaderCfg))).Deserialize(reader);
|
||||
config.InitCfgBaseFromEntity(component, factory);
|
||||
return config;
|
||||
}
|
||||
return string.Format("Name={0}, Parent={1}",
|
||||
Name,
|
||||
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ namespace TBF.BenchControl.Elde.FixedStartRegisterReader
|
||||
|
||||
public IComponentCfg DefaultConfig(IList<Entities.Component> components)
|
||||
{
|
||||
return new RegisterReaderCfg(this, "Dummy", "CB");
|
||||
return new RegisterReaderCfg(this);
|
||||
}
|
||||
|
||||
public IComponentCfgCtrl CreateCfgCtrl()
|
||||
@@ -27,7 +27,7 @@ namespace TBF.BenchControl.Elde.FixedStartRegisterReader
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Entities.Component component)
|
||||
{
|
||||
return RegisterReaderCfg.CreateFromDbEntity(component, this);
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(RegisterReaderCfg), component, this);
|
||||
}
|
||||
|
||||
public bool HasProcedureParams { get { return true; } }
|
||||
|
||||
@@ -7,55 +7,31 @@ namespace TBF.BenchControl.Elde.FlowMeter
|
||||
{
|
||||
public class FlowMeterCfg : ComponentCfgBase, Generic.IChildComponentCfg
|
||||
{
|
||||
public int Idx1; /// 1..5
|
||||
|
||||
public int Idx1; /// 1..5
|
||||
public float NominalFlow; /// Nominal flow in m3/h at output frequency 2000 Hz
|
||||
|
||||
/// Parameterless constructor
|
||||
public FlowMeterCfg()
|
||||
{
|
||||
Name = "FlowMeter";
|
||||
ParentName = "CB";
|
||||
Idx1 = 1;
|
||||
NominalFlow = 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flow meter configuration parameters
|
||||
/// </summary>
|
||||
/// <param name="name">Flow meter name</param>
|
||||
/// <param name="idx1">Position on the control board 1..5</param>
|
||||
public FlowMeterCfg(IComponentFactory factory, string name, string parentName, int idx1, float nominalFlow)
|
||||
: base(factory, name, parentName)
|
||||
public FlowMeterCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
if (idx1 < 1 || idx1 > 5) throw new ArgumentOutOfRangeException("idx1");
|
||||
this.Idx1 = idx1;
|
||||
this.NominalFlow = nominalFlow;
|
||||
}
|
||||
|
||||
public IComponentCfg Clone()
|
||||
{
|
||||
return new FlowMeterCfg(Factory, Name, ParentName, Idx1, NominalFlow);
|
||||
}
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("idx1={0}, nominalFlow={1}", Idx1, NominalFlow);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
return string.Format("Name={0}, Parent={1}, Idx1={2}, NominalFlow={3}",
|
||||
Name,
|
||||
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
|
||||
Idx1,
|
||||
NominalFlow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace TBF.BenchControl.Elde.FlowMeter
|
||||
|
||||
public IComponentCfg DefaultConfig(IList<Entities.Component> components)
|
||||
{
|
||||
return new FlowMeterCfg(this, "FlowMeter", "CB", 1, 1);
|
||||
return new FlowMeterCfg(this);
|
||||
}
|
||||
|
||||
public IComponentCfgCtrl CreateCfgCtrl()
|
||||
@@ -35,7 +35,7 @@ namespace TBF.BenchControl.Elde.FlowMeter
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Entities.Component component)
|
||||
{
|
||||
return FlowMeterCfg.CreateFromDbEntity(component, this);
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(FlowMeterCfg), component, this);
|
||||
}
|
||||
|
||||
public void ResetStaticProperties() { FlowMeter.ResetStaticProperties(); }
|
||||
|
||||
@@ -14,49 +14,27 @@ namespace TBF.BenchControl.Elde.FlowMeterTwins
|
||||
/// Parameterless constructor
|
||||
public FlowMeterCfg()
|
||||
{
|
||||
}
|
||||
Name = "FlowMeterTwins";
|
||||
ParentName = "CB";
|
||||
NominalFlow = 1600;
|
||||
FlowMeter1 = string.Empty;
|
||||
FlowMeter2 = string.Empty;
|
||||
}
|
||||
|
||||
/// <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)
|
||||
public FlowMeterCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
this.NominalFlow = nominalFlow;
|
||||
this.FlowMeter1 = flowMeter1;
|
||||
this.FlowMeter2 = flowMeter2;
|
||||
}
|
||||
|
||||
public IComponentCfg Clone()
|
||||
{
|
||||
return new FlowMeterCfg(Factory, Name, ParentName, NominalFlow, FlowMeter1, FlowMeter2);
|
||||
}
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
return string.Format("Name={0}, Parent={1}, NominalFlow={2}, Flowmeter1={3}, Flowmeter2={4}",
|
||||
Name,
|
||||
string.IsNullOrEmpty(ParentName) ? "-" : ParentName,
|
||||
NominalFlow,
|
||||
string.IsNullOrEmpty(FlowMeter1) ? "-" : FlowMeter1,
|
||||
string.IsNullOrEmpty(FlowMeter2) ? "-" : FlowMeter2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace TBF.BenchControl.Elde.FlowMeterTwins
|
||||
|
||||
public IComponentCfg DefaultConfig(IList<Entities.Component> components)
|
||||
{
|
||||
return new FlowMeterCfg(this, "FlowMeterTwins", "CB", 1600, "---", "---");
|
||||
return new FlowMeterCfg(this);
|
||||
}
|
||||
|
||||
public IComponentCfgCtrl CreateCfgCtrl()
|
||||
@@ -35,7 +35,7 @@ namespace TBF.BenchControl.Elde.FlowMeterTwins
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Entities.Component component)
|
||||
{
|
||||
return FlowMeterCfg.CreateFromDbEntity(component, this);
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(FlowMeterCfg), component, this);
|
||||
}
|
||||
|
||||
public void ResetStaticProperties() { FlowMeter.ResetStaticProperties(); }
|
||||
|
||||
@@ -13,51 +13,25 @@ namespace TBF.BenchControl.Elde.PressureMeter
|
||||
/// Parameterless constructor
|
||||
public PressureMeterCfg()
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Regulation valve configuration parameters
|
||||
/// </summary>
|
||||
/// <param name="name">Regulation valve name</param>
|
||||
/// <param name="idx0">Position on the control board 0..3</param>
|
||||
/// <param name="dacValueClosed">0..1023</param>
|
||||
/// <param name="dacValueOpen">0..1023</param>
|
||||
public PressureMeterCfg(IComponentFactory factory, string name, string parentName, int idx0, byte rs485Address)
|
||||
: base(factory, name, parentName)
|
||||
Name = "PressureMeter";
|
||||
ParentName = "CB";
|
||||
Idx0 = 0;
|
||||
RS485Address = 99;
|
||||
}
|
||||
|
||||
public PressureMeterCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
if (idx0 < 0 || idx0 > 3) throw new ArgumentOutOfRangeException("Index (0-based)");
|
||||
this.Idx0 = idx0;
|
||||
|
||||
if (rs485Address < 0 || rs485Address > 255) throw new ArgumentOutOfRangeException("RS485Address");
|
||||
this.RS485Address = rs485Address;
|
||||
}
|
||||
|
||||
public IComponentCfg Clone()
|
||||
{
|
||||
return new PressureMeterCfg(Factory, Name, ParentName, Idx0, RS485Address);
|
||||
}
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("idx0={0}, RS485 address={1}", Idx0, RS485Address);
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
PressureMeterCfg config = (PressureMeterCfg)(new XmlSerializer(typeof(PressureMeterCfg))).Deserialize(reader);
|
||||
config.InitCfgBaseFromEntity(component, factory);
|
||||
return config;
|
||||
}
|
||||
return string.Format("Name={0}, Parent={1}, Idx0={2}, Address={3}",
|
||||
Name,
|
||||
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
|
||||
Idx0,
|
||||
RS485Address);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace TBF.BenchControl.Elde.PressureMeter
|
||||
|
||||
public IComponentCfg DefaultConfig(IList<Entities.Component> components)
|
||||
{
|
||||
return new PressureMeterCfg(this, "PressureMeter", "CB", 1, 99);
|
||||
return new PressureMeterCfg(this);
|
||||
}
|
||||
|
||||
public IComponentCfgCtrl CreateCfgCtrl()
|
||||
@@ -34,7 +34,7 @@ namespace TBF.BenchControl.Elde.PressureMeter
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Entities.Component component)
|
||||
{
|
||||
return PressureMeterCfg.CreateFromDbEntity(component, this);
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(PressureMeterCfg), component, this);
|
||||
}
|
||||
|
||||
public void ResetStaticProperties() { PressureMeter.ResetStaticProperties(); }
|
||||
|
||||
@@ -12,44 +12,25 @@ namespace TBF.BenchControl.Elde.Pump
|
||||
/// Parameterless constructor
|
||||
public PumpCfg()
|
||||
{
|
||||
Name = "Pump";
|
||||
ParentName = "CB";
|
||||
BitPosition = 0;
|
||||
Delay = 1;
|
||||
}
|
||||
|
||||
/// Constructor
|
||||
public PumpCfg(IComponentFactory factory, string name, string parentName, int bitPosition, int delay)
|
||||
: base(factory, name, parentName)
|
||||
public PumpCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
this.BitPosition = bitPosition;
|
||||
this.Delay = delay;
|
||||
}
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public IComponentCfg Clone()
|
||||
{
|
||||
return new PumpCfg(Factory, Name, ParentName, BitPosition, Delay);
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("bit={0}, delay={1}s", BitPosition, Delay);
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
PumpCfg config = (PumpCfg)(new XmlSerializer(typeof(PumpCfg))).Deserialize(reader);
|
||||
config.InitCfgBaseFromEntity(component, factory);
|
||||
return config;
|
||||
}
|
||||
}
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("Name={0}, Parent={1}, Bit={2}, Delay={3}",
|
||||
Name,
|
||||
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
|
||||
BitPosition,
|
||||
Delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace TBF.BenchControl.Elde.Pump
|
||||
|
||||
public IComponentCfg DefaultConfig(IList<Entities.Component> components)
|
||||
{
|
||||
return new PumpCfg(this, "Pump", "CB", 0, 1);
|
||||
return new PumpCfg(this);
|
||||
}
|
||||
|
||||
public IComponentCfgCtrl CreateCfgCtrl()
|
||||
@@ -31,7 +31,7 @@ namespace TBF.BenchControl.Elde.Pump
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Entities.Component component)
|
||||
{
|
||||
return PumpCfg.CreateFromDbEntity(component, this);
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(PumpCfg), component, this);
|
||||
}
|
||||
|
||||
public void ResetStaticProperties() { Pump.ResetStaticProperties(); }
|
||||
|
||||
@@ -13,44 +13,27 @@ namespace TBF.BenchControl.Elde.PumpWithFM
|
||||
/// Parameterless constructor
|
||||
public PumpCfg()
|
||||
{
|
||||
Name = "Pump";
|
||||
ParentName = "CB";
|
||||
BitPosition = 0;
|
||||
FMIndex = 0;
|
||||
Delay = 1;
|
||||
}
|
||||
/// Constructor
|
||||
public PumpCfg(IComponentFactory factory, string name, string parentName, int bitPosition, int fmIndex, int delay)
|
||||
: base(factory, name, parentName)
|
||||
}
|
||||
|
||||
public PumpCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
this.BitPosition = bitPosition;
|
||||
this.FMIndex = fmIndex;
|
||||
this.Delay = delay;
|
||||
}
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public IComponentCfg Clone()
|
||||
{
|
||||
return new PumpCfg(Factory, Name, ParentName, BitPosition, FMIndex, Delay);
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("bit={0}, fmIdx={1}, delay={2}s", BitPosition, FMIndex, Delay);
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
PumpCfg config = (PumpCfg)(new XmlSerializer(typeof(PumpCfg))).Deserialize(reader);
|
||||
config.InitCfgBaseFromEntity(component, factory);
|
||||
return config;
|
||||
}
|
||||
}
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("Name={0}, Parent={1}, Bit={2}, FMIndex={3}, Delay={4}",
|
||||
Name,
|
||||
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
|
||||
BitPosition,
|
||||
FMIndex,
|
||||
Delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace TBF.BenchControl.Elde.PumpWithFM
|
||||
|
||||
public IComponentCfg DefaultConfig(IList<Entities.Component> components)
|
||||
{
|
||||
return new PumpCfg(this, "Pump", "CB", 0, 0, 1);
|
||||
return new PumpCfg(this);
|
||||
}
|
||||
|
||||
public IComponentCfgCtrl CreateCfgCtrl()
|
||||
@@ -34,7 +34,7 @@ namespace TBF.BenchControl.Elde.PumpWithFM
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Entities.Component component)
|
||||
{
|
||||
return PumpCfg.CreateFromDbEntity(component, this);
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(PumpCfg), component, this);
|
||||
}
|
||||
|
||||
public void ResetStaticProperties() { Pump.ResetStaticProperties(); }
|
||||
|
||||
@@ -12,49 +12,23 @@ namespace TBF.BenchControl.Elde.RegisterReader
|
||||
/// Parameterless constructor
|
||||
public RegisterReaderCfg()
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Regulation valve configuration parameters
|
||||
/// </summary>
|
||||
/// <param name="name">Regulation valve name</param>
|
||||
/// <param name="position">Position on the control board 1 .. nrWaterMeters</param>
|
||||
public RegisterReaderCfg(IComponentFactory factory, string name, string parentName, int position)
|
||||
: base(factory, name, parentName)
|
||||
Name = "Sick";
|
||||
ParentName = "CB";
|
||||
Position = 1;
|
||||
}
|
||||
|
||||
public RegisterReaderCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
if (position < 1 || position >= 2 * Program.WMsCount)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("position");
|
||||
}
|
||||
this.Position = position;
|
||||
}
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public IComponentCfg Clone()
|
||||
{
|
||||
return new RegisterReaderCfg(Factory, Name, ParentName, Position);
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("position={0}", Position);
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
RegisterReaderCfg config = (RegisterReaderCfg)(new XmlSerializer(typeof(RegisterReaderCfg))).Deserialize(reader);
|
||||
config.InitCfgBaseFromEntity(component, factory);
|
||||
return config;
|
||||
}
|
||||
}
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("Name={0}, Parent={1}, Position={2}",
|
||||
Name,
|
||||
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
|
||||
Position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace TBF.BenchControl.Elde.RegisterReader
|
||||
|
||||
public IComponentCfg DefaultConfig(IList<Entities.Component> components)
|
||||
{
|
||||
return new RegisterReaderCfg(this, "Sick", "CB", 1);
|
||||
return new RegisterReaderCfg(this);
|
||||
}
|
||||
|
||||
public IComponentCfgCtrl CreateCfgCtrl()
|
||||
@@ -27,7 +27,7 @@ namespace TBF.BenchControl.Elde.RegisterReader
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Entities.Component component)
|
||||
{
|
||||
return RegisterReaderCfg.CreateFromDbEntity(component, this);
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(RegisterReaderCfg), component, this);
|
||||
}
|
||||
|
||||
public bool HasProcedureParams { get { return true; } }
|
||||
|
||||
@@ -7,9 +7,6 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
{
|
||||
public class RegulValveCfg : ComponentCfgBase, IChildComponentCfg
|
||||
{
|
||||
///
|
||||
/// Stored parameters
|
||||
///
|
||||
public int Idx1; /// 1..7
|
||||
public int DacValueClosed; /// 0..1023
|
||||
public int DacValueOpen; /// 0..1023
|
||||
@@ -26,63 +23,35 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
/// Parameterless constructor
|
||||
public RegulValveCfg()
|
||||
{
|
||||
Name = "RegulationValve";
|
||||
ParentName = "CB";
|
||||
Idx1 = 1;
|
||||
DacValueClosed = 100;
|
||||
DacValueOpen = 500;
|
||||
PidCoef = 20;
|
||||
StableTimeMs = 500;
|
||||
StoredPositionReuse = false;
|
||||
FlowStableSec = 5;
|
||||
}
|
||||
/// <summary>
|
||||
/// Regulation valve configuration parameters
|
||||
/// </summary>
|
||||
/// <param name="name">Regulation valve name</param>
|
||||
/// <param name="idx1">Position on the control board 0..7</param>
|
||||
/// <param name="dacValueClosed">0..1023</param>
|
||||
/// <param name="dacValueOpen">0..1023</param>
|
||||
/// <param name="pidCoef">1..100</param>
|
||||
public RegulValveCfg(IComponentFactory factory, string name, string parentName, int idx1, int dacValueClosed, int dacValueOpen, int pidCoef, int stableTimeMs, bool storedPositionReuse, int flowStableSec)
|
||||
: base(factory, name, parentName)
|
||||
}
|
||||
|
||||
public RegulValveCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
if (idx1 < 1 || idx1 > 7) throw new ArgumentOutOfRangeException("position");
|
||||
if (dacValueClosed < 0 || dacValueClosed > 1023) throw new ArgumentOutOfRangeException("dacValueOpen");
|
||||
if (dacValueOpen < 0 || dacValueOpen > 1023) throw new ArgumentOutOfRangeException("dacValueOpen");
|
||||
if (pidCoef < 1 || pidCoef > 100) throw new ArgumentOutOfRangeException("pidCoef");
|
||||
|
||||
this.Idx1 = idx1;
|
||||
this.DacValueClosed = dacValueClosed;
|
||||
this.DacValueOpen = dacValueOpen;
|
||||
this.PidCoef = pidCoef;
|
||||
this.StableTimeMs = stableTimeMs;
|
||||
this.StoredPositionReuse = storedPositionReuse;
|
||||
this.FlowStableSec = flowStableSec;
|
||||
}
|
||||
|
||||
public IComponentCfg Clone()
|
||||
{
|
||||
return new RegulValveCfg(Factory, Name, ParentName, Idx1, DacValueClosed, DacValueOpen, PidCoef, StableTimeMs, StoredPositionReuse, FlowStableSec);
|
||||
}
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("idx1={0}, DA-closed={1}, DA-open={2}, PID={3}, stabT={4}ms, posReuse={5}, flowStable={6}s",
|
||||
Idx1, DacValueClosed, DacValueOpen, PidCoef, StableTimeMs, StoredPositionReuse, FlowStableSec);
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
RegulValveCfg config = (RegulValveCfg)(new XmlSerializer(typeof(RegulValveCfg))).Deserialize(reader);
|
||||
config.InitCfgBaseFromEntity(component, factory);
|
||||
return config;
|
||||
}
|
||||
return string.Format("Name={0}, Parent={1}, Idx1={2}, ADC-Closed={3}, ADC-Open={4}, PID={5}, StabTm={6}ms, PosReuse={7}, FlowStable={8}s",
|
||||
Name,
|
||||
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
|
||||
Idx1,
|
||||
DacValueClosed,
|
||||
DacValueOpen,
|
||||
PidCoef,
|
||||
StableTimeMs,
|
||||
StoredPositionReuse,
|
||||
FlowStableSec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
|
||||
public IComponentCfg DefaultConfig(IList<Entities.Component> components)
|
||||
{
|
||||
return new RegulValveCfg(this, "RegulationValve", "CB", 1, 100, 500, 20, 500, false, 5);
|
||||
return new RegulValveCfg(this);
|
||||
}
|
||||
|
||||
public IComponentCfgCtrl CreateCfgCtrl()
|
||||
@@ -31,7 +31,7 @@ namespace TBF.BenchControl.Elde.RegulValve
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Entities.Component component)
|
||||
{
|
||||
return RegulValveCfg.CreateFromDbEntity(component, this);
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(RegulValveCfg), component, this);
|
||||
}
|
||||
|
||||
public void ResetStaticProperties() { RegulValve.ResetStaticProperties(); }
|
||||
|
||||
@@ -18,61 +18,29 @@ namespace TBF.BenchControl.Elde.TempMeter
|
||||
/// Parameterless constructor
|
||||
public TempMeterCfg()
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Temperature meter configuration parameters
|
||||
/// </summary>
|
||||
/// <param name="name">Temperature meter name</param>
|
||||
/// <param name="idx0">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 idx0, float a1, float a2, float a3, float a4, float a5)
|
||||
: base(factory, name, parentName)
|
||||
{
|
||||
if (idx0 < 0 || idx0 > 7) throw new ArgumentOutOfRangeException("position");
|
||||
this.Idx0 = idx0;
|
||||
Name = "TempMeter";
|
||||
ParentName = "CB";
|
||||
Idx0 = 0;
|
||||
A1 = 0;
|
||||
A2 = 0;
|
||||
A3 = 0;
|
||||
A4 = 0;
|
||||
A5 = 0;
|
||||
}
|
||||
|
||||
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 TempMeterCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public IComponentCfg Clone()
|
||||
{
|
||||
return new TempMeterCfg(Factory, Name, ParentName, Idx0, A1, A2, A3, A4, A5);
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("idx0={0}, A1={1}, A2={2}, A3={3}, A4={4}, A5={5}", Idx0, 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;
|
||||
}
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("Name={0}, Parent={1}, Idx0={2}, A1={3}, A2={4}, A3={5}, A4={6}, A5={7}",
|
||||
Name,
|
||||
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
|
||||
Idx0,
|
||||
A1, A2, A3, A4, A5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace TBF.BenchControl.Elde.TempMeter
|
||||
|
||||
public IComponentCfg DefaultConfig(IList<Entities.Component> components)
|
||||
{
|
||||
return new TempMeterCfg(this, "TempMeter", "CB", 0);
|
||||
return new TempMeterCfg(this);
|
||||
}
|
||||
|
||||
public IComponentCfgCtrl CreateCfgCtrl()
|
||||
@@ -31,7 +31,7 @@ namespace TBF.BenchControl.Elde.TempMeter
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Entities.Component component)
|
||||
{
|
||||
return TempMeterCfg.CreateFromDbEntity(component, this);
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(TempMeterCfg), component, this);
|
||||
}
|
||||
|
||||
public void ResetStaticProperties() { TempMeter.ResetStaticProperties(); }
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace TBF.BenchControl.Elde.Valve
|
||||
{
|
||||
public class ValveCfg : ComponentCfgBase, IChildComponentCfg
|
||||
{
|
||||
public int OpenCloseTime; /// Delay for SetValvesOp operations
|
||||
public int BitPosition; /// Bit-position
|
||||
public ValveCategory Category; /// None, Feeding, Bench or Output
|
||||
public int OpenCloseTime; /// Delay for SetValvesOp operations
|
||||
public bool Inverted; /// The valve is inverted: 0=open, 1=closed
|
||||
///
|
||||
public string CoupledToName; /// Name of the coupled valve or null
|
||||
@@ -20,65 +20,37 @@ namespace TBF.BenchControl.Elde.Valve
|
||||
/// Parameterless constructor
|
||||
public ValveCfg()
|
||||
{
|
||||
OpenCloseTime = 1; /// Defaut value
|
||||
}
|
||||
/// Constructor 1
|
||||
public ValveCfg(IComponentFactory factory, string name, string parentName, int bitPosition, bool inverted, int openCloseTime,
|
||||
ValveCategory category, string coupledToName, bool invertCouple, int lagOpening, int lagClosing)
|
||||
: base(factory, name, parentName)
|
||||
{
|
||||
this.OpenCloseTime = openCloseTime;
|
||||
this.BitPosition = bitPosition;
|
||||
this.Category = category;
|
||||
this.Inverted = inverted;
|
||||
Name = "V";
|
||||
ParentName = "CB";
|
||||
BitPosition = 0;
|
||||
Category = ValveCategory.None;
|
||||
OpenCloseTime = 1;
|
||||
Inverted = false;
|
||||
CoupledToName = string.Empty;
|
||||
InvertCouple = false;
|
||||
LagOpening = 0;
|
||||
LagClosing = 0;
|
||||
}
|
||||
|
||||
this.CoupledToName = coupledToName;
|
||||
this.InvertCouple = invertCouple;
|
||||
this.LagOpening = lagOpening;
|
||||
this.LagClosing = lagClosing;
|
||||
}
|
||||
/// Constructor 2 without CoupledTo valve
|
||||
public ValveCfg(IComponentFactory factory, string name, string parentName, int bitPosition, bool inverted, int openCloseTime, ValveCategory category)
|
||||
: this(factory, name, parentName, bitPosition, inverted, openCloseTime, category, null, false, 0, 0)
|
||||
{
|
||||
}
|
||||
|
||||
public IComponentCfg Clone()
|
||||
{
|
||||
return new ValveCfg(Factory, Name, ParentName, BitPosition, Inverted, OpenCloseTime, Category, CoupledToName, InvertCouple, LagOpening, LagClosing);
|
||||
}
|
||||
public ValveCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("bit={0}, inv.={1}, delay={2}s, cat.={3}, coupledTo={4}, inv.Couple={5}, lagOpen={6}s, lagClose={7}s",
|
||||
return string.Format("Name={0}, Parent={1}, Bit={2}, Inv.={3}, Delay={4}s, Cat.={5}, CoupledTo={6}, Inv.Couple={7}, LagOpen={8}s, LagClose={9}s",
|
||||
Name,
|
||||
string.IsNullOrEmpty(ParentName) ? "-" : ParentName,
|
||||
BitPosition,
|
||||
(Inverted ? "yes" : "no"),
|
||||
Inverted ? "yes" : "no",
|
||||
OpenCloseTime,
|
||||
Category,
|
||||
(string.IsNullOrEmpty(CoupledToName) ? "---" : CoupledToName),
|
||||
(InvertCouple ? "yes" : "no"),
|
||||
string.IsNullOrEmpty(CoupledToName) ? "-" : CoupledToName,
|
||||
InvertCouple ? "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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace TBF.BenchControl.Elde.Valve
|
||||
|
||||
public IComponentCfg DefaultConfig(IList<Entities.Component> components)
|
||||
{
|
||||
return new ValveCfg(this, "Valve", "CB", 0, false, 1, ValveCategory.None);
|
||||
return new ValveCfg(this);
|
||||
}
|
||||
|
||||
public IComponentCfgCtrl CreateCfgCtrl()
|
||||
@@ -31,7 +31,7 @@ namespace TBF.BenchControl.Elde.Valve
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Entities.Component component)
|
||||
{
|
||||
return ValveCfg.CreateFromDbEntity(component, this);
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(ValveCfg), component, this);
|
||||
}
|
||||
|
||||
public void ResetStaticProperties() { Valve.ResetStaticProperties(); }
|
||||
|
||||
Reference in New Issue
Block a user