/// <summary>
        /// Tag对象注册事件
        /// </summary>
        /// <param name="group">TagGroup对象</param>
        /// <param name="tag">Tag对象</param>
        private void OnTagInGroupRegister(CustomGroup group, CustomTag tag)
        {
            _tagRegisterInParentHandler?.Invoke(group, tag);

            SiemensTag siemensTag = tag as SiemensTag;

            Block.Add(siemensTag.DB_Offset, siemensTag.Length);
        }
        /// <summary>
        /// 读取西门子PLC中该Tag的值
        /// </summary>
        /// <param name="tag"></param>
        /// <returns></returns>
        public SiemensTag ReadTagValue(SiemensTag tag)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();

            if (tag is SiemensBoolOfTag)
            {
                byte[] buffer = new byte[1];
                int    resNo  =
                    specialRWConnection.ReadBlock(
                        DBType,
                        DBNumber,
                        tag.DB_Offset,
                        1,
                        ref buffer,
                        out string errText);
                SetTagValue(buffer, tag, tag.DB_Offset);
            }
            else if (tag is SiemensLengthTag)
            {
                if (tag is SiemensRealOfTag)
                {
                    SiemensRealOfTag ltag  = tag as SiemensRealOfTag;
                    float            value = 0;
                    int resNo =
                        specialRWConnection.ReadFloat(
                            DBType,
                            DBNumber,
                            ltag.DB_Offset,
                            ref value,
                            out string errText);
                    ltag.Value = value;
                }
                else
                {
                    SiemensLengthTag ltag   = tag as SiemensLengthTag;
                    byte[]           buffer = new byte[ltag.Length];
                    int resNo =
                        specialRWConnection.ReadBlock(
                            DBType,
                            DBNumber,
                            ltag.DB_Offset,
                            ltag.Length,
                            ref buffer,
                            out string errText);
                    SetTagValue(buffer, tag, tag.DB_Offset);
                }
            }

            sw.Stop();
            _log.Debug($"触发信号[{tag.Name}]的执行时长:[{sw.ElapsedMilliseconds}]毫秒");

            return(tag);
        }
        /// <summary>
        /// Tag对象注册事件
        /// </summary>
        /// <param name="group">TagGroup对象</param>
        /// <param name="tag">Tag对象</param>
        private void OnTagRegister(CustomGroup group, CustomTag tag)
        {
            _log.Trace($"Device[{Name}]:Tag[{tag.Name}],Offset[{tag.DB_Offset}]");

            if (!(tag is SiemensTag))
            {
                throw new Exception($"tag对象:{tag.Name}不是SiemensTag对象");
            }

            SiemensTag siemensTag = tag as SiemensTag;

            switch (CycleReadMode)
            {
            case SiemensCycleReadMode.FullBlock:
                FullBlock.Add(siemensTag.DB_Offset, siemensTag.Length);
                break;

            case SiemensCycleReadMode.ControlBlock:
                if (siemensTag.Type == TagType.C)
                {
                    string key = "";
                    if (group is SiemensTagGroup)
                    {
                        key = (group as SiemensTagGroup).Name;
                    }
                    else if (group is SiemensSubTagGroup)
                    {
                        SiemensSubTagGroup subGroup = group as SiemensSubTagGroup;
                        key = $"{subGroup.Parent.Name}.{subGroup.Prefix}";
                    }

                    PLCDBBlock block = ControlBlock[key];
                    if (block == null)
                    {
                        block = new PLCDBBlock();
                        ControlBlock.Add(key, block);
                    }
                    block.Add(siemensTag.DB_Offset, siemensTag.Length);
                }
                break;
            }
        }