You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
2.8 KiB

using Infrastructure.Domain;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
namespace Application.Domain.Entities
{
[Display(Name = "设备")]
public class Device : BaseEntity, IDisableRemove
{
[Display(Name = "网关编号")]
public string GatewayNumber { get; set; }
[Display(Name = "分类编号")]
public string CategoryNumber { get; set; }
[Display(Name = "名称")]
public string Name { get; set; }
[Display(Name = "编号")]
public string Number { get; set; }
[Display(Name = "显示名称")]
public string DisplayName { get; set; }
[Display(Name = "图标")]
public string Icon { get; set; }
[Display(Name = "在线状态")]
public bool IsOnline { get; set; }
[Display(Name = "IP")]
public string Ip { get; set; }
[Display(Name = "用户名")]
public string UserName { get; set; }
[Display(Name = "密码")]
public string Password { get; set; }
[Display(Name = "启用")]
public bool Enable { get; set; }
[Display(Name = "中转")]
public bool IsTransfer { get; set; }
[Display(Name = "分类Id")]
public Guid InfoId { get; set; }
[Display(Name = "分类")]
public DeviceInfo Info { get; set; }
[Display(Name = "节点编号")]
public string NodeNumber { get; set; }
[Display(Name = "型号")]
public string InfoNumber { get; set; }
[Display(Name = "分类Id")]
public Guid? CategoryId { get; set; }
[Display(Name = "分类")]
public Category Category { get; set; }
[Display(Name = "节点Id")]
public Guid? NodeId { get; set; }
[Display(Name = "节点")]
public Node Node { get; set; }
[Display(Name = "连接Id")]
public string ConnectId { get; set; }
[Display(Name = "数据")]
public List<Data> Data { get; set; } = new List<Data>();
public Data GetData(string key)
{
return this.Data.FirstOrDefault(o => o.Key == key);
}
public string GetDataValue(string key)
{
return this.GetData(key)?.Value;
}
public void AddorUpdateData(string key, object value, DeviceDataType type, string name, string unit = null, string description = null, bool hidden = false)
{
var data = this.Data.FirstOrDefault(o => o.Key == key);
if (data == null)
{
data = new Data { Key = key, Type = type, Name = name, Unit = unit, Description = description, Hidden = hidden };
this.Data.Add(data);
}
data.Value = Convert.ToString(value);
}
}
}