|
|
|
@ -1,8 +1,8 @@
|
|
|
|
|
|
|
|
|
|
using Infrastructure.Domain;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.Text.Json;
|
|
|
|
|
|
|
|
|
|
namespace Application.Domain.Entities
|
|
|
|
|
{
|
|
|
|
@ -21,8 +21,14 @@ namespace Application.Domain.Entities
|
|
|
|
|
[Display(Name = "名称")]
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
|
|
|
[Display(Name = "类型")]
|
|
|
|
|
public IoTValueType Type { get; set; }
|
|
|
|
|
[Display(Name = "数据类型")]
|
|
|
|
|
public IoTDataType DataType { get; set; }
|
|
|
|
|
|
|
|
|
|
[Display(Name = "数值类型")]
|
|
|
|
|
public IoTValueType ValueType { get; set; }
|
|
|
|
|
|
|
|
|
|
[Display(Name = "枚举定义")]
|
|
|
|
|
public String EnumValues { get; set; }
|
|
|
|
|
|
|
|
|
|
[Display(Name = "单位")]
|
|
|
|
|
public string Unit { get; set; }
|
|
|
|
@ -44,17 +50,27 @@ namespace Application.Domain.Entities
|
|
|
|
|
|
|
|
|
|
public List<IoTTigger> IoTTiggers { get; set; } = new List<IoTTigger>();
|
|
|
|
|
|
|
|
|
|
public Dictionary<int,string> GetEnumValues()
|
|
|
|
|
{
|
|
|
|
|
return JsonSerializer.Deserialize<Dictionary<int, string>>(this.EnumValues);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetEnumValues(Dictionary<int, string> values)
|
|
|
|
|
{
|
|
|
|
|
this.EnumValues = JsonSerializer.Serialize(values);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public dynamic GetValue()
|
|
|
|
|
{
|
|
|
|
|
if (this.Type == IoTValueType.Int)
|
|
|
|
|
if (this.ValueType == IoTValueType.Int)
|
|
|
|
|
{
|
|
|
|
|
return Convert.ToInt32(this.Value);
|
|
|
|
|
}
|
|
|
|
|
else if (this.Type == IoTValueType.Float)
|
|
|
|
|
else if (this.ValueType == IoTValueType.Float)
|
|
|
|
|
{
|
|
|
|
|
return Convert.ToSingle(this.Value);
|
|
|
|
|
}
|
|
|
|
|
else if (this.Type == IoTValueType.Long)
|
|
|
|
|
else if (this.ValueType == IoTValueType.Long)
|
|
|
|
|
{
|
|
|
|
|
return Convert.ToInt64(this.Value);
|
|
|
|
|
}
|
|
|
|
|