using SqlSugar;
namespace Model.Entity.Config
{
///
/// IOT 设备(IOT设备注册与管理 - 设备管理)
/// 一台设备 = 一个从站实例,通过所属网关(IP:端口 或 串口)通讯
///
public class IotDeviceEntity : BaseEntity
{
#region 基础信息
///
/// 设备编号(唯一)
///
[SugarColumn(ColumnDescription = "设备编号", Length = 64)]
public string Code { get; set; }
///
/// 设备名称
///
[SugarColumn(ColumnDescription = "设备名称", Length = 100)]
public string Name { get; set; }
///
/// 设备类型(型号,如 温度箱/充放电柜,对应 DeviceCommand 驱动类)
///
[SugarColumn(ColumnDescription = "设备类型", Length = 64)]
public string DeviceType { get; set; }
///
/// 所属产品Id(关联 ProductEntity.Id,仅用于归类,0=未分类)
///
[SugarColumn(ColumnDescription = "所属产品Id", DefaultValue = "0")]
public long ProductId { get; set; }
///
/// 所属网关Code(对应网关实体/通道的标识,连接时据此刻查找 IP/端口/串口)
///
[SugarColumn(ColumnDescription = "所属网关Code", Length = 64)]
public string GatewayCode { get; set; }
///
/// 从站地址(协议从站号,网关下区分设备)
///
[SugarColumn(ColumnDescription = "从站地址")]
public byte SlaveId { get; set; }
///
/// 制造商
///
[SugarColumn(ColumnDescription = "制造商", Length = 100, IsNullable = true)]
public string? Manufacturer { get; set; }
///
/// 设备描述
///
[SugarColumn(ColumnDescription = "设备描述", Length = 500, IsNullable = true)]
public string? Description { get; set; }
#endregion
#region 连接与协议配置
///
/// 通讯协议类型(ModbusTcp/ModbusRtu/S7/Tcp/Serial)
///
[SugarColumn(ColumnDescription = "通讯协议类型")]
public IotDeviceProtocolEnum ProtocolType { get; set; } = IotDeviceProtocolEnum.ModbusTcp;
///
/// 是否启用采集(停用则采集调度跳过该设备)
///
[SugarColumn(ColumnDescription = "是否启用")]
public bool IsEnabled { get; set; } = true;
#endregion
#region 运行状态(采集调度器更新)
///
/// 在线状态
///
[SugarColumn(ColumnDescription = "在线状态")]
public IotDeviceOnlineStatusEnum OnlineStatus { get; set; } = IotDeviceOnlineStatusEnum.Offline;
///
/// 最后采集时间
///
[SugarColumn(ColumnDescription = "最后采集时间", IsNullable = true)]
public DateTime? LastCollectTime { get; set; }
///
/// 最近错误信息(通讯异常时记录)
///
[SugarColumn(ColumnDescription = "最近错误", Length = 500, IsNullable = true)]
public string? LastError { get; set; }
#endregion
#region 审计信息
///
/// 备注
///
[SugarColumn(ColumnDescription = "备注", Length = 500, IsNullable = true)]
public string? Remark { get; set; }
#endregion
}
}