Example #1
0
        /// <summary>
        /// Converts an ADS symbol to tag.
        /// </summary>
        /// <param name="symbol">The symbol.</param>
        /// <param name="adsPort">The ads port.</param>
        /// <returns></returns>
        /// <exception cref="TagException"></exception>
        public static Tag ConvertSymbolToTag(ITcAdsSymbol symbol, int adsPort)
        {
            if (symbol == null)
            {
                return(null);
            }

            string[] names = symbol.Name.Split('.');

            string name;
            string scope;

            if (names.Length == 1)
            {
                scope = string.Empty;
                name  = names[0];
            }
            else
            {
                scope = names[0];
                name  = symbol.Name.Replace(scope + ".", string.Empty);
            }

            var tag = new Tag
            {
                AdsPort     = adsPort,
                Name        = name,
                Scope       = scope,
                BitSize     = symbol.Size * 8,
                DataType    = symbol.Type,
                IndexGroup  = symbol.IndexGroup,
                IndexOffset = symbol.IndexOffset
            };

            tag.MetaData = MetaDataParser.Parse(symbol.Comment);

            return(tag);
        }
        public void ExtractComment()
        {
            var metadata = _testee.Parse(_ptrRawMetaData);

            metadata.Comment.Should().Be(Comment);
        }