按照软件设计文档开始重构代码01
This commit is contained in:
@@ -1,172 +1,30 @@
|
||||
using DMS.Core.Enums;
|
||||
using SqlSugar;
|
||||
using SqlSugar.DbConvert;
|
||||
using SqlSugar;
|
||||
|
||||
namespace DMS.Infrastructure.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 表示数据库中的变量数据实体。
|
||||
/// </summary>
|
||||
[SugarTable("VarData")]
|
||||
[SugarTable("Variables")]
|
||||
public class DbVariable
|
||||
{
|
||||
/// <summary>
|
||||
/// 变量唯一标识符。
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)] //数据库是自增才配自增
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 变量名称。
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 节点ID,用于标识变量在设备或系统中的唯一路径。
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public string NodeId { get; set; } = String.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 节点ID,用于标识变量在设备或系统中的唯一路径。
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public string S7Address { get; set; } = String.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// OPC UA Endpoint URL。
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public string? OpcUaEndpointUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// OPC UA Node ID。
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public string? OpcUaNodeId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 变量描述。
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 协议类型,例如Modbus、OPC UA等。
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(20)", SqlParameterDbType = typeof(EnumToStringConvert))]
|
||||
public ProtocolType ProtocolType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 信号类型,例如模拟量、数字量等。
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(20)", IsNullable = true, SqlParameterDbType = typeof(EnumToStringConvert))]
|
||||
public SignalType SignalType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据类型,例如Int、Float、String等。
|
||||
/// </summary>
|
||||
public string DataType { get; set; } = String.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 变量当前原始数据值。
|
||||
/// </summary>
|
||||
public string DataValue { get; set; } = String.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 变量经过转换或格式化后的显示值。
|
||||
/// </summary>
|
||||
public string DisplayValue { get; set; } = String.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 指示变量是否处于激活状态。
|
||||
/// </summary>
|
||||
public string Address { get; set; }
|
||||
public int DataType { get; set; } // 对应 SignalType 枚举
|
||||
public int PollLevel { get; set; } // 对应 PollLevelType 枚举
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 指示是否需要保存变量数据。
|
||||
/// </summary>
|
||||
public bool IsSave { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 指示是否需要对变量进行报警监测。
|
||||
/// </summary>
|
||||
public bool IsAlarm { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轮询级别,例如1秒、5秒等。
|
||||
/// </summary>
|
||||
|
||||
[SugarColumn(ColumnDataType = "varchar(20)",IsNullable =true, SqlParameterDbType = typeof(EnumToStringConvert))]
|
||||
public PollLevelType PollLevelType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// OPC UA更新类型,例如轮询或订阅。
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(20)", IsNullable = true, SqlParameterDbType = typeof(EnumToStringConvert))]
|
||||
public OpcUaUpdateType OpcUaUpdateType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 指示变量是否已被逻辑删除。
|
||||
/// </summary>
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警的最大值阈值。
|
||||
/// </summary>
|
||||
public double AlarmMax { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警的最小值阈值。
|
||||
/// </summary>
|
||||
public double AlarmMin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据转换规则或表达式。
|
||||
/// </summary>
|
||||
public string Converstion { get; set; } = String.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 数据保存的范围或阈值。
|
||||
/// </summary>
|
||||
public double SaveRange { get; set; }
|
||||
/// <summary>
|
||||
/// 变量数据最后更新时间。
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 变量数据最后更新时间。
|
||||
/// </summary>
|
||||
public DateTime UpdateTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 最后更新变量数据的用户。
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public DbUser? UpdateUser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关联的变量表ID。
|
||||
/// </summary>
|
||||
public int VariableTableId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关联的变量表实体。
|
||||
/// </summary>
|
||||
[Navigate(NavigateType.ManyToOne, nameof(VariableTableId))]
|
||||
public DbVariableTable? VariableTable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关联的MQTT配置列表。
|
||||
/// </summary>
|
||||
[Navigate(NavigateType.OneToMany, nameof(DbVariableMqtt.VariableId))]
|
||||
public List<DbVariableMqtt>? VariableMqtts { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关联的历史记录列表。
|
||||
/// </summary>
|
||||
[Navigate(NavigateType.OneToMany, nameof(DbVariableHistory.VariableId))]
|
||||
public List<DbVariableHistory>? HistoryRecords { get; set; }
|
||||
public string OpcUaNodeId { get; set; }
|
||||
public bool IsHistoryEnabled { get; set; }
|
||||
public double HistoryDeadband { get; set; }
|
||||
public bool IsAlarmEnabled { get; set; }
|
||||
public double AlarmMinValue { get; set; }
|
||||
public double AlarmMaxValue { get; set; }
|
||||
public double AlarmDeadband { get; set; }
|
||||
public int Protocol { get; set; } // 对应 ProtocolType 枚举
|
||||
public int CSharpDataType { get; set; } // 对应 CSharpDataType 枚举
|
||||
public string ConversionFormula { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
public string UpdatedBy { get; set; }
|
||||
public bool IsModified { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user