完成添加变量功能

This commit is contained in:
2025-07-03 12:55:00 +08:00
parent 6a503de26e
commit 4159e95bf3
16 changed files with 528 additions and 124 deletions

View File

@@ -13,7 +13,8 @@ public class DbDevice
public string Name { get; set; }
[SugarColumn(IsNullable = true)] public string? Description { get; set; }
[SugarColumn(IsNullable = true)]
public string? Description { get; set; }
public string Ip { get; set; }
public bool IsActive { get; set; }

View File

@@ -4,45 +4,123 @@ using SqlSugar.DbConvert;
namespace PMSWPF.Data.Entities;
[SugarTable("VariableData")]
[SugarTable("VarData")]
public class DbVariableData
{
/// <summary>
/// 变量唯一标识符
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)] //数据库是自增才配自增
public int Id { get; set; }
[SugarColumn(IsNullable = true)] public int? VariableTableId { get; set; }
/// <summary>
/// 关联的变量表ID
/// </summary>
public int VariableTableId { get; set; }
/// <summary>
/// 关联的变量表实体
/// </summary>
[Navigate(NavigateType.ManyToOne, nameof(VariableTableId))]
public DbVariableTable? VariableTable { get; set; }
/// <summary>
/// 变量名称
/// </summary>
public string Name { get; set; }
[SugarColumn(IsNullable = true)] public string? Description { get; set; }
/// <summary>
/// 变量描述
/// </summary>
[SugarColumn(IsNullable = true)]
public string? Description { get; set; }
public string NodeId { get; set; }
/// <summary>
/// 节点ID用于标识变量在设备或系统中的唯一路径
/// </summary>
public string NodeId { get; set; } = String.Empty;
/// <summary>
/// 协议类型例如Modbus、OPC UA等
/// </summary>
[SugarColumn(ColumnDataType = "varchar(20)", SqlParameterDbType = typeof(EnumToStringConvert))]
public ProtocolType ProtocolType { get; set; }
public string DataType { get; set; }
[SugarColumn(IsNullable = true)] public List<DbMqtt>? Mqtts { get; set; }
public string DataValue { get; set; } = String.Empty;
public string DisplayValue { get; set; } = String.Empty;
public DateTime UpdateTime { get; set; }
[SugarColumn(IsNullable = true)] public DbUser? UpdateUser { get; set; }
public string Converstion { get; set; } = String.Empty;
public bool IsDeleted { get; set; }
public bool IsActive { get; set; }
public bool IsSave { get; set; }
public double SaveRange { get; set; }
public bool IsAlarm { get; set; }
public double AlarmMin { get; set; }
public double AlarmMax { get; set; }
/// <summary>
/// 数据类型例如Int、Float、String等
/// </summary>
public string DataType { get; set; }=String.Empty;
/// <summary>
/// 信号类型,例如模拟量、数字量等
/// </summary>
[SugarColumn(ColumnDataType = "varchar(20)", IsNullable = true, SqlParameterDbType = typeof(EnumToStringConvert))]
public SignalType SignalType { get; set; }
/// <summary>
/// 变量当前原始数据值
/// </summary>
public string DataValue { get; set; } = String.Empty;
/// <summary>
/// 变量经过转换或格式化后的显示值
/// </summary>
public string DisplayValue { get; set; } = String.Empty;
/// <summary>
/// 变量数据最后更新时间
/// </summary>
public DateTime UpdateTime { get; set; } = DateTime.Now;
/// <summary>
/// 最后更新变量数据的用户
/// </summary>
[SugarColumn(IsNullable = true)]
public DbUser? UpdateUser { get; set; }
/// <summary>
/// 关联的MQTT配置列表
/// </summary>
[SugarColumn(IsNullable = true)]
public List<DbMqtt>? Mqtts { get; set; }
/// <summary>
/// 数据转换规则或表达式
/// </summary>
public string Converstion { get; set; } = String.Empty;
/// <summary>
/// 指示变量是否处于激活状态
/// </summary>
public bool IsActive { get; set; }
/// <summary>
/// 指示是否需要保存变量数据
/// </summary>
public bool IsSave { get; set; }
/// <summary>
/// 数据保存的范围或阈值
/// </summary>
public double SaveRange { get; set; }
/// <summary>
/// 指示是否需要对变量进行报警监测
/// </summary>
public bool IsAlarm { get; set; }
/// <summary>
/// 报警的最小值阈值
/// </summary>
public double AlarmMin { get; set; }
/// <summary>
/// 报警的最大值阈值
/// </summary>
public double AlarmMax { get; set; }
/// <summary>
/// 指示变量是否已被逻辑删除
/// </summary>
public bool IsDeleted { get; set; }
}