InterlockManagerBase的Initialize()方法新增对配置文件的Action节点ignoreReverse属性的支持,允许将Action配置为忽略Limit命中后翻转电平动作。
This commit is contained in:
DESKTOP-OKMOOJ9\MK 2023-08-30 23:06:49 +08:00
parent 96e892a34f
commit 86af260ad6
2 changed files with 26 additions and 12 deletions

View File

@ -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
}
}

View File

@ -163,6 +163,14 @@ public abstract class InterlockManagerBase<TAction>
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<TAction>();
@ -178,6 +186,7 @@ public abstract class InterlockManagerBase<TAction>
Debug.Assert(false, err);
}
// 遍历Action下的Limit节点并创建InterlockLimit对象。
foreach (XmlNode limitNode in actionNode.ChildNodes)
{
@ -203,14 +212,17 @@ public abstract class InterlockManagerBase<TAction>
_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<IInterlockAction>();
foreach (var limit in action.Limits)
{
// 创建以Limit分组的Action字典
if (!_dicLimitToActionMap.ContainsKey(limit))
_dicLimitToActionMap[limit] = new List<IInterlockAction>();
_dicLimitToActionMap[limit].Add(action);
_dicLimitToActionMap[limit].Add(action);
}
}
}