From 4823105e6293a84173d908d4ee1cfc437ef245b9 Mon Sep 17 00:00:00 2001 From: fyf Date: Wed, 11 May 2022 16:27:35 +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 --- BPASmartClient.Device/BaseDevice.cs | 18 ++++++++++++++++-- BPASmartClient.Device/IDevice.cs | 11 ++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/BPASmartClient.Device/BaseDevice.cs b/BPASmartClient.Device/BaseDevice.cs index 51f1b77f..246267d8 100644 --- a/BPASmartClient.Device/BaseDevice.cs +++ b/BPASmartClient.Device/BaseDevice.cs @@ -76,8 +76,7 @@ namespace BPASmartClient.Device public List Error { get; set; } = new List(); public List variableMonitors { get; set; } = new List(); - ConcurrentDictionary IDevice.Log { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - ConcurrentDictionary IDevice.Error { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } + /// /// 外设状态,硬件设备数据 @@ -434,6 +433,7 @@ namespace BPASmartClient.Device public object GetError() { + object time= GetPropertyValue(Error[0], "Time"); return new { data = Error }; } @@ -446,5 +446,19 @@ namespace BPASmartClient.Device { return new { data = variableMonitors }; } + + /// + /// 获取某个对象中的属性值 + /// + /// + /// + /// + public object GetPropertyValue(object info, string field) + { + if (info == null) return null; + Type t = info.GetType(); + IEnumerable property = from pi in t.GetProperties() where pi.Name.ToLower() == field.ToLower() select pi; + return property.First().GetValue(info, null); + } } } diff --git a/BPASmartClient.Device/IDevice.cs b/BPASmartClient.Device/IDevice.cs index d755a731..eb0fbe70 100644 --- a/BPASmartClient.Device/IDevice.cs +++ b/BPASmartClient.Device/IDevice.cs @@ -33,11 +33,11 @@ namespace BPASmartClient.Device /// /// 运行日志 /// - public ConcurrentDictionary Log { get; set; } + public List Log { get; set; } /// /// 运行告警 /// - public ConcurrentDictionary Error { get; set; } + public List Error { get; set; } /// /// 设备变量信息 /// @@ -75,6 +75,11 @@ namespace BPASmartClient.Device /// 获取硬件信息 /// object GetVariableMonitor(); - + /// + /// 获取属性变量 + /// + /// + /// + object GetPropertyValue(object info, string field); } }