using BPA.Helper;
using BPA.Model.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.Model.Recipe
{
    /// <summary>
    /// 根据设备生成的配方数据。
    /// </summary>
    public class RecipeData : NotifyBase
    {
        private int currentStation;
        private bool[] isMakeComplete;
        private DateTime issueTime;
        private DateTime startTime;
        private DateTime completeTime;
        private Dictionary<int, BatchStep> batchStatus;

        public string ID { get; set; }
        public string Name { get; set; }
        /// <summary>
        /// 该配方当前所在的工位。
        /// </summary>
        public int CurrentStation { get => currentStation; set { currentStation = value; OnPropertyChanged(); } }
        /// <summary>
        /// 配方对应的各设备的下料数据，键为设备编号，值为设备下各个料仓的下料重量。
        /// </summary>
        public Dictionary<int, ushort[]> MaterialData { get; set; }
        /// <summary>
        /// 各个设备是否下料完成。
        /// </summary>
        public bool[] IsMakeComplete { get => isMakeComplete; set { isMakeComplete = value; OnPropertyChanged(); } }
        /// <summary>
        /// 下发时间
        /// </summary>
        public DateTime IssueTime { get => issueTime; set {
                issueTime = value;
                OnPropertyChanged();
            } }
        /// <summary>
        /// 开始制作时间
        /// </summary>
        public DateTime StartTime { get => startTime; set {
                startTime = value;
                OnPropertyChanged();
            } }
        /// <summary>
        /// 制作完成时间。
        /// </summary>
        public DateTime CompleteTime { get => completeTime; set {
                completeTime = value;
                OnPropertyChanged();
            } }
        public Dictionary<int, BatchStep> BatchStatus { get => batchStatus; set {
                batchStatus = value;
                OnPropertyChanged();
            } }
        public RecipeData(string id, string name, Dictionary<int, ushort[]> materialData, int stationCount = 5)
        {
            ID = id;
            Name = name;
            MaterialData = materialData;
            //取决于工位数量，本案例中，有五个工位，但是第三个工位没有设备。

            CurrentStation = 1;//初始默认为1。
            IsMakeComplete = new bool[stationCount];
            IssueTime = DateTime.Now;
            BatchStatus = new();
            for (int i = 1; i <= stationCount; i++)
            {
                BatchStatus.Add(i, BatchStep.WaitBatch);
            }
        }

    }
}
