From 86af260ad6ecf122e452442bd1767256c5b203d1 Mon Sep 17 00:00:00 2001 From: "DESKTOP-OKMOOJ9\\MK" <123@123.com> Date: Wed, 30 Aug 2023 23:06:49 +0800 Subject: [PATCH] =?UTF-8?q?[Common]=20InterlockManagerBase=E7=9A=84Initial?= =?UTF-8?q?ize()=E6=96=B9=E6=B3=95=E6=96=B0=E5=A2=9E=E5=AF=B9=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E7=9A=84Action=E8=8A=82=E7=82=B9ign?= =?UTF-8?q?oreReverse=E5=B1=9E=E6=80=A7=E7=9A=84=E6=94=AF=E6=8C=81?= =?UTF-8?q?=EF=BC=8C=E5=85=81=E8=AE=B8=E5=B0=86Action=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E4=B8=BA=E5=BF=BD=E7=95=A5Limit=E5=91=BD=E4=B8=AD=E5=90=8E?= =?UTF-8?q?=E7=BF=BB=E8=BD=AC=E7=94=B5=E5=B9=B3=E5=8A=A8=E4=BD=9C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Interlock/Actions/InterlockAction.cs | 14 ++++++----- .../IOCore/Interlock/InterlockManagerBase.cs | 24 ++++++++++++++----- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/MECF.Framework.Common/Aitex/Core/RT/IOCore/Interlock/Actions/InterlockAction.cs b/MECF.Framework.Common/Aitex/Core/RT/IOCore/Interlock/Actions/InterlockAction.cs index 318b794..b2fa7b9 100644 --- a/MECF.Framework.Common/Aitex/Core/RT/IOCore/Interlock/Actions/InterlockAction.cs +++ b/MECF.Framework.Common/Aitex/Core/RT/IOCore/Interlock/Actions/InterlockAction.cs @@ -34,11 +34,13 @@ namespace Aitex.Core.RT.IOCore.Interlock.Actions return true; } - #endregion + public override void Monitor() + { + throw new System.NotSupportedException(); + } - public override void Monitor() - { - throw new System.NotSupportedException(); - } - } + #endregion + + + } } diff --git a/MECF.Framework.Common/Aitex/Core/RT/IOCore/Interlock/InterlockManagerBase.cs b/MECF.Framework.Common/Aitex/Core/RT/IOCore/Interlock/InterlockManagerBase.cs index 1052430..39b61a7 100644 --- a/MECF.Framework.Common/Aitex/Core/RT/IOCore/Interlock/InterlockManagerBase.cs +++ b/MECF.Framework.Common/Aitex/Core/RT/IOCore/Interlock/InterlockManagerBase.cs @@ -163,6 +163,14 @@ public abstract class InterlockManagerBase if (actionNode.HasAttribute("tip.en-US")) dicTips["en-US"] = actionNode.GetAttribute("tip.en-US"); + var ignoreReverse = false; + if (actionNode.HasAttribute("ignoreReverse")) + { + var strIgnoreReverse = actionNode.GetAttribute("ignoreReverse"); + if (!bool.TryParse(strIgnoreReverse, out ignoreReverse)) + LOG.Error($"Unable to convert attribute 'ignoreReverse' of action '{doName}' to bool."); + } + var moduleName = GetModuleFromIo(targetDo.Name); if (!_dicActionsPerModule.ContainsKey(moduleName)) _dicActionsPerModule[moduleName] = new List(); @@ -178,6 +186,7 @@ public abstract class InterlockManagerBase Debug.Assert(false, err); } + // 遍历Action下的Limit节点,并创建InterlockLimit对象。 foreach (XmlNode limitNode in actionNode.ChildNodes) { @@ -203,14 +212,17 @@ public abstract class InterlockManagerBase _dicActionsPerModule[moduleName].Add(action); _lstActions.Add(action); - - foreach (var limit in action.Limits) + // 如果当前Action设置了忽略翻转,则不要注册Limit到当前Action的映射,避免Limit触发导致Action翻转。 + if (!ignoreReverse) { - // 创建以Limit分组的Action字典 - if (!_dicLimitToActionMap.ContainsKey(limit)) - _dicLimitToActionMap[limit] = new List(); + foreach (var limit in action.Limits) + { + // 创建以Limit分组的Action字典 + if (!_dicLimitToActionMap.ContainsKey(limit)) + _dicLimitToActionMap[limit] = new List(); - _dicLimitToActionMap[limit].Add(action); + _dicLimitToActionMap[limit].Add(action); + } } }