//------------------------------------------------------------------------------
//  此代码版权声明为全文件覆盖，如有原作者特别声明，会在下方手动补充
//  此代码版权（除特别声明外的代码）归作者本人Diego所有
//  源代码使用协议遵循本仓库的开源协议及附加协议
//  Gitee源代码仓库：https://gitee.com/diego2098/ThingsGateway
//  Github源代码仓库：https://github.com/kimdiego2098/ThingsGateway
//  使用文档：https://thingsgateway.cn/
//  QQ群：605534569
//------------------------------------------------------------------------------

using BootstrapBlazor.Components;

using Newtonsoft.Json;

namespace ThingsGateway.Gateway.Application;

/// <summary>
/// 报警变量
/// </summary>
public class AlarmVariable : PrimaryIdEntity, IDBHistoryAlarm
{
    /// <inheritdoc  cref="Variable.Name"/>
    [SugarColumn(ColumnDescription = "变量名称", IsNullable = false)]
    [AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true)]
    public string Name { get; set; }

    /// <inheritdoc  cref="Variable.Description"/>
    [SugarColumn(ColumnDescription = "描述", IsNullable = true)]
    [AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true)]
    [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
    [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
    public string? Description { get; set; }

    /// <inheritdoc  cref="IBaseDataEntity.CreateOrgId"/>
    [SugarColumn(ColumnDescription = "组织Id", IsNullable = true)]
    [AutoGenerateColumn(Visible = false, Filterable = true, Sortable = true)]
    public long CreateOrgId { get; set; }

    /// <inheritdoc  cref="IBaseEntity.CreateUserId"/>
    [SugarColumn(ColumnDescription = "创建用户Id", IsNullable = true)]
    [AutoGenerateColumn(Visible = false, Filterable = true, Sortable = true)]
    public long CreateUserId { get; set; }

    /// <inheritdoc  cref="Variable.DeviceId"/>
    [SugarColumn(ColumnDescription = "设备Id", IsNullable = true)]
    [AutoGenerateColumn(Visible = false, Filterable = true, Sortable = true)]
    public long DeviceId { get; set; }

    /// <inheritdoc  cref="VariableRuntime.DeviceName"/>
    [SugarColumn(ColumnDescription = "设备名称", IsNullable = true)]
    [AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true)]
    public string DeviceName { get; set; }

    /// <inheritdoc  cref="Variable.RegisterAddress"/>
    [SugarColumn(ColumnDescription = "变量地址")]
    [AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true)]
    [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
    [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
    public string RegisterAddress { get; set; }

    /// <inheritdoc  cref="Variable.DataType"/>
    [SugarColumn(ColumnDescription = "数据类型")]
    [AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true)]
    public DataTypeEnum DataType { get; set; }

    /// <inheritdoc  cref="VariableRuntime.AlarmCode"/>
    [SugarColumn(ColumnDescription = "报警值", IsNullable = false)]
    [AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true)]
    public string AlarmCode { get; set; }

    /// <inheritdoc  cref="VariableRuntime.AlarmLimit"/>
    [SugarColumn(ColumnDescription = "报警限值", IsNullable = false)]
    [AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true)]
    public string AlarmLimit { get; set; }

    /// <inheritdoc  cref="VariableRuntime.AlarmText"/>
    [SugarColumn(ColumnDescription = "报警文本", IsNullable = true)]
    [AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true)]
    public string? AlarmText { get; set; }

    /// <inheritdoc  cref="VariableRuntime.RecoveryCode"/>
    [SugarColumn(ColumnDescription = "恢复值", IsNullable = false)]
    [AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true)]
    public string RecoveryCode { get; set; }

    /// <inheritdoc  cref="VariableRuntime.AlarmTime"/>
    [SugarColumn(ColumnDescription = "报警时间", IsNullable = false)]
    [AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true)]
    public DateTime AlarmTime { get; set; }

    /// <inheritdoc  cref="VariableRuntime.EventTime"/>
    [SugarColumn(ColumnDescription = "事件时间", IsNullable = false)]
    [AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true)]
    [TimeDbSplitField(DateType.Month)]
    public DateTime EventTime { get; set; }

    /// <summary>
    /// 报警类型
    /// </summary>
    [SugarColumn(ColumnDescription = "报警类型", IsNullable = false)]
    [AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true)]
    public AlarmTypeEnum? AlarmType { get; set; }

    /// <summary>
    /// 事件类型
    /// </summary>
    [SugarColumn(ColumnDescription = "事件类型", IsNullable = false)]
    [AutoGenerateColumn(Visible = true, Filterable = true, Sortable = true)]
    public EventTypeEnum EventType { get; set; }

    /// <inheritdoc cref="Device.Remark1"/>
    [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
    [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
    public string Remark1 { get; set; }

    /// <inheritdoc cref="Device.Remark2"/>
    [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
    [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
    public string Remark2 { get; set; }

    /// <inheritdoc cref="Device.Remark3"/>
    [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
    [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
    public string Remark3 { get; set; }

    /// <inheritdoc cref="Device.Remark4"/>
    [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
    [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
    public string Remark4 { get; set; }

    /// <inheritdoc cref="Device.Remark5"/>
    [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
    [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
    public string Remark5 { get; set; }
}
