diff --git a/BPASmartClient.Device/BaseDevice.cs b/BPASmartClient.Device/BaseDevice.cs index be2eea4b..3ef2b91e 100644 --- a/BPASmartClient.Device/BaseDevice.cs +++ b/BPASmartClient.Device/BaseDevice.cs @@ -122,6 +122,7 @@ namespace BPASmartClient.Device public IAlarm InterfaceAlarm { get; set; } public AlarmHelper alarmHelper { get; set; } = new AlarmHelper(); public IStatus InterfaceStatus { get; set; } + public ObservableCollection variables { get; set; } = new ObservableCollection(); #endregion @@ -284,7 +285,7 @@ namespace BPASmartClient.Device foreach (var faces in res) { if (faces.Name == "IStatus") - { + { InterfaceStatus = item.GetValue(this) as IStatus; GetMonitorData(InterfaceStatus); } diff --git a/BPASmartClient.Device/IDevice.cs b/BPASmartClient.Device/IDevice.cs index 2fd0dcdd..ae7aaa2d 100644 --- a/BPASmartClient.Device/IDevice.cs +++ b/BPASmartClient.Device/IDevice.cs @@ -62,6 +62,8 @@ namespace BPASmartClient.Device /// ObservableCollection variableMonitors { get; set; } + ObservableCollection variables { get; set; } + /// /// 设备报警信息集合 /// diff --git a/BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs b/BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs index 07f19945..6181cc29 100644 --- a/BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs +++ b/BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs @@ -41,6 +41,23 @@ namespace BPASmartClient.PLC } } } + + //foreach (var par in tempVar) + //{ + // if (par.Value?.Address.Length > 0) + // { + // var res = modbusTcp.Read(par.Value.Address, (ushort)par.Value.ReadLeng); + // if (status.ContainsKey(par.Value.Address)) + // { + // status[par.Value.Address] = res; + // } + // else + // { + // status.TryAdd(par.Value.Address, res); + // } + // } + //} + Thread.Sleep(100); } Thread.Sleep(1000); @@ -78,6 +95,18 @@ namespace BPASmartClient.PLC modbusTcp.Write(address, value); } + public override void AddVarInfo(string add, int len) + { + if (!tempVar.ContainsKey(add) && !string.IsNullOrEmpty(add) && len > 0) + { + tempVar.TryAdd(add, new Variable() + { + Address = add, + ReadLeng = len + }); + } + } + protected override void InitStatus() { diff --git a/BPASmartClient.MorkS/View/ParSet.xaml b/BPASmartClient.MorkS/View/ParSet.xaml index 8cfaca7b..531a53ed 100644 --- a/BPASmartClient.MorkS/View/ParSet.xaml +++ b/BPASmartClient.MorkS/View/ParSet.xaml @@ -129,8 +129,8 @@ -