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; return true;
} }
#endregion
public override void Monitor() public override void Monitor()
{ {
throw new System.NotSupportedException(); throw new System.NotSupportedException();
} }
#endregion
} }
} }

View File

@ -163,6 +163,14 @@ public abstract class InterlockManagerBase<TAction>
if (actionNode.HasAttribute("tip.en-US")) if (actionNode.HasAttribute("tip.en-US"))
dicTips["en-US"] = actionNode.GetAttribute("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); var moduleName = GetModuleFromIo(targetDo.Name);
if (!_dicActionsPerModule.ContainsKey(moduleName)) if (!_dicActionsPerModule.ContainsKey(moduleName))
_dicActionsPerModule[moduleName] = new List<TAction>(); _dicActionsPerModule[moduleName] = new List<TAction>();
@ -178,6 +186,7 @@ public abstract class InterlockManagerBase<TAction>
Debug.Assert(false, err); Debug.Assert(false, err);
} }
// 遍历Action下的Limit节点并创建InterlockLimit对象。 // 遍历Action下的Limit节点并创建InterlockLimit对象。
foreach (XmlNode limitNode in actionNode.ChildNodes) foreach (XmlNode limitNode in actionNode.ChildNodes)
{ {
@ -203,7 +212,9 @@ public abstract class InterlockManagerBase<TAction>
_dicActionsPerModule[moduleName].Add(action); _dicActionsPerModule[moduleName].Add(action);
_lstActions.Add(action); _lstActions.Add(action);
// 如果当前Action设置了忽略翻转则不要注册Limit到当前Action的映射避免Limit触发导致Action翻转。
if (!ignoreReverse)
{
foreach (var limit in action.Limits) foreach (var limit in action.Limits)
{ {
// 创建以Limit分组的Action字典 // 创建以Limit分组的Action字典
@ -213,6 +224,7 @@ public abstract class InterlockManagerBase<TAction>
_dicLimitToActionMap[limit].Add(action); _dicLimitToActionMap[limit].Add(action);
} }
} }
}
Debug.Assert(!_dicActionsPerModule.ContainsKey(ModuleName.UnDefined), Debug.Assert(!_dicActionsPerModule.ContainsKey(ModuleName.UnDefined),
$"InterlockManager {nameof(_dicActionsPerModule)} contains key {ModuleName.UnDefined}"); $"InterlockManager {nameof(_dicActionsPerModule)} contains key {ModuleName.UnDefined}");