using SQLite;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;

namespace FLY.Thick.FilmCasting.Server.Model
{
    /// <summary>
    /// 订单记录
    /// </summary>
    [Table("Profile")]
    public class Db_Profile:INotifyPropertyChanged
    {
        [Key]
        [Index]
        [PropertyIndex(0)]
        public Int64 ID { get; set; }

        /// <summary>
        /// 产品名称
        /// </summary>
        [PropertyIndex(1)]
        public string PName { get; set; }

        /// <summary>
        /// 订单号 或者 批号
        /// </summary>
        [PropertyIndex(2)]
        public string Batch { get; set; }

        /// <summary>
        /// 卷号
        /// </summary>
        [PropertyIndex(3)]
        public string Number { get; set; }

        /// <summary>
        /// 开始时间
        /// </summary>
        [Time]//时间标记，用于删除数据 KeepDBSize
        [Index]//数据库的 INDEX
        [PropertyIndex(4)]
        public DateTime StartTime { get; set; }

        /// <summary>
        /// 结束时间
        /// </summary>
        [PropertyIndex(5)]
        public DateTime EndTime { get; set; }

        /// <summary>
        /// 膜长度 m
        /// </summary>
        [PropertyIndex(6)]
        public double FilmLength { get; set; }
        /// <summary>
        /// 已经结束
        /// </summary>
        [PropertyIndex(7)]
        public bool IsFinished { get; set; }

        /// <summary>
        /// 目标值
        /// </summary>
        [PropertyIndex(8)]
        public double Target { get; set; }

        /// <summary>
        /// 工艺%
        /// </summary>
        [PropertyIndex(9)]
        public double TolerancePercent { get; set; }

        /// <summary>
        /// 扫描范围 开始
        /// </summary>
        [PropertyIndex(10)]
        public int ScanBegin { get; set; }

        /// <summary>
        /// 扫描范围 结束
        /// </summary>
        [PropertyIndex(11)]
        public int ScanEnd { get; set; }

        public event PropertyChangedEventHandler PropertyChanged;
    }

    /// <summary>
    /// 横向厚度记录
    /// </summary>
    [Table("ScanData")]
    public class Db_ScanData
    {
        [Key]
        [Index]
        [PropertyIndex(0)]
        public Int64 ID { get; set; }

        [Index]
        [PropertyIndex(1)]
        public Int64 ProfileID { get; set; }

        /// <summary>
        /// 测量数据开始时间
        /// </summary>
        [Time]//时间标记，用于删除数据 KeepDBSize
        [Index]//数据库的 INDEX
        [PropertyIndex(2)]
        public DateTime Time { get; set; }

        /// <summary>
        /// 测量数据结束时间
        /// </summary>
        [PropertyIndex(3)]
        public DateTime EndTime { get; set; }

        /// <summary>
        /// 目标值
        /// </summary>
        [PropertyIndex(4)]
        public double Target { get; set; }

        /// <summary>
        /// 规格线% ，最后规格值为目标值*TolerancePercent 
        /// </summary>
        [PropertyIndex(5)]
        public double TolerancePercent { get; set; }

        /// <summary>
        /// 斜率补偿
        /// </summary>
        [PropertyIndex(6)]
        public double K { get; set; }

        /// <summary>
        /// 平移补偿
        /// </summary>
        [PropertyIndex(7)]
        public double B { get; set; }

        /// <summary>
        /// 位置 m
        /// </summary>
        [PropertyIndex(8)]
        public double FilmPosition { get; set; }

        /// <summary>
        /// 线速度
        /// </summary>
        [PropertyIndex(9)]
        public double FilmVelocity { get; set; }

        /// <summary>
        /// 膜宽度 mm
        /// </summary>
        [PropertyIndex(10)]
        public double FilmWidth { get; set; }

        /// <summary>
        /// 厚度均值
        /// </summary>
        [PropertyIndex(11)]
        public double Avg { get; set; }

        /// <summary>
        /// double[] 的 json字符串
        /// 1幅数据 1螺丝 一个数据.
        /// </summary>
        [PropertyIndex(12)]
        public string Thicks { get; set; }

        /// <summary>
        /// 样品AD int[]
        /// </summary>
        [PropertyIndex(13)]
        public string SampleADs { get; set; }

        /// <summary>
        /// 分区表信息
        /// </summary>
        [PropertyIndex(14)]
        public string BoltMapInfo { get; set; }
    }

    /// <summary>
    /// 信号记录
    /// </summary>
    [Table("Sample")]
    public class Db_Sample
    {
        [Key]
        [Index]//数据库的 INDEX
        [PropertyIndex(0)]
        public Int64 ID { get; set; }

        /// <summary>
        /// 采集时间
        /// </summary>
        [Time]//时间标记，用于删除数据 KeepDBSize
        [Index]//数据库的 INDEX
        [PropertyIndex(1)]
        public DateTime Time { get; set; }

        /// <summary>
        /// 样品AD int[]
        /// </summary>
        [PropertyIndex(2)]
        public string SampleADs { get; set; }
    }
}
