IOControls.cs 3.7 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.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)
        {
            for (int i = 1;i<=4; i++)
                cb_motolist.Items.Add(new KeyValuePair<string, string>($"出料口_U{i}", i.ToString()));

            cb_motolist.SelectedIndex = 0;
        }

        private void btn_fwd_Click(object sender, EventArgs e)
        {
            var u = (KeyValuePair<string, string>)cb_motolist.SelectedItem;

            IOManager.IOMove($"U{u.Value}_Moto_Fwd", IO_VALUE.HIGH);
            IOManager.IOMove($"U{u.Value}_Moto_Rwd", IO_VALUE.LOW);

            LogUtil.info($"手动点击 U{u.Value} 电机正转");
        }

        private void btn_rwd_Click(object sender, EventArgs e)
        {
            var u = (KeyValuePair<string, string>)cb_motolist.SelectedItem;

            IOManager.IOMove($"U{u.Value}_Moto_Fwd", IO_VALUE.LOW);
            IOManager.IOMove($"U{u.Value}_Moto_Rwd", IO_VALUE.HIGH);

            LogUtil.info($"手动点击 U{u.Value} 电机反转");
        }

        private void btn_stop_Click(object sender, EventArgs e)
        {
            var u = (KeyValuePair<string, string>)cb_motolist.SelectedItem;

            IOManager.IOMove($"U{u.Value}_Moto_Fwd", IO_VALUE.LOW);
            IOManager.IOMove($"U{u.Value}_Moto_Rwd", IO_VALUE.LOW);

            LogUtil.info($"手动点击 U{u.Value} 电机停止");
        }

        private void btnUp_Click(object sender, EventArgs e)
        {
            var u = (KeyValuePair<string, string>)cb_motolist.SelectedItem; 
            IOManager.IOMove($"U{u.Value}_Location_Up", IO_VALUE.HIGH);
            IOManager.IOMove($"U{u.Value}_Location_Down", IO_VALUE.LOW); 
            LogUtil.info($"手动点击 U{u.Value} 定位上升");

        }

        private void btnDown_Click(object sender, EventArgs e)
        { 
            var u = (KeyValuePair<string, string>)cb_motolist.SelectedItem; 
            IOManager.IOMove($"U{u.Value}_Location_Down", IO_VALUE.HIGH);
            IOManager.IOMove($"U{u.Value}_Location_Up", IO_VALUE.LOW); 
            LogUtil.info($"手动点击 U{u.Value} 定位下降"); 
        }

        private void btnLocationStop_Click(object sender, EventArgs e)
        { 
            var u = (KeyValuePair<string, string>)cb_motolist.SelectedItem; 
            IOManager.IOMove($"U{u.Value}_Location_Up", IO_VALUE.LOW);
            IOManager.IOMove($"U{u.Value}_Location_Down", IO_VALUE.LOW); 
            LogUtil.info($"手动点击 U{u.Value} 定位停止"); 
        }

        private void cylinderButton7_Click(object sender, EventArgs e)
        {

        }

        private void btnRfid_Click(object sender, EventArgs e)
        {
            var u = (KeyValuePair<string, string>)cb_motolist.SelectedItem;
            string name = "U" + u.Value;
            OutShelfBean outShelf = RobotManage.mainMachine.getOutShelf(name);
            string rfid = outShelf.ReadTest();

            LogUtil.info($"手动点击 U{u.Value}  读取rfid测试 结果:" + rfid);
            MessageBox.Show($"U{u.Value}  读取rfid测试 结果:" + rfid);
        }
    }
}