public bool UpdateTag(IBLTag tag, Dictionary <string, string> properties, bool isConstant, int rowNumber) { return((bool)TiaStarter.RunInSynchronizer(Synchronizer, (p_tag, p_properties, p_isConstant) => { return Reflector.RunInstanceMethodByName(XLSXImporter, "UpdateTag", ReflectionWays.SystemReflection, p_tag, p_properties, p_isConstant); }, tag, properties, isConstant)); }
public static IBLTag UpdateOrCreateTag( this ICoreObject cpu, string Name, string Path, string DataType, string address, string Comment, bool isConstant = false, ISynchronizeInvoke synchronizer = null) { ISynchronizeInvoke UsingSynchronizer; if (synchronizer == null) { UsingSynchronizer = cpu.GetSynchronizer(); } else { UsingSynchronizer = synchronizer; } return(TiaStarter.RunInSynchronizer(UsingSynchronizer, (Func <ICoreObject, string, string, string, string, string, bool, IBLTag>) ((p_cpu, p_Name, p_Path, p_DataType, p_address, p_Comment, p_isConstant) => { string[] values = new string[] { p_Name, p_Path, p_DataType, p_address, p_Comment, "True", "True" }; Dictionary <string, string> properties = CreateTagProperties(values); IBLTag findTag = FindRootTagByName(p_cpu, p_Name, UsingSynchronizer); ICoreObject tagTable = GetOrCreateTagTable(p_cpu, p_Path, UsingSynchronizer); IBLTag newTag = null; if (findTag == null) { newTag = CreateRootTagInTagTable(p_cpu, tagTable, properties, isConstant); } else { newTag = UpdateTag(tagTable, findTag, properties, isConstant, UsingSynchronizer); } return newTag; }), cpu, Name, Path, DataType, address, Comment, isConstant) as IBLTag); }
/// <summary> /// 更新变量 /// </summary> /// <param name="tagTable">变量表</param> /// <param name="tag">变量</param> /// <param name="properties">变量数据</param> /// <param name="isConstant">是否静态变量</param> public static IBLTag UpdateTag( this ICoreObject tagTable, IBLTag tag, Dictionary <string, string> properties, bool isConstant = false, ISynchronizeInvoke synchronizer = null) { ISynchronizeInvoke UsingSynchronizer; if (synchronizer == null) { UsingSynchronizer = tagTable.GetSynchronizer(); } else { UsingSynchronizer = synchronizer; } return(TiaStarter.RunFuncInSynchronizer(UsingSynchronizer, () => { bool result = UpdateTagReal(tagTable, tag, properties, isConstant); return FindRootTagByName(tagTable.GetParent(), tag.Name); }) as IBLTag); }
/// <summary> /// 更新变量 /// </summary> /// <param name="tagTable">变量表</param> /// <param name="tag">变量</param> /// <param name="properties">变量数据</param> /// <param name="isConstant">是否静态变量</param> public static bool UpdateTagReal( this ICoreObject tagTable, IBLTag tag, Dictionary <string, string> properties, bool isConstant = false) { if (tag == null) { throw new ArgumentNullException("tag"); } if (properties == null) { throw new ArgumentNullException("properties"); } string str = null; if (properties.TryGetValue("Siemens.Automation.DomainServices.IBLTag.DataTypeNameStructureRef", out str) && !tag.IsAttributeReadOnly("DataTypeNameStructureRef")) { tag.SetStringAttribute("DataTypeNameStructureRef", str); } if (properties.TryGetValue("Siemens.Automation.DomainServices.IBLTag.LogicalAddress", out str) && !tag.IsAttributeReadOnly("LogicalAddress")) { tag.LogicalAddress = str; } if (properties.TryGetValue("Siemens.Automation.DomainServices.IBLTag.Comment", out str) && !tag.IsAttributeReadOnly("Comment")) { tag.Comment = str; } if (properties.TryGetValue("Siemens.Automation.DomainServices.IBLTag.HmiStructureTypeRelevant", out str)) { bool result; if (!bool.TryParse(str, out result)) { return(false); } if (!tag.IsAttributeReadOnly("HmiStructureTypeRelevant")) { tag.HmiStructureTypeRelevant = result; } } if (properties.TryGetValue("Siemens.Automation.DomainServices.IBLTag.HmiVisible", out str)) { bool result; if (!bool.TryParse(str, out result)) { return(false); } if (!tag.IsAttributeReadOnly("HmiVisible")) { tag.HmiVisible = result; } } if (properties.TryGetValue("Siemens.Automation.DomainServices.IBLTag.Value", out str) && !tag.IsAttributeReadOnly("Value")) { tag.Value = str; } if (!tag.IsAttributeReadOnly("TagTable")) { tag.TagTable = tagTable; return(true); } else { return(false); } }