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
+10 -16
View File
@@ -17,7 +17,8 @@ namespace TBF.Rig.Modbus.WaterAnalyzer
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
readonly AnalyzerCfg myCfg;
readonly Common.Modbus modbus;
Common.Modbus modbus;
///
/// Measured values when MsrmntState == MsrmntState.Valid
@@ -39,28 +40,21 @@ namespace TBF.Rig.Modbus.WaterAnalyzer
: base(cfg)
{
myCfg = cfg as AnalyzerCfg;
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()
{
if (myCfg.DebugLevel == DebugMode.Simulate)
{
conductivity = 0.0F;
temperature = 0.0;
modbus = TbfComponents.FindComponent(myCfg.ParentName) as Common.Modbus;
if (modbus == null) throw new Exception("Cannot find " + Name + " parent");
msrmntTimeStamp = StateMachine.Time;
return;
}
conductivity = 0.0F;
temperature = 0.0;
msrmntTimeStamp = 0;
modbus.ComponentNames[myCfg.ModbusAddress] = Name;
ticketNumber = modbus.RegisterForPolling();
log.FatalFormat("Successfully initialized device {0}", ToString());
log.FatalFormat("{0} initialized: {1}", Name, this);
}
@@ -123,7 +117,7 @@ namespace TBF.Rig.Modbus.WaterAnalyzer
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);
}
}