AgvControl.cs 4.6 KB
using DeviceLibrary;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AutoScanAndLabel.UC
{
    public partial class AgvControl : UserControl
    {
        public AgvControl()
        {
            InitializeComponent();
        }


        private void button_rightneedempty_Click(object sender, EventArgs e)
        {
            if (!RobotManage.isRunning)
            {
                MessageBox.Show("机器尚未启动不能呼叫Agv");
                return;
            }

            if (RobotManage.mainMachine.IOValue(IO_Type.RightEnd_Check).Equals(IO_VALUE.LOW))
            {
                //请求AGV代码放这里
                //等待agv到位
                RobotManage.mainMachine.RightMoveInfo.NewMove(MoveStep.R40_InShelf);//等待agv到位后执行,启动进入

                Task.Run(() =>
                {
                    while (RobotManage.mainMachine.RightMoveInfo.MoveStep >= MoveStep.R40_InShelf)
                    {
                        Task.Delay(1000).Wait();
                    }
                    //通知agv上料结束, 也可以把上料结束的代码放到 R40_InShelf的结束步骤里去
                });
            }
            else
                MessageBox.Show("当前有料串不能请求进入料串");
        }

        private void button_rightleavefull_Click(object sender, EventArgs e)
        {
            if (!RobotManage.isRunning)
            {
                MessageBox.Show("机器尚未启动不能呼叫Agv");
                return;
            }
            if (RobotManage.mainMachine.IOValue(IO_Type.RightEnd_Check).Equals(IO_VALUE.HIGH))
            {
                //请求AGV代码放这里
                //等待agv到位
                RobotManage.mainMachine.RightMoveInfo.NewMove(MoveStep.R30_OutShelf);//等待agv到位后执行,启动料串离开 
                Task.Run(() =>
                {
                    while (RobotManage.mainMachine.RightMoveInfo.MoveStep >= MoveStep.R30_OutShelf)
                    {
                        Task.Delay(1000).Wait();
                    }
                    //通知agv上料结束, 也可以把上料结束的代码放到R30_OutShelf的结束步骤里去
                });
            }
            else
                MessageBox.Show("当前没有料串不能请求取料串");
        }

        private void button_Leftleavefull_Click(object sender, EventArgs e)
        {
            if (!RobotManage.isRunning)
            {
                MessageBox.Show("机器尚未启动不能呼叫Agv");
                return;
            }
            if (RobotManage.mainMachine.IOValue(IO_Type.LeftEnd_Check).Equals(IO_VALUE.HIGH))
            {
                //请求AGV代码放这里
                //等待agv到位
                RobotManage.mainMachine.LeftMoveInfo.NewMove(MoveStep.L50_OutShelf);//等待agv到位后执行,启动料串离开 
                Task.Run(() =>
                {
                    while (RobotManage.mainMachine.LeftMoveInfo.MoveStep >= MoveStep.L50_OutShelf)
                    {
                        Task.Delay(1000).Wait();
                    }
                    //通知agv上料结束, 也可以把上料结束的代码放到L50_OutShelf的结束步骤里去
                });
            }
            else
                MessageBox.Show("当前没有料串不能请求取料串");
        }

        private void button_leftneedempty_Click(object sender, EventArgs e)
        {
            if (!RobotManage.isRunning)
            {
                MessageBox.Show("机器尚未启动不能呼叫Agv");
                return;
            }
            if (RobotManage.mainMachine.IOValue(IO_Type.LeftEnd_Check).Equals(IO_VALUE.LOW))
            {
                //请求AGV代码放这里
                //等待agv到位
                RobotManage.mainMachine.LeftMoveInfo.NewMove(MoveStep.L60_InShelf);//等待agv到位后执行,启动进入
                Task.Run(() =>
                {
                    while (RobotManage.mainMachine.LeftMoveInfo.MoveStep >= MoveStep.L60_InShelf)
                    {
                        Task.Delay(1000).Wait();
                    }
                    //通知agv上料结束, 也可以把上料结束的代码放到 L60_InShelf的结束步骤里去
                });
            }
            else
                MessageBox.Show("当前有料串不能请求进入料串");
        }
    }
}