HYControl.cs 2.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.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 += (s,o)=> crc.LanguageProcess(this);
            crc.CurrLanguage = Setting_Init.Device_Default_Language;
        }
        public void Init(string devicetype)
        {
            this.devicetype = devicetype;

            foreach (var c in this.Controls) {
                if (!(c is CylinderButton))
                    continue;
                var cc = (c as CylinderButton);
                cc.DeviceType = devicetype;
                if (!RobotManage.Config.DOList[devicetype].ContainsKey(cc.IO_HIGH))
                    cc.Visible = false;
            }
            ioControl1.Init(RobotManage.Config, devicetype);
            if (!RobotManage.Config.DOList[devicetype].ContainsKey(IO_Type.Ls_A_LineRun)) {

                btn_linerun.Visible = false;
                btn_linerev.Visible = false;
                btn_linestop.Visible = false;
            }
            crc.LanguageProcess(this);
        }
        string devicetype = "root";
        private void btn_linerun_Click(object sender, EventArgs e)
        {
            IOManager.IOMove(IO_Type.Ls_A_LineRwd, IO_VALUE.LOW, devicetype);
            IOManager.IOMove(IO_Type.Ls_A_LineRun, IO_VALUE.HIGH, devicetype);            
        }

        private void btn_linerev_Click(object sender, EventArgs e)
        {
            IOManager.IOMove(IO_Type.Ls_A_LineRwd, IO_VALUE.HIGH, devicetype);
            IOManager.IOMove(IO_Type.Ls_A_LineRun, IO_VALUE.HIGH, devicetype);            
        }

        private void btn_linestop_Click(object sender, EventArgs e)
        {
            IOManager.IOMove(IO_Type.Ls_A_LineRwd, IO_VALUE.LOW, devicetype);
            IOManager.IOMove(IO_Type.Ls_A_LineRun, IO_VALUE.LOW, devicetype);
        }
    }
}