2021-12-12 14:55:48 +08:00
|
|
|
|
using PluginInterface;
|
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2023-04-12 23:40:00 +08:00
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Converters;
|
2021-12-12 14:55:48 +08:00
|
|
|
|
using WalkingTec.Mvvm.Core;
|
|
|
|
|
|
|
|
|
|
namespace IoTGateway.Model
|
|
|
|
|
{
|
|
|
|
|
public class DeviceVariable : TopBasePoco, IVariable
|
|
|
|
|
{
|
2023-12-23 17:34:58 +08:00
|
|
|
|
[Display(Name = "Tag Name")]
|
2021-12-12 14:55:48 +08:00
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
2023-12-23 17:34:58 +08:00
|
|
|
|
[Display(Name = "Description")]
|
2021-12-12 14:55:48 +08:00
|
|
|
|
public string Description { get; set; }
|
|
|
|
|
|
2023-12-23 17:34:58 +08:00
|
|
|
|
[Display(Name = "Method")]
|
2021-12-12 14:55:48 +08:00
|
|
|
|
public string Method { get; set; }
|
|
|
|
|
|
2023-12-23 17:34:58 +08:00
|
|
|
|
[Display(Name = "Address")]
|
2021-12-12 14:55:48 +08:00
|
|
|
|
public string DeviceAddress { get; set; }
|
|
|
|
|
|
2023-12-23 17:34:58 +08:00
|
|
|
|
[Display(Name = "DataType")]
|
2022-12-06 22:39:28 +08:00
|
|
|
|
public DataTypeEnum DataType { get; set; }
|
|
|
|
|
|
2023-12-23 17:34:58 +08:00
|
|
|
|
[Display(Name = "EndianType")]
|
2022-12-06 22:39:28 +08:00
|
|
|
|
public EndianEnum EndianType { get; set; }
|
2021-12-12 14:55:48 +08:00
|
|
|
|
|
2023-12-23 17:34:58 +08:00
|
|
|
|
[Display(Name = "Expressions")]
|
2021-12-17 15:51:25 +08:00
|
|
|
|
public string Expressions { get; set; }
|
2021-12-12 14:55:48 +08:00
|
|
|
|
|
2023-12-23 17:34:58 +08:00
|
|
|
|
[Display(Name = "Upload")]
|
2023-04-12 23:40:00 +08:00
|
|
|
|
public bool IsUpload { get; set; }
|
|
|
|
|
|
2023-12-23 17:34:58 +08:00
|
|
|
|
[Display(Name = "Permissions")]
|
2021-12-12 14:55:48 +08:00
|
|
|
|
public ProtectTypeEnum ProtectType { get; set; }
|
|
|
|
|
|
2023-12-23 17:34:58 +08:00
|
|
|
|
[Display(Name = "sort")]
|
2022-08-25 08:59:49 +08:00
|
|
|
|
public uint Index { get; set; }
|
|
|
|
|
|
2022-08-21 22:01:32 +08:00
|
|
|
|
[Newtonsoft.Json.JsonIgnore]
|
2021-12-12 14:55:48 +08:00
|
|
|
|
public Device Device { get; set; }
|
2023-12-23 17:34:58 +08:00
|
|
|
|
[Display(Name = "ID")]
|
2021-12-12 14:55:48 +08:00
|
|
|
|
public Guid? DeviceId { get; set; }
|
2023-04-12 23:40:00 +08:00
|
|
|
|
|
2023-12-23 17:34:58 +08:00
|
|
|
|
[Display(Name = "Alias")]
|
2023-04-12 23:40:00 +08:00
|
|
|
|
public string Alias { get; set; }
|
|
|
|
|
|
|
|
|
|
[NotMapped]
|
2023-12-23 17:34:58 +08:00
|
|
|
|
[Display(Name = "Value")]
|
2023-04-12 23:40:00 +08:00
|
|
|
|
public object Value { get; set; }
|
|
|
|
|
[NotMapped]
|
2023-12-23 17:34:58 +08:00
|
|
|
|
[Display(Name = "CookedValue")]
|
2023-04-12 23:40:00 +08:00
|
|
|
|
public object CookedValue { get; set; }
|
|
|
|
|
[NotMapped]
|
|
|
|
|
public string Message { get; set; }
|
|
|
|
|
[NotMapped]
|
2023-12-23 17:34:58 +08:00
|
|
|
|
[Display(Name = "Update time")]
|
2023-04-12 23:40:00 +08:00
|
|
|
|
public DateTime Timestamp { get; set; }
|
|
|
|
|
[NotMapped]
|
2023-12-23 17:34:58 +08:00
|
|
|
|
[Display(Name = "State")]
|
2023-04-12 23:40:00 +08:00
|
|
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
|
|
|
public VaribaleStatusTypeEnum StatusType { get; set; } = VaribaleStatusTypeEnum.UnKnow;
|
2023-10-18 10:26:40 +08:00
|
|
|
|
|
2023-12-23 17:34:58 +08:00
|
|
|
|
[NotMapped][Display(Name = "The Most Recent Values")] public object[] Values { get; set; } = new object[3];
|
2023-10-18 10:26:40 +08:00
|
|
|
|
public void EnqueueVariable(object value)
|
|
|
|
|
{
|
|
|
|
|
Values[2] = Values[1];
|
|
|
|
|
Values[1] = Values[0];
|
|
|
|
|
Values[0] = value;
|
|
|
|
|
}
|
2021-12-12 14:55:48 +08:00
|
|
|
|
}
|
|
|
|
|
}
|