예제 #1
0
        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);
        }
예제 #2
0
        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;
            }
        }
예제 #3
0
        public void Add(TagEntity tag)
        {
            if (tags.ContainsKey(tag.ID))
            {
                throw new Exception("已经存在相同的标记");
            }

            tags.Add(tag.ID, tag);
            DataHelper.Instance.AllEntities.Add(tag);
        }
예제 #4
0
        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);
        }
예제 #5
0
        public SubGroupEntity(XmlNode node, GroupEntity parent) : this(parent)
        {
            #region 从Xml节点属性中获取属性值
            if (node.Attributes["Prefix"] != null)
            {
                prefix = node.Attributes["Prefix"].Value;
            }
            #endregion

            XmlNode childNode = node.FirstChild;
            while (childNode != null)
            {
                if (childNode.Name == "Tag")
                {
                    TagEntity tag = new TagEntity(childNode, this);
                    Tags.Add(tag);
                }

                childNode = childNode.NextSibling;
            }
        }
예제 #6
0
        public static TagEntity ImportFromXmlNode(GroupEntity 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);
            }
        }
예제 #7
0
 public void Remove(TagEntity tag)
 {
     tags.Remove(tag.ID);
     DataHelper.Instance.AllEntities.Remove(tag.ID);
 }