From 1c93108e888b0f6e78a92e026c0a564de8b4e37d Mon Sep 17 00:00:00 2001 From: fyf Date: Thu, 22 Sep 2022 14:51:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs | 7 ++++--- BeDesignerSCADA/ViewModel/MainViewModelNew.cs | 14 +++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs b/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs index 62aa15d2..56e1b1ef 100644 --- a/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs +++ b/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs @@ -345,9 +345,10 @@ namespace BeDesignerSCADA.Controls { System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender; if (toggle.Tag == null) return; - if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(toggle.Tag.ToString())) + CommunicationModel mode=viewModel.communicationPar?.CommunicationDevices?.ToList().Find(par => par.DeviceName == toggle.Tag.ToString()); + if (mode != null) { - Class_DataBus.GetInstance().Dic_DeviceData[toggle.Tag.ToString()].Keys?.ToList().ForEach(key => { viewModel.DevValueList.Add(key); }); + mode?.VarTableModels?.ToList().ForEach(par => { viewModel.DevValueList.Add(par.VarName); }); } } } @@ -390,7 +391,7 @@ namespace BeDesignerSCADA.Controls private void namebox_DropDownOpened(object sender, EventArgs e) { viewModel.DevNameList = new System.Collections.ObjectModel.ObservableCollection(); - Class_DataBus.GetInstance().Dic_DeviceData.Keys?.ToList().ForEach(key => { viewModel.DevNameList.Add(key); }); + viewModel.communicationPar?.CommunicationDevices?.ToList().ForEach(x => { viewModel.DevNameList.Add(x.DeviceName); }); } #endregion } diff --git a/BeDesignerSCADA/ViewModel/MainViewModelNew.cs b/BeDesignerSCADA/ViewModel/MainViewModelNew.cs index a5665ae2..718ae6e1 100644 --- a/BeDesignerSCADA/ViewModel/MainViewModelNew.cs +++ b/BeDesignerSCADA/ViewModel/MainViewModelNew.cs @@ -1,6 +1,7 @@ using BeDesignerSCADA.Common; using BeDesignerSCADA.Controls; using BeDesignerSCADA.View; +using BPASmart.Model; using BPASmartClient.Compiler; using BPASmartClient.DATABUS; using BPASmartClient.MessageName; @@ -12,6 +13,7 @@ using Microsoft.Toolkit.Mvvm.ComponentModel; using Microsoft.Toolkit.Mvvm.Input; using Microsoft.Win32; using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; @@ -35,7 +37,7 @@ namespace BeDesignerSCADA.ViewModel { IsRunning = !IsRunning; }); - DataBusModel.GetInstance().RefreshTheVariableManagerAction += RefreshTheVariableManagerActionHader; + DataBusModel.GetInstance().RefreshTheVariableManagerAction += RefreshTheVariableManagerActionHader; } #region 变量 @@ -43,7 +45,10 @@ namespace BeDesignerSCADA.ViewModel /// 变量管理器地址 /// public string VariablePath = string.Empty; - + /// + /// 当前变量管理器变量 + /// + public CommunicationPar communicationPar = new CommunicationPar(); /// /// 是否正在运行状态 /// @@ -211,7 +216,10 @@ namespace BeDesignerSCADA.ViewModel { if (path == VariablePath && !string.IsNullOrEmpty(VariablePath)) { - + if (DataBusModel.GetInstance().KeyValues.ContainsKey(VariablePath)) + { + communicationPar = DataBusModel.GetInstance().KeyValues[VariablePath]; + } } } catch (Exception ex)