using JiShe.CollectBus.Analyzers.Shared;
using JiShe.CollectBus.IoTDB.Attribute;
using JiShe.CollectBus.IoTDB.Enums;
using JiShe.CollectBus.IoTDB.Model;
using System;

namespace JiShe.CollectBus.IotSystems.MeterReadingRecords
{
    /// <summary>
    /// 抄读任务数据
    /// </summary>
    [EntityType(EntityTypeEnum.TableModel)]
    [SourceAnalyzers]
    public class MeterReadingTelemetryPacketInfo : IoTEntity
    {
        /// <summary>
        /// 排序索引分数值，具体值可以根据不同业务场景进行定义，例如时间戳、或者某一个固定的标识1
        /// </summary>
        [FIELDColumn]
        public string ScoreValue { get; set; }

        /// <summary>
        /// 数据包类型
        /// </summary>
        [FIELDColumn]
        public int PacketType { get; set; }

        /// <summary>
        /// 是否手动操作
        /// </summary>
        [FIELDColumn]
        public bool ManualOrNot { get; set; }

        /// <summary>
        /// 任务数据唯一标记
        /// </summary>
        [FIELDColumn]
        public string TaskMark { get; set; }

        /// <summary>
        /// 是否超时
        /// </summary>
        [FIELDColumn]
        public bool IsTimeout { get; set; } = false;

        /// <summary>
        /// 待抄读时间
        /// </summary>
        [FIELDColumn]
        public DateTime PendingCopyReadTime { get; set; }

        /// <summary>
        /// 集中器Id
        /// </summary>
        [FIELDColumn]
        public int FocusId { get; set; }


        /// <summary>
        /// 集中器地址
        /// </summary>
        [FIELDColumn]
        public string FocusAddress { get; set; }
          
        /// <summary>
        /// 表地址
        /// </summary>
        [FIELDColumn]
        public string MeterAddress { get; set; }

        /// <summary>
        /// 数据库业务ID
        /// </summary>
        [FIELDColumn]
        public int DatabaseBusiID { get; set; }

        /// <summary>
        /// AFN功能码
        /// </summary>
        [FIELDColumn]
        public int AFN { get; set; }

        /// <summary>
        /// 抄读功能码
        /// </summary>
        [FIELDColumn]
        public int Fn { get; set; }

        /// <summary>
        /// 抄读计量点
        /// </summary>
        [FIELDColumn]
        public int Pn { get; set; }

        /// <summary>
        /// 采集项编码
        /// </summary>
        [FIELDColumn]
        public string ItemCode { get; set; }


        /// <summary>
        /// 子项编码，一般用于透明转发的编码
        /// </summary>
        [FIELDColumn]
        public string SubItemCode { get; set; }

        /// <summary>
        /// 帧序列域 SEQ
        /// </summary>
        [FIELDColumn]
        public int Seq { get; set; }

        /// <summary>
        /// 地址域A3的主站地址MSA
        /// </summary>
        [FIELDColumn]
        public int MSA { get; set; }

        /// <summary>
        /// 是否发送
        /// </summary>
        [FIELDColumn]
        public bool IsSend { get; set; }

        /// <summary>
        /// 发送次数
        /// </summary>
        [FIELDColumn]
        public int? SendNum { get; set; }

        /// <summary>
        /// 下次发送时间
        /// </summary>
        [FIELDColumn]
        public DateTime? NextSendTime { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [FIELDColumn]
        public DateTime CreationTime { get; set; }

        /// <summary>
        /// 下发消息内容
        /// </summary>
        [FIELDColumn]
        public string IssuedMessageHexString { get; set; }

        /// <summary>
        /// 下发消息Id
        /// </summary>
        [FIELDColumn]
        public string IssuedMessageId { get; set; }

        /// <summary>
        /// 消息上报内容
        /// </summary>
        [FIELDColumn]
        public string? ReceivedMessageHexString { get; set; }

        /// <summary>
        /// 消息上报时间
        /// </summary>
        [FIELDColumn]
        public DateTime? ReceivedTime { get; set; }

        /// <summary>
        /// 上报消息Id
        /// </summary>
        [FIELDColumn]
        public string ReceivedMessageId { get; set; }

        /// <summary>
        /// 上报报文解析备注，异常情况下才有
        /// </summary>
        [FIELDColumn]
        public string ReceivedRemark { get; set; }

        /// <summary>
        /// 是否已上报
        /// </summary>
        [FIELDColumn]
        public bool IsReceived { get; set; }

    }
}
