FrmRobot.cs 3.8 KB
using OnlineStore.DeviceLibrary;
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 OnlineStore.DoubleLineClient
{
    public partial class FrmRobot : FrmBase
    {
        public FrmRobot()
        {
            InitializeComponent();
        }
        public List<string> IpList = new List<string>();
        private void FrmRobot_Load(object sender, EventArgs e)
        {
            IpList.Add(LineManager.Config.ABB1_IP);
            IpList.Add(LineManager.Config.ABB2_IP);
            IpList.Add(LineManager.Config.ABB3_IP);


            DgvABBInfo.Rows.Add("ABB1(右)",LineManager.Config.ABB1_IP, "关闭", "" );
            DgvABBInfo.Rows.Add("ABB2(左)", LineManager.Config.ABB2_IP, "关闭", "");
            DgvABBInfo.Rows.Add("ABB3(包装料)", LineManager.Config.ABB3_IP, "关闭", "");
            CboAbbAction.Items.Add(ABBRobotServer.Cmd_movep);
            CboAbbAction.Items.Add(ABBRobotServer.Cmd_moveput);
            CboAbbAction.Items.Add(ABBRobotServer.Cmd_moveget);
            CboAbbAction.Items.Add(ABBRobotServer.Cmd_validateP);
            CboAbbAction.SelectedIndex = 0;
            CboAbbType.Items.Add("C:大料架");
            CboAbbType.Items.Add("D:7寸料架");
            CboAbbType.SelectedIndex = 0;
        } 
        private void BtnAbbMove_Click(object sender, EventArgs e)
        {
            if (DgvABBInfo.SelectedCells.Count == 0) return;
            int idx = DgvABBInfo.SelectedCells[0].RowIndex;
            string command = CboAbbAction.Text;
            string point = "p" + numericUpDown1.Value;
            if (command == ABBRobotServer.Cmd_moveput)
            {
                if (CboAbbType.SelectedIndex == 0)
                    point = "cp" + numericUpDown1.Value;
                else
                    point = "dp" + numericUpDown1.Value;
            }
            string movement = RdoAbbMove1.Checked ? "L" : "J";
            int speed = Convert.ToInt32(NudAbbSpeed.Value);

            string s = string.Format("{0},{1},{2},{3}", command, point, movement, speed);
            ABBRobotServer.SendMovePoint(IpList[idx], command, point, movement, speed.ToString()  );
        }

        private void BtnAbbMove2_Click(object sender, EventArgs e)
        {
            if (DgvABBInfo.SelectedCells.Count == 0) return;
            int idx = DgvABBInfo.SelectedCells[0].RowIndex;
            string command = CboAbbAction.Text;
            string point = "p{0}";
            if (command == ABBRobotServer.Cmd_moveput)
            {
                if (CboAbbType.SelectedIndex == 0)
                    point = "cp{0}";
                else
                    point = "dp{0}";
            }
            int p1 = Convert.ToInt32(numericUpDown1.Value);
            int p2 = Convert.ToInt32(numericUpDown2.Value);
            string movement = RdoAbbMove1.Checked ? "L" : "J";
            int speed = Convert.ToInt32(NudAbbSpeed.Value);


            string s = string.Format("{0},{1},{2},{3}", command, point, movement, speed);
          //  ABBRobotServer.SendMovePoint(IpList[idx], command, point, movement, speed.ToString());
        }

        //private void Robot_StatusChanged(int idx, string sta)
        //{
        //    Invoke(new Action(() =>
        //    {
        //        DgvABBInfo.Rows[idx].Cells[2].Value = sta;
        //        Common.ABB_Dev[idx].State = sta;
        //        groupBox13.Controls["LblABBSta" + idx].BackColor = Color.Lime;

        //    }));
        //}

        //private void Robot_ServerChanged(int idx, string sta)
        //{
        //    Invoke(new Action(() =>
        //    {
        //        DgvABBInfo.Rows[idx].Cells[3].Value = sta;
        //        Common.ABB_Dev[idx].Server = sta;
        //    }));
        //}
         

    }
}