Boilerplate code reduced from factories, GetComponent() and GetControl() added to cfg-s
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.Xml.Serialization;
|
||||
using TBF.BenchControl.Generic;
|
||||
@@ -7,6 +8,16 @@ namespace TBF.BenchControl.MettlerToledo
|
||||
{
|
||||
public class BalanceCfg : ComponentCfgBase, Generic.IComponentCfg
|
||||
{
|
||||
public IComponent GetComponent(IList<IComponent> components)
|
||||
{
|
||||
if (Factory.ClassName.Equals("MettlerToledo Balance")) return new BalanceDev(this);
|
||||
else return new BalanceNewDev(this);
|
||||
}
|
||||
public IComponentCfgCtrl GetControl() { return new BalanceCfgCtrl(); }
|
||||
|
||||
///
|
||||
/// Serialized parameters
|
||||
///
|
||||
public int ComPortNr;
|
||||
public int BaudRate;
|
||||
public Parity Parity;
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace TBF.BenchControl.MettlerToledo
|
||||
/// </summary>
|
||||
/// <param name="cfg">Balance properties</param>
|
||||
/// <param components="cfg">A list of components loaded so far</param>
|
||||
public BalanceDev(BalanceCfg cfg, IList<Generic.IComponent> components)
|
||||
public BalanceDev(BalanceCfg cfg)
|
||||
: base(cfg)
|
||||
{
|
||||
balanceCfg = cfg;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace TBF.BenchControl.MettlerToledo
|
||||
/// <summary>Max. number of components of this class in the system</summary>
|
||||
public int MaxCount { get { return 5; } }
|
||||
|
||||
public IComponentCfg DefaultConfig(IList<Entities.Component> components)
|
||||
public IComponentCfg DefaultConfig()
|
||||
{
|
||||
return new BalanceCfg(this);
|
||||
}
|
||||
@@ -22,7 +22,7 @@ namespace TBF.BenchControl.MettlerToledo
|
||||
|
||||
public IComponent ComponentFromCmpntCfg(IComponentCfg config, IList<Generic.IComponent> components)
|
||||
{
|
||||
return new BalanceDev((BalanceCfg)config, components);
|
||||
return new BalanceDev((BalanceCfg)config);
|
||||
}
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Entities.Component component)
|
||||
|
||||
@@ -27,8 +27,8 @@ namespace TBF.BenchControl.MettlerToledo
|
||||
public string SerialNumber { get { return serialNumber; } }
|
||||
string serialNumber;
|
||||
|
||||
public BalanceNewDev(BalanceCfg cfg, IList<Generic.IComponent> components)
|
||||
: base(cfg, components)
|
||||
public BalanceNewDev(BalanceCfg cfg)
|
||||
: base(cfg)
|
||||
{
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace TBF.BenchControl.MettlerToledo
|
||||
/// <summary>Max. number of components of this class in the system</summary>
|
||||
public int MaxCount { get { return 5; } }
|
||||
|
||||
public IComponentCfg DefaultConfig(IList<Entities.Component> components)
|
||||
public IComponentCfg DefaultConfig()
|
||||
{
|
||||
return new BalanceCfg(this);
|
||||
}
|
||||
@@ -22,7 +22,7 @@ namespace TBF.BenchControl.MettlerToledo
|
||||
|
||||
public IComponent ComponentFromCmpntCfg(IComponentCfg config, IList<Generic.IComponent> components)
|
||||
{
|
||||
return new BalanceNewDev((BalanceCfg)config, components);
|
||||
return new BalanceNewDev((BalanceCfg)config);
|
||||
}
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Entities.Component component)
|
||||
|
||||
Reference in New Issue
Block a user