DataItem.cs 936 Bytes
using HHECS.EquipmentModel;

namespace HHECS.DAQClient.Communications
{
    public class DataItem
    {
        public int Id { get; set; }

        public string Code { get; set; }

        /// <summary>
        /// 地址数据
        /// </summary>
        /// <remarks>
        /// <para>示例:DB100.0.0</para>
        /// <para>字符串地址:DB100.0,20表示从DB100.0读取20位</para>
        /// </remarks>
        public string DataAddress { get; set; }

        public EquipmentDataType DataType { get; set; }

        public string Value { get; set; }

        /// <summary>
        /// 数据长度
        /// </summary>
        /// <remarks>仅<see cref="char"/>类型有效</remarks>
        public ushort Length
        {
            get
            {
                _ = ushort.TryParse(DataAddress.Split(',').LastOrDefault() ?? "1", out var val);
                return val;
            }
        }
    }
}