//public override void WriteTagToDevice(Tag tag)
        //{
        //    throw new Message("不支持WriteTagToDevice");


        //}

        private void UpdateAllDataFinished(object sender, ModbusTCPDataUpdatedEventArgs args)
        {
            //LOG.Info("ModbusTCP_UpdateAllDataFinished");
            // Update MonitorTags Value
            //foreach (Tag tag in MonitorTags.Values)
            //{
            //    tag.TagValue = ReadTagFromBuffer(tag.Address);
            //}

            foreach (Tag tag in Tags.Values)
            {
                if (tag.AccessType == TagAccessType.Read || tag.AccessType == TagAccessType.ReadWrite)
                {
                    //if (MonitorTags[tag].Address.Substring(0, 2) == "IC")
                    //{
                    tag.TagValue = ReadTagFromBuffer(tag);
                    //LOG.Info(string.Format("读取Modbus地址{0}值{1}", MonitorTags[tag].Address, MonitorTags[tag].TagValue));
                    //}
                }
            }
        }
        //private void AddModbusItem(string Name, Int16 Address)
        //{
        //}

        //public void AsyncReadAllData()
        //{
        //    Thread checkThread = new Thread(SyncReadAllData);
        //    checkThread.Start();
        //}

        public void SyncReadAllData(ModbusAddressType address)
        {
            try
            {
                //LOG.Info("ModbusTCP_Driver");
                if (!_connected)
                {
                    return;
                }

                // Read from device to Buffer
                //_inputStatus = _master.ReadInputs(InputStatusStartAddress, InputStatusSize);

                //if (InputRegisterSize > 0)
                //{
                //    _inputRegister = _master.ReadInputRegisters(InputRegisterStartAddress, InputRegisterSize);
                //}
                if (address == ModbusAddressType.IC)
                {
                    if (InputStatusSize > 0)
                    {
                        _inputStatus = _master.ReadCoils(InputStatusStartAddress, InputStatusSize);
                    }
                }
                else
                {
                    LOG.Error(string.Format("读取ModbusTCPDriver数据出错:不支持{0}类型", address.ToString()));
                    return;
                }

                // Notification
                ModbusTCPDataUpdatedEventArgs Evargs = new ModbusTCPDataUpdatedEventArgs();
                DataArrivalEvent(this, Evargs);
            }
            catch (Exception ex)
            {
                _connected = false;
                LOG.Error(string.Format("读取ModbusTCPDriver数据出错:{0}", ex.Message));
            }
        }