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:
@@ -13,20 +13,12 @@ namespace TBF.BenchControl.Greco
|
||||
/// Ambient temperature / humidity / pressure meter 'Greco' connected via serial interface (RS232)
|
||||
/// Connection settings: 19200 Bd 8-bits No-parity 1-stop-bit Flow control: none or hardware.
|
||||
/// </summary>
|
||||
public class Ambient : TestBenchSim, IComponent, IDevice, IOperation, GenericDevices.IAmbient
|
||||
public class Ambient : ComponentBase, IDevice, IOperation, GenericDevices.IAmbient
|
||||
{
|
||||
/// <summary>
|
||||
/// Info: Successful measurement
|
||||
/// Warn: Invalid serial response format
|
||||
/// </summary>
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(Ambient));
|
||||
|
||||
public static void ResetStaticProperties() { }
|
||||
public override string ToString() { return string.Format("Ambient({0})", Cfg.ToString(1)); }
|
||||
|
||||
private readonly AmbientCfg ambientCfg;
|
||||
public Generic.IComponentCfg Cfg { get { return ambientCfg; } }
|
||||
|
||||
public string Name { get { return ambientCfg.Name; } }
|
||||
|
||||
/// Private fields
|
||||
SerialPort serialPort;
|
||||
@@ -52,12 +44,13 @@ namespace TBF.BenchControl.Greco
|
||||
/// Connection settings: 19200 Bd 8-bits No-parity 1-stop-bit Flow control: none or hardware.
|
||||
/// </summary>
|
||||
public Ambient(AmbientCfg cfg, IList<Generic.IComponent> components)
|
||||
: base(cfg)
|
||||
{
|
||||
if (cfg == null) throw new ArgumentNullException("cfg");
|
||||
this.ambientCfg = cfg;
|
||||
ambientCfg = cfg;
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
public new void Initialize()
|
||||
public void Initialize()
|
||||
{
|
||||
if (ambientCfg.DebugLevel == Entities.DebugMode.Simulate)
|
||||
{
|
||||
@@ -65,7 +58,7 @@ namespace TBF.BenchControl.Greco
|
||||
humidity = 40.0f;
|
||||
pressure = 1.0f;
|
||||
msrmntTimeStamp = StateMachine.Time;
|
||||
msrmntState = BenchControl.MsrmntState.Valid;
|
||||
msrmntState = MsrmntState.Valid;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ namespace TBF.BenchControl.Greco
|
||||
public StopBits StopBits;
|
||||
public Handshake Handshake;
|
||||
|
||||
/// Parameterless constructor
|
||||
public AmbientCfg()
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
AmbientCfg()
|
||||
{
|
||||
Name = "Ambient";
|
||||
ParentName = string.Empty;
|
||||
@@ -35,7 +35,7 @@ namespace TBF.BenchControl.Greco
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("Name={0}, COM{1}, {2}Bd, {3}-bits, parity={4}, stopBits={5}, {6}",
|
||||
return string.Format("Name={0}, Com{1}, {2}Bd, {3}-bits, parity={4}, stopBits={5}, {6}",
|
||||
Name, ComPortNr, BaudRate, DataBits, Parity, StopBits, Handshake);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,6 @@ namespace TBF.BenchControl.Greco
|
||||
public class AmbientFactory : IComponentFactory
|
||||
{
|
||||
public string ClassName { get { return "Greco Ambient"; } }
|
||||
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 1; } }
|
||||
|
||||
Reference in New Issue
Block a user