using StandardLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Model
{

    public enum Status
    {
        EMG = 1,
        ERROR = 2,
        HOMING = 3,
        Ready = 4,
        Running = 5,
        Paused = 6,
        Reserved1 = 7,
        Reserved2 = 8,
        Reserved3 = 8,
    }

    public class MachineState:IPlcAddressToPropertyPaths
    {
        /// <summary>
        /// 批次是否在运行
        /// </summary>
        public bool IsBatchOn { get; set; }
        public bool IsRunning { get; set; }
        public Status Status { get; set; }

        private Dictionary<string, string> PropertyPathPlcAddressPairs;

        public Dictionary<string, List<string>> PlcAddressPropertyPathsPairs { get; set; }

        public MachineState()
        {
            PropertyPathPlcAddressPairs = new Dictionary<string, string>()
            {
                {PropertyPathHelper.GetPath(()=>IsBatchOn),"Application.Var_state.b批次执行中" },
                {PropertyPathHelper.GetPath(()=>Status),"Application.Var_state.i_MachineState" },

                //{PropertyPathHelper.GetPath(()=>测试1.TestEnable),"Application.Var_state.站位启用[5]"},
            };

            PlcAddressPropertyPathsPairs = PropertyPathPlcAddressPairs
                .GroupBy(kvp => kvp.Value)
                .ToDictionary(
                    g => g.Key,
                    g => g.Select(kvp => CommonLib.RemoveUpToSecondDot(kvp.Key)).ToList()
                );
        }
    }
}
