TransplantControl.cs 3.2 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 TransplantControl : UserControl, Idevicetab
    {
        public TransplantControl()
        {
            InitializeComponent();
            this.Tag = "not";
            crc.OpenResourceLog = true;
            crc.LanguageChangeEvent += (s, o) => crc.LanguageProcess(this);
            crc.CurrLanguage = Setting_Init.Device_Default_Language;
        }
        public void Init(string deviceGroupName)
        {
            this.DeviceGroupName = deviceGroupName;

            foreach (var c in panel1.Controls)
            {
                if (!(c is CylinderButton))
                    continue;
                var cc = (c as CylinderButton);
                cc.DeviceType = deviceGroupName;
                if (!RobotManage.Config.DOList[deviceGroupName].ContainsKey(cc.IO_HIGH))
                    cc.Visible = false;
            }
            ioControl1.Init(RobotManage.Config, deviceGroupName);
            //var axis = RobotManage.Config.moveAxisList.Find(ma => ma.GetAxisValue() == RobotManage.DeviceGroup[devicetype].AxisID);
            
            axisMoveControl1.LoadData(AxisBean.List[deviceGroupName]);
            textBox_p2.Text = RobotManage.DeviceGroup[DeviceGroupName].p2.ToString();
            textBox_p3.Text = RobotManage.DeviceGroup[DeviceGroupName].p3.ToString();

            if (TransplantMove.DeviceList[deviceGroupName].RFID_1 != null)
                rfidControl1.Init(deviceGroupName, TransplantMove.DeviceList[deviceGroupName].RFID_1);
            crc.LanguageProcess(this);
        }
        public string DeviceGroupName { get; set; }

        private void button1_Click(object sender, EventArgs e)
        {
            if (int.TryParse(textBox_p2.Text,out int p2))
                RobotManage.DeviceGroup[DeviceGroupName].p2=p2;

            if (int.TryParse(textBox_p3.Text, out int p3))
                RobotManage.DeviceGroup[DeviceGroupName].p3 = p3;

            CSVPositionReader<DeviceGroup>.SavePostion("Config\\DeviceGroup.csv", RobotManage.DeviceGroup[DeviceGroupName],"GroupName");
        }

        private void button_p2_Click(object sender, EventArgs e)
        {
            if (int.TryParse(textBox_p2.Text, out int p2))
            {
                var axis = AxisBean.List[DeviceGroupName][0];
                axis.AbsMove(null, p2,RobotManage.Config.AMH_TS_P1_speed);
            }
        }

        private void button_p3_Click(object sender, EventArgs e)
        {
            if (int.TryParse(textBox_p3.Text, out int p3))
            {
                var axis = AxisBean.List[DeviceGroupName][0];
                axis.AbsMove(null, p3, RobotManage.Config.AMH_TS_P1_speed);
            }
        }

        private void button_p1_Click(object sender, EventArgs e)
        {
            var axis = AxisBean.List[DeviceGroupName][0];
            axis.AbsMove(null, RobotManage.Config.AMH_TS_P1, RobotManage.Config.AMH_TS_P1_speed);
        }
    }
}