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

namespace DynStatDisk.App.Com
{
    public class PLCSglModel
    {
        public delegate void CylinderNoSglDelegate(bool UpdateValue, string UpdateName);
        public event CylinderNoSglDelegate CylinderNoSglEvent;

        public delegate void PalletPassSglDelegate(bool UpdateValue, string UpdateName);
        public event PalletPassSglDelegate PalletPassSglEvent;

        public delegate void TongZhiGuiSglDelegate(bool UpdateValue, string UpdateName);
        public event TongZhiGuiSglDelegate TongZhiGuiSglEvent;

        public PLCSglModel()
        {
            _CodeEnable = false;

        }


        private bool _CodeEnable;
        /// <summary>
        /// 条码准备完毕信号
        /// </summary>
        public bool CodeEnable
        {
            get
            {
                return _CodeEnable;
            }
            set
            {
                if (value != _CodeEnable && value == true)
                {
                    _CodeEnable = value;
                    CylinderNoSglEvent(true, "CodeReadOK");//开始动作
                }
                else if (value != _CodeEnable && value == false)
                {
                    _CodeEnable = false;
                    //PLCCodeEnableEvent(false, "记录和计算信号OFF");
                }
            }
        }


        private bool _PalletPassEnable;
        /// <summary>
        /// 托盘放行信号
        /// </summary>
        public bool PalletPassEnable
        {
            get
            {
                return _PalletPassEnable;
            }
            set
            {
                if (value != _PalletPassEnable && value == true)
                {
                    _PalletPassEnable = value;
                    PalletPassSglEvent(true, "PalletPass");//开始动作
                }
                else if (value != _PalletPassEnable && value == false)
                {
                    _PalletPassEnable = false;
                    //PLCCodeEnableEvent(false, "记录和计算信号OFF");
                }
            }
        }


        private bool _TongZhiGuiEnable;
        /// <summary>
        /// 通止规信号
        /// </summary>
        public bool TongZhiGuiEnable
        {
            get
            {
                return _TongZhiGuiEnable;
            }
            set
            {
                if (value != _TongZhiGuiEnable && value == true)
                {
                    _TongZhiGuiEnable = value;
                    //TongZhiGuiSglEvent(false, "Off");//开始动作
                    TongZhiGuiSglEvent(true, "ON");//开始动作
                }
                else if (value != _TongZhiGuiEnable && value == false)
                {
                    //从On到Off是通止规的启用的信号
                    _TongZhiGuiEnable = value;
                    //TongZhiGuiSglEvent(true, "ON");//开始动作
                    TongZhiGuiSglEvent(false, "Off");//开始动作
                }
            }
        }
    }
}
