Initialization of 30 components changed, done in Initialize( ).

This commit is contained in:
Milan Hanajik
2021-04-03 00:54:27 +02:00
parent cb1a66381f
commit a58fe1f997
30 changed files with 347 additions and 445 deletions
@@ -17,10 +17,7 @@ namespace TBF.Rig.Modbus.UltrasoundLevelMeter
public override string ToString() { return string.Format("LevelMeter({0})", Cfg.ToString(-1)); }
readonly LevelMeterCfg myCfg;
readonly GenericDevices.IModbus modbus;
/// <summary>The state of the measurement</summary>
MsrmntState msrmntState;
readonly Common.Modbus modbus;
///
/// Measured values when MsrmntState == MsrmntState.Valid
@@ -46,17 +43,14 @@ namespace TBF.Rig.Modbus.UltrasoundLevelMeter
{
myCfg = cfg as LevelMeterCfg;
modbus = (GenericDevices.IModbus)TbfComponents.FindComponent(cfg.ParentName, components);
modbus = TbfComponents.FindComponent(cfg.ParentName, components) as Common.Modbus;
if (modbus == null) throw new Exception("Cannot find " + Name + " parent");
/// Connect to handler
//ModbusAddress.MeretRS485Address[Idx0] = ModbusAddress;
log.Warn(this.ToString());
}
/// <summary>Initialize this device</summary>
public void Initialize()
public override void Initialize()
{
if (myCfg.DebugLevel == DebugMode.Simulate)
{
@@ -67,14 +61,13 @@ namespace TBF.Rig.Modbus.UltrasoundLevelMeter
state = 0;
msrmntTimeStamp = StateMachine.Time;
msrmntState = MsrmntState.Valid;
return;
log.FatalFormat("{0} - Device simulated", Name);
}
else
{
ticketNumber = modbus.RegisterForPolling();
log.FatalFormat("{0} - Device successfully initialized", Name);
}
msrmntState = MsrmntState.Busy;
ticketNumber = modbus.RegisterForPolling();
log.FatalFormat("Successfully initialized device {0}", ToString());
}