コード例 #1
0
        private bool initEnv()
        {
            bool envOK = false;

            lock (LockController.getLockController().getLockTask()) {
                ForkLiftWrappersService.getInstance().connectForks();
            }

            Thread.Sleep(100);
            while (true)
            {
                foreach (ForkLiftWrapper fl in AGVCacheData.getForkLiftWrapperList())
                {
                    if (fl.getForkLift().isUsed == 1)
                    {
                        if (fl.getPosition().getPx() == 0 || fl.getPosition().getPy() == 0)
                        {
                            Console.WriteLine("Wait for Fork " + fl.getForkLift().id + " to update position");
                            //continue;
                        }
                    }
                }
                break;
            }
            return(envOK);
        }
コード例 #2
0
 public static void disableForklift(int forkliftNumber)         //不使用某辆车,用于设置楼上只用一辆车运行任务
 {
     foreach (ForkLiftWrapper fl in AGVCacheData.getForkLiftWrapperList())
     {
         if (fl.getForkLift().forklift_number == forkliftNumber)
         {
             fl.getForkLift().isUsed = 0;
         }
     }
 }
コード例 #3
0
 /// <summary>
 /// 可能有缓存任务,刚启动时,车子的状态需要设置
 /// </summary>
 private void setForkliftStateFirst()
 {
     foreach (ForkLiftWrapper fl in AGVCacheData.getForkLiftWrapperList())
     {
         List <TaskRecord> taskRecordList = TaskReordService.getInstance().getTaskRecordList();
         foreach (TaskRecord tr in taskRecordList)
         {
             if (tr.taskRecordStat == TASKSTAT_T.TASK_SEND || tr.taskRecordStat == TASKSTAT_T.TASK_SEND_SUCCESS)
             {
                 if (tr.forkLiftWrapper != null && tr.forkLiftWrapper.getForkLift().forklift_number == fl.getForkLift().forklift_number)
                 {
                     fl.getForkLift().taskStep = TASK_STEP.TASK_EXCUTE;
                 }
             }
         }
     }
 }
コード例 #4
0
        private void initAgvPanel()
        {
            int tmp = 0;

            foreach (ForkLiftWrapper fl in AGVCacheData.getForkLiftWrapperList())
            {
                AGVPanel ap_s = new AGVPanel();
                Console.WriteLine(" fl id " + fl.getForkLift().id);
                ap_s.initPanel(fl);
                ap_s.Location = new Point(780 + tmp, 40);
                ap_s.Size     = new Size(120, 200);
                this.agvPanel.Controls.Add(ap_s);
                tmp += 300;

                ap_s.AutoSize = true;
                ap_s.Anchor   = AnchorStyles.Right & AnchorStyles.Left;
                Console.WriteLine(" init agv panel number = " + fl.getForkLift().forklift_number);
                agvPanelList.Add(ap_s);
            }
        }
コード例 #5
0
		private ForkLiftWrapper getSheduleForkLift()  //如果两辆AGV都空闲,必须选择前面一辆AGV,否则后面一辆AGV一直不能走
		{
			ForkLiftWrapper fl_1 = null;
			ForkLiftWrapper fl_2 = null;  //另一辆车
			ForkLiftWrapper forklift = null;
			int freeForkCount = 0; //空闲车辆总数
			foreach (ForkLiftWrapper fl in AGVCacheData.getForkLiftWrapperList()) {
				if (fl.getForkLift().forklift_number == 3)  //只考虑楼上的车子
					continue;

				if (fl_1 == null) {
					fl_1 = fl;
				} else {
					fl_2 = fl;
				}

				if (fl.getForkLift().isUsed == 1 && fl.getForkLift().taskStep == TASK_STEP.TASK_IDLE && fl.getForkLift().finishStatus == 1)  //如果有车子同时满足要求,选择使用优先级较高的车
				{
					fl.getPosition().updateStartPosition();  //车子执行完任务回到起始位置 这时候的起始位置才是有效的
					freeForkCount++;
					forklift = fl;                   //可用的叉车
				}
			}

			if (freeForkCount == 1) {
				if (forklift.getForkLift().id == fl_1.getForkLift().id) {
					if (!check_start_state(forklift, fl_2)) {
						return null;
					}
				} else if (forklift.getForkLift().id == fl_2.getForkLift().id) {
					if (!check_start_state(forklift, fl_1)) {
						return null;
					}
				}

			} else if (freeForkCount == 2) {
				forklift = getHighLevel_ForkLiftf(fl_1, fl_2);  //有车可选的时候,使用优先级高的车
			}

			return forklift;
		}
コード例 #6
0
        public void initAGVMCForm()
        {
            int tmp = 0;

            foreach (ForkLiftWrapper fl in AGVCacheData.getForkLiftWrapperList())
            {
                if (fl.getForkLift().forklift_number == 3)
                {
                    //continue;
                }
                PauseCtrlPanel pcp = new PauseCtrlPanel();
                pcp.initPanel(fl);
                pcp.Location = new Point(40, 30 + tmp * 60);
                pcp.Size     = new Size(200, 50);

                this.Controls.Add(pcp);

                pausePanelHash.Add(fl.getForkLift().forklift_number, pcp);
                tmp++;
            }
        }
コード例 #7
0
		private bool checkDownDeliverPeriodOver(int upStep) {
			foreach (ForkLiftWrapper fl in AGVCacheData.getForkLiftWrapperList()) {
				if (fl.getForkLift().isUsed == 1 && fl.getForkLift().taskStep != TASK_STEP.TASK_IDLE) //如果有车在运行
				{
					return false;
				}
			}

			if (ElevatorFactory.getElevator().getOutCommand() != 0) //升降机上有任务, 表示上料没有结束
			{
				return false;
			}

			if (upStep > 0) {
				Console.WriteLine("当前处于上货 " + upStep + " 阶段");
				AGVLog.WriteError("当前处于上货 " + upStep + " 阶段", new StackFrame(true));
				return false;
			}

			return true;
		}
コード例 #8
0
        private void shedulePause()          //用于系统暂停时,检测暂停是否发送成功,如果没有发送成功,则一直向该车发送暂停
        {
            while (currentPause > SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_TYPE_MIN && currentPause < SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_UP_MAX)
            {
                foreach (ForkLiftWrapper fl in AGVCacheData.getForkLiftWrapperList())
                {
                    if (currentPause == SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_UP_WITH_START || currentPause == SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_UP_WITHOUT_START)                     //楼上楼下都有货时,暂停楼上的车,露楼下的车不用检测20160929 破凉
                    {
                        if (fl.getForkLift().forklift_number == 3)
                        {
                            continue;
                        }
                    }
                    if (fl.getPauseStr().Equals("运行"))                      //如果该车返回的pauseStat没有被设置成1,则向该车发送暂停
                    {
                        AGVUtil.setForkCtrlWithPrompt(fl, 1);
                    }
                }

                Thread.Sleep(30000);
            }
        }
コード例 #9
0
        public void scheduleInstruction()
        {
            while (ScheduleFactory.getSchedule().getScheduleFlag())
            {
                Thread.Sleep(500);
                sheduleLift();

                if (AGVSystem.getSystem().getSystemPause())
                {
                    if (AGVSystem.getSystem().getLastPause() != SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_SYSTEM_WITH_START && AGVSystem.getSystem().getLastPause() != SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_SYSTEM_WITHOUT_START)                     //避免多次设置
                    {
                        foreach (ForkLiftWrapper fl in AGVCacheData.getForkLiftWrapperList())
                        {
                            if (fl.getForkLift().shedulePause == 0)
                            {
                                AGVUtil.setForkCtrl(fl, 1);                                  //向不是暂停的车发送暂停指令
                            }
                        }
                    }

                    AGVSystem.getSystem().setLastPause(AGVSystem.getSystem().getCurrentPause());
                    continue;                                                                                                                                                                                           //系统暂停后不需要调度
                }
                else if (AGVSystem.getSystem().getCurrentPause() == SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_UP_WITH_START || AGVSystem.getSystem().getCurrentPause() == SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_UP_WITHOUT_START) //暂停楼上的车,有时候卸货不及时
                {
                    if (AGVSystem.getSystem().getLastPause() != SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_UP_WITH_START && AGVSystem.getSystem().getLastPause() != SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_UP_WITHOUT_START)        //避免多次设置
                    {
                        foreach (ForkLiftWrapper fl in AGVCacheData.getForkLiftWrapperList())
                        {
                            if (fl.getForkLift().forklift_number != 3 && fl.getForkLift().shedulePause == 0)                              //只调度楼上的车
                            {
                                AGVUtil.setForkCtrl(fl, 1);
                            }
                        }
                    }

                    AGVSystem.getSystem().setLastPause(AGVSystem.getSystem().getCurrentPause());
                    continue;                      //楼上的车子被暂停后,不需要调度
                }
                else if (AGVSystem.getSystem().getCurrentPause() == SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_DOWN_WITH_START || AGVSystem.getSystem().getCurrentPause() == SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_DOWN_WITHOUT_START)
                {
                    if (AGVSystem.getSystem().getLastPause() != SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_DOWN_WITH_START && AGVSystem.getSystem().getLastPause() != SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_DOWN_WITHOUT_START)                     //避免多次设置
                    {
                        ForkLiftWrapper fl = ForkLiftWrappersService.getInstance().getForkLiftByNunber(3);
                        AGVUtil.setForkCtrl(fl, 1);
                    }

                    AGVSystem.getSystem().setLastPause(AGVSystem.getSystem().getCurrentPause());
                }
                else
                {
                    if (AGVSystem.getSystem().getLastPause() == SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_SYSTEM_WITH_START)
                    {
                        foreach (ForkLiftWrapper fl in AGVCacheData.getForkLiftWrapperList())
                        {
                            if (fl.getForkLift().shedulePause == 0)
                            {
                                AGVUtil.setForkCtrl(fl, 0);                                  //之前不是暂停的车,发送启动指令
                            }
                        }
                    }

                    if (AGVSystem.getSystem().getLastPause() == SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_UP_WITH_START)
                    {
                        foreach (ForkLiftWrapper fl in AGVCacheData.getForkLiftWrapperList())
                        {
                            if (fl.getForkLift().forklift_number != 3 && fl.getForkLift().shedulePause == 0)
                            {
                                AGVUtil.setForkCtrl(fl, 0);                                  //之前不是暂停的车,发送启动指令
                            }
                        }
                    }

                    if (AGVSystem.getSystem().getLastPause() == SHEDULE_PAUSE_TYPE_T.SHEDULE_PAUSE_DOWN_WITH_START)
                    {
                        ForkLiftWrapper fl = ForkLiftWrappersService.getInstance().getForkLiftByNunber(3);
                        AGVUtil.setForkCtrl(fl, 0);
                    }

                    AGVSystem.getSystem().setLastPause(AGVSystem.getSystem().getCurrentPause());
                }

                lock (LockController.getLockController().getLockForkLift())                  //加锁,避免车的状态不一致
                {
                    _sheduleRunning();
                }
            }
        }
コード例 #10
0
        private void _sheduleRunning()
        {
            ForkLiftWrapper fl_1         = null;
            ForkLiftWrapper fl_2         = null;
            SHEDULE_TYPE_T  shedule_type = SHEDULE_TYPE_T.SHEDULE_TYPE_MIN;

            foreach (ForkLiftWrapper fl in AGVCacheData.getForkLiftWrapperList())
            {
                if (fl.getForkLift().forklift_number != 3 && fl.getForkLift().isUsed == 1 && fl.getForkLift().taskStep != TASK_STEP.TASK_IDLE)                  //调度没有在使用的车 车子任务没有完成,只有当两辆车同时使用时,才调度
                {
                    if (fl_1 != null)
                    {
                        fl_2 = fl;
                    }
                    else
                    {
                        fl_1 = fl;
                    }
                }
            }

            if (fl_1 != null && fl_2 != null)              //两车同时运行时才需要调度
            {
                shedule_type = getForkSheduleType(fl_1);

                if (shedule_type == SHEDULE_TYPE_T.SHEDULE_TYPE_1TO2)
                {
                    if (fl_2.getForkLift().shedulePause == 0 && fl_2.getPosition().getArea() == 2)                      //检测到另一辆车在区域2运行,需要暂停刚进入区域2的车
                    {
                        if (fl_1.getForkLift().shedulePause == 0)
                        {
                            AGVUtil.setForkCtrl(fl_1, 1);
                            fl_1.getForkLift().shedulePause = 1;
                        }
                    }
                    else                       //否则该车正常进入区域2,考虑到之前可能被暂停,没有车在区域2后,该车将被启动
                    {
                        fl_1.getPosition().setArea(2);
                        if (fl_1.getForkLift().shedulePause == 1)
                        {
                            //向1车发送启动
                            AGVUtil.setForkCtrl(fl_1, 0);
                            fl_1.getForkLift().shedulePause = 0;
                        }
                    }
                }
                else if (shedule_type == SHEDULE_TYPE_T.SHEDULE_TYPE_2TO3)
                {
                    if (fl_2.getForkLift().shedulePause == 0 && fl_2.getPosition().getArea() == 3)
                    {
                        if (fl_1.getForkLift().shedulePause == 0)
                        {
                            AGVUtil.setForkCtrl(fl_1, 1);
                            fl_1.getForkLift().shedulePause = 1;
                        }
                    }
                    else
                    {
                        fl_1.getPosition().setArea(3);
                        if (fl_1.getForkLift().shedulePause == 1)
                        {
                            //向1车发送启动
                            AGVUtil.setForkCtrl(fl_1, 0);
                            fl_1.getForkLift().shedulePause = 0;
                        }
                    }
                }
                else if (shedule_type == SHEDULE_TYPE_T.SHEDULE_TYPE_3TO2)
                {
                    if (fl_2.getForkLift().shedulePause == 0 && fl_2.getPosition().getArea() == 2)
                    {
                        if (fl_1.getForkLift().shedulePause == 0)
                        {
                            AGVUtil.setForkCtrl(fl_1, 1);
                            fl_1.getForkLift().shedulePause = 1;
                        }
                    }
                    else
                    {
                        fl_1.getPosition().setArea(2);
                        if (fl_1.getForkLift().shedulePause == 1)
                        {
                            //向1车发送启动
                            AGVUtil.setForkCtrl(fl_1, 0);
                            fl_1.getForkLift().shedulePause = 0;
                        }
                    }
                }
                else if (shedule_type == SHEDULE_TYPE_T.SHEDULE_TYPE_2TO1)
                {
                    if (fl_2.getForkLift().shedulePause == 0 && fl_2.getPosition().getArea() == 1)
                    {
                        if (fl_1.getForkLift().shedulePause == 0)
                        {
                            AGVUtil.setForkCtrl(fl_1, 1);
                            fl_1.getForkLift().shedulePause = 1;
                        }
                    }
                    else
                    {
                        fl_1.getPosition().setArea(1);
                        if (fl_1.getForkLift().shedulePause == 1)
                        {
                            //向1车发送启动
                            AGVUtil.setForkCtrl(fl_1, 0);
                            fl_1.getForkLift().shedulePause = 0;
                        }
                    }
                }

                shedule_type = getForkSheduleType(fl_2);

                if (shedule_type == SHEDULE_TYPE_T.SHEDULE_TYPE_1TO2)
                {
                    if (fl_1.getForkLift().shedulePause == 0 && fl_1.getPosition().getArea() == 2)                      //检测到另一辆车在区域2运行,需要暂停刚进入区域2的车
                    {
                        if (fl_2.getForkLift().shedulePause == 0)
                        {
                            AGVUtil.setForkCtrl(fl_2, 1);
                            fl_2.getForkLift().shedulePause = 1;
                        }
                    }
                    else                       //否则该车正常进入区域2,考虑到之前可能被暂停,没有车在区域2后,该车将被启动
                    {
                        fl_2.getPosition().setArea(2);
                        if (fl_2.getForkLift().shedulePause == 1)
                        {
                            //向1车发送启动
                            AGVUtil.setForkCtrl(fl_2, 0);
                            fl_2.getForkLift().shedulePause = 0;
                        }
                    }
                }
                else if (shedule_type == SHEDULE_TYPE_T.SHEDULE_TYPE_2TO3)
                {
                    if (fl_1.getForkLift().shedulePause == 0 && fl_1.getPosition().getArea() == 3)
                    {
                        if (fl_2.getForkLift().shedulePause == 0)
                        {
                            AGVUtil.setForkCtrl(fl_2, 1);
                            fl_2.getForkLift().shedulePause = 1;
                        }
                    }
                    else
                    {
                        fl_2.getPosition().setArea(3);
                        if (fl_2.getForkLift().shedulePause == 1)
                        {
                            //向1车发送启动
                            AGVUtil.setForkCtrl(fl_2, 0);
                            fl_2.getForkLift().shedulePause = 0;
                        }
                    }
                }
                else if (shedule_type == SHEDULE_TYPE_T.SHEDULE_TYPE_3TO2)
                {
                    if (fl_1.getForkLift().shedulePause == 0 && fl_1.getPosition().getArea() == 2)
                    {
                        if (fl_2.getForkLift().shedulePause == 0)
                        {
                            AGVUtil.setForkCtrl(fl_2, 1);
                            fl_2.getForkLift().shedulePause = 1;
                        }
                    }
                    else
                    {
                        fl_2.getPosition().setArea(2);
                        if (fl_2.getForkLift().shedulePause == 1)
                        {
                            //向1车发送启动
                            AGVUtil.setForkCtrl(fl_2, 0);
                            fl_2.getForkLift().shedulePause = 0;
                        }
                    }
                }
                else if (shedule_type == SHEDULE_TYPE_T.SHEDULE_TYPE_2TO1)
                {
                    if (fl_1.getForkLift().shedulePause == 0 && fl_1.getPosition().getArea() == 1)
                    {
                        if (fl_2.getForkLift().shedulePause == 0)
                        {
                            AGVUtil.setForkCtrl(fl_2, 1);
                            fl_2.getForkLift().shedulePause = 1;
                        }
                    }
                    else
                    {
                        fl_2.getPosition().setArea(1);
                        if (fl_2.getForkLift().shedulePause == 1)
                        {
                            //向1车发送启动
                            AGVUtil.setForkCtrl(fl_2, 0);
                            fl_2.getForkLift().shedulePause = 0;
                        }
                    }
                }

                checkPausePosition(fl_1);
                checkPausePosition(fl_2);
            }
            else if (fl_1 != null && fl_2 == null)
            {
                shedule_type = getForkSheduleType(fl_1);
                if (shedule_type == SHEDULE_TYPE_T.SHEDULE_TYPE_1TO2)
                {
                    fl_1.getPosition().setArea(2);
                }
                else if (shedule_type == SHEDULE_TYPE_T.SHEDULE_TYPE_2TO3)
                {
                    fl_1.getPosition().setArea(3);
                }
                else if (shedule_type == SHEDULE_TYPE_T.SHEDULE_TYPE_3TO2)
                {
                    fl_1.getPosition().setArea(2);
                }
                else if (shedule_type == SHEDULE_TYPE_T.SHEDULE_TYPE_2TO1)
                {
                    fl_1.getPosition().setArea(1);
                }

                if (fl_1.getForkLift().shedulePause == 1)                 //如果车子被暂停,启动该车
                {
                    AGVUtil.setForkCtrl(fl_1, 0);
                    fl_1.getForkLift().shedulePause = 0;
                }
            }
        }