コード例 #1
0
        public void Add(PLCData <T> item)
        {
            if (m_plcDataList.Count == 0)
            {
                this.Prefix          = item.Prefix;
                this.IsBitCollection = item.IsBit;
            }

            if (this.Prefix == item.Prefix &&
                this.IsBitCollection == item.IsBit)
            {
                m_plcDataList.Add(item);
            }
        }
コード例 #2
0
        /// <summary>
        /// 向PLC数据集中添加一个地址
        /// </summary>
        /// <param name="name"></param>
        /// <param name="addr"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public void Add(string name, string addr, uint index = 0)
        {
            if (addr.Contains('.'))
            {
                AddBit(name, addr, index);
                return;
            }
            PLCData <T> plcData = new PLCData <T>()
            {
                Name      = name,
                NameIndex = index,
                Prefix    = addr[0].ToString(),
                Addr      = int.Parse(addr.Substring(1))
            };

            Add(plcData);
        }
コード例 #3
0
        /// <summary>
        /// 向PLC数据集中添加一个Bit地址
        /// </summary>
        /// <param name="name"></param>
        /// <param name="addr"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        private void AddBit(string name, string addr, uint index = 0)
        {
            if (DataType != DataType.BoolAddress)
            {
                return;
            }

            string[] splits = addr.Substring(1).Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);

            PLCData <T> plcData = new PLCData <T>()
            {
                Name      = name,
                NameIndex = index,
                Prefix    = addr[0].ToString(),
                Addr      = int.Parse(splits[0]),
                Bit       = byte.Parse(splits[1]),
                Length    = UnitLength,
                IsBit     = true
            };

            Add(plcData);
        }
コード例 #4
0
 public bool Remove(PLCData <T> item)
 {
     return(m_plcDataList.Remove(item));
 }
コード例 #5
0
 public bool Contains(PLCData <T> item)
 {
     return(m_plcDataList.Contains(item));
 }