fyf 2 роки тому
джерело
коміт
4823105e62
2 змінених файлів з 24 додано та 5 видалено
  1. +16
    -2
      BPASmartClient.Device/BaseDevice.cs
  2. +8
    -3
      BPASmartClient.Device/IDevice.cs

+ 16
- 2
BPASmartClient.Device/BaseDevice.cs Переглянути файл

@@ -76,8 +76,7 @@ namespace BPASmartClient.Device
public List<object> Error { get; set; } = new List<object>();

public List<VariableMonitor> variableMonitors { get; set; } = new List<VariableMonitor>();
ConcurrentDictionary<string, object> IDevice.Log { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
ConcurrentDictionary<string, object> IDevice.Error { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

/// <summary>
/// 外设状态,硬件设备数据
@@ -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 };
}

/// <summary>
/// 获取某个对象中的属性值
/// </summary>
/// <param name="info"></param>
/// <param name="field"></param>
/// <returns></returns>
public object GetPropertyValue(object info, string field)
{
if (info == null) return null;
Type t = info.GetType();
IEnumerable<System.Reflection.PropertyInfo> property = from pi in t.GetProperties() where pi.Name.ToLower() == field.ToLower() select pi;
return property.First().GetValue(info, null);
}
}
}

+ 8
- 3
BPASmartClient.Device/IDevice.cs Переглянути файл

@@ -33,11 +33,11 @@ namespace BPASmartClient.Device
/// <summary>
/// 运行日志
/// </summary>
public ConcurrentDictionary<string, object> Log { get; set; }
public List<object> Log { get; set; }
/// <summary>
/// 运行告警
/// </summary>
public ConcurrentDictionary<string, object> Error { get; set; }
public List<object> Error { get; set; }
/// <summary>
/// 设备变量信息
/// </summary>
@@ -75,6 +75,11 @@ namespace BPASmartClient.Device
/// 获取硬件信息
/// </summary>
object GetVariableMonitor();

/// <summary>
/// 获取属性变量
/// </summary>
/// <param name="info"></param>
/// <param name="field"></param>
object GetPropertyValue(object info, string field);
}
}

Завантаження…
Відмінити
Зберегти