Components Initialize() rewritten, double StartChangeHandler() calls avoided, ToString() methods are equl, use ClassName.
This commit is contained in:
@@ -13,7 +13,7 @@ namespace TBF.BenchControl.Modbus.Novus
|
||||
public class Novus : ComponentBase, IDevice, GenericDevices.ITempMeter
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(Novus));
|
||||
public override string ToString() { return string.Format("Novus({0})", Cfg.ToString(1)); }
|
||||
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
|
||||
|
||||
const ushort SetpointAddress = 0; /// Temperature setpoint
|
||||
const ushort ProcessValueAddress = 1; /// Actual temperature
|
||||
@@ -27,9 +27,8 @@ namespace TBF.BenchControl.Modbus.Novus
|
||||
|
||||
public float requiredTemp { get { return novusCfg.ProcParams.RequiredTemp; } }
|
||||
|
||||
public Novus()
|
||||
{
|
||||
}
|
||||
|
||||
public Novus() { }
|
||||
|
||||
public Novus(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
|
||||
: base(cfg)
|
||||
@@ -38,26 +37,27 @@ namespace TBF.BenchControl.Modbus.Novus
|
||||
|
||||
modbus = (GenericDevices.IModbus)TbfComponents.FindComponent(cfg.ParentName, components);
|
||||
if (modbus == null) throw new Exception("Cannot find " + Name + " parent");
|
||||
|
||||
log.Warn(this.ToString());
|
||||
}
|
||||
|
||||
/// <summary>Initialize this device</summary>
|
||||
public void Initialize()
|
||||
public override void Initialize()
|
||||
{
|
||||
if (novusCfg.DebugLevel == DebugMode.Simulate) return;
|
||||
|
||||
temperatureSetPointValid = false;
|
||||
temperatureSetPointRequested = false;
|
||||
actualTemperatureIsValid = false;
|
||||
|
||||
if (novusCfg.DebugLevel == DebugMode.Simulate)
|
||||
log.FatalFormat("{0} simulated: {1}", Name, this);
|
||||
else
|
||||
log.FatalFormat("{0} initialized: {1}", Name, this);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>Run this device</summary>
|
||||
public void RunDeviceBefore()
|
||||
{
|
||||
if (novusCfg.DebugLevel == DebugMode.Simulate) return;
|
||||
|
||||
|
||||
if (modbus.ReceivedTelegrams[novusCfg.ModbusAddress].Count > 0)
|
||||
{
|
||||
byte[] telegram = modbus.ReceivedTelegrams[novusCfg.ModbusAddress].Dequeue();
|
||||
@@ -91,16 +91,21 @@ namespace TBF.BenchControl.Modbus.Novus
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>Run this device</summary>
|
||||
public void RunDeviceAfter()
|
||||
{
|
||||
if (novusCfg.DebugLevel == DebugMode.Simulate) return;
|
||||
|
||||
if (!temperatureSetPointValid && !temperatureSetPointRequested)
|
||||
{
|
||||
RequestTemperatureSetpoint();
|
||||
{
|
||||
RequestTemperatureSetpoint();
|
||||
temperatureSetPointRequested = true;
|
||||
}
|
||||
else if (temperatureSetPointValid && requiredTemp != temperatureSetPoint)
|
||||
{
|
||||
SetTemperatureSetpoint(requiredTemp);
|
||||
}
|
||||
else if (temperatureSetPointValid && requiredTemp != temperatureSetPoint)
|
||||
{
|
||||
SetTemperatureSetpoint(requiredTemp);
|
||||
log.InfoFormat("{0} - Set new temperature setpoint = {1}", Name, requiredTemp);
|
||||
}
|
||||
else if ((StateMachine.Time % 10) == (novusCfg.ModbusAddress % 10)) /// This is to prevent overflow of the Modbus component queue for sending data
|
||||
@@ -109,7 +114,6 @@ namespace TBF.BenchControl.Modbus.Novus
|
||||
}
|
||||
}
|
||||
|
||||
public void RunDeviceAfter() { }
|
||||
public void StopDevice() { }
|
||||
public void StopDevice2() { }
|
||||
|
||||
@@ -178,7 +182,6 @@ namespace TBF.BenchControl.Modbus.Novus
|
||||
}
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// Operations, etc.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user