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 Mesnac.Action.ChemicalWeighing.ProjectDebug
{
    public partial class FrmSpeedProjectDebug : Form
    {
        public string FormText = "";
        public string PlcName = "";
        public string PlcValue = "";
        private string ReadGroupName = "DB101_ProjectDebug";
        public FrmSpeedProjectDebug()
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;
        }

        private void btn_Set_Click(object sender, EventArgs e) //来源 响应
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("修改值不能为空!");
                return;
            }
            //获取工程调试器件列表
            foreach (Mesnac.Equips.BaseEquip equip in Equips.Factory.Instance.AllEquips.Values)
            {
                if (equip.Group.ContainsKey(ReadGroupName))
                {
                    foreach (Mesnac.Equips.BaseInfo.Data data in equip.Group[ReadGroupName].Data.Values)
                    {
                        if (data.KeyName.Contains(PlcName))
                        {

                            int hlsd1 = int.Parse(textBox1.Text);
                            var writeResult16 = BasePlcHelper.Instance.PlcWriteByRunName(data.Name, new object[] { hlsd1 });
                            return;
                        }

                    }
                }
            }
        }

        private void btn_Cancle_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void FrmSpeedProjectDebug_Load(object sender, EventArgs e)
        {
            this.Text = FormText;
        }
    }
}