public override BaseAction Clone() { var basAction = new TagsAction(Name) { ActionInParameterManager = ActionInParameterManager.Clone(), ActionOutParameterManager = ActionOutParameterManager.Clone() }; basAction.InitializeNewAction(_readTags, _writeTags, _checkTags, _checkResultType); return(basAction); }
/// <summary> /// Created By Dongmin 20170310 /// Last modified By Dongmin 20170310 /// Example: <ActionItem Type="ReadTag" Tag="BatteryID1" Parameter="ScannedBatteryID1" /> /// 读取ActionItem /// </summary> /// <param name="node"></param> /// <param name="action"></param> /// <returns></returns> public virtual bool LoadFromConfig(XmlNode node, TagsAction action) { try { // level -- "ActionItem" if (node.NodeType == XmlNodeType.Comment) { return(true); } _action = action; // add by David 20170528 var item = (XmlElement)node; var attribute = item.GetAttribute("Type"); // 加载执行条件 /*if (item.HasAttribute("ConditionParameter")) * { * var strCondition = item.GetAttribute("ConditionParameter"); * ConditionParameter = action.ActionInParameterManager.GetBasicParametereter(strCondition); * * if (ConditionParameter == null) * { * Log.Error($"装载机器Action:{action.Name},节点{node.Name}时装载参数:{strCondition}出错"); * return false; * } * * }*/ /*if (item.HasAttribute("CondtionValue")) * { * ConditionValue = item.GetAttribute("CondtionValue"); * }*/ //// 加载Tag if (item.HasAttribute("Tag")) { // Tag action item var tagName = item.GetAttribute("Tag"); // 找到Tag var machine = action.OwnerMachine; Tag = machine.GetTag(tagName); if (Tag == null) { Log.Error($"装载机器Action:{action.Name},节点{node.Name}时装载Tag:{tagName}出错"); return(false); } } /*else if (item.HasAttribute("ReferenceTag")) // Add by David 20170528 * { // Reference Tag * RefTagName = item.GetAttribute("ReferenceTag"); * RefTagParameter = action.ActionInParameterManager.GetBasicParametereter(RefTagName); * if (RefTagParameter != null) * { * IsRefTag = true; * } * }*/ //// 加载参数 string strParameter; //Parameter _parameter = null; // 找到Parameter if (item.HasAttribute("InParameter")) { strParameter = item.GetAttribute("InParameter"); InParameter = action.ActionInParameterManager.GetBasicParam(strParameter); } if (item.HasAttribute("OutParameter")) { strParameter = item.GetAttribute("OutParameter"); OutParameter = action.ActionOutParameterManager.GetBasicParam(strParameter); } if (item.HasAttribute("ConstValue")) { ConstValue = item.GetAttribute("ConstValue"); } return(true); } catch (Exception ex) { Log.Error($"装载机器Action:{action.Name},节点{node.Name}时出错:{ex.Message}"); return(false); } }