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);
}
}
}
}