Files
DMS/DMS.WPF/ViewModels/Items/DeviceItemViewModel.cs

78 lines
1.7 KiB
C#
Raw Normal View History

2025-07-26 10:05:43 +08:00
// 文件: DMS.WPF/ViewModels/Items/DeviceItemViewModel.cs
2025-07-27 21:58:50 +08:00
using System.Collections.ObjectModel;
2025-07-26 10:05:43 +08:00
using CommunityToolkit.Mvvm.ComponentModel;
using DMS.Core.Enums;
namespace DMS.WPF.ViewModels.Items;
/// <summary>
/// 代表设备列表中的单个设备项的ViewModel。
/// 实现了INotifyPropertyChanged其任何属性变化都会自动通知UI。
/// </summary>
public partial class DeviceItemViewModel : ObservableObject
{
2025-07-28 13:06:36 +08:00
public int Id { get; set; }
2025-07-26 10:05:43 +08:00
[ObservableProperty]
private string _name;
[ObservableProperty]
private string _description;
2025-07-26 10:05:43 +08:00
[ObservableProperty]
private ProtocolType _protocol;
[ObservableProperty]
private string _ipAddress;
[ObservableProperty]
private int _port=102;
2025-07-26 10:05:43 +08:00
[ObservableProperty]
2025-09-05 15:59:14 +08:00
private int _rack;
2025-07-26 10:05:43 +08:00
[ObservableProperty]
2025-09-05 15:59:14 +08:00
private int _slot=1;
2025-07-26 10:05:43 +08:00
[ObservableProperty]
2025-07-27 21:58:50 +08:00
private CpuType _cpuType;
[ObservableProperty]
private DeviceType _deviceType;
2025-07-26 10:05:43 +08:00
[ObservableProperty]
private string _opcUaServerUrl;
[ObservableProperty]
private bool _isActive =true;
2025-07-26 10:05:43 +08:00
[ObservableProperty]
private bool _isRunning;
2025-07-26 10:05:43 +08:00
[ObservableProperty]
private string _status;
2025-07-28 11:08:56 +08:00
[ObservableProperty]
private bool _isAddDefVarTable=true;
2025-07-27 21:58:50 +08:00
2025-07-28 11:08:56 +08:00
partial void OnIpAddressChanged(string newIpAddress)
{
2025-07-28 11:08:56 +08:00
if (Protocol == ProtocolType.OpcUa)
{
OpcUaServerUrl="opc.tcp://" + IpAddress+":"+Port;
}
}
2025-07-28 11:08:56 +08:00
partial void OnPortChanged(int newPort)
2025-07-26 10:05:43 +08:00
{
2025-07-28 11:08:56 +08:00
if (Protocol == ProtocolType.OpcUa)
{
OpcUaServerUrl="opc.tcp://" + IpAddress+":"+Port;
}
2025-07-26 10:05:43 +08:00
}
2025-07-28 11:08:56 +08:00
public ObservableCollection<VariableTableItemViewModel> VariableTables { get; set; } = new();
2025-07-26 10:05:43 +08:00
}