HYControl.cs 3.4 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 HYControl : UserControl, Idevicetab
    {
        public HYControl()
        {
            InitializeComponent();
            if (DesignMode)
                return;
            this.Tag = "not";
            crc.OpenResourceLog = true;
            crc.LanguageChangeEvent += Crc_LanguageChangeEvent;
            if (!string.IsNullOrEmpty(Setting_Init.Device_Default_Language))
                crc.CurrLanguage = Setting_Init.Device_Default_Language;
        }

        private void Crc_LanguageChangeEvent(object sender, EventArgs e)
        {
            crc.LanguageProcess(this);
            btn_linerun.Text = RobotManage.Config.DOList[DeviceGroupName][IO_Type.Ls_A_LineRun].ElectricalDefinition+" " + btn_linerun.Text;
            btn_linestop.Text = RobotManage.Config.DOList[DeviceGroupName][IO_Type.Ls_A_LineRun].ElectricalDefinition+" " + btn_linestop.Text;
            if (RobotManage.Config.DOList[DeviceGroupName].ContainsKey(IO_Type.Ls_A_LineRwd))
                btn_linerev.Text = RobotManage.Config.DOList[DeviceGroupName][IO_Type.Ls_A_LineRwd].ElectricalDefinition+" " + btn_linerev.Text;
            
        }

        public void Init(string _deviceGroup)
        {
            this.DeviceGroupName = _deviceGroup;

            foreach (var c in this.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);
            if (!RobotManage.Config.DOList[DeviceGroupName].ContainsKey(IO_Type.Ls_A_LineRun)) {

                btn_linerun.Visible = false;
                btn_linerev.Visible = false;
                btn_linestop.Visible = false;
            }
            if (!RobotManage.Config.DOList[DeviceGroupName].ContainsKey(IO_Type.Ls_A_LineRwd))
            {
                btn_linerev.Visible = false;
            }
            if (SideMove.DeviceList[DeviceGroupName].RFID_2 != null)
            {
                rfidControl1.Init(DeviceGroupName+"-1", SideMove.DeviceList[DeviceGroupName].RFID_1);
                rfidControl2.Init(DeviceGroupName + "-2", SideMove.DeviceList[DeviceGroupName].RFID_2);
            }
            else if (SideMove.DeviceList[DeviceGroupName].RFID_1 != null)
                rfidControl1.Init(DeviceGroupName, SideMove.DeviceList[DeviceGroupName].RFID_1);
            crc.LanguageProcess(this);
        }
        public string DeviceGroupName { get; set; }
        private void btn_linerun_Click(object sender, EventArgs e)
        {
            SideMove.DeviceList[DeviceGroupName].Line.LineRun("n", false, 999);           
        }

        private void btn_linerev_Click(object sender, EventArgs e)
        {
            SideMove.DeviceList[DeviceGroupName].Line.LineRun("n", true, 999);
        }

        private void btn_linestop_Click(object sender, EventArgs e)
        {
            SideMove.DeviceList[DeviceGroupName].Line.LineStop("n");
        }
    }
}