StandbyJob.cs 2.6 KB
using DeviceLib.Model.AGV;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DeviceLib.BLL
{
    public class StandbyJob : ImpJob
    {
        public StandbyJob(JobParam jobParam) : base(jobParam)
        {
            JobName = "待机任务";
        }

        public override Job Run(Robot robot)
        {
            Job job = this;
            switch (JobRunStep.CurStep)
            {
                case RunStep.None:
                    ToNextStep(RunStep.Standby_03_CrossDoorSuccess, $"开始待机任务");
                    break;
                case RunStep.Standby_01_Start:
                    ToNextStep(RunStep.Standby_02_CrossDoor, $"准备去目标车间");
                    GenJobCallBack(this.GetType(), RunStep.Standby_03_CrossDoorSuccess, JobParam);
                    job = new CrossDoorJob(JobParam);
                    break;
                //case RunStep.Standby_02_CrossDoor:
                //    break;
                case RunStep.Standby_03_CrossDoorSuccess:
                    ToNextStep(RunStep.Standby_04_ToDst, $"准备去待机点");
                    MoveToNode(robot, JobParam.CurDstNode);
                    break;
                case RunStep.Standby_04_ToDst:
                    ToNextStep(RunStep.Standby_05_End, $"到达待机点");
                    SetRobotState(robot,RobotState.待机中);
                    break;
                case RunStep.Standby_05_End:
                    //1. 获取运输任务
                    bool newJob = JobManager.CheckNewJob(robot);
                    if (newJob)
                         job= null;
                    else
                    {
                        //2. 该机器人在待机点,且未找到其他电量低于当前车电量的小车
                        NodeJobState chargePile = ChargeStandJobType.getChargePile(robot);
                        if (chargePile != null && !ChargeStandJobType.FindOtherLowerRobor(robot))
                        {
                            List<NodeJobState> targets = new List<NodeJobState>();
                            targets.Add(chargePile);
                            JobParam param = new JobParam(null, targets);
                            param.PreDstNode = JobType.getPreDstNode(robot);
                            param.JobGoal = JobGoal.None;
                            param.RobotIp = robot.ip;
                            ChargeJob chargeJob = new ChargeJob(param);
                            return chargeJob;
                        }
                    }

                    break;
            }
            return job;
        }
    }
}