WashPointJob.cs 2.4 KB
using System;
using Model;

namespace BLL
{
    public class WashPointJob : IJob
    {
        private AgvInfo _info;
        private MoveJob move;
        private string mission;
        private JobStep<WashPointStep> washPointStep;

        public WashPointJob()
        {
            washPointStep = new JobStep<WashPointStep>(WashPointStep.None);
            Common.log.Debug("加载WashPointJob");
        }

        public bool IsEnd { get; private set; }

        public IJob Execute(AgvInfo info)
        {
            _info = info;
            if (washPointStep.Equals(WashPointStep.None))
            {
                if (_info.IsWorkspace())
                    MoveWash();
                else
                    PassDoor();
            }
            else if (washPointStep.Equals(WashPointStep.PassDoor))
            {
                move.Execute(_info);
                if (move.IsEnd)
                    MoveWash();
            }
            else if (washPointStep.Equals(WashPointStep.MoveWash))
            {
                move.Execute(_info);
                if (move.IsEnd)
                {
                    washPointStep.NextStep(WashPointStep.End);
                    washPointStep.Msg = _info.Name + "到达清洗点";
                }
            }
            else if (washPointStep.Equals(WashPointStep.End))
            {
                IJob job = SteelManage.GetSteelJob(info);
                if (job == null)
                    return new StandbyJob();
                else
                    return job;
            }

            return this;
        }

        private void MoveWash()
        {
            mission = Common.MISSION_MOVE_WASH + _info.Workshop;
            _info.Place = mission;
            move = new MoveJob(mission);
            move.Execute(_info);
            washPointStep.NextStep(WashPointStep.MoveWash);
            washPointStep.Msg = _info.Name + "发送任务" + mission;
        }

        private void PassDoor()
        {
            mission = Common.MISSION_PASS_DOOR_INTO + _info.Workshop;
            _info.Place = mission;
            move = new MoveJob(mission);
            move.Execute(_info);
            washPointStep.NextStep(WashPointStep.PassDoor);
            washPointStep.Msg = _info.Name + "发送任务" + mission;
        }


        private enum WashPointStep
        {
            None,
            End,
            PassDoor,
            MoveWash,
        }
    }



}