非標框架(10)-有限狀態機3-空閒狀態

using LaserWelder.Agency;
using LaserWelder.Machine;

namespace LaserWelder.StateMachine
{
    /// <summary>
    /// 空閒狀態
    /// </summary>
    public class IdleState : StateBase
    {
        private static IdleState instance = new IdleState();
        public static IdleState Instance => instance;
        public override StateType Type => StateType.Idle;

        public override void Enter(StateType oldState)
        {
            //InnerAgency.Instance.MovWait();
            //ConvAgency.Instance.MotorStopAll();
            //不是空跑,則進板
            if (RunTypeAgency.Instance.RunType != RunType.空跑測試)
            {
                ConvAgency.Instance.PalletMov();
                ConvAgency.Instance.PalletDown();
            } FSM.Instance.CurrWelderState = WeldWorkType.Idle;
           
            FSM.Instance.IsWorkEnd = false;
        }
        public override void Exit(StateType newState)
        {

        }
        /// <summary>
        /// 2ms更新一次
        /// </summary>
        public override void Update()
        {
            if (RunTypeAgency.Instance.RunType == RunType.正式運行 ||
                RunTypeAgency.Instance.RunType == RunType.軌道測試)
            {
                if (FSM.Instance.CanRequestPallet)
                {
                    FSM.Instance.ChangeState(RequestPalletState.Instance);
                }
            }
            else if (RunTypeAgency.Instance.RunType == RunType.空跑測試)
            {
                FSM.Instance.ChangeState(WorkingState.Instance);
            }
        }
    }
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章