Modbus logging with child component names, ver. 3.1.1606

This commit is contained in:
Milan Hanajik
2021-04-09 16:29:24 +02:00
parent f33bc4f167
commit 9724e8779a
16 changed files with 183 additions and 164 deletions
+7 -8
View File
@@ -58,7 +58,7 @@ namespace TBF.Rig.Modbus.Ambient.Comet
}
}
readonly Common.Modbus modbus;
Common.Modbus modbus;
///
/// Measured values when MsrmntState == MsrmntState.Valid
@@ -83,21 +83,20 @@ namespace TBF.Rig.Modbus.Ambient.Comet
: base(cfg)
{
ambientCfg = cfg as AmbientCfg;
modbus = TbfComponents.FindComponent(cfg.ParentName, components) as Common.Modbus;
if (modbus == null) throw new Exception("Cannot find " + Name + " parent");
log.Warn(this.ToString());
}
public override void Initialize()
{
modbus = TbfComponents.FindComponent(ambientCfg.ParentName) as Common.Modbus;
if (modbus == null) throw new Exception("Cannot find " + Name + " parent");
temperature = DefaultTemperature;
pressure = DefaultPressure;
humidity = DefaultHumidity;
msrmntTimeStamp = 0;
modbus.ComponentNames[ambientCfg.ModbusAddress] = Name;
ticketNumber = modbus.RegisterForPolling();
log.FatalFormat("{0} - Device successfully initialized", Name);
log.FatalFormat("{0} initialized: {1}", Name, this);
}
/// <summary>Run this device</summary>
@@ -144,7 +143,7 @@ namespace TBF.Rig.Modbus.Ambient.Comet
msg[4] = (byte)(count >> 8); /// Serial Com Reference Hi
msg[5] = (byte)(count & 0xFF); /// Serial Com Reference Lo
modbus.SendMessage(msg);
modbus.SendMessage(msg, Name);
}
}