2025-07-21 14:35:17 +08:00
|
|
|
|
using DMS.Core.Enums;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
|
|
namespace DMS.Application.DTOs;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 用于在UI上显示变量基本信息的DTO。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class VariableDto
|
|
|
|
|
|
{
|
|
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
|
public string Name { get; set; }
|
2025-07-27 21:08:58 +08:00
|
|
|
|
public string S7Address { get; set; }
|
|
|
|
|
|
public string DataValue { get; set; }
|
2025-09-13 08:24:06 +08:00
|
|
|
|
public double NumericValue { get; set; }
|
2025-07-27 21:08:58 +08:00
|
|
|
|
public string DisplayValue { get; set; }
|
2025-09-13 08:24:06 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 更新数值属性,根据DataValue的值进行转换。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void UpdateNumericValue()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(DataValue))
|
|
|
|
|
|
{
|
|
|
|
|
|
NumericValue = 0.0;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 尝试将字符串转换为数值
|
|
|
|
|
|
if (double.TryParse(DataValue, out double numericValue))
|
|
|
|
|
|
{
|
|
|
|
|
|
NumericValue = numericValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 如果是布尔值
|
|
|
|
|
|
else if (bool.TryParse(DataValue, out bool boolValue))
|
|
|
|
|
|
{
|
|
|
|
|
|
NumericValue = boolValue ? 1.0 : 0.0;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 如果无法转换,保持为0.0
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
NumericValue = 0.0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-07-24 21:41:00 +08:00
|
|
|
|
public VariableTableDto? VariableTable { get; set; }
|
2025-09-07 08:51:18 +08:00
|
|
|
|
public List<VariableMqttAliasDto>? MqttAliases { get; set; } = new List<VariableMqttAliasDto>();
|
2025-07-27 21:08:58 +08:00
|
|
|
|
public SignalType SignalType { get; set; }
|
2025-09-05 20:24:27 +08:00
|
|
|
|
public int PollingInterval { get; set; }
|
2025-07-21 14:35:17 +08:00
|
|
|
|
public bool IsActive { get; set; }
|
|
|
|
|
|
public int VariableTableId { 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 ProtocolType Protocol { get; set; }
|
2025-09-02 16:45:24 +08:00
|
|
|
|
public DataType DataType { get; set; }
|
2025-07-21 14:35:17 +08:00
|
|
|
|
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; }
|
2025-07-24 21:41:00 +08:00
|
|
|
|
public string Description { get; set; }
|
2025-07-27 21:08:58 +08:00
|
|
|
|
public OpcUaUpdateType OpcUaUpdateType { get; set; }
|
2025-07-21 14:35:17 +08:00
|
|
|
|
}
|