Esempio n. 1
0
        private static Task GenerateTask3(ResourceMapper resourceMapper, String taskName, int layer, int rack, int column, int targetRack)
        {
            Task task = new Task(taskName, layer, rack, column, targetRack);

            task.AddNewPreMission(new Mission(resourceMapper.GetJoint("Rail 2-2-3"), resourceMapper.GetJoint("Lifter 2-2-2"), task, MissionType.Transmission, 5, resourceMapper));
            task.AddNewPreMission(new Mission(resourceMapper.GetJoint("Lifter 2-2-2"), resourceMapper.GetJoint("Lifter 0-2-2"), task, MissionType.Lift, 0, resourceMapper));
            task.AddNewPreMission(new Mission(resourceMapper.GetJoint("Lifter 0-2-2"), resourceMapper.GetJoint("Input point 0-1-1"), task, MissionType.Transmission, 6, resourceMapper));
            task.AddNewPreMission(new Mission(resourceMapper.GetJoint("Input point 0-1-1"), resourceMapper.GetJoint("Input point 0-1-1"), task, MissionType.Transmission, 2, resourceMapper));
            task.AddNewPreMission(new Mission(resourceMapper.GetJoint("Input point 0-1-1"), resourceMapper.GetJoint("Lifter 0-2-2"), task, MissionType.Transmission, 6, resourceMapper));
            task.AddNewPreMission(new Mission(resourceMapper.GetJoint("Lifter 0-2-2"), resourceMapper.GetJoint("Lifter 2-2-2"), task, MissionType.Lift, 0, resourceMapper));
            task.AddNewPreMission(new Mission(resourceMapper.GetJoint("Lifter 2-2-2"), resourceMapper.GetJoint("Rail 2-2-3"), task, MissionType.Transmission, 5, resourceMapper));
            task.AddNewDoMission(new Mission(resourceMapper.GetJoint("Rail 2-2-3"), new Joint("", layer, rack, column, JointType.Rail), task, MissionType.DoWork, 0, resourceMapper));
            task.AddNewDoMission(new Mission(new Joint("", layer, rack, column, JointType.Rail), new Joint("", layer, targetRack, column, JointType.Rail), task, MissionType.DoWork, 0, resourceMapper));
            task.AddNewDoMission(new Mission(new Joint("", layer, targetRack, column, JointType.Rail), new Joint("", layer, rack, column, JointType.Rail), task, MissionType.DoWork, 0, resourceMapper));
            return(task);
        }
Esempio n. 2
0
        public double GetDoWorkTime(ResourceMapper resourceMapper)
        {
            double timeCost = 0;

            foreach (Mission mission in this._doMissionList)
            {
                if (mission.Type == MissionType.DoWork)
                {
                    timeCost += mission.TimeCost;
                    Debugger.WriteLine(mission.ToString());
                }
                else
                {
                    throw new Exception("Misison not in correct list...At Task " + this.TaskName);
                }
            }
            return(timeCost);
        }
Esempio n. 3
0
        /// <summary>
        /// 计算本任务的动态前摇时间,并生成序列的前置归位任务。
        /// </summary>
        public double GetPreMustWorkTime(ResourceMapper resourceMapper)
        {
            double preMustTimeCost = 0;

            _preMustMissionList.Clear();
            //扫描本任务的前摇任务和后摇任务所需的资源joint,以及各个mission的动作种类,
            //结合传入的resource mapper中的各个资源joint的状态,生成需要执行的前摇复位任务,
            //并计算所有前摇任务所需的时间,一般只有电梯资源点和轨道(代表子母车)会有此类操作
            HashSet <Joint> replacingLifter = new HashSet <Joint>();
            Joint           jointLifter     = null;
            Joint           jointRail       = null;

            foreach (Mission mission in this._preMissionList)
            {
                //运输任务即为传送带,为复位电梯列表添加电梯,复位至0层
                if (mission.Type == MissionType.Transmission)
                {
                    if (mission.FromJoint.Type == JointType.Lifter)
                    {
                        replacingLifter.Add(mission.FromJoint);
                    }
                    if (mission.ToJoint.Type == JointType.Lifter)
                    {
                        replacingLifter.Add(mission.ToJoint);
                    }
                }
            }
            jointRail = this._preMissionList[0].FromJoint;
            foreach (Mission mission in this._preMissionList)
            {
                //提升任务,该joint即为关键电梯资源,复位至rail位置所在层
                if (mission.Type == MissionType.Lift)
                {
                    if (mission.FromJoint.Type == JointType.Lifter &&
                        mission.ToJoint.Type == JointType.Lifter)
                    {
                        replacingLifter.Remove(mission.FromJoint);
                        jointLifter = mission.FromJoint;
                    }
                    else
                    {
                        throw new Exception("Lift mission ERROR..." + mission.ToString());
                    }
                }
            }
            //生成并行复位任务,并计算最大复位时间
            //传输电梯到底层
            foreach (Joint joint in replacingLifter)
            {
                Joint from = joint.Copy();
                from.Layer     = resourceMapper.GetJointStatus(from).Layer;
                from.JointName = from.AssembleJointName();
                Joint to = from.Copy();
                to.Layer     = 0;
                to.JointName = to.AssembleJointName();
                if (from.Layer == to.Layer)
                {
                    continue;
                }
                Mission tmpMission = new Mission(from, to, this, MissionType.Lift, 0, resourceMapper);
                preMustTimeCost = preMustTimeCost < tmpMission.TimeCost ? tmpMission.TimeCost : preMustTimeCost;
                _preMustMissionList.Add(tmpMission);
                Debugger.WriteLine(tmpMission.ToString());
            }
            //生成关键电梯复位任务,并计算时间
            //关键电梯到mission的位置
            if (jointLifter != null)
            {
                Joint from = jointLifter.Copy();
                from.Layer     = resourceMapper.GetJointStatus(jointLifter).Layer;
                from.JointName = from.AssembleJointName();
                Joint to = from.Copy();
                to.Layer     = this.Layer;
                to.JointName = to.AssembleJointName();
                if (from.Layer != to.Layer)
                {
                    Mission tmpMission = new Mission(from, to, this, MissionType.Lift, 0, resourceMapper);
                    preMustTimeCost = preMustTimeCost < tmpMission.TimeCost ? tmpMission.TimeCost : preMustTimeCost;
                    _preMustMissionList.Add(tmpMission);
                    Debugger.WriteLine(tmpMission.ToString());
                }
            }
            //生成子母车复位任务,并计算时间
            //子母车到接轨Rail的位置
            if (jointRail == null)
            {
                throw new Exception("Mission ERROR...At Task " + this.TaskName);
            }
            else
            {
                Joint to   = jointRail;
                Joint from = to.Copy();
                from.Column    = resourceMapper.GetJointStatus(from).Column;
                from.JointName = from.AssembleJointName();
                if (from.Column != to.Column)
                {
                    Mission tempMission = new Mission(from, to, this, MissionType.DoWork, 0, resourceMapper);
                    preMustTimeCost = preMustTimeCost < tempMission.TimeCost ? tempMission.TimeCost : preMustTimeCost;
                    _preMustMissionList.Add(tempMission);
                    Debugger.WriteLine(tempMission.ToString());
                }
            }
            return(preMustTimeCost);
        }