diff --git a/Modules/Mainframe/PMs/PMModuleDevice.cs b/Modules/Mainframe/PMs/PMModuleDevice.cs index 665a8b6..36f2a65 100644 --- a/Modules/Mainframe/PMs/PMModuleDevice.cs +++ b/Modules/Mainframe/PMs/PMModuleDevice.cs @@ -580,7 +580,7 @@ namespace SicModules.PMs public void InitDevice() { - if (IsInstalled) + if (IsInstalled) // 如果未安装,不要初始化Module中的Device,以免触发不必要的报警 { if (SC.GetValue("System.IsSimulatorMode")) { @@ -594,40 +594,42 @@ namespace SicModules.PMs (Plc as SicAds).Initialize(); } - } - if (Plc != null) - { - Plc.OnDeviceAlarmStateChanged += OnModuleDeviceAlarmStateChanged; - Plc.OnConnected += PlcConnected; - Plc.OnDisconnected += PlcDisconnected; - _allModuleDevice.Add(Plc); - } - - _isTagAttribute = attribute => attribute is TagAttribute; - _hasTagAttribute = mi => mi.GetCustomAttributes(false).Any(_isTagAttribute); - Parallel.ForEach(this.GetType().GetProperties().Where(_hasTagAttribute), - field => + if (Plc != null) { - TagAttribute tag = field.GetCustomAttributes(false).First(_isTagAttribute) as TagAttribute; - IDevice device = DEVICE.GetDevice($"{Module}.{tag.Tag}"); - device.OnDeviceAlarmStateChanged += OnModuleDeviceAlarmStateChanged; + Plc.OnDeviceAlarmStateChanged += OnModuleDeviceAlarmStateChanged; + Plc.OnConnected += PlcConnected; + Plc.OnDisconnected += PlcDisconnected; - _allModuleDevice.Add(device); + _allModuleDevice.Add(Plc); + } - PropertyInfo pi = (PropertyInfo)field; + _isTagAttribute = attribute => attribute is TagAttribute; + _hasTagAttribute = mi => mi.GetCustomAttributes(false).Any(_isTagAttribute); + Parallel.ForEach(this.GetType().GetProperties().Where(_hasTagAttribute), + field => + { + TagAttribute tag = field.GetCustomAttributes(false).First(_isTagAttribute) as TagAttribute; + IDevice device = DEVICE.GetDevice($"{Module}.{tag.Tag}"); + device.OnDeviceAlarmStateChanged += OnModuleDeviceAlarmStateChanged; - var convertedValue = Convert.ChangeType(device, pi.PropertyType); + _allModuleDevice.Add(device); - System.Diagnostics.Debug.Assert(convertedValue != null); + PropertyInfo pi = (PropertyInfo)field; - pi.SetValue(this, convertedValue); - }); + var convertedValue = Convert.ChangeType(device, pi.PropertyType); - if (_pmInterLock == null) - { - _pmInterLock = DEVICE.GetDevice($"{Module}.PMInterLock"); + System.Diagnostics.Debug.Assert(convertedValue != null); + + pi.SetValue(this, convertedValue); + }); + + + if (_pmInterLock == null) + { + _pmInterLock = DEVICE.GetDevice($"{Module}.PMInterLock"); + } } } diff --git a/ThirdParty/MECF.Framework/MECF.Framework.Common.dll b/ThirdParty/MECF.Framework/MECF.Framework.Common.dll index ac325e6..a8a28ac 100644 Binary files a/ThirdParty/MECF.Framework/MECF.Framework.Common.dll and b/ThirdParty/MECF.Framework/MECF.Framework.Common.dll differ diff --git a/ThirdParty/MECF.Framework/MECF.Framework.RT.EquipmentLibrary.dll b/ThirdParty/MECF.Framework/MECF.Framework.RT.EquipmentLibrary.dll index cd3e3cb..11c4657 100644 Binary files a/ThirdParty/MECF.Framework/MECF.Framework.RT.EquipmentLibrary.dll and b/ThirdParty/MECF.Framework/MECF.Framework.RT.EquipmentLibrary.dll differ diff --git a/ThirdParty/MECF.Framework/MECF.Framework.UI.Client.dll b/ThirdParty/MECF.Framework/MECF.Framework.UI.Client.dll index 7993966..79ae487 100644 Binary files a/ThirdParty/MECF.Framework/MECF.Framework.UI.Client.dll and b/ThirdParty/MECF.Framework/MECF.Framework.UI.Client.dll differ