临时提交
This commit is contained in:
@@ -62,8 +62,6 @@ public class DeviceAppService : IDeviceAppService
|
|||||||
await _repoManager.BeginTranAsync();
|
await _repoManager.BeginTranAsync();
|
||||||
|
|
||||||
var device = _mapper.Map<Device>(dto.Device);
|
var device = _mapper.Map<Device>(dto.Device);
|
||||||
if (device.Protocol == ProtocolType.OpcUA)
|
|
||||||
device.OpcUaServerUrl = $"opc.tcp://{device.IpAddress}:{device.Port}";
|
|
||||||
var addDevice = await _repoManager.Devices.AddAsync(device);
|
var addDevice = await _repoManager.Devices.AddAsync(device);
|
||||||
if (addDevice == null || addDevice.Id == 0)
|
if (addDevice == null || addDevice.Id == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,5 +21,4 @@ public enum ProtocolType
|
|||||||
/// Modbus TCP 协议。
|
/// Modbus TCP 协议。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ModbusTcp,
|
ModbusTcp,
|
||||||
OpcUA
|
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ public class OpcUaBackgroundService : BackgroundService
|
|||||||
|
|
||||||
private async void HandleDeviceIsActiveChanged(Device device, bool isActive)
|
private async void HandleDeviceIsActiveChanged(Device device, bool isActive)
|
||||||
{
|
{
|
||||||
if (device.Protocol != ProtocolType.OpcUA)
|
if (device.Protocol != ProtocolType.OpcUa)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_logger.LogInformation($"设备 {device.Name} (ID: {device.Id}) 的IsActive状态改变为 {isActive}。");
|
_logger.LogInformation($"设备 {device.Name} (ID: {device.Id}) 的IsActive状态改变为 {isActive}。");
|
||||||
@@ -194,7 +194,7 @@ public class OpcUaBackgroundService : BackgroundService
|
|||||||
|
|
||||||
_logger.LogInformation("开始加载OPC UA变量....");
|
_logger.LogInformation("开始加载OPC UA变量....");
|
||||||
var opcUaDevices = _deviceDataService
|
var opcUaDevices = _deviceDataService
|
||||||
.Devices.Where(d => d.Protocol == ProtocolType.OpcUA && d.IsActive == true)
|
.Devices.Where(d => d.Protocol == ProtocolType.OpcUa && d.IsActive == true)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
if (opcUaDevices.Count == 0)
|
if (opcUaDevices.Count == 0)
|
||||||
@@ -213,7 +213,7 @@ public class OpcUaBackgroundService : BackgroundService
|
|||||||
//查找设备中所有要轮询的变量
|
//查找设备中所有要轮询的变量
|
||||||
var dPollList = opcUaDevice.VariableTables?.SelectMany(vt => vt.Variables)
|
var dPollList = opcUaDevice.VariableTables?.SelectMany(vt => vt.Variables)
|
||||||
.Where(vd => vd.IsActive == true &&
|
.Where(vd => vd.IsActive == true &&
|
||||||
vd.Protocol == ProtocolType.OpcUA &&
|
vd.Protocol == ProtocolType.OpcUa &&
|
||||||
vd.OpcUaUpdateType == OpcUaUpdateType.OpcUaPoll)
|
vd.OpcUaUpdateType == OpcUaUpdateType.OpcUaPoll)
|
||||||
.ToList();
|
.ToList();
|
||||||
// 将变量保存到字典中,方便Read后还原
|
// 将变量保存到字典中,方便Read后还原
|
||||||
@@ -229,7 +229,7 @@ public class OpcUaBackgroundService : BackgroundService
|
|||||||
//查找设备中所有要订阅的变量
|
//查找设备中所有要订阅的变量
|
||||||
var dSubList = opcUaDevice.VariableTables?.SelectMany(vt => vt.Variables)
|
var dSubList = opcUaDevice.VariableTables?.SelectMany(vt => vt.Variables)
|
||||||
.Where(vd => vd.IsActive == true &&
|
.Where(vd => vd.IsActive == true &&
|
||||||
vd.Protocol == ProtocolType.OpcUA &&
|
vd.Protocol == ProtocolType.OpcUa &&
|
||||||
vd.OpcUaUpdateType == OpcUaUpdateType.OpcUaSubscription)
|
vd.OpcUaUpdateType == OpcUaUpdateType.OpcUaSubscription)
|
||||||
.ToList();
|
.ToList();
|
||||||
totalSubVariableCount += dSubList.Count;
|
totalSubVariableCount += dSubList.Count;
|
||||||
|
|||||||
@@ -8,17 +8,19 @@ namespace DMS.WPF.Profiles
|
|||||||
{
|
{
|
||||||
public MappingProfile()
|
public MappingProfile()
|
||||||
{
|
{
|
||||||
CreateMap<DeviceDto, DeviceItemViewModel>().ConstructUsing(src => new DeviceItemViewModel(src));
|
CreateMap<DeviceDto, DeviceItemViewModel>()
|
||||||
CreateMap<DeviceItemViewModel, DeviceDto>();
|
.ReverseMap();
|
||||||
|
|
||||||
CreateMap<MenuBeanDto, MenuBeanItemViewModel>()
|
CreateMap<MenuBeanDto, MenuBeanItemViewModel>()
|
||||||
.ForMember(dest => dest.Children, opt => opt.Ignore())
|
.ForMember(dest => dest.Children, opt => opt.Ignore())
|
||||||
.ConstructUsing(src => new MenuBeanItemViewModel(src, null)); // 假设 NavigationService 可以通过依赖注入获取或在ViewModel中处理
|
.ConstructUsing(src => new MenuBeanItemViewModel(
|
||||||
CreateMap<MqttServerDto, MqttServerItemViewModel>().ConstructUsing(src => new MqttServerItemViewModel(src));
|
src, null)); // 假设 NavigationService 可以通过依赖注入获取或在ViewModel中处理
|
||||||
CreateMap<UserDto, UserItemViewModel>().ConstructUsing(src => new UserItemViewModel(src));
|
CreateMap<MqttServerDto, MqttServerItemViewModel>().ReverseMap();
|
||||||
CreateMap<VariableHistoryDto, VariableHistoryItemViewModel>().ConstructUsing(src => new VariableHistoryItemViewModel(src));
|
CreateMap<UserDto, UserItemViewModel>().ReverseMap();
|
||||||
CreateMap<VariableDto, VariableItemViewModel>().ConstructUsing(src => new VariableItemViewModel(src));
|
CreateMap<VariableHistoryDto, VariableHistoryItemViewModel>().ReverseMap();
|
||||||
CreateMap<VariableMqttAliasDto, VariableMqttAliasItemViewModel>().ConstructUsing(src => new VariableMqttAliasItemViewModel(src));
|
CreateMap<VariableDto, VariableItemViewModel>().ReverseMap();
|
||||||
CreateMap<VariableTableDto, VariableTableItemViewModel>().ConstructUsing(src => new VariableTableItemViewModel(src));
|
CreateMap<VariableMqttAliasDto, VariableMqttAliasItemViewModel>().ReverseMap();
|
||||||
|
CreateMap<VariableTableDto, VariableTableItemViewModel>().ReverseMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,39 +97,6 @@ public partial class DataServices : ObservableRecipient, IRecipient<LoadMessage>
|
|||||||
// AllVariables = new ConcurrentDictionary<int, Variable>();
|
// AllVariables = new ConcurrentDictionary<int, Variable>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// /// <summary>
|
|
||||||
// /// 接收加载消息,根据消息类型从数据库加载对应的数据。
|
|
||||||
// /// </summary>
|
|
||||||
// /// <param name="message">加载消息,包含要加载的数据类型。</param>
|
|
||||||
// /// <exception cref="ArgumentException">如果加载类型未知,可能会抛出此异常(尽管当前实现中未显式抛出)。</exception>
|
|
||||||
// public async void Receive(LoadMessage message)
|
|
||||||
// {
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// switch (message.LoadType)
|
|
||||||
// {
|
|
||||||
// case LoadTypes.All: // 加载所有数据
|
|
||||||
// await LoadDevices();
|
|
||||||
// await LoadMenus();
|
|
||||||
// await LoadMqtts();
|
|
||||||
// break;
|
|
||||||
// case LoadTypes.Devices: // 仅加载设备数据
|
|
||||||
// await LoadDevices();
|
|
||||||
// break;
|
|
||||||
// case LoadTypes.Menu: // 仅加载菜单数据
|
|
||||||
// await LoadMenus();
|
|
||||||
// break;
|
|
||||||
// case LoadTypes.Mqtts: // 仅加载MQTT配置数据
|
|
||||||
// await LoadMqtts();
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// catch (Exception e)
|
|
||||||
// {
|
|
||||||
// // 捕获加载数据时发生的异常,并通过通知和日志记录错误信息。
|
|
||||||
// NotificationHelper.ShowError($"加载数据出现了错误:{e.Message}", e);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步加载设备数据,并以高效的方式更新UI集合。
|
/// 异步加载设备数据,并以高效的方式更新UI集合。
|
||||||
@@ -186,17 +153,6 @@ public partial class DataServices : ObservableRecipient, IRecipient<LoadMessage>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private void Device_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
|
||||||
// {
|
|
||||||
// if (e.PropertyName == nameof(Device.IsActive))
|
|
||||||
// {
|
|
||||||
// if (sender is Device device)
|
|
||||||
// {
|
|
||||||
// NlogHelper.Info($"设备 {device.Name} 的IsActive状态改变为 {device.IsActive},触发设备IsActive状态变更事件。");
|
|
||||||
// OnDeviceIsActiveChanged?.Invoke(device, device.IsActive);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步加载菜单数据,并以高效的方式更新UI集合。
|
/// 异步加载菜单数据,并以高效的方式更新UI集合。
|
||||||
@@ -292,36 +248,6 @@ public partial class DataServices : ObservableRecipient, IRecipient<LoadMessage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// /// <summary>
|
|
||||||
// /// 异步根据ID获取设备数据。
|
|
||||||
// /// </summary>
|
|
||||||
// /// <param name="id">设备ID。</param>
|
|
||||||
// /// <returns>设备对象,如果不存在则为null。</returns>
|
|
||||||
// public async Task<Device> GetDeviceByIdAsync(int id)
|
|
||||||
// {
|
|
||||||
// return await _deviceRepository.GetByIdAsync(id);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /// <summary>
|
|
||||||
// /// 异步加载变量数据。
|
|
||||||
// /// </summary>
|
|
||||||
// /// <returns>表示异步操作的任务。</returns>
|
|
||||||
// private async Task LoadVariables()
|
|
||||||
// {
|
|
||||||
// Variables = await _varDataRepository.GetAllAsync();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /// <summary>
|
|
||||||
// /// 异步更新变量数据。
|
|
||||||
// /// </summary>
|
|
||||||
// /// <param name="variable">要更新的变量数据。</param>
|
|
||||||
// /// <returns>表示异步操作的任务。</returns>
|
|
||||||
// public async Task UpdateVariableAsync(Variable variable)
|
|
||||||
// {
|
|
||||||
// await _variableAppService.UpdateVariableAsync(_mapper.Map<VariableDto>(variable));
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void Receive(LoadMessage message)
|
public void Receive(LoadMessage message)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,29 +120,10 @@ public partial class DevicesViewModel : ViewModelBase, INavigatable
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeviceItemViewModel device = new DeviceItemViewModel()
|
|
||||||
// {
|
|
||||||
// Name = "Test",
|
|
||||||
// Description = "Test Device",
|
|
||||||
// IpAddress = "127.0.0.1",
|
|
||||||
// Port = 8080,
|
|
||||||
// Protocol = ProtocolType.S7,
|
|
||||||
// CpuType = "S7-1200",
|
|
||||||
// DeviceType = DeviceType.SiemensPLC,
|
|
||||||
// IsActive = true,
|
|
||||||
//
|
|
||||||
// };
|
|
||||||
|
|
||||||
|
|
||||||
CreateDeviceWithDetailsDto dto = new CreateDeviceWithDetailsDto();
|
CreateDeviceWithDetailsDto dto = new CreateDeviceWithDetailsDto();
|
||||||
dto.Device = _mapper.Map<DeviceDto>(device);
|
dto.Device = _mapper.Map<DeviceDto>(device);
|
||||||
|
|
||||||
dto.VariableTable = new VariableTableDto()
|
|
||||||
{
|
|
||||||
Name = "默认变量表",
|
|
||||||
Description = "默认变量表",
|
|
||||||
IsActive = true
|
|
||||||
};
|
|
||||||
|
|
||||||
dto.DeviceMenu = new MenuBeanDto()
|
dto.DeviceMenu = new MenuBeanDto()
|
||||||
{
|
{
|
||||||
@@ -150,18 +131,34 @@ public partial class DevicesViewModel : ViewModelBase, INavigatable
|
|||||||
Icon = SegoeFluentIcons.Devices2.Glyph,
|
Icon = SegoeFluentIcons.Devices2.Glyph,
|
||||||
TargetViewKey = "DevicesView"
|
TargetViewKey = "DevicesView"
|
||||||
};
|
};
|
||||||
|
if (device.IsAddDefVarTable)
|
||||||
|
{
|
||||||
|
dto.VariableTable = new VariableTableDto()
|
||||||
|
{
|
||||||
|
Name = "默认变量表",
|
||||||
|
Description = "默认变量表",
|
||||||
|
IsActive = true
|
||||||
|
};
|
||||||
dto.VariableTableMenu = new MenuBeanDto()
|
dto.VariableTableMenu = new MenuBeanDto()
|
||||||
{
|
{
|
||||||
Header = dto.VariableTable.Name,
|
Header = dto.VariableTable.Name,
|
||||||
Icon = SegoeFluentIcons.DataSense.Glyph,
|
Icon = SegoeFluentIcons.DataSense.Glyph,
|
||||||
TargetViewKey = "VariableTableView"
|
TargetViewKey = "VariableTableView"
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var addDto = await _deviceAppService.CreateDeviceWithDetailsAsync(dto);
|
var addDto = await _deviceAppService.CreateDeviceWithDetailsAsync(dto);
|
||||||
|
|
||||||
DataServices.Devices.Add(_mapper.Map<DeviceItemViewModel>(addDto.Device));
|
DataServices.Devices.Add(_mapper.Map<DeviceItemViewModel>(addDto.Device));
|
||||||
//
|
if (addDto.DeviceMenu != null)
|
||||||
// await _deviceRepository.AddAsync(device);
|
{
|
||||||
|
var deviceMenu = DataServices.Menus.FirstOrDefault(m => m.Id == addDto.DeviceMenu.ParentId);
|
||||||
|
if (deviceMenu!=null)
|
||||||
|
{
|
||||||
|
deviceMenu.Children.Add(_mapper.Map<MenuBeanItemViewModel>(addDto.DeviceMenu));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using DMS.Application.DTOs;
|
|
||||||
using DMS.Core.Enums;
|
using DMS.Core.Enums;
|
||||||
|
|
||||||
namespace DMS.WPF.ViewModels.Items;
|
namespace DMS.WPF.ViewModels.Items;
|
||||||
@@ -54,54 +53,25 @@ public partial class DeviceItemViewModel : ObservableObject
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string _status;
|
private string _status;
|
||||||
|
|
||||||
partial void OnProtocolChanged(ProtocolType oldValue, ProtocolType newValue)
|
[ObservableProperty]
|
||||||
{
|
private bool _isAddDefVarTable;
|
||||||
|
|
||||||
|
partial void OnIpAddressChanged(string newIpAddress)
|
||||||
|
{
|
||||||
|
if (Protocol == ProtocolType.OpcUa)
|
||||||
|
{
|
||||||
|
OpcUaServerUrl="opc.tcp://" + IpAddress+":"+Port;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
partial void OnPortChanged(int newPort)
|
||||||
|
{
|
||||||
|
if (Protocol == ProtocolType.OpcUa)
|
||||||
|
{
|
||||||
|
OpcUaServerUrl="opc.tcp://" + IpAddress+":"+Port;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableCollection<VariableTableItemViewModel> VariableTables { get; set; } = new();
|
public ObservableCollection<VariableTableItemViewModel> VariableTables { get; set; } = new();
|
||||||
|
|
||||||
public DeviceItemViewModel(DeviceDto dto)
|
|
||||||
{
|
|
||||||
Id = dto.Id;
|
|
||||||
_name = dto.Name;
|
|
||||||
_description = dto.Description;
|
|
||||||
_protocol = dto.Protocol;
|
|
||||||
_ipAddress = dto.IpAddress;
|
|
||||||
_port = dto.Port;
|
|
||||||
_rack = dto.Rack;
|
|
||||||
_slot = dto.Slot;
|
|
||||||
_cpuType = dto.CpuType;
|
|
||||||
_deviceType = dto.DeviceType;
|
|
||||||
_opcUaServerUrl = dto.OpcUaServerUrl;
|
|
||||||
_isActive = dto.IsActive;
|
|
||||||
_isRunning = dto.IsRunning;
|
|
||||||
_status = dto.Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DeviceItemViewModel()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public DeviceDto ToDto()
|
|
||||||
{
|
|
||||||
return new DeviceDto
|
|
||||||
{
|
|
||||||
Id = this.Id,
|
|
||||||
Name = this.Name,
|
|
||||||
Description = this.Description,
|
|
||||||
Protocol = this.Protocol,
|
|
||||||
IpAddress = this.IpAddress,
|
|
||||||
Port = this.Port,
|
|
||||||
Rack = this.Rack,
|
|
||||||
Slot = this.Slot,
|
|
||||||
CpuType = this.CpuType,
|
|
||||||
DeviceType = this.DeviceType,
|
|
||||||
OpcUaServerUrl = this.OpcUaServerUrl,
|
|
||||||
IsActive = this.IsActive,
|
|
||||||
IsRunning = this.IsRunning,
|
|
||||||
Status = this.Status
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,22 +52,5 @@ public partial class MqttServerItemViewModel : ObservableObject
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private ObservableCollection<VariableMqttAliasItemViewModel> _variableAliases = new();
|
private ObservableCollection<VariableMqttAliasItemViewModel> _variableAliases = new();
|
||||||
|
|
||||||
public MqttServerItemViewModel(MqttServerDto dto)
|
|
||||||
{
|
|
||||||
Id = dto.Id;
|
|
||||||
_serverName = dto.ServerName;
|
|
||||||
_brokerAddress = dto.BrokerAddress;
|
|
||||||
_port = dto.Port;
|
|
||||||
_username = dto.Username;
|
|
||||||
_password = dto.Password;
|
|
||||||
_isActive = dto.IsActive;
|
|
||||||
_subscribeTopic = dto.SubscribeTopic;
|
|
||||||
_publishTopic = dto.PublishTopic;
|
|
||||||
_clientId = dto.ClientId;
|
|
||||||
_createdAt = dto.CreatedAt;
|
|
||||||
_connectedAt = dto.ConnectedAt;
|
|
||||||
_connectionDuration = dto.ConnectionDuration;
|
|
||||||
_messageFormat = dto.MessageFormat;
|
|
||||||
_variableAliases = new ObservableCollection<VariableMqttAliasItemViewModel>(dto.VariableAliases.Select(va => new VariableMqttAliasItemViewModel(va)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,5 @@ public partial class UserItemViewModel : ObservableObject
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool _isActive;
|
private bool _isActive;
|
||||||
|
|
||||||
public UserItemViewModel(UserDto dto)
|
|
||||||
{
|
|
||||||
Id = dto.Id;
|
|
||||||
_username = dto.Username;
|
|
||||||
_role = dto.Role;
|
|
||||||
_isActive = dto.IsActive;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,11 +17,5 @@ public partial class VariableHistoryItemViewModel : ObservableObject
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private DateTime _timestamp;
|
private DateTime _timestamp;
|
||||||
|
|
||||||
public VariableHistoryItemViewModel(VariableHistoryDto dto)
|
|
||||||
{
|
|
||||||
Id = dto.Id;
|
|
||||||
_variableId = dto.VariableId;
|
|
||||||
_value = dto.Value;
|
|
||||||
_timestamp = dto.Timestamp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,34 +89,5 @@ public partial class VariableItemViewModel : ObservableObject
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private OpcUaUpdateType _opcUaUpdateType;
|
private OpcUaUpdateType _opcUaUpdateType;
|
||||||
|
|
||||||
public VariableItemViewModel(VariableDto dto)
|
|
||||||
{
|
|
||||||
Id = dto.Id;
|
|
||||||
_name = dto.Name;
|
|
||||||
_s7Address = dto.S7Address;
|
|
||||||
_dataValue = dto.DataValue;
|
|
||||||
_displayValue = dto.DisplayValue;
|
|
||||||
_variableTable = dto.VariableTable;
|
|
||||||
_mqttAliases = dto.MqttAliases;
|
|
||||||
_signalType = dto.SignalType;
|
|
||||||
_pollLevel = dto.PollLevel;
|
|
||||||
_isActive = dto.IsActive;
|
|
||||||
_variableTableId = dto.VariableTableId;
|
|
||||||
_opcUaNodeId = dto.OpcUaNodeId;
|
|
||||||
_isHistoryEnabled = dto.IsHistoryEnabled;
|
|
||||||
_historyDeadband = dto.HistoryDeadband;
|
|
||||||
_isAlarmEnabled = dto.IsAlarmEnabled;
|
|
||||||
_alarmMinValue = dto.AlarmMinValue;
|
|
||||||
_alarmMaxValue = dto.AlarmMaxValue;
|
|
||||||
_alarmDeadband = dto.AlarmDeadband;
|
|
||||||
_protocol = dto.Protocol;
|
|
||||||
_cSharpDataType = dto.CSharpDataType;
|
|
||||||
_conversionFormula = dto.ConversionFormula;
|
|
||||||
_createdAt = dto.CreatedAt;
|
|
||||||
_updatedAt = dto.UpdatedAt;
|
|
||||||
_updatedBy = dto.UpdatedBy;
|
|
||||||
_isModified = dto.IsModified;
|
|
||||||
_description = dto.Description;
|
|
||||||
_opcUaUpdateType = dto.OpcUaUpdateType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,12 +19,5 @@ public partial class VariableMqttAliasItemViewModel : ObservableObject
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string _alias;
|
private string _alias;
|
||||||
|
|
||||||
public VariableMqttAliasItemViewModel(VariableMqttAliasDto dto)
|
|
||||||
{
|
|
||||||
Id = dto.Id;
|
|
||||||
_variableId = dto.VariableId;
|
|
||||||
_mqttServerId = dto.MqttServerId;
|
|
||||||
_mqttServerName = dto.MqttServerName;
|
|
||||||
_alias = dto.Alias;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,14 +28,5 @@ public partial class VariableTableItemViewModel : ObservableObject
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private ObservableCollection<VariableItemViewModel> _variables = new();
|
private ObservableCollection<VariableItemViewModel> _variables = new();
|
||||||
|
|
||||||
public VariableTableItemViewModel(VariableTableDto dto)
|
|
||||||
{
|
|
||||||
Id = dto.Id;
|
|
||||||
_name = dto.Name;
|
|
||||||
_description = dto.Description;
|
|
||||||
_isActive = dto.IsActive;
|
|
||||||
_deviceId = dto.DeviceId;
|
|
||||||
_protocol = dto.Protocol;
|
|
||||||
_variables = new ObservableCollection<VariableItemViewModel>(dto.Variables.Select(v => new VariableItemViewModel(v)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@
|
|||||||
<TextBlock Text="设备类型"
|
<TextBlock Text="设备类型"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Style="{StaticResource TextBlockSubTitle}" />
|
Style="{StaticResource TextBlockSubTitle}" />
|
||||||
<ComboBox SelectedItem="{Binding Device}"
|
<ComboBox SelectedItem="{Binding Device.DeviceType}"
|
||||||
ItemsSource="{Binding Source={StaticResource deviceType} }">
|
ItemsSource="{Binding Source={StaticResource deviceType} }">
|
||||||
<ComboBox.ItemTemplate>
|
<ComboBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
@@ -111,6 +111,25 @@
|
|||||||
</ComboBox.ItemTemplate>
|
</ComboBox.ItemTemplate>
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
|
|
||||||
|
<StackPanel Background="LightGray">
|
||||||
|
<StackPanel.Style>
|
||||||
|
<Style TargetType="StackPanel">
|
||||||
|
<Setter Property="Visibility" Value="Collapsed" />
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding ElementName=ProtocolComboBox, Path=SelectedItem, Converter={StaticResource EnumToStringConverter}}"
|
||||||
|
Value="OpcUa">
|
||||||
|
<Setter Property="Visibility" Value="Visible" />
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</StackPanel.Style>
|
||||||
|
<TextBlock Text="OpcUa服务器地址"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Style="{StaticResource TextBlockSubTitle}" />
|
||||||
|
<TextBox Text="{Binding Device.OpcUaServerUrl}"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
|
||||||
<!-- S7 Specific Properties -->
|
<!-- S7 Specific Properties -->
|
||||||
<StackPanel x:Name="S7PropertiesPanel" Background="LightGray">
|
<StackPanel x:Name="S7PropertiesPanel" Background="LightGray">
|
||||||
<StackPanel.Style>
|
<StackPanel.Style>
|
||||||
|
|||||||
Reference in New Issue
Block a user