Base_EquipmentProp.cs 2.77 KB

using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
using System.Text.Json.Serialization;

namespace RCS.Model.Entity
{
    [Table("t_base_equipmentprop")]

    public class Base_EquipmentProp
    {
        /// <summary>
        /// 主键
        /// </summary>
        [Key]
        [Column(Order = 1)]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int ID { get; set; }
        /// <summary>
        /// 设备属性编码
        /// </summary>
        public string Code { get; set; }
        /// <summary>
        /// 设备属性名称
        /// </summary>

        public string Name { get; set; }
        /// <summary>
        /// 设备编码
        /// </summary>

        public string EquipmentCode { get; set; }
        /// <summary>
        /// 设备属性地址
        /// </summary>

        public string Address { get; set; }
        /// <summary>
        /// 数据占用的字节数
        /// </summary>

        public ushort ByteSize { get; set; }
        /// <summary>
        /// 设备属性值
        /// </summary>

        public string Value { get; set; }
        /// <summary>
        /// 设备属性数据类型
        /// </summary>

        public string DataType { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>

        public DateTime Created { get; set; }
        /// <summary>
        /// 创建人
        /// </summary>

        public string CreatedBy { get; set; }
        /// <summary>
        /// 修改时间
        /// </summary>

        public DateTime Updated { get; set; }
        /// <summary>
        /// 修改人
        /// </summary>

        public string UpdatedBy { get; set; }

        public override string ToString()
        {


            var sb = new StringBuilder();
            sb.Append(EquipmentCode); 
            sb.Append('-');
            sb.Append(Name);  
            sb.Append(':');
            sb.Append(Value);
            return sb.ToString();
        }
        #region 扩展属性

        /// <summary>
        /// 批量操作时候的设备属性地址
        /// </summary>
        [NotMapped]
        public string BatchAddress { get; set; }

        /// <summary>
        /// 位偏移,相对于读取bit而言,取值为0到7,其他类型为0
        /// </summary>
        [NotMapped]
        public int BitOffset { get; set; }

        /// <summary>
        /// 设备编码
        /// </summary>
        [NotMapped]
        public string EquipmentName { get; set; }

        /// <summary>
        /// 逻辑外键--设备实体
        /// </summary>
        [NotMapped]
        [JsonIgnore]
        public Base_Equipment Equipment { get; set; }

        #endregion
    }
}