Exemplo n.º 1
0
        private SHEDULE_TYPE_T getForkSheduleType(ForkLiftWrapper fl)
        {
            if (fl.getPosition().getArea() == 1 && fl.getPosition().getPx() < AGVConstant.BORDER_X_2 - AGVConstant.BORDER_X_DEVIARION)
            {
                Console.WriteLine(" check " + fl.getForkLift().forklift_number + "号车 从区域1进入2");
                return(SHEDULE_TYPE_T.SHEDULE_TYPE_1TO2);
            }
            else if (fl.getPosition().getArea() == 2 && fl.getPosition().getPx() < AGVConstant.BORDER_X_3 - AGVConstant.BORDER_X_DEVIARION)
            {
                Console.WriteLine(" check " + fl.getForkLift().forklift_number + "号车 从区域2进入3");
                return(SHEDULE_TYPE_T.SHEDULE_TYPE_2TO3);
            }
            else if (fl.getPosition().getArea() == 3 && fl.getPosition().getPx() > AGVConstant.BORDER_X_3 + AGVConstant.BORDER_X_DEVIARION)
            {
                Console.WriteLine(" check " + fl.getForkLift().forklift_number + "号车 从区域3进入2");
                return(SHEDULE_TYPE_T.SHEDULE_TYPE_3TO2);
            }
            else if (fl.getPosition().getArea() == 2 && fl.getPosition().getPx() > AGVConstant.BORDER_X_2 + AGVConstant.BORDER_X_DEVIARION)
            {
                Console.WriteLine(" check " + fl.getForkLift().forklift_number + "号车 从区域2进入1");
                return(SHEDULE_TYPE_T.SHEDULE_TYPE_2TO1);
            }

            return(SHEDULE_TYPE_T.SHEDULE_TYPE_MIN);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新车子状态
        /// </summary>
        public void updateForkLift(ForkLiftWrapper fl)
        {
            string sql = "update forklift set currentTask = \"" + fl.getForkLift().currentTask + "\", taskStep = " +
                         (int)fl.getForkLift().taskStep + " where id = " + fl.getForkLift().id;

            AGVLog.WriteInfo("updateForkLift sql = " + sql, new StackFrame(true));
            try {
                lock (lockDB) {
                    dataReader = execNonQuery(sql);
                }
            } catch (Exception ex) {
                Console.WriteLine(ex.ToString());
            }
        }
        /// <summary>
        /// 重新与车子建立连接
        /// </summary>
        public void reConnect()
        {
            Console.WriteLine("ConnectStatus:   " + connectStatus);
            AGVLog.WriteInfo("ConnectStatus: " + connectStatus, new StackFrame(true));

            while (forkLiftWrapper.getForkLift().isUsed == 1 && !connectStatus)
            {
                isConnectThread = true;              //设置重连标志true
                Thread.Sleep(5000);                  //5秒钟重连一次

                Console.WriteLine("start to reconnect");
                AGVLog.WriteWarn("start to reconnect", new StackFrame(true));

                TcpConnect(forkLiftWrapper.getForkLift().ip, forkLiftWrapper.getForkLift().port);

                if (connectStatus == true)
                {
                    AGVLog.WriteInfo("reconnect ip: " + forkLiftWrapper.getForkLift().ip + " :" + forkLiftWrapper.getForkLift().port + "success", new StackFrame(true));
                    Console.WriteLine("reconnect ip: " + forkLiftWrapper.getForkLift().ip + ":" + forkLiftWrapper.getForkLift().port + "success");
                    AGVLog.WriteInfo("restart recv thread", new StackFrame(true));

                    //hrctCallback?.Invoke(forkLiftWrapper, true);
                    if (hrctCallback != null)
                    {
                        hrctCallback(forkLiftWrapper, true);
                    }
                }
            }
            isConnectThread = false;             //重连成功
        }
Exemplo n.º 4
0
        public static bool setForkCtrlWithPrompt(ForkLiftWrapper fl, int ctrl)
        {
            string cmd = "cmd=pause;pauseStat=" + ctrl;

            try {
                fl.getAGVSocketClient().SendMessage(cmd);
            } catch {
                Console.WriteLine("setForkCtrlWithPrompt forklift " + fl.getForkLift().id + "cmd = " + cmd + "failed");
                AGVLog.WriteInfo("setForkCtrlWithPrompt forklift " + fl.getForkLift().id + "cmd = " + cmd + "failed", new StackFrame(true));
            }

            Console.WriteLine("setForkCtrlWithPrompt forklift " + fl.getForkLift().id + "cmd = " + cmd + "success");
            AGVLog.WriteInfo("setForkCtrlWithPrompt forklift " + fl.getForkLift().id + "cmd = " + cmd + "success", new StackFrame(true));
            return(true);
        }
Exemplo n.º 5
0
        public void initPanel(ForkLiftWrapper fl)
        {
            numberLabel.Text    = fl.getForkLift().forklift_number.ToString();
            stateLabel.Text     = "任务状态";
            batteryLabel.Text   = "电池电量";
            pauseLabel.Text     = "暂停状态";
            batteryLabel_c.Text = "";

            numberLabel.Location = new Point(70, 0);
            numberLabel.Size     = new Size(20, 20);
            stateLabel_c.Text    = "";
            stateLabel.Location  = new System.Drawing.Point(10, 25);
            stateLabel.Size      = new System.Drawing.Size(60, 29);


            stateLabel_c.Location = new System.Drawing.Point(85, 25);
            stateLabel_c.Size     = new System.Drawing.Size(40, 29);

            batteryLabel.Location = new System.Drawing.Point(10, 65);
            batteryLabel.Size     = new System.Drawing.Size(60, 29);


            batteryLabel_c.Location = new System.Drawing.Point(85, 65);
            batteryLabel_c.Size     = new System.Drawing.Size(40, 29);

            pauseLabel.Location = new System.Drawing.Point(10, 105);
            pauseLabel.Size     = new System.Drawing.Size(60, 29);

            pauseLabel_c.Location = new System.Drawing.Point(85, 105);
            pauseLabel_c.Size     = new System.Drawing.Size(40, 29);

            this.fl = fl;
            this.infoPanel.Location    = new Point(0, 30);
            this.infoPanel.Size        = new Size(150, 140);
            this.infoPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.Name = "panel_a" + fl.getForkLift().forklift_number;
            this.infoPanel.Controls.Add(stateLabel);
            this.infoPanel.Controls.Add(stateLabel_c);
            this.infoPanel.Controls.Add(batteryLabel);
            this.infoPanel.Controls.Add(batteryLabel_c);

            this.infoPanel.Controls.Add(pauseLabel);
            this.infoPanel.Controls.Add(pauseLabel_c);

            this.Controls.Add(numberLabel);

            this.Controls.Add(infoPanel);
        }
        public void initPanel(ForkLiftWrapper fl)
        {
            this.forklift = fl;

            forkNumberLabel.Text = fl.getForkLift().forklift_number.ToString() + "号车";


            if (fl.getPauseStr().Equals("暂停"))
            {
                pauseCtrlButton.Text = "启动";
            }
            else
            {
                pauseCtrlButton.Text = fl.getPauseStr();
            }

            forkNumberLabel.Location = new Point(10, 20);
            forkNumberLabel.Size     = new Size(60, 30);

            pauseCtrlButton.Location = new Point(80, 10);
            pauseCtrlButton.Size     = new Size(60, 30);

            if (fl.getPauseStr().Equals("运行")) //不支持运行的时候设置暂停
            {
                pauseCtrlButton.Enabled = false;
            }

            pauseCtrlButton.Click += pauseCtroButton_Click;
            this.Controls.Add(forkNumberLabel);
            this.Controls.Add(pauseCtrlButton);
        }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="needStart">需要启动的车</param>
		/// <param name="work"></param>
		/// <returns></returns>
		private bool check_start_state(ForkLiftWrapper needStart, ForkLiftWrapper work) {
			if (work.getPosition().getArea() == 1 && work.getForkLift().isUsed == 1) //只有下货阶段可以提前启动
			{
				if (!ScheduleFactory.getSchedule().getDownDeliverPeriod() && work.getPosition().getPx() - needStart.getPosition().getPx() > 500) {
					return true;
				}

				///上货的时候直接不给启动
				Console.WriteLine("叉车 " + work.getForkLift().id + "在区域1,不能启动" + " 距离 " + (work.getPosition().getPx() - needStart.getPosition().getPx()));
				AGVLog.WriteInfo("叉车 " + work.getForkLift().id + "在区域1,不能启动" + " 距离 " + (work.getPosition().getPx() - needStart.getPosition().getPx()), new StackFrame(true));
				return false;
			}

			return true;

		}
		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;
		}
Exemplo n.º 9
0
        public static bool setForkCtrl(ForkLiftWrapper fl, int ctrl)
        {
            string cmd   = "cmd=pause;pauseStat=" + ctrl;
            int    times = 0;

            while (times < 3)
            {
                try {
                    fl.getAGVSocketClient().SendMessage(cmd);
                    break;
                } catch {
                    AGVMessage message = new AGVMessage();
                    message.setMessageType(AGVMessageHandler_TYPE_T.AGVMessageHandler_SENDPAUSE_ERR);
                    message.setMessageStr("发送中断错误");
                    AGVMessageHandler.getMessageHandler().setMessage(message);
                }
                times++;
            }
            Console.WriteLine("setForkCtrl forklift " + fl.getForkLift().id + "cmd = " + cmd);
            AGVLog.WriteInfo("setForkCtrl forklift " + fl.getForkLift().id + "cmd = " + cmd, new StackFrame(true));
            return(true);
        }
Exemplo n.º 10
0
        private void checkPausePosition(ForkLiftWrapper fl)
        {
            if (fl.getForkLift().shedulePause == 1)
            {
                if (fl.getPosition().getArea() == 3 && fl.getPosition().getPx() > AGVConstant.BORDER_X_3 + AGVConstant.BORDER_X_3_DEVIATION_PLUS)                  //从区域3进入区域2的时候, 如果没有暂停成功或暂停慢了,重新启动车子,并报警
                {
                    Console.WriteLine(fl.getForkLift().forklift_number + "号车 pause position = " + fl.getPosition().getPx());

                    fl.getPosition().setArea(2);
                    fl.getForkLift().shedulePause = 0;

                    AGVMessage message = new AGVMessage();
                    message.setMessageType(AGVMessageHandler_TYPE_T.AGVMessageHandler_SENDPAUSE_ERR);
                    message.setMessageStr("第二分界线 检测中断错误");

                    AGVLog.WriteError("第二分界线 检测中断错误", new StackFrame(true));
                    AGVMessageHandler.getMessageHandler().setMessage(message);
                }
                else if (fl.getPosition().getArea() == 2 && fl.getPosition().getPx() > AGVConstant.BORDER_X_2 + AGVConstant.BORDER_X_2_DEVIATION_PLUS)                    //从区域2进入区域1的时候, 如果没有暂停成功或暂停慢了,重新启动车子,并报警
                {
                    Console.WriteLine(fl.getForkLift().forklift_number + "号车 pause position = " + fl.getPosition().getPx());

                    fl.getPosition().setArea(1);
                    fl.getForkLift().shedulePause = 0;

                    AGVMessage message = new AGVMessage();
                    message.setMessageType(AGVMessageHandler_TYPE_T.AGVMessageHandler_SENDPAUSE_ERR);
                    message.setMessageStr("第一分界线 检测中断错误");

                    AGVLog.WriteError("第一分界线 检测中断错误", new StackFrame(true));
                    AGVMessageHandler.getMessageHandler().setMessage(message);
                }
                else if (fl.getPosition().getArea() == 2 && fl.getPosition().getPx() < AGVConstant.BORDER_X_3 - AGVConstant.BORDER_X_3_DEVIATION_PLUS)                   //从区域2进入区域3的时候,暂停没成功或暂停慢了, 报警,需要手动启动
                {
                    Console.WriteLine(fl.getForkLift().forklift_number + "号车 pause position = " + fl.getPosition().getPx());

                    fl.getPosition().setArea(3);
                    fl.getForkLift().shedulePause = 0;

                    AGVMessage message = new AGVMessage();
                    message.setMessageType(AGVMessageHandler_TYPE_T.AGVMessageHandler_SENDPAUSE_ERR);
                    message.setMessageStr("第二分界线 检测中断错误");

                    AGVLog.WriteError("第二分界线 检测中断错误", new StackFrame(true));
                    AGVMessageHandler.getMessageHandler().setMessage(message);
                }
                else if (fl.getPosition().getArea() == 1 && fl.getPosition().getPx() < AGVConstant.BORDER_X_2 - AGVConstant.BORDER_X_2_DEVIATION_PLUS)                   //从区域2进入区域3的时候,暂停没成功或暂停慢了, 报警,需要手动启动
                {
                    Console.WriteLine(fl.getForkLift().forklift_number + "号车 pause position = " + fl.getPosition().getPx());

                    fl.getPosition().setArea(2);
                    fl.getForkLift().shedulePause = 0;

                    AGVMessage message = new AGVMessage();
                    message.setMessageType(AGVMessageHandler_TYPE_T.AGVMessageHandler_SENDPAUSE_ERR);
                    message.setMessageStr("第二分界线 检测中断错误");

                    AGVLog.WriteError("第一分界线 检测中断错误", new StackFrame(true));
                    AGVMessageHandler.getMessageHandler().setMessage(message);
                }
            }
        }
Exemplo n.º 11
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;
                }
            }
        }
Exemplo n.º 12
0
 private TcpClient getTcpClient()
 {
     return(getTcpConnect(forkLiftWrapper.getForkLift().ip, forkLiftWrapper.getForkLift().port));
 }
		public void sheduleTask() {
			ForkLiftWrapper tmpForkLiftWrapper = null;
			SingleTask tmpSingleTask = null;
			int upRecordStep = 0;  //没有上货, 该值大于0的时候,表示上货还没有结束,可能存在升降机正在运送,车子当前没有任务
			int downRecordStep = 0;  //没有下货,该值大于0的时候, 表示下货没有结束
			int result = -1;

			///***开始处理任务的循环语句***///
			while (ScheduleFactory.getSchedule().getScheduleFlag()) {

				Thread.Sleep(2000);
				if (AGVSystem.getSystem().getSystemPause()) {  //系统暂停后,调度程序不执行
					Console.WriteLine("system pause");
					continue;
				}

				//Console.WriteLine(" shedule Task");
				lock (LockController.getLockController().getLockTask()) {
					taskRecordList = TaskReordService.getInstance().getTaskRecordList();
					upTaskRecord = checkUpTaskRecord();
				}
				//if (upTaskRecord != null)
				//  Console.WriteLine(" upTaskRecord name = " + upTaskRecord.taskRecordName);

				if (ScheduleFactory.getSchedule().getDownDeliverPeriod()) //当前处于上货阶段,有的话控制升降机上升
				{
					//读取升降机上料信号
					if (ElevatorFactory.getElevator().getOutCommand() == COMMAND_FROME2S.LIFT_OUT_COMMAND_UP)  //检测到楼下有货,发送指令到升降机运货到楼上
					{
						ElevatorFactory.getElevator().setDataCommand(COMMAND_FROMS2E.LIFT_IN_COMMAND_UP);
						while (ElevatorFactory.getElevator().getOutCommand() != COMMAND_FROME2S.LIFT_OUT_COMMAND_DOWN)  //等待升降机送货到楼上
						{
							Console.WriteLine("wait lifter up goods");
							Thread.Sleep(100);
						}

						if (upRecordStep > 0) //升降机将货运到楼上,保证upRecordStep不小于0
						{
							upRecordStep--;
							AGVLog.WriteError("上货期间 升降机将货运送到楼上: step = " + upRecordStep, new StackFrame(true));
						}
					}

					if (ElevatorFactory.getElevator().getOutCommand() == COMMAND_FROME2S.LIFT_OUT_COMMAND_DOWN
						|| ElevatorFactory.getElevator().getOutCommand() == COMMAND_FROME2S.LIFT_OUT_COMMAND_UP_DOWN) //上货期间 楼上楼下都有货, 楼上的车子需要继续运行
					{
						lock (LockController.getLockController().getLockForkLift()) {
							//运动到楼上后,发送指令到楼上AGV,把货取走
							tmpForkLiftWrapper = getSheduleForkLift();
							if (tmpForkLiftWrapper != null) {
								tmpSingleTask = getUpPickSingleTaskOnTurn();
								TaskRecord tr_tmp = new TaskRecord();
								tr_tmp.singleTask = tmpSingleTask;
								tr_tmp.taskRecordName = tmpSingleTask.taskName;
								TaskReordService.getInstance().addTaskRecord(tr_tmp);
								tmpForkLiftWrapper.sendTask(tr_tmp); //发送任务
								upPicSingleTaskkUsed++; //用于下次切换卸货点
							} else {
								Console.WriteLine(" 楼上没有可用的车去卸货");
								AGVLog.WriteError(" 楼上没有可用的车去卸货", new StackFrame(true));
							}
						}
						if (tmpForkLiftWrapper != null) {

							while (ElevatorFactory.getElevator().getOutCommand() == COMMAND_FROME2S.LIFT_OUT_COMMAND_DOWN
								|| ElevatorFactory.getElevator().getOutCommand() == COMMAND_FROME2S.LIFT_OUT_COMMAND_UP_DOWN)  //等待楼上货物被取走,如果车的状态回到idle,说明任务发送失败
							{
								if (tmpForkLiftWrapper.getForkLift().taskStep == TASK_STEP.TASK_IDLE) {
									break;
								}
								Console.WriteLine("wait lifter goods to be pick");
								Thread.Sleep(500);
							}

							if (upRecordStep > 0) //升降机将货运到楼上,保证upRecordStep不小于0
							{
								upRecordStep--;
								AGVLog.WriteError("上货期间 楼上货物被取走: step = " + upRecordStep, new StackFrame(true));
							}
						}
					}


					if (checkDownDeliverPeriodOver(upRecordStep))  //检测上料任务有没有结束 条件1:没有上料任务缓存  条件2:所有车子空闲 条件3:升降机上没有货物
					{
						ScheduleFactory.getSchedule().setDownDeliverPeriod ( false);
					}

					downRecordStep = 0; //下料信号置0
					Console.WriteLine("上料阶段");
				}

				if (upTaskRecord != null) {
					if (!ScheduleFactory.getSchedule().getDownDeliverPeriod() && !checkUpDeliverPeriodOver(downRecordStep)) //检查下货任务有没有结束,升降机从楼上到楼下流程走完,没有正在执行的下货任务
						{
						Console.WriteLine("当前下货任务没有执行完成,执行完后再开始执行上货任务");

					} else if (upTaskRecord.taskRecordStat == TASKSTAT_T.TASK_READY_SEND) {
						tmpForkLiftWrapper = ForkLiftWrappersService.getInstance().getForkLiftByNunber(3);  //获取楼下三号车

						if (tmpForkLiftWrapper.getForkLift().taskStep != TASK_STEP.TASK_IDLE) {
							Console.WriteLine("上料任务正在执行,等待上料任务执行完成");
							continue;
						}

						if (ElevatorFactory.getElevator().getOutCommand() != COMMAND_FROME2S.LIFT_OUT_COMMAND_MIN) //只要升降机上有货或有异常都不发送上货任务,否则容易造成楼上楼下都要货
						{
							Console.WriteLine(" 升降机楼下有货,不发送上货任务");
						} else {
							lock (LockController.getLockController().getLockForkLift())  //锁住车的状态
							{
								result = tmpForkLiftWrapper.sendTask(upTaskRecord); //发送任务
								ScheduleFactory.getSchedule().setDownDeliverPeriod(true);//上货任务发送后,才进入上料阶段

								if (result == 0) //发送成功 才正式进入上货阶段
								{
									if (upRecordStep <= 2) //避免上货 step被加得太多,不能进入下货阶段
									{
										upRecordStep += 2;
										AGVLog.WriteError("上货期间 发送任务: step = " + upRecordStep, new StackFrame(true));
									}
								}
							}
						}
					}
				}

				//检测升降机2楼有货物,发送指令将升降机送货到楼下
				//检测升降机1楼有货物,调度1楼AGV送货
				//读取升降机上料信号
				if (!ScheduleFactory.getSchedule().getDownDeliverPeriod()) {
					Console.WriteLine(" 下料阶段");
					upRecordStep = 0; //上料信号置0
					if (ElevatorFactory.getElevator().getOutCommand() == COMMAND_FROME2S.LIFT_OUT_COMMAND_DOWN)  //检测到楼上有货,发送指令到升降机运货到楼下
					{
						int times_tmp = 0;
						ElevatorFactory.getElevator().setDataCommand(COMMAND_FROMS2E.LIFT_IN_COMMAND_DOWN);
						while (ElevatorFactory.getElevator().getOutCommand() == COMMAND_FROME2S.LIFT_OUT_COMMAND_DOWN && times_tmp < 60)  //等待升降机送货到楼下
						{
							Console.WriteLine("wait lifter down goods"); //光电感应大概10S可以结束
							times_tmp++;
							Thread.Sleep(1000);
						}

						if (times_tmp < 60) {
							if (downRecordStep > 0) //升降机将货运到楼上,保证upRecordStep不小于0
							{
								downRecordStep--;
								AGVLog.WriteError("下货期间 楼上货物送到楼下: step = " + downRecordStep, new StackFrame(true));
							}
						}

						times_tmp = 0;
					}

					if (ElevatorFactory.getElevator().getOutCommand() == COMMAND_FROME2S.LIFT_OUT_COMMAND_UP ||
							ElevatorFactory.getElevator().getOutCommand() == COMMAND_FROME2S.LIFT_OUT_COMMAND_UP_DOWN) //检测到楼下有货,通知AGV来取货
					{
						TaskRecord tr_tmp = new TaskRecord();
						tmpForkLiftWrapper = ForkLiftWrappersService.getInstance().getForkLiftByNunber(3);
						tmpSingleTask = getDownPickSingleTaskOnTurn();
						tr_tmp.singleTask = tmpSingleTask;
						tr_tmp.taskRecordName = tmpSingleTask.taskName;
						if (tmpForkLiftWrapper != null && tmpForkLiftWrapper.getForkLift().taskStep == TASK_STEP.TASK_IDLE) {
							TaskReordService.getInstance().addTaskRecord(tr_tmp); //发货后,才确认添加该记录
							result = tmpForkLiftWrapper.sendTask(tr_tmp);
							if (result == 0) //任务发送成功
							{
								downPicSingleTaskkUsed++; //用于下次切换卸货点
								if (downRecordStep > 0) //升降机将货运到楼上,保证upRecordStep不小于0
								{
									downRecordStep--;
									AGVLog.WriteError("下货期间 楼下货物被取走: step = " + downRecordStep, new StackFrame(true));
								}
							} else {
								TaskReordService.getInstance().removeTaskRecord(tr_tmp.singleTask, tr_tmp.taskRecordStat);  //如果任务没发送成功,删除该条记录
							}
						}

					}

					lock (LockController.getLockController().getLockTask()) {
						foreach (TaskRecord tr in taskRecordList) {
							lock (LockController.getLockController().getLockForkLift()) {
								if (tr.taskRecordStat == TASKSTAT_T.TASK_READY_SEND) {
									tmpForkLiftWrapper = null;
									if (tr.singleTask.taskType == TASKTYPE_T.TASK_TYPE_DOWN_PICK)
										tmpForkLiftWrapper = ForkLiftWrappersService.getInstance().getForkLiftByNunber(3);
									else if (tr.singleTask.taskType == TASKTYPE_T.TASK_TYPE_UP_DILIVERY)
										tmpForkLiftWrapper = getSheduleForkLift();  //有任务执行的时候,才考虑检查车子状态
																					//if (fl.getForkLift().taskStep == TASK_STEP.TASK_IDLE && fl.finishStatus == 1)  //检查车子的状态,向空闲的车子发送任务,如果发送失败,后面会检测发送状态,
																					//并将该任务状态改成待发重新发送
									if (tmpForkLiftWrapper != null && tmpForkLiftWrapper.getForkLift().taskStep == TASK_STEP.TASK_IDLE) {
										result = tmpForkLiftWrapper.sendTask(tr); //发送任务
										if (result == -1) //任务没有发送成功会中断本次循环,防止发送任务到后面的车
										{
											break;
										}

										if (tr.singleTask.taskType == TASKTYPE_T.TASK_TYPE_UP_DILIVERY && downRecordStep < 4) //发送的是楼上送货,并且送货发送次数小于2次
										{
											downRecordStep += 2;
											AGVLog.WriteError("下货期间 发送任务: step = " + downRecordStep, new StackFrame(true));
										}

									}
								}
							}
						}
					}
				}
			}
		}