/// <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 = "坐标点数据读入完毕`";
        }
        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
        }
示例#3
0
        public static Dictionary <string, string> createWeldRoutine0(string filePath, [DefaultArgumentAttribute("{Plane.ByOriginNormal(Point.ByCoordinates(0,0,0),Vector.ByCoordinates(0,0,-1))}")] List <Plane> planes, double waitTime = 2.9, double weldTime = 0.9, double retract = -10)
        {
            // setup
            var targBuilder = new StringBuilder();
            int ct          = planes.Count;

            foreach (Plane plane in planes)
            {
                RobTarget targ  = Dynamo_TORO.DataTypes.RobTargetAtPlane(plane);
                string    targ2 = "\n\t\t" + "[" + targ.ToString() + "],";
                if (plane == planes[planes.Count - 1])
                {
                    targ2 = "\n\t\t" + "[" + targ.ToString() + "]";
                }
                targBuilder.Append(targ2);
            }

            // create rapid
            string r = "";

            using (var tw = new StreamWriter(filePath, false))
            {
                r = "MODULE MainModule" +
                    "\n" +

                    "\n\t" + "! variables" +
                    "\n\t" + "CONST num wt:=" + waitTime + ";" +
                    "\n\t" + "CONST num wd:=" + weldTime + ";" +
                    "\n\t" + "CONST num dz:=" + retract + ";" +
                    "\n" +

                    "\n\t" + "! targets" +
                    "\n\t" + "VAR robtarget targets{" + ct + ",1}:=" +
                    "\n\t" + "[" + targBuilder.ToString() +
                    "\n\t" + "];" +
                    "\n" +

                    "\n\t" + "! weld routine" +
                    "\n\t" + "PROC wStart(robtarget target)" +
                    "\n\t\t" + "MoveL RelTool(target,0,0,dz),v300,z5,t_welder\\WObj:=w_plate;" +
                    "\n\t\t" + "MoveL target,v300,fine,t_welder\\WObj:=w_plate;" +
                    "\n\t\t" + "SetDO welder,1;" +
                    "\n\t\t" + "WaitTime\\InPos,wd;" +
                    "\n\t\t" + "SetDO welder,0;" +
                    "\n\t\t" + "MoveL RelTool(target,0,0,dz),v300,z5,t_welder\\WObj:=w_plate;" +
                    "\n\t\t" + "WaitTime\\InPos,wt;" +
                    "\n\t" + "ENDPROC\n" +

                    "\n\t" + "! main routine" +
                    "\n\t" + "PROC main()" +
                    "\n\t\t" + "ConfL\\On;" +
                    "\n\t\t" + "SingArea\\Wrist;" +
                    "\n\t\t" + "FOR i FROM 1 TO " + ct + " DO" +
                    "\n\t\t\t" + "TPWrite(valtostr(i))" + " + \" of " + ct + " \" + \"(\" + valtostr(100*i/" + ct + ") + \"%)\";" +
                    "\n\t\t\t" + "wStart(targets{i,1});" +
                    "\n\t\t" + "ENDFOR" +
                    "\n\t\t" + "Stop;" +
                    "\n\t" + "ENDPROC" +
                    "\n" +

                    "\n" + "ENDMODULE"
                ;
                tw.Write(r);
                tw.Flush();
            }

            // end step
            return(new Dictionary <string, string>
            {
                { "filePath", filePath },
                { "robotCode", r }
            });
        }