public GroupEntity( XmlNode node, DeviceEntity parent) : this(parent) { #region 从Xml节点属性中获取属性值 if (node.Attributes["Name"] != null) { name = node.Attributes["Name"].Value; } #endregion XmlNode childNode = node.FirstChild; while (childNode != null) { if (childNode.Name == "Tag") { TagEntity tag = new TagEntity(childNode, this); Tags.Add(tag); } else if (childNode.Name == "SubTagGroup") { SubGroupEntity subGroup = new SubGroupEntity(childNode, this); SubGroups.Add(subGroup); } childNode = childNode.NextSibling; } }
public static SubGroupEntity ImportFromXmlNode(GroupEntity parent, XmlNode node) { if (node.Name.ToUpper() != "SUBTAGGROUP") { return(null); } SubGroupEntity sgroup = new SubGroupEntity(parent) { Prefix = XMLHelper.GetAttributeStringValue(node, "Prefix", "00"), }; XmlNode child = node.FirstChild; while (child != null) { TagEntity tag = TagEntity.ImportFromXmlNode(sgroup, child); if (tag != null) { sgroup.Tags.Add(tag); } child = child.NextSibling; } return(sgroup); }
public TagEntity(SubGroupEntity parent) { SubGroupParent = parent ?? throw new Exception( "标记对象不能单独存在,必须依赖GroupEntity/SubGroupEntity对象"); }
public void Add(SubGroupEntity sGroup) { if (sGroups.ContainsKey(sGroup.ID)) { throw new Exception("已经存在相同的标记子组"); } sGroups.Add(sGroup.ID, sGroup); DataHelper.Instance.AllEntities.Add(sGroup); }
public static GroupEntity ImportFromXmlNode( DeviceEntity parent, XmlNode node) { GroupEntity rlt = null; if (node.Name.ToUpper() != "TAGGROUP") { return(rlt); } rlt = new GroupEntity(parent) { Name = XMLHelper.GetAttributeStringValue(node, "Name", "Unknown"), }; XmlNode child = node.FirstChild; while (child != null) { switch (child.Name.ToUpper()) { case "TAG": TagEntity tag = TagEntity.ImportFromXmlNode(rlt, child); if (tag != null) { rlt.Tags.Add(tag); } break; case "SUBTAGGROUP": SubGroupEntity sgroup = SubGroupEntity.ImportFromXmlNode(rlt, child); if (sgroup != null) { rlt.SubGroups.Add(sgroup); } break; } child = child.NextSibling; } return(rlt); }
public static TagEntity ImportFromXmlNode(SubGroupEntity parent, XmlNode node) { if (node.Name.ToUpper() != "TAG") { return(null); } try { TagEntity rlt = new TagEntity(parent) { Name = XMLHelper.GetAttributeStringValue(node, "Name", "Unknown"), Offset = XMLHelper.GetAttributeStringValue(node, "Offset", "0"), }; Enum.TryParse( XMLHelper.GetAttributeStringValue(node, "Datatype", "Bool"), true, out TagDataType dataType); rlt.DataType = dataType; if (rlt.DataType == TagDataType.ArrayChar) { rlt.Length = XMLHelper.GetAttributeStringValue(node, "Length", "0.1"); } Enum.TryParse( XMLHelper.GetAttributeStringValue(node, "Type", "A"), true, out TagType type); rlt.Type = type; return(rlt); } catch { return(null); } }
public void Remove(SubGroupEntity sGroup) { sGroup.RemoveChildren(); sGroups.Remove(sGroup.ID); DataHelper.Instance.AllEntities.Remove(sGroup.ID); }
public TagEntity(XmlNode node, SubGroupEntity parent) : this(parent) { InitTagValue(node); }