IOControls.cs 3.3 KB
using DeviceLibrary;
using OnlineStore;
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;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TheMachine
{
    public partial class IOControls : UserControl
    {
        Robot_Config _Config;
        public Robot_Config Config
        {
            get { return _Config; }
            set
            {
                _Config = value;
                ioControl1.Config = value;
            }
        }
        public IOControls()
        {
            InitializeComponent();
        }


        private void ioControl1_Load(object sender, EventArgs e)
        {
        }

        private void btn_FlipEquip_Click(object sender, EventArgs e)
        {
            RobotManage.mainMachine.FlipEquip.LiftUp(null);
            LogUtil.info("手动点击:FlipEquip.LiftUp");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            RobotManage.mainMachine.FlipEquip.LiftDown(null);
            LogUtil.info("手动点击:FlipEquip.LiftDown");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            RobotManage.mainMachine.RotateEquip.TurnToEnd(true);
            LogUtil.info("手动点击:RotateEquip.TurnToEnd 水平");
        }

        private void button3_Click(object sender, EventArgs e)
        {
            RobotManage.mainMachine.RotateEquip.TurnToEnd(false);
            LogUtil.info("手动点击:RotateEquip.TurnToEnd 垂直");
        }

        private void button5_Click(object sender, EventArgs e)
        {
            RobotManage.mainMachine.TPMove.ToLow(null);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            RobotManage.mainMachine.TPMove.ToHigh(null);
        }

        private void button6_Click(object sender, EventArgs e)
        {
            RobotManage.mainMachine.RotateEquip.TurnDegree(45);
        }

        private void button7_Click(object sender, EventArgs e)
        {
            RobotManage.mainMachine.RotateEquip.TurnDegree(-45);
        }

        private void button8_Click(object sender, EventArgs e)
        {
            RobotManage.mainMachine.RotateEquip.TurnRound();
        }

        private void button9_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < 6;i++) {
                Thread.Sleep(200);
                if (RobotManage.RFID.ReadEPC(12,out byte[] data)) {
                    if (data[0] != 0xFF)
                    {
                        MessageBox.Show(RobotManage.RFID.HexBuff(data) + "\r\n" + Encoding.ASCII.GetString(data).Trim());
                        return;
                    }
                }
            }
            MessageBox.Show("no data");
        }

        private void button10_Click(object sender, EventArgs e)
        {
            Thread.Sleep(300);
            var epc = "20418002Z-203";
            epc = "20418002Z-20";
            epc = epc.PadRight(12);
            var result = RobotManage.RFID.WriteEPC(Encoding.ASCII.GetBytes(epc));
            if (result)
            {
                MessageBox.Show("写入成功");
                return;
            }
        }
    }
}