完成打开导入OPC变量对话框自动连接服务器
This commit is contained in:
@@ -37,6 +37,8 @@ public partial class OpcUaImportDialogViewModel : ObservableObject
|
||||
{
|
||||
OpcUaNodes = new ObservableCollection<OpcUaNode>();
|
||||
SelectedNodeVariables = new ObservableCollection<VariableData>();
|
||||
// Automatically connect when the ViewModel is created
|
||||
_ = Connect().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
|
||||
@@ -232,7 +232,13 @@ partial class VariableTableViewModel : ViewModelBase
|
||||
{
|
||||
try
|
||||
{
|
||||
var importedVariables = await _dialogService.ShowOpcUaImportDialog();
|
||||
string opcUaEndpointUrl = VariableTable?.Device?.OpcUaEndpointUrl;
|
||||
if (string.IsNullOrEmpty(opcUaEndpointUrl))
|
||||
{
|
||||
NotificationHelper.ShowError("OPC UA Endpoint URL 未设置。请在设备详情中配置。");
|
||||
return;
|
||||
}
|
||||
var importedVariables = await _dialogService.ShowOpcUaImportDialog(opcUaEndpointUrl);
|
||||
if (importedVariables == null || !importedVariables.Any())
|
||||
{
|
||||
return; // 用户取消或没有选择任何变量
|
||||
|
||||
Reference in New Issue
Block a user