using Infrastructure.Domain; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; namespace IoT.Shared.Application.Domain.Entities { [Display(Name = "数据")] [Scope] [Group("物联管控", "IoTCenter")] public class IoTData : BaseEntity { [Display(Name = "键")] [Required(ErrorMessage = nameof(RequiredAttribute))] public string Key { get; set; } [Display(Name = "值")] public string Value { get; set; } [Display(Name = "名称")] public string Name { get; set; } [Display(Name = "类型")] public IoTDataType Type { get; set; } [Display(Name = "单位")] public string Unit { get; set; } [Display(Name = "描述")] public string Description { get; set; } [Display(Name = "时间戳")] public long Timestamp { get; set; } [Display(Name = "隐藏")] public bool Hidden { get; set; } [Display(Name = "设备Id")] public Guid DeviceId { get; set; } [Display(Name = "设备")] public IoTDevice Device { get; set; } //public List Tiggers { get; set; } = new List(); //public List OrganSceneTiggers { get; set; } = new List(); public dynamic GetValue() { if (this.Type == IoTDataType.Int) { return Convert.ToInt32(this.Value); } if (this.Type == IoTDataType.Float) { return Convert.ToSingle(this.Value); } if (this.Type == IoTDataType.Bool) { return Convert.ToBoolean(this.Value); } return Value; } } }