修正PM未安装时,仍然会触发报警的问题。
This commit is contained in:
parent
c89c1ca41b
commit
70e11bc6b0
|
@ -580,7 +580,7 @@ namespace SicModules.PMs
|
||||||
|
|
||||||
public void InitDevice()
|
public void InitDevice()
|
||||||
{
|
{
|
||||||
if (IsInstalled)
|
if (IsInstalled) // 如果未安装,不要初始化Module中的Device,以免触发不必要的报警
|
||||||
{
|
{
|
||||||
if (SC.GetValue<bool>("System.IsSimulatorMode"))
|
if (SC.GetValue<bool>("System.IsSimulatorMode"))
|
||||||
{
|
{
|
||||||
|
@ -594,40 +594,42 @@ namespace SicModules.PMs
|
||||||
|
|
||||||
(Plc as SicAds).Initialize();
|
(Plc as SicAds).Initialize();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (Plc != null)
|
|
||||||
{
|
|
||||||
Plc.OnDeviceAlarmStateChanged += OnModuleDeviceAlarmStateChanged;
|
|
||||||
Plc.OnConnected += PlcConnected;
|
|
||||||
Plc.OnDisconnected += PlcDisconnected;
|
|
||||||
|
|
||||||
_allModuleDevice.Add(Plc);
|
if (Plc != null)
|
||||||
}
|
|
||||||
|
|
||||||
_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;
|
Plc.OnDeviceAlarmStateChanged += OnModuleDeviceAlarmStateChanged;
|
||||||
IDevice device = DEVICE.GetDevice<IDevice>($"{Module}.{tag.Tag}");
|
Plc.OnConnected += PlcConnected;
|
||||||
device.OnDeviceAlarmStateChanged += OnModuleDeviceAlarmStateChanged;
|
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<IDevice>($"{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)
|
System.Diagnostics.Debug.Assert(convertedValue != null);
|
||||||
{
|
|
||||||
_pmInterLock = DEVICE.GetDevice<IoInterLock>($"{Module}.PMInterLock");
|
pi.SetValue(this, convertedValue);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (_pmInterLock == null)
|
||||||
|
{
|
||||||
|
_pmInterLock = DEVICE.GetDevice<IoInterLock>($"{Module}.PMInterLock");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue