public override void Execute() { try { _waitTagName = ActionInParameterManager["WaitTagName"].GetValueInString(); _expectedValue = ActionInParameterManager["ExpectedValue"]; _waitCycle = (short)ActionInParameterManager["CheckCycle"].GetValue(); } catch (Exception e) { Log.Error("等待TagOnOrOff出错" + e); } }
public bool LoadFromConfig(XmlNode node) { // 绑定Paramenter try { var level0Item = (XmlElement)node; if (level0Item.HasAttribute("ProcessParameter")) { // 检查类型 Parameter if (node.Attributes != null) { var parameter = node.Attributes["ProcessParameter"].Value; _parameter = _owner.OwnerProcess.ProcessParameterManager[parameter]; _nextStepId = Convert.ToInt16(node.Attributes["NextStepIndex"].Value); var type = _parameter.GetType(); var constVal = node.Attributes["ConstValue"].Value; _value = Parameter.CreateBasicValue(type.ToString(), constVal); } _checkType = StepCheckType.Parameter; } else { throw new Exception("StepCheck没有ProcessParameter节点"); } return(true); } catch (Exception ex) { Log.Error($"加载StepCheck出错{_owner.Name},{ex}"); return(false); } }
/// <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); } }
public override bool LoadFromConfig(XmlElement node) { try { foreach (XmlNode level1Node in node) { // level1 -- "TrigTags" if (level1Node.NodeType == XmlNodeType.Comment) { continue; } var level1Item = (XmlElement)level1Node; if (string.Equals(level1Item.Name, "TrigTags", StringComparison.CurrentCultureIgnoreCase)) { foreach (XmlNode level2Node in level1Node) { if (level2Node.NodeType == XmlNodeType.Comment) { continue; } var level2Item = (XmlElement)level2Node; if (!string.Equals(level2Item.Name, "TrigTag", StringComparison.CurrentCultureIgnoreCase) ) { continue; // level2 -- "TrigTag" } var strMachine = level2Item.GetAttribute("Container"); //jiansun, 2019-11-23 由Machine改为Container。 var strTag = level2Item.GetAttribute("Tag"); var machine = (Machine)ResourceManager.GetResource(strMachine); var tag = machine.GetTag(strTag); if (tag != null) { if (tag.TagType != "bool") { throw new Exception($"装载AllTagsOnCondition时Tag{strTag}不是BOOL量"); } _tags.Add(tag); //Tag _lastTag = (Tag)tag.Clone(); //_lastTags.Add(_lastTag); } else { throw new Exception($"装载AllTagsOnCondition时未找到Tag:{strTag}"); } } } else if (string.Equals(level1Item.Name, "OutParameter", StringComparison.CurrentCultureIgnoreCase)) { var strMachineName = level1Item.GetAttribute("Container");//jiansun 2019-11-23 由MachineName改为Container。 var strTagName = level1Item.GetAttribute("TagName"); _outMachineName = Owner.ProcessParameterManager.GetBasicParam(strMachineName); _outTagName = Owner.ProcessParameterManager.GetBasicParam(strTagName); if (_outMachineName == null || _outTagName == null) { throw new Exception($"未能在process参数里找到机器名{strMachineName}或标签名{strTagName}"); } } } return(true); } catch (Exception ex) { Log.Error($"装载AllTagsOnCondition时出错:{ex.Message}."); return(false); } }
public override bool LoadFromConfig(XmlElement node) { try { foreach (XmlNode level1Node in node) { // level1 -- "TrigTags" if (level1Node.NodeType == XmlNodeType.Comment) { continue; } var level1Item = (XmlElement)level1Node; if (string.Equals(level1Item.Name, "TrigTags", StringComparison.CurrentCultureIgnoreCase)) { foreach (XmlNode level2Node in level1Node) { if (level2Node.NodeType == XmlNodeType.Comment) { continue; } var level2Item = (XmlElement)level2Node; if (string.Equals(level2Item.Name, "TrigTag", StringComparison.CurrentCultureIgnoreCase)) { // level2 -- "TrigTag" var strMachine = level2Item.GetAttribute("Machine"); var strTag = level2Item.GetAttribute("Tag"); var machine = (Machine)ResourceManager.GetResource(strMachine); var tag = machine.GetTag(strTag); if (tag != null) { /*if (tag.TagType != "bool") * throw new Exception($"装载MultiTagsOnCondition时Tag{strTag}不是BOOL量");*/ MonitorTags.Add(new TagModel { Tag = tag }); var lastTag = (Tag)tag.Clone(); LastTags.Add(lastTag); MonitorTagChangeDic.Add(new TagModel { Tag = tag }, lastTag); } else { throw new Exception($"装载MultiTagsOnCondition时未找到Tag:{strTag}"); } } } } else if (string.Equals(level1Item.Name, "OutParameter", StringComparison.CurrentCultureIgnoreCase)) { var strMachineName = level1Item.GetAttribute("MachineName"); var strTagName = level1Item.GetAttribute("TagName"); OutMachineName = Owner.ProcessParameterManager.GetBasicParam(strMachineName); OutTagName = Owner.ProcessParameterManager.GetBasicParam(strTagName); if (OutMachineName == null || OutTagName == null) { throw new Exception($"未能在过程参数里找到机器名{strMachineName}或标签名{strTagName}。"); } } } return(true); } catch (Exception ex) { Log.Error($"装载MultiTagsCondition时出错:{ex.Message}."); return(false); } }