Everything works OK after serious changes:

- all components, componentCfg-s and parameter providers use base classes
 - less boilerplate code, simpler access to test/procedure parameters from code
 - CreateTestParams(test), CreateProcedureParams(procedure) methods added
 - TestBenchSim class is made static, it is not inheritted by any device anymore
This commit is contained in:
Milan Hanajik
2015-01-02 12:51:27 +01:00
parent 752719bd62
commit 94de991bf6
126 changed files with 1117 additions and 1629 deletions
@@ -5,32 +5,22 @@ using TBF.BenchControl.GenericDevices;
namespace TBF.BenchControl.Elde.Valve
{
public class Valve : GenericDevices.ValveBase, Generic.IComponent, IValve
public class Valve : GenericDevices.ValveBase, IValve
{
/// <summary>
/// Info: StartMassMeasurement() and "Balance response = .., Mass = ..."
/// Warn: Start measurement when busy is true
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(Valve));
public override string ToString()
{
return string.Format("Valve({0},{1},{2})", Name, bitPosition, (CoupledTo != null ? CoupledTo.Cfg.Name : "-"));
}
public static void ResetStaticProperties() { }
public override string ToString() { return string.Format("Valve({0})", Cfg.ToString(1)); }
readonly ValveCfg valveCfg;
public Generic.IComponentCfg Cfg { get { return valveCfg; } }
readonly IValve coupledTo;
readonly ControlBoardDev controlBoard;
readonly int bitPosition; /// 0 .. 63
public string Name { get { return valveCfg.Name; } }
public ValveCategory Category { get { return valveCfg.Category; } }
public int Delay { get { return valveCfg.OpenCloseTime; } }
public bool Inverted { get { return valveCfg.Inverted; } }
public IValve CoupledTo { get { return coupledTo; } }
readonly IValve coupledTo;
public bool InvertCouple { get { return valveCfg.InvertCouple; } }
public int LagOpening { get { return valveCfg.LagOpening; } }
public int LagClosing { get { return valveCfg.LagClosing; } }
@@ -39,20 +29,22 @@ namespace TBF.BenchControl.Elde.Valve
public Valve(ValveCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
if (cfg == null) throw new ArgumentNullException("cfg");
this.valveCfg = cfg;
valveCfg = cfg;
controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
if (bitPosition < 0 || bitPosition >= 64) throw new ArgumentOutOfRangeException("position");
this.bitPosition = cfg.BitPosition;
this.Mask = (((ulong)1) << bitPosition);
if (valveCfg.BitPosition < 0 || valveCfg.BitPosition >= 64)
{
throw new ArgumentOutOfRangeException("position");
}
this.Mask = (((ulong)1) << valveCfg.BitPosition);
if (cfg.CoupledToName != null)
{
this.coupledTo = (IValve)TbfComponents.FindComponent(cfg.CoupledToName, components);
coupledTo = (IValve)TbfComponents.FindComponent(cfg.CoupledToName, components);
}
log.Debug(this.ToString());
@@ -17,8 +17,8 @@ namespace TBF.BenchControl.Elde.Valve
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()
/// Private parameterless constructor invoked by all other (public) constructors
ValveCfg()
{
Name = "V";
ParentName = "CB";
@@ -6,10 +6,6 @@ namespace TBF.BenchControl.Elde.Valve
public class ValveFactory : IComponentFactory
{
public string ClassName { get { return "Valve"; } }
public bool HasProcedureParams { get { return false; } }
public bool HasTestParams { get { return false; } }
public IParamsProvider GetTestParams(Entities.ComponentTest testParams) { return null; }
public IParamsProvider GetProcedureParams(Entities.ComponentProcedure procedureParams) { return null; }
/// <summary>Max. number of components of this class in the system</summary>
public int MaxCount { get { return int.MaxValue; } }