iotgateway/IoTGateway.Model/DeviceVariable.cs

75 lines
2.2 KiB
C#
Raw Normal View History

2021-12-12 14:55:48 +08:00
using PluginInterface;
using System;
using System.ComponentModel.DataAnnotations;
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")]
public string Expressions { get; set; }
2021-12-12 14:55:48 +08:00
2023-12-23 17:34:58 +08:00
[Display(Name = "Upload")]
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-12-23 17:34:58 +08:00
[Display(Name = "Alias")]
public string Alias { get; set; }
[NotMapped]
2023-12-23 17:34:58 +08:00
[Display(Name = "Value")]
public object Value { get; set; }
[NotMapped]
2023-12-23 17:34:58 +08:00
[Display(Name = "CookedValue")]
public object CookedValue { get; set; }
[NotMapped]
public string Message { get; set; }
[NotMapped]
2023-12-23 17:34:58 +08:00
[Display(Name = "Update time")]
public DateTime Timestamp { get; set; }
[NotMapped]
2023-12-23 17:34:58 +08:00
[Display(Name = "State")]
[JsonConverter(typeof(StringEnumConverter))]
public VaribaleStatusTypeEnum StatusType { get; set; } = VaribaleStatusTypeEnum.UnKnow;
2023-12-23 17:34:58 +08:00
[NotMapped][Display(Name = "The Most Recent Values")] public object[] Values { get; set; } = new object[3];
public void EnqueueVariable(object value)
{
Values[2] = Values[1];
Values[1] = Values[0];
Values[0] = value;
}
2021-12-12 14:55:48 +08:00
}
}