RecoveryJobType.cs 1.4 KB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DeviceLibrary.bean.jobType
{
    public class RecoveryJobType : JobType
    {
        public override Job GetNewJob(AgvInfo agv)
        {

            if (agv.JobContext.MissionId.Equals(""))
            {
                return null;
            }
            else
            {
                service.model.MissionInfo missionInfo = manager.MissionManager.GetMission(agv.JobContext.MissionId);
                if (missionInfo != null)
                {
                    agv.TaskRunState = new TaskRunState();
                    agv.TaskRunState.Task = agv.JobContext.AgvTask;
                    Type type = Type.GetType(agv.JobContext.JobFullName);      // 通过类名获取同名类
                    Job job = (Job)System.Activator.CreateInstance(type);
                    job.JobParam = agv.JobContext.JobParam;
                    job.JobParam.CurTargetNode = manager.NodeManager.GetNodeByName(agv.JobContext.JobParam.CurTargetNode.Name);
                    job.JobParam.SetMissionInfo(missionInfo);
                    job.Task = agv.JobContext.AgvTask;
                    job.JobRunStep.ToNextStep((RunStep)Enum.Parse(typeof(RunStep), agv.JobContext.JobStep));
                    return job;
                }
            }

            return null;
        }
    }
}