2021-12-12 06:55:48 +00:00
|
|
|
|
using PluginInterface;
|
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2023-04-12 15:40:00 +00:00
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Converters;
|
2021-12-12 06:55:48 +00:00
|
|
|
|
using WalkingTec.Mvvm.Core;
|
2024-07-19 01:23:04 +00:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2021-12-12 06:55:48 +00:00
|
|
|
|
|
|
|
|
|
namespace IoTGateway.Model
|
|
|
|
|
{
|
2024-07-19 01:23:04 +00:00
|
|
|
|
[Comment("变量配置")]
|
|
|
|
|
[Index(nameof(Name))]
|
|
|
|
|
[Index(nameof(Method))]
|
|
|
|
|
[Index(nameof(DeviceAddress))]
|
|
|
|
|
[Index(nameof(DataType))]
|
2021-12-12 06:55:48 +00:00
|
|
|
|
public class DeviceVariable : TopBasePoco, IVariable
|
|
|
|
|
{
|
2024-07-19 01:23:04 +00:00
|
|
|
|
[Comment("变量名")]
|
2024-01-08 14:18:16 +00:00
|
|
|
|
[Display(Name = "VariableName")]
|
2021-12-12 06:55:48 +00:00
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
2024-07-19 01:23:04 +00:00
|
|
|
|
[Comment("描述")]
|
2023-12-23 09:34:58 +00:00
|
|
|
|
[Display(Name = "Description")]
|
2021-12-12 06:55:48 +00:00
|
|
|
|
public string Description { get; set; }
|
|
|
|
|
|
2024-07-19 01:23:04 +00:00
|
|
|
|
[Comment("方法")]
|
2023-12-23 09:34:58 +00:00
|
|
|
|
[Display(Name = "Method")]
|
2021-12-12 06:55:48 +00:00
|
|
|
|
public string Method { get; set; }
|
|
|
|
|
|
2024-07-19 01:23:04 +00:00
|
|
|
|
[Comment("地址")]
|
2023-12-23 09:34:58 +00:00
|
|
|
|
[Display(Name = "Address")]
|
2021-12-12 06:55:48 +00:00
|
|
|
|
public string DeviceAddress { get; set; }
|
|
|
|
|
|
2024-07-19 01:23:04 +00:00
|
|
|
|
[Comment("数据类型")]
|
2023-12-23 09:34:58 +00:00
|
|
|
|
[Display(Name = "DataType")]
|
2022-12-06 14:39:28 +00:00
|
|
|
|
public DataTypeEnum DataType { get; set; }
|
|
|
|
|
|
2024-07-19 01:23:04 +00:00
|
|
|
|
[Comment("触发")]
|
2024-05-31 14:58:58 +00:00
|
|
|
|
[Display(Name = "IsTrigger")]
|
|
|
|
|
public bool IsTrigger { get; set; }
|
|
|
|
|
|
2024-07-19 01:23:04 +00:00
|
|
|
|
[Comment("大小端")]
|
2023-12-23 09:34:58 +00:00
|
|
|
|
[Display(Name = "EndianType")]
|
2022-12-06 14:39:28 +00:00
|
|
|
|
public EndianEnum EndianType { get; set; }
|
2021-12-12 06:55:48 +00:00
|
|
|
|
|
2024-07-19 01:23:04 +00:00
|
|
|
|
[Comment("表达式")]
|
2023-12-23 09:34:58 +00:00
|
|
|
|
[Display(Name = "Expressions")]
|
2021-12-17 07:51:25 +00:00
|
|
|
|
public string Expressions { get; set; }
|
2021-12-12 06:55:48 +00:00
|
|
|
|
|
2024-07-19 01:23:04 +00:00
|
|
|
|
[Comment("上传")]
|
2023-12-23 09:34:58 +00:00
|
|
|
|
[Display(Name = "Upload")]
|
2023-04-12 15:40:00 +00:00
|
|
|
|
public bool IsUpload { get; set; }
|
|
|
|
|
|
2024-07-19 01:23:04 +00:00
|
|
|
|
[Comment("权限")]
|
2023-12-23 09:34:58 +00:00
|
|
|
|
[Display(Name = "Permissions")]
|
2021-12-12 06:55:48 +00:00
|
|
|
|
public ProtectTypeEnum ProtectType { get; set; }
|
|
|
|
|
|
2024-07-19 01:23:04 +00:00
|
|
|
|
[Comment("排序")]
|
2024-01-08 14:18:16 +00:00
|
|
|
|
[Display(Name = "Sort")]
|
2022-08-25 00:59:49 +00:00
|
|
|
|
public uint Index { get; set; }
|
|
|
|
|
|
2022-08-21 14:01:32 +00:00
|
|
|
|
[Newtonsoft.Json.JsonIgnore]
|
2021-12-12 06:55:48 +00:00
|
|
|
|
public Device Device { get; set; }
|
2024-07-19 01:23:04 +00:00
|
|
|
|
[Comment("所属设备")]
|
2024-01-08 14:18:16 +00:00
|
|
|
|
[Display(Name = "Device")]
|
2021-12-12 06:55:48 +00:00
|
|
|
|
public Guid? DeviceId { get; set; }
|
2023-04-12 15:40:00 +00:00
|
|
|
|
|
2024-07-19 01:23:04 +00:00
|
|
|
|
[Comment("别名")]
|
2023-12-23 09:34:58 +00:00
|
|
|
|
[Display(Name = "Alias")]
|
2023-04-12 15:40:00 +00:00
|
|
|
|
public string Alias { get; set; }
|
|
|
|
|
|
2024-07-19 01:23:04 +00:00
|
|
|
|
[Comment("原值")]
|
2023-04-12 15:40:00 +00:00
|
|
|
|
[NotMapped]
|
2024-01-08 14:18:16 +00:00
|
|
|
|
[Display(Name = "RawValue")]
|
2023-04-12 15:40:00 +00:00
|
|
|
|
public object Value { get; set; }
|
2024-07-19 01:23:04 +00:00
|
|
|
|
|
|
|
|
|
[Comment("计算后的值")]
|
2023-04-12 15:40:00 +00:00
|
|
|
|
[NotMapped]
|
2023-12-23 09:34:58 +00:00
|
|
|
|
[Display(Name = "CookedValue")]
|
2023-04-12 15:40:00 +00:00
|
|
|
|
public object CookedValue { get; set; }
|
2024-07-19 01:23:04 +00:00
|
|
|
|
|
|
|
|
|
[Comment("错误信息")]
|
2023-04-12 15:40:00 +00:00
|
|
|
|
[NotMapped]
|
2024-01-08 14:18:16 +00:00
|
|
|
|
[Display(Name = "Message")]
|
2023-04-12 15:40:00 +00:00
|
|
|
|
public string Message { get; set; }
|
2024-07-19 01:23:04 +00:00
|
|
|
|
|
|
|
|
|
[Comment("更新时间")]
|
2023-04-12 15:40:00 +00:00
|
|
|
|
[NotMapped]
|
2024-01-08 14:18:16 +00:00
|
|
|
|
[Display(Name = "Timestamp")]
|
2023-04-12 15:40:00 +00:00
|
|
|
|
public DateTime Timestamp { get; set; }
|
2024-07-19 01:23:04 +00:00
|
|
|
|
|
|
|
|
|
[Comment("状态")]
|
2023-04-12 15:40:00 +00:00
|
|
|
|
[NotMapped]
|
2024-01-08 14:18:16 +00:00
|
|
|
|
[Display(Name = "Status")]
|
2023-04-12 15:40:00 +00:00
|
|
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
|
|
|
public VaribaleStatusTypeEnum StatusType { get; set; } = VaribaleStatusTypeEnum.UnKnow;
|
2023-10-18 02:26:40 +00:00
|
|
|
|
|
2024-07-19 01:23:04 +00:00
|
|
|
|
[Comment("最新三次原值")]
|
2024-01-08 14:18:16 +00:00
|
|
|
|
[NotMapped][Display(Name = "MostRecentValues")] public object[] Values { get; set; } = new object[3];
|
2024-07-19 01:23:04 +00:00
|
|
|
|
|
|
|
|
|
[Comment("最新三次计算后的值")]
|
2024-05-31 14:58:58 +00:00
|
|
|
|
[NotMapped][Display(Name = "MostRecentCookedValues")] public object[] CookedValues { get; set; } = new object[3];
|
2023-10-18 02:26:40 +00:00
|
|
|
|
public void EnqueueVariable(object value)
|
|
|
|
|
{
|
|
|
|
|
Values[2] = Values[1];
|
|
|
|
|
Values[1] = Values[0];
|
|
|
|
|
Values[0] = value;
|
|
|
|
|
}
|
2024-05-31 14:58:58 +00:00
|
|
|
|
public void EnqueueCookedVariable(object value)
|
|
|
|
|
{
|
|
|
|
|
CookedValues[2] = CookedValues[1];
|
|
|
|
|
CookedValues[1] = CookedValues[0];
|
|
|
|
|
CookedValues[0] = value;
|
|
|
|
|
}
|
2021-12-12 06:55:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|