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)