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
@@ -17,7 +17,8 @@ namespace TBF.Rig.Modbus.UltrasoundLevelMeter
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
readonly LevelMeterCfg myCfg;
readonly Common.Modbus modbus;
Common.Modbus modbus;
///
/// Measured values when MsrmntState == MsrmntState.Valid
@@ -42,16 +43,14 @@ namespace TBF.Rig.Modbus.UltrasoundLevelMeter
: base(cfg)
{
myCfg = cfg as LevelMeterCfg;
modbus = TbfComponents.FindComponent(cfg.ParentName, components) as Common.Modbus;
if (modbus == null) throw new Exception("Cannot find " + Name + " parent");
log.Warn(this.ToString());
}
/// <summary>Initialize this device</summary>
public override void Initialize()
{
modbus = TbfComponents.FindComponent(myCfg.ParentName) as Common.Modbus;
if (modbus == null) throw new Exception("Cannot find " + Name + " parent");
if (myCfg.DebugLevel == DebugMode.Simulate)
{
distance = 200.0;
@@ -61,12 +60,12 @@ namespace TBF.Rig.Modbus.UltrasoundLevelMeter
state = 0;
msrmntTimeStamp = StateMachine.Time;
log.FatalFormat("{0} - Device simulated", Name);
log.FatalFormat("{0} simulated: {1}", Name, this);
}
else
{
ticketNumber = modbus.RegisterForPolling();
log.FatalFormat("{0} - Device successfully initialized", Name);
log.FatalFormat("{0} initialized: {1}", Name, this);
}
}
@@ -140,7 +139,7 @@ namespace TBF.Rig.Modbus.UltrasoundLevelMeter
msg[3] = (byte)(regAddr & 0xFF); /// Control Word Lo
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);
/////
///// Read STATUS1