2025-07-18 22:21:16 +08:00
|
|
|
|
using DMS.Core.Enums;
|
2025-07-21 14:35:17 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
2025-06-20 18:53:29 +08:00
|
|
|
|
|
2025-07-19 09:25:01 +08:00
|
|
|
|
namespace DMS.Core.Models;
|
2025-06-20 18:53:29 +08:00
|
|
|
|
|
2025-07-03 13:17:25 +08:00
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 核心数据点,代表从设备读取的单个值。
|
2025-07-03 13:17:25 +08:00
|
|
|
|
/// </summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
public class Variable
|
2025-06-20 18:53:29 +08:00
|
|
|
|
{
|
2025-07-03 12:55:00 +08:00
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 唯一标识符。
|
2025-07-03 12:55:00 +08:00
|
|
|
|
/// </summary>
|
2025-07-04 13:40:14 +08:00
|
|
|
|
public int Id { get; set; }
|
2025-07-03 20:12:07 +08:00
|
|
|
|
|
2025-07-04 13:40:14 +08:00
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 变量名。
|
2025-07-04 13:40:14 +08:00
|
|
|
|
/// </summary>
|
2025-07-19 09:25:01 +08:00
|
|
|
|
public string Name { get; set; }
|
2025-07-03 13:17:25 +08:00
|
|
|
|
|
2025-07-03 12:55:00 +08:00
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 变量的描述信息。
|
2025-07-03 12:55:00 +08:00
|
|
|
|
/// </summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
public string Description { get; set; }
|
2025-07-04 13:40:14 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 在设备中的地址 (例如: DB1.DBD0, M100.0)。
|
2025-07-04 13:40:14 +08:00
|
|
|
|
/// </summary>
|
2025-07-24 15:07:03 +08:00
|
|
|
|
public string S7Address { get; set; }
|
2025-07-04 13:40:14 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 变量的信号类型,例如启动信号、停止信号。
|
2025-07-04 13:40:14 +08:00
|
|
|
|
/// </summary>
|
2025-07-27 21:08:58 +08:00
|
|
|
|
public SignalType SignalType { get; set; }
|
2025-07-03 12:55:00 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 变量的轮询级别,决定了其读取频率。
|
2025-07-03 12:55:00 +08:00
|
|
|
|
/// </summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
public PollLevelType PollLevel { get; set; }
|
2025-07-03 12:55:00 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 指示此变量是否处于激活状态。
|
2025-07-03 12:55:00 +08:00
|
|
|
|
/// </summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
public bool IsActive { get; set; }
|
2025-07-03 12:55:00 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 所属变量表的ID。
|
2025-07-03 12:55:00 +08:00
|
|
|
|
/// </summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
public int VariableTableId { get; set; }
|
2025-07-03 12:55:00 +08:00
|
|
|
|
|
2025-07-09 19:38:36 +08:00
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 所属变量表的导航属性。
|
2025-07-09 19:38:36 +08:00
|
|
|
|
/// </summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
public VariableTable VariableTable { get; set; }
|
2025-07-09 19:38:36 +08:00
|
|
|
|
|
2025-07-03 12:55:00 +08:00
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 此变量的所有MQTT发布别名关联。一个变量可以关联多个MQTT服务器,每个关联可以有独立的别名。
|
2025-07-03 12:55:00 +08:00
|
|
|
|
/// </summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
public List<VariableMqttAlias> MqttAliases { get; set; } = new();
|
2025-07-03 12:55:00 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// OPC UA NodeId (仅当 Protocol 为 OpcUa 时有效)。
|
2025-07-03 12:55:00 +08:00
|
|
|
|
/// </summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
public string OpcUaNodeId { get; set; }
|
2025-07-03 12:55:00 +08:00
|
|
|
|
|
2025-07-05 12:29:10 +08:00
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 是否启用历史数据保存。
|
2025-07-05 12:29:10 +08:00
|
|
|
|
/// </summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
public bool IsHistoryEnabled { get; set; }
|
2025-07-05 12:29:10 +08:00
|
|
|
|
|
2025-07-10 17:16:15 +08:00
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 历史数据保存的死区值。当变量值变化超过此死区时才保存。
|
2025-07-10 17:16:15 +08:00
|
|
|
|
/// </summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
public double HistoryDeadband { get; set; }
|
2025-07-10 17:16:15 +08:00
|
|
|
|
|
2025-07-05 12:56:13 +08:00
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 是否启用报警。
|
2025-07-05 12:56:13 +08:00
|
|
|
|
/// </summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
public bool IsAlarmEnabled { get; set; }
|
2025-07-05 12:56:13 +08:00
|
|
|
|
|
2025-07-03 12:55:00 +08:00
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 报警最小值。
|
2025-07-03 12:55:00 +08:00
|
|
|
|
/// </summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
public double AlarmMinValue { get; set; }
|
2025-07-03 12:55:00 +08:00
|
|
|
|
|
2025-07-03 20:12:07 +08:00
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 报警最大值。
|
2025-07-03 20:12:07 +08:00
|
|
|
|
/// </summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
public double AlarmMaxValue { get; set; }
|
2025-07-03 20:12:07 +08:00
|
|
|
|
|
2025-07-03 12:55:00 +08:00
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 报警死区。当变量值变化超过此死区时才触发报警。
|
2025-07-03 12:55:00 +08:00
|
|
|
|
/// </summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
public double AlarmDeadband { get; set; }
|
2025-07-03 12:55:00 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 存储从设备读取到的最新值。此属性不应持久化到数据库,仅用于运行时。
|
2025-07-03 12:55:00 +08:00
|
|
|
|
/// </summary>
|
2025-07-27 21:08:58 +08:00
|
|
|
|
public string DataValue { get; set; }
|
2025-07-03 12:55:00 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 变量的通讯协议。
|
2025-07-03 12:55:00 +08:00
|
|
|
|
/// </summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
public ProtocolType Protocol { get; set; }
|
2025-07-03 12:55:00 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 变量的数据类型。
|
2025-07-03 12:55:00 +08:00
|
|
|
|
/// </summary>
|
2025-09-02 16:45:24 +08:00
|
|
|
|
public DataType DataType { get; set; }
|
2025-07-03 12:55:00 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 数值转换公式,例如 "+3*5"。
|
2025-07-03 12:55:00 +08:00
|
|
|
|
/// </summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
public string ConversionFormula { get; set; }
|
2025-07-03 12:55:00 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 经过转换公式计算后的显示值。此属性不应持久化到数据库,仅用于运行时。
|
2025-07-03 12:55:00 +08:00
|
|
|
|
/// </summary>
|
2025-07-27 21:08:58 +08:00
|
|
|
|
public string DisplayValue { get; set; }
|
2025-07-03 12:55:00 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 变量的创建时间。
|
2025-07-03 12:55:00 +08:00
|
|
|
|
/// </summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
public DateTime CreatedAt { get; set; }
|
2025-07-03 12:55:00 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 变量的最后更新时间。
|
2025-07-03 12:55:00 +08:00
|
|
|
|
/// </summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
public DateTime UpdatedAt { get; set; }
|
2025-07-03 20:12:07 +08:00
|
|
|
|
|
2025-07-08 20:19:06 +08:00
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 最后更新变量的用户。
|
2025-07-08 20:19:06 +08:00
|
|
|
|
/// </summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
public string UpdatedBy { get; set; }
|
2025-07-08 20:19:06 +08:00
|
|
|
|
|
2025-07-04 13:40:14 +08:00
|
|
|
|
/// <summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
/// 指示变量是否被修改。
|
2025-07-04 13:40:14 +08:00
|
|
|
|
/// </summary>
|
2025-07-21 14:35:17 +08:00
|
|
|
|
public bool IsModified { get; set; }
|
2025-07-24 22:03:26 +08:00
|
|
|
|
|
2025-07-27 21:08:58 +08:00
|
|
|
|
|
2025-07-24 22:18:22 +08:00
|
|
|
|
public OpcUaUpdateType OpcUaUpdateType { get; set; }
|
2025-06-20 18:53:29 +08:00
|
|
|
|
}
|