IOControls.cs 2.1 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<=5; i++)
                cb_motolist.Items.Add(new KeyValuePair<string, string>($"出料口{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} 电机停止");
        }
    }
}