Ejemplo n.º 1
0
        /// <summary>
        /// 读入Rapid中robtarget数据至ListView
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void readPointsBtn_Click(object sender, EventArgs e)
        {
            if (abbtask == null)
            {
                Data.LogString = "[error] abbtask is null";
                return;
            }
            //获得RobTarget数据
            rd_p1 = (RobTarget)abbtask.GetRapidData("MainModule", "p1").Value;
            rd_p2 = (RobTarget)abbtask.GetRapidData("MainModule", "p2").Value;
            rd_p3 = (RobTarget)abbtask.GetRapidData("MainModule", "p3").Value;
            rd_p4 = (RobTarget)abbtask.GetRapidData("MainModule", "p4").Value;
            string[]     rd_p_strings = new string[] { rd_p1.ToString(), rd_p2.ToString(), rd_p3.ToString(), rd_p4.ToString() };
            string[]     points       = new string[] { "p1", "p2", "p3", "p4" };
            ListViewItem item         = null;

            this.pointslistView.BeginUpdate();
            for (int i = 0; i < points.Length; i++)
            {
                item = new ListViewItem(points[i]);
                item.SubItems.Add(rd_p_strings[i]);
                this.pointslistView.Items.Add(item);        //添加元素
            }
            this.pointslistView.EndUpdate();                //更新控件
            Data.LogString = "坐标点数据读入完毕`";
        }
Ejemplo n.º 2
0
        public void InitDataStream()
        {
            // This loads the Task, ensure that the task name matches in robot studio
            ABB.Robotics.Controllers.RapidDomain.Task tRob1 = controller.Rapid.GetTask("T_ROB1");
            if (tRob1 != null)
            {
                // this line reads the variable Start on Rapid and passes the value to this app
                rd_start = tRob1.GetRapidData("Module1", "Start");

                if (rd_start.Value is Num)
                {
                    // We set the process flag to the start variable
                    processFlag = (Num)rd_start.Value;
                }

                rd_begin = tRob1.GetRapidData("Module1", "flag");

                if (rd_begin.Value is Num)
                {
                    processFlag = (Num)rd_start.Value;
                }

                position = tRob1.GetRapidData("Module1", "position");
            }
        }
        private void button_Read_Click(object sender, EventArgs e)
        {
#if ROBOT_EXIST
            ControllerInfo controllerInfo = main_form.controllers[0]; // 我们很自信,就一个控制器,以后有多个的话,这里肯定需要修改
            Controller     ctrl           = ControllerFactory.CreateFrom(controllerInfo);
            ctrl.Logon(UserInfo.DefaultUser);
            tRob1 = ctrl.Rapid.GetTask("T_ROB1");
#endif
            string module_name = comboBox_Module.SelectedItem.ToString();
            string var_type    = comboBox_Var.SelectedItem.ToString();
            int    var_type_no = comboBox_Var.SelectedIndex;
            string var_name    = textBox_varName.Text;
#if ROBOT_EXIST
            string str_read_res = "";
            switch (var_type)
            {
            case "Num":
                RD_time      = tRob1.GetRapidData(module_name, var_name);
                ABB_Num_time = (Num)RD_time.Value;
                str_read_res = ABB_Num_time.ToString();
                break;

            case "RobTarget":
                RD_rt        = tRob1.GetRapidData(module_name, var_name);
                ABB_RT_rt    = (RobTarget)RD_rt.Value;
                str_read_res = ABB_RT_rt.ToString();
                break;

            default:
                break;
            }
            textBox1_Result.Text = str_read_res;
            textBox1_Result.Update();
            ctrl.Logoff();
            ctrl.Dispose();
#else
            switch (var_type)
            {
            case "Num":
                textBox1_Result.Text = "Num";
                break;

            case "RobTarget":
                textBox1_Result.Text = "RobTarget";
                break;

            default:
                break;
            }
            textBox1_Result.Update();
#endif
        }