Esempio n. 1
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");
            }
        }
Esempio n. 2
0
File: YuMi.cs Progetto: david0f/yumi
        private void PrintRapidData(string taskName, string moduleName, string varName)
        {
            try
            {
                rdt = controller.Rapid.GetRapidDataType(taskName, moduleName, varName);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace); Thread.Sleep(5000);
            }
            try
            {
                if (rd != null)
                {
                    rd.Dispose();
                }
                rd = controller.Rapid.GetRapidData(taskName, moduleName, varName);
            }
            catch (Exception e)
            {
                Console.WriteLine("Could not fetch rapid data");
                Console.WriteLine(e.StackTrace);
            }

            if (!string.IsNullOrWhiteSpace(rd.StringValue))
            {
                Console.WriteLine("{0} : {1} ", taskName, rd.StringValue);
            }
            // subscribing to variable change
            rd.ValueChanged += RapidVar_ValueChanged;
        }
Esempio n. 3
0
        private void btnHome_Click(object sender, EventArgs e)
        {
            // JointTarget jCurPos = this.controller.MotionSystem.ActiveMechanicalUnit.GetPosition();
            JointTarget jCurPos = new JointTarget();

            jCurPos.FillFromString2("[[0,0,0,0,90,0],[9E9,9E9,9E9,9E9,9E9,9E9]]");

            try
            {
                using (this.master = Mastership.Request(controller.Rapid))
                {
                    RapidData rd = controller.Rapid.GetRapidData("T_ROB1", "Module1", "jTarget");
                    controller.Rapid.GetTask("T_ROB1").SetProgramPointer("Module1", "moveJoint");
                    rd.Value = jCurPos;
                    controller.Rapid.Start();
                }
                if (this.controller.Rapid.ExecutionStatus != ExecutionStatus.Running)
                {
                    master.Release();
                }
            }
            catch (System.InvalidOperationException ex)
            {
                MessageBox.Show("Mastership is held by another client." + ex.Message);
                master.Release();
                master = Mastership.Request(controller);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Unexpected error occurred: " + ex.Message);
            }
        }
Esempio n. 4
0
        public static Dictionary <string, List <string[]> > readProgramData(bool run, string[] controllerData)
        {
            List <string[]> progData = new List <string[]> {
            };

            ///List<string[]> currData = new List<string[]> { };

            if (run == true)
            {
                Guid       systemId   = new Guid(controllerData[1]);
                Controller controller = new Controller(systemId);
                controller.Logon(UserInfo.DefaultUser);

                Task newTask = controller.Rapid.GetTask("T_ROB1");
                using (Mastership.Request(controller.Rapid))
                {
                    RapidSymbolSearchProperties sProp = RapidSymbolSearchProperties.CreateDefault();

                    sProp.Types = SymbolTypes.Data;
                    RapidSymbol[] progDatas = newTask.GetModule("MainModule").SearchRapidSymbol(sProp);
                    foreach (RapidSymbol rs in progDatas)
                    {
                        RapidData rd = controller.Rapid.GetTask("T_ROB1").GetModule("MainModule").GetRapidData(rs);
                        if ((rd.Value is ToolData) | (rd.Value is WobjData))
                        {
                            string[] eachProg = new string[3]
                            {
                                rd.RapidType,
                                rd.Name,
                                rd.Value.ToString()
                            };
                            progData.Add(eachProg);
                        }
                    }

                    /*
                     * RapidSymbol[] currDatas = newTask.GetModule("MainModule").SearchRapidSymbol(sProp);
                     * foreach (RapidSymbol rs in currDatas)
                     * {
                     *  RapidData rd = controller.Rapid.GetTask("T_ROB1").GetModule("MainModule").GetRapidData(rs);
                     *  if ((rd.Value is ToolData) | (rd.Value is WobjData))
                     *  {
                     *      string[] eachCurr = new string[3]
                     *      {
                     *          rd.RapidType,
                     *          rd.Name,
                     *          rd.Value.ToString()
                     *      };
                     *      currData.Add(eachCurr);
                     *  }
                     * }
                     */
                }
            }

            return(new Dictionary <string, List <string[]> >
            {
                { "programData", progData } /*,{"currentData", currData}*/
            });
        }
Esempio n. 5
0
        private void button2_Click(object sender, EventArgs e)
        {
            RapidData aData = controller.Rapid.GetTask("T_ROB1").GetModule(textBox2.Text).GetRapidData(textBox1.Text);

            textBox_rapidType.Text  = aData.RapidType;
            textBox_symbolType.Text = aData.Symbol.ToString();
            textBox_varName.Text    = aData.Name;
            textBox_varValue.Text   = aData.StringValue;
        }
Esempio n. 6
0
        public void RefreshData(RWSystem rwSystem)
        {
            RapidData     rPipeGrooveModel           = rwSystem.Controller.Rapid.GetRapidData(strTaskName, strDataModuleName, strDataName);
            RapidDataType rPipeGrooveModelType       = rwSystem.Controller.Rapid.GetRapidDataType(strTaskName, strDataTypeModuleName, strDataType);
            UserDefined   rPipeGrooveModelUserDefine = new UserDefined(rPipeGrooveModelType);

            rPipeGrooveModelUserDefine.FillFromString(rPipeGrooveModel.Value.ToString());

            int i = 0;

            this.numIndex          = int.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());
            this.numPipeGrooveType = int.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());

            this.numSeamCenterX     = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());
            this.numSeamNormalAngle = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());

            this.numHeaderDiameter  = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());
            this.numHeaderThickness = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());
            this.numHeaderMaterial  = int.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());

            this.numBranchDiameter  = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());
            this.numBranchThickness = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());
            this.numBranchMaterial  = int.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());

            this.numMultiPassTotal    = int.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());
            this.numCooperativeRobots = int.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());
            this.numPathSource        = int.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());

            this.numReviseScanBranchType = int.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());
            this.numReviseScanHeaderType = int.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());

            this.numWeldLegWidth      = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());
            this.numGrooveGap         = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());
            this.numBranchGrooveRoot  = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());
            this.numBranchGrooveAngle = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());

            this.numBranchGrooveAngle90 = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());
            this.numTopHeight90         = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());
            this.numBottomHeight90      = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());
            this.numProfCosine          = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());

            this.numLayerHeight             = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());
            this.numLayerPassTotalRoundType = decimal.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());
            this.numAlgorithmType           = int.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());

            this.boolContinuous = bool.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());
            this.boolUseAlignedSTNbyFixedValue = bool.Parse(rPipeGrooveModelUserDefine.Components[i++].ToString());

            this.strID     = rPipeGrooveModelUserDefine.Components[i++].ToString();
            this.strRemark = rPipeGrooveModelUserDefine.Components[i++].ToString();

            rPipeGrooveModelUserDefine.Dispose();
            rPipeGrooveModelType.Dispose();
            rPipeGrooveModel.Dispose();
        }
Esempio n. 7
0
        private void Jogging(string joint, float OffsJointValue)
        {
            JointTarget jCurPos = this.controller.MotionSystem.ActiveMechanicalUnit.GetPosition();

            switch (joint)
            {
            case "J1":
                jCurPos.RobAx.Rax_1 += OffsJointValue;
                break;

            case "J2":
                jCurPos.RobAx.Rax_2 += OffsJointValue;
                break;

            case "J3":
                jCurPos.RobAx.Rax_3 += OffsJointValue;
                break;

            case "J4":
                jCurPos.RobAx.Rax_4 += OffsJointValue;
                break;

            case "J5":
                jCurPos.RobAx.Rax_5 += OffsJointValue;
                break;

            case "J6":
                jCurPos.RobAx.Rax_6 += OffsJointValue;
                break;
            }
            try
            {
                using (this.master = Mastership.Request(controller.Rapid))
                {
                    RapidData rd = controller.Rapid.GetRapidData("T_ROB1", "Module1", "jTarget");
                    controller.Rapid.GetTask("T_ROB1").SetProgramPointer("Module1", "moveJoint");
                    rd.Value = jCurPos;
                    controller.Rapid.Start();
                }
                if (this.controller.Rapid.ExecutionStatus != ExecutionStatus.Running)
                {
                    master.Release();
                }
            }
            catch (System.InvalidOperationException ex)
            {
                MessageBox.Show("Mastership is held by another client." + ex.Message);
                master.Release();
                master = Mastership.Request(controller);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Unexpected error occurred: " + ex.Message);
            }
        }
Esempio n. 8
0
        public void Write_ABB_DataRecord(string Data_Record_Name, string Module_Name, string Task_Name, Controller aController, List <string> Variables, int ArrayIndex)
        {
            string        L_Module_Name      = Module_Name;
            string        L_Task_Name        = Task_Name;
            string        L_Data_Record_Name = Data_Record_Name;
            List <string> _Variables         = Variables;
            Controller    L_aController      = aController;
            int           _ArrayIndex        = ArrayIndex;
            string        _info;

            try
            {
                //Get the array with the records
                rd_array = aController.Rapid.GetRapidData(Task_Name, Module_Name, "RawIndividuals");
                ad       = (ArrayData)rd_array.Value;
                int aRank = ad.Rank;

                //Read the record
                rd  = L_aController.Rapid.GetRapidData(Task_Name, Module_Name, L_Data_Record_Name);
                rdt = L_aController.Rapid.GetRapidDataType(L_Task_Name, L_Module_Name, L_Data_Record_Name);
                UserDefined processdata = new UserDefined(rdt);

                //Prepare the parameters
                for (int i = 0; i < 5; i++)
                {
                    processdata.Components[i].FillFromString(_Variables[i]);
                }

                //Add the parameters to the array
                rd_array.Value = ad;
                ad[ArrayIndex] = processdata;
            }

            catch (ABB.Robotics.Controllers.RapidDomain.RapidModuleNotFoundException ee)
            {
                _info = "Error: " + ee.Message;
            }
            catch (ABB.Robotics.Controllers.RapidDomain.RapidSymbolNotFoundException ee)
            {
                _info = "Error: " + ee.Message;
            }
            catch (ABB.Robotics.GenericControllerException ee)
            {
                _info = "Error: " + ee.Message;
            }
            catch (System.Exception ee)
            {
                _info = "Error: " + ee.Message;
            }
            finally
            {
                // Release resources
            }
        }
Esempio n. 9
0
        public void RefreshData(RWSystem rwSystem, int intGroupIndex, int intIndex)
        {
            this.intGroupIndex = intGroupIndex;
            this.intIndex      = intIndex;

            RapidData rWeldProcedureArray = rwSystem.Controller.Rapid.GetRapidData(strTaskName, strDataModuleName, strDataName + this.intGroupIndex);
            //RapidDataType rWeldProcedureType = rwSystem.Controller.Rapid.GetRapidDataType(strTaskName, strDataTypeModuleName, strDataType);
            UserDefined rWeldProcedure = (UserDefined)rWeldProcedureArray.ReadItem(this.intIndex);

            int i = 0;

            this.strWeldProcedureID = rWeldProcedure.Components[i++].ToString();
            this.strWeldProcedureID = this.strWeldProcedureID.Substring(1, this.strWeldProcedureID.Length - 2);

            this.numWeldSpeed = decimal.Parse(rWeldProcedure.Components[i++].ToString());
            this.numPreFlow   = decimal.Parse(rWeldProcedure.Components[i++].ToString());

            this.numSche         = decimal.Parse(rWeldProcedure.Components[i++].ToString());
            this.numTrackCurrent = decimal.Parse(rWeldProcedure.Components[i++].ToString());

            this.numPostFlow   = decimal.Parse(rWeldProcedure.Components[i++].ToString());
            this.numWeaveShape = int.Parse(rWeldProcedure.Components[i++].ToString());
            this.numWeaveType  = int.Parse(rWeldProcedure.Components[i++].ToString());

            this.numWeaveLength = decimal.Parse(rWeldProcedure.Components[i++].ToString());
            this.numWeaveWidth  = decimal.Parse(rWeldProcedure.Components[i++].ToString());
            this.numWeaveHeigth = decimal.Parse(rWeldProcedure.Components[i++].ToString());

            this.numDwellLeft   = decimal.Parse(rWeldProcedure.Components[i++].ToString());
            this.numDwellCenter = decimal.Parse(rWeldProcedure.Components[i++].ToString());
            this.numDwellRight  = decimal.Parse(rWeldProcedure.Components[i++].ToString());

            this.numWeaveDir  = decimal.Parse(rWeldProcedure.Components[i++].ToString());
            this.numWeaveTilt = decimal.Parse(rWeldProcedure.Components[i++].ToString());

            this.numWeaveOri  = decimal.Parse(rWeldProcedure.Components[i++].ToString());
            this.numWeaveBias = decimal.Parse(rWeldProcedure.Components[i++].ToString());
            this.numTrackType = int.Parse(rWeldProcedure.Components[i++].ToString());
            this.numGainY     = decimal.Parse(rWeldProcedure.Components[i++].ToString());

            this.numGainZ        = decimal.Parse(rWeldProcedure.Components[i++].ToString());
            this.numPenetration  = decimal.Parse(rWeldProcedure.Components[i++].ToString());
            this.numTrackBias    = decimal.Parse(rWeldProcedure.Components[i++].ToString());
            this.numWeaveWidth90 = decimal.Parse(rWeldProcedure.Components[i++].ToString());

            this.strRemark = rWeldProcedure.Components[i++].ToString();
            this.strRemark = this.strRemark.Substring(1, this.strRemark.Length - 2);

            //rWeldProcedureType.Dispose();
            rWeldProcedure.Dispose();
            rWeldProcedureArray.Dispose();
        }
        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
        }
        /// <summary>
        /// 定时器更新机器人状态信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (Timer_ON)
            {
                if (this.comboBox2.Text.Contains("工件坐标"))
                {
                    gripper_Loc = abbcontroller.MotionSystem.ActiveMechanicalUnit.GetPosition(CoordinateSystemType.WorkObject);//读取当前坐标系
                }
                else if (this.comboBox2.Text.Contains("基坐标"))
                {
                    gripper_Loc = abbcontroller.MotionSystem.ActiveMechanicalUnit.GetPosition(CoordinateSystemType.Base);//读取当前坐标系
                }
                else if (this.comboBox2.Text.Contains("世界坐标"))
                {
                    gripper_Loc = abbcontroller.MotionSystem.ActiveMechanicalUnit.GetPosition(CoordinateSystemType.World);//读取当前坐标系
                }
                this.x_label.Text  = gripper_Loc.Trans.X.ToString();
                this.y_label.Text  = gripper_Loc.Trans.Y.ToString();
                this.z_label.Text  = gripper_Loc.Trans.Z.ToString();
                this.q1_label.Text = gripper_Loc.Rot.Q1.ToString();
                this.q2_label.Text = gripper_Loc.Rot.Q2.ToString();
                this.q3_label.Text = gripper_Loc.Rot.Q3.ToString();
                this.q4_label.Text = gripper_Loc.Rot.Q4.ToString();

                speedData = abbcontroller.Rapid.GetRapidData("T_ROB1", "MainModule", "speeddef");
                string[] speedstr = speedData.Value.ToString().Split('[', ',', ']');    //分割字符串
                this.speedlabel.Text = speedstr[1] + "mm/s " + this.abbcontroller.MotionSystem.SpeedRatio.ToString() + "%";

                this.cyclelabel.Text      = this.abbcontroller.Rapid.Cycle.ToString();
                this.modelabel.Text       = this.abbcontroller.OperatingMode.ToString();
                this.motorStatelabel.Text = this.abbcontroller.State.ToString();
                if (this.motorStatelabel.Text == "MotorsOn")
                {
                    this.motorStatelabel.ForeColor = Color.Green;
                }
                else
                {
                    this.motorStatelabel.ForeColor = Color.Red;
                }
                if (this.modelabel.Text == "Auto")
                {
                    this.modelabel.ForeColor = Color.Green;
                }
                else
                {
                    this.modelabel.ForeColor = Color.Red;
                }
            }
            else
            {
            }
        }
Esempio n. 12
0
        //Functions


        public string Read_ABB_DataRecord(string Data_Record_Name, string Module_Name, string Task_Name, Controller aController, int ArrayIndex)
        {
            string Data_Records_Time = " ";

            string     L_Module_Name      = Module_Name;
            string     L_Task_Name        = Task_Name;
            string     L_Data_Record_Name = Data_Record_Name;
            Controller L_aController      = aController;
            string     _info;

            try
            {
                //Get the array with the records
                rd_array = aController.Rapid.GetRapidData(Task_Name, Module_Name, "RawIndividuals");
                ad       = (ArrayData)rd_array.Value;
                int aRank = ad.Rank;

                //Read the record
                rd  = L_aController.Rapid.GetRapidData(Task_Name, Module_Name, L_Data_Record_Name);
                rdt = L_aController.Rapid.GetRapidDataType(L_Task_Name, L_Module_Name, L_Data_Record_Name);
                UserDefined processdata = new UserDefined(rdt);

                processdata = (UserDefined)ad[ArrayIndex];

                //Get the time elapsed using the individual's parameters
                Data_Records_Time = processdata.Components[5].ToString();
                return(Data_Records_Time);
            }

            catch (ABB.Robotics.Controllers.RapidDomain.RapidModuleNotFoundException ee)
            {
                return(_info = "Error: " + ee.Message);
            }
            catch (ABB.Robotics.Controllers.RapidDomain.RapidSymbolNotFoundException ee)
            {
                return(_info = "Error: " + ee.Message);
            }
            catch (ABB.Robotics.GenericControllerException ee)
            {
                return(_info = "Error: " + ee.Message);
            }
            catch (System.Exception ee)
            {
                return(_info = "Error: " + ee.Message);
            }
            finally
            {
                //
            }
        }
Esempio n. 13
0
        public void ApplyData(RWSystem rwSystem)
        {
            RapidData rWeldProcedureArray = rwSystem.Controller.Rapid.GetRapidData(strTaskName, strDataModuleName, strDataName + this.intGroupIndex);
            //RapidDataType rWeldProcedureType = rwSystem.Controller.Rapid.GetRapidDataType(strTaskName, strDataTypeModuleName, strDataType);
            UserDefined rWeldProcedure = (UserDefined)rWeldProcedureArray.ReadItem(this.intIndex);

            rWeldProcedure.FillFromString(this.ToString());
            ErrorHandler.AddErrorMessage("MichaelLog", this.ToString());
            rWeldProcedureArray.WriteItem(rWeldProcedure, this.intIndex);

            //rWeldProcedureType.Dispose();
            rWeldProcedure.Dispose();
            rWeldProcedureArray.Dispose();
        }
Esempio n. 14
0
        public void InitDataStream()
        {
            Task tRob1 = controller.Rapid.GetTask("T_ROB1");

            if (tRob1 != null)
            {
                rd_repeat = tRob1.GetRapidData("Module1", "repeat");
                if (rd_repeat.Value is Bool)
                {
                    repeatBool = (Bool)rd_repeat.Value;
                }

                rd_start = tRob1.GetRapidData("Module1", "flag");
                if (rd_start.Value is Num)
                {
                    processFlag = (Num)rd_start.Value;
                }

                rd_targetsNum = tRob1.GetRapidData("Module1", "targetsNum");
                if (rd_targetsNum.Value is Num)
                {
                    processFlag = (Num)rd_start.Value;
                }

                rd_speedLevel = tRob1.GetRapidData("Module1", "speedLevel");
                if (rd_speedLevel.Value is Num)
                {
                    speedLevel = (Num)rd_speedLevel.Value;
                }

                rd_targets = tRob1.GetRapidData("Module1", "tgPos");
                if (rd_targets.IsArray)
                {
                    targets = (ArrayData)rd_targets.Value;
                    int aRank = targets.Rank;
                    maxLength = targets.GetLength(aRank - 1);
                    ArrayModes am = targets.Mode;
                    Debug.WriteLine("ARRAY MODE! ::: " + am.ToString());
                    targets.Mode = ArrayModes.Dynamic;
                }
                else
                {
                    MessageBox.Show("'targets' data is not array!");
                }
                if (rd_targets == null)
                {
                    MessageBox.Show("'targets' data does not exist!");
                }
            }
        }
Esempio n. 15
0
        public void ApplyData(RWSystem rwSystem)
        {
            RapidData     rLayerParameter           = rwSystem.Controller.Rapid.GetRapidData(strTaskName, strDataModuleName, string.Format("{0}{1:00}", strDataName, this.intLayerNo));
            RapidDataType rLayerParameterType       = rwSystem.Controller.Rapid.GetRapidDataType(strTaskName, strDataTypeModuleName, strDataType);
            UserDefined   rLayerParameterUserDefine = new UserDefined(rLayerParameterType);

            rLayerParameterUserDefine.FillFromString(this.ToString());
            ErrorHandler.AddErrorMessage("MichaelLog", this.ToString());
            rLayerParameter.Value = rLayerParameterUserDefine;

            rLayerParameterUserDefine.Dispose();
            rLayerParameterType.Dispose();
            rLayerParameter.Dispose();
        }
Esempio n. 16
0
        public void ApplyData(RWSystem rwSystem)
        {
            RapidData     rPipeGrooveModel           = rwSystem.Controller.Rapid.GetRapidData(strTaskName, strDataModuleName, strDataName);
            RapidDataType rPipeGrooveModelType       = rwSystem.Controller.Rapid.GetRapidDataType(strTaskName, strDataTypeModuleName, strDataType);
            UserDefined   rPipeGrooveModelUserDefine = new UserDefined(rPipeGrooveModelType);

            rPipeGrooveModelUserDefine.FillFromString(this.ToString());
            ErrorHandler.AddErrorMessage("MichaelLog", this.ToString());
            rPipeGrooveModel.Value = rPipeGrooveModelUserDefine;

            rPipeGrooveModelUserDefine.Dispose();
            rPipeGrooveModelType.Dispose();
            rPipeGrooveModel.Dispose();
        }
Esempio n. 17
0
        public void JudgeColor()
        {
            crd_SelectAction = RobotClass.con.Rapid.GetRapidData("T_ROB1", "RobotData", "SelectAction");
            ArrayData pp = (ArrayData)crd_SelectAction.Value;

            switch (((Bool)pp[cPint - 1, 0]).ToString())
            {
            case "False":
                btn_cy1.BackColor = Color.Gainsboro;
                break;

            case "True":
                btn_cy1.BackColor = Color.Red;
                break;

            default:
                btn_cy1.BackColor = Color.Gainsboro;
                break;
            }
            switch (((Bool)pp[cPint - 1, 1]).ToString())
            {
            case "False":
                btn_cy2.BackColor = Color.Gainsboro;
                break;

            case "True":
                btn_cy2.BackColor = Color.Red;
                break;

            default:
                btn_cy2.BackColor = Color.Gainsboro;
                break;
            }
            switch (((Bool)pp[cPint - 1, 2]).ToString())
            {
            case "False":
                btn_cy3.BackColor = Color.Gainsboro;
                break;

            case "True":
                btn_cy3.BackColor = Color.Red;
                break;

            default:
                btn_cy3.BackColor = Color.Gainsboro;
                break;
            }
        }
Esempio n. 18
0
        public Boolean Read_ABB_Bool(string Module_Name, string Task_Name, Controller aController, string Boolean_Name)
        {
            Boolean Boolean_Value = false;

            string     L_Module_Name      = Module_Name;
            string     L_Task_Name        = Task_Name;
            string     L_Data_Record_Name = Boolean_Name;
            Controller L_aController      = aController;

            try
            {
                rd = L_aController.Rapid.GetRapidData(Task_Name, Module_Name, Boolean_Name);
                if (rd.Value is Bool)
                {
                    //Write the value
                    rapid_bool.Value = (Bool)rd.Value;
                    Boolean_Value    = rapid_bool.Value;
                }
                return(Boolean_Value);
            }

            catch (ABB.Robotics.Controllers.RapidDomain.RapidModuleNotFoundException ee)
            {
                // TODO: Add error handling
                //MessageBox.Show("Error: " + ee.Message);
            }
            catch (ABB.Robotics.Controllers.RapidDomain.RapidSymbolNotFoundException ee)
            {
                // TODO: Add error handling
                //MessageBox.Show("Error: " + ee.Message);
            }
            catch (ABB.Robotics.GenericControllerException ee)
            {
                // TODO: Add error handling
                //MessageBox.Show("Error: " + ee.Message);
            }
            catch (System.Exception ee)
            {
                // TODO: Add error handling
                //MessageBox.Show("Error: " + ee.Message);
            }
            finally
            {
                // Release resources
            }

            return(Boolean_Value);
        }
Esempio n. 19
0
        private void UpdateGUI(object sender, EventArgs e)
        {
            try
            {
                this.pipeGrooveModel.RefreshData(this.rwSystem);
                this.comboBox_numPipeGrooveType.SelectedIndex = this.pipeGrooveModel.numPipeGrooveType - 1;
                this.numEditor_numSeamCenterX.Value           = this.pipeGrooveModel.numSeamCenterX;
                this.numEditor_numSeamNormalAngle.Value       = this.pipeGrooveModel.numSeamNormalAngle;

                RapidData rapidData = rwSystem.Controller.Rapid.GetRapidData("T_ROB1", "CalibDataModule", "wobjCurrent");
                this.wobjCurrent.FillFromString(rapidData.Value.ToString());

                this.numEditor_oframeX.Value = (Decimal)Math.Round(this.wobjCurrent.Oframe.Trans.X, 1);
                this.numEditor_oframeY.Value = (Decimal)Math.Round(this.wobjCurrent.Oframe.Trans.Y, 1);
                this.numEditor_oframeZ.Value = (Decimal)Math.Round(this.wobjCurrent.Oframe.Trans.Z, 1);

                if (this.pipeGrooveModel.numPipeGrooveType >= 3)
                {
                    this.numEditor_WorldXOffset.Value = (Decimal)Math.Round(this.wobjCurrent.Oframe.Trans.Z, 1);

                    double dSeamNormalAngle = 0 - Math.PI * ((double)this.numEditor_numSeamNormalAngle.Value) / 180;

                    double doframeX = this.wobjCurrent.Oframe.Trans.X;
                    double doframeY = this.wobjCurrent.Oframe.Trans.Y;

                    this.numEditor_WorldYOffset.Value = (decimal)Math.Round(doframeX * Math.Cos(dSeamNormalAngle) + doframeY * Math.Sin(dSeamNormalAngle), 1);
                    this.numEditor_WorldZOffset.Value = (decimal)Math.Round(0 - doframeX * Math.Sin(dSeamNormalAngle) + doframeY * Math.Cos(dSeamNormalAngle), 1);
                }
                else
                {
                    this.numEditor_WorldXOffset.Value = (Decimal)Math.Round(this.wobjCurrent.Oframe.Trans.X, 1);
                    this.numEditor_WorldYOffset.Value = (Decimal)Math.Round(this.wobjCurrent.Oframe.Trans.Y, 1);
                    this.numEditor_WorldZOffset.Value = (Decimal)Math.Round(this.wobjCurrent.Oframe.Trans.Z, 1);
                }

                this.menuItem_Apply.Enabled = false;
            }
            catch (Exception ex)
            {
                GTPUMessageBox.Show(this.Parent.Parent, null
                                    , string.Format("An unexpected error occurred when reading RAPID data 'rPipeGrooveModel'. Message {0}", ex.ToString())
                                    , "System Error"
                                    , System.Windows.Forms.MessageBoxIcon.Hand
                                    , System.Windows.Forms.MessageBoxButtons.OK);
            }
        }
Esempio n. 20
0
 //public string readLoaderString
 public RobotStatus readString(string controller, string modual, string variable, out string result)
 {
     if (this._controller.OperatingMode == ControllerOperatingMode.Auto)
     {
         using (Mastership m = Mastership.Request(this._controller.Rapid))
         {
             RapidData rd = this._controller.Rapid.GetRapidData(controller, modual, variable);
             result = rd.Value.ToString();
         }
         return(RobotStatus.finish);
     }
     else
     {
         result = "fail";
         return(RobotStatus.nonAuto);
     }
 }
Esempio n. 21
0
 private RobotStatus writeString(string controller, string modual, string variableName, string ipValue)
 {
     if (this._controller.OperatingMode == ControllerOperatingMode.Auto)
     {
         using (Mastership m = Mastership.Request(this._controller.Rapid))
         {
             RapidData rd = this._controller.Rapid.GetRapidData(controller, modual, variableName);
             ABB.Robotics.Controllers.RapidDomain.String rapidString;
             rapidString.FillFromString(ipValue);
             rd.Value = rapidString;
         }
         return(RobotStatus.finish);
     }
     else
     {
         return(RobotStatus.nonAuto);
     }
 }
Esempio n. 22
0
        public void Write_ABB_Boolean(string Var_Name, string Module_Name, string Task_Name, Controller aController, Boolean Bit)
        {
            string     L_Var_Name    = Var_Name;
            string     L_Module_Name = Module_Name;
            string     L_Task_Name   = Task_Name;
            Controller L_aController = aController;

            rapid_bool.Value = Bit;

            try
            {
                rd = L_aController.Rapid.GetRapidData(Task_Name, Module_Name, Var_Name);
                if (rd.Value is Bool)
                {
                    //Write the value
                    rd.Value = rapid_bool;
                }
            }

            catch (ABB.Robotics.Controllers.RapidDomain.RapidModuleNotFoundException ee)
            {
                // TODO: Add error handling
                //MessageBox.Show("Error: " + ee.Message);
            }
            catch (ABB.Robotics.Controllers.RapidDomain.RapidSymbolNotFoundException ee)
            {
                // TODO: Add error handling
                //MessageBox.Show("Error: " + ee.Message);
            }
            catch (ABB.Robotics.GenericControllerException ee)
            {
                // TODO: Add error handling
                //MessageBox.Show("Error: " + ee.Message);
            }
            catch (System.Exception ee)
            {
                // TODO: Add error handling
                //MessageBox.Show("Error: " + ee.Message);
            }
            finally
            {
                // Release resources
            }
        }
Esempio n. 23
0
        private void DataValueIsChanged(object sender, DataValueChangedEventArgs e)
        {
            /////////////////////////////////////////////////////////////////////////
            ///watching data value
            ////////////////////////////////////////////////////////////////////////
            try
            {
                for (int i = 0; i < varList.Count; i++)
                {
                    this.rd = this.ctl.Rapid.GetTask(taskName).GetModule(moduleName).GetRapidData(varList[i].ToString());

                    listViewData.Items[i].SubItems[1].Text = rd.Value.ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void ConnectToRobotProgram()
        {
            //method try connect to robot controller and getting data from it (robot speed value, robot zone value, programStart variable and also actual robot position)
            try
            {
                if (controller.OperatingMode == ControllerOperatingMode.Auto)
                {
                    tasks = controller.Rapid.GetTasks();
                    using (Mastership m = Mastership.Request(controller.Rapid))
                    {
                        rdRobotPosition = tasks[0].GetRapidData("Module1", "position1");
                        if (rdRobotPosition.Value is Pos)
                        {
                            robotPosition = (Pos)rdRobotPosition.Value;

                            sliderAxisX.Value     = robotPosition.X;
                            lblValueAxisX.Content = robotPosition.X.ToString();
                            sliderAxisY.Value     = robotPosition.Y;
                            lblValueAxisY.Content = robotPosition.Y.ToString();
                            sliderAxisZ.Value     = robotPosition.Z;
                            lblValueAxisZ.Content = robotPosition.Z.ToString();
                        }
                        rdZone         = tasks[0].GetRapidData("Module1", "robotZone");
                        rdSpeed        = tasks[0].GetRapidData("Module1", "robotSpeed");
                        rdProgramStart = tasks[0].GetRapidData("Module1", "programStart");
                    }
                }
                else
                {
                    MessageBox.Show("Automatic mode is required to start execution from a remote client.");
                }
            }
            catch (System.InvalidOperationException ex)
            {
                MessageBox.Show("Mastership is held by another client." + ex.Message);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Unexpected error occurred: " + ex.Message);
            }
        }
Esempio n. 25
0
        public void InitDataStream()
        {
            Task tRob1 = controller.Rapid.GetTask("T_ROB1");

            if (tRob1 != null)
            {
                rd_start = tRob1.GetRapidData("Module1", "Start");

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

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

                if (rd_begin.Value is Num)
                {
                    processFlag = (Num)rd_start.Value;
                }
            }
        }
        //初始化数据流(上电时初始化数据流):
        public void InitDataStream(Controller controller)
        {
            controller.Logon(ABB.Robotics.Controllers.UserInfo.DefaultUser);
            ABB.Robotics.Controllers.RapidDomain.Task[] tasks = controller.Rapid.GetTasks();
            if (tasks[0] != null)
            {
                //单点运动
                DstPosQuat = tasks[0].GetRapidData("MainModule", "DstPosQuat");//获取实例
                if (DstPosQuat.Value is Pose)
                {
                    posquat = (Pose)DstPosQuat.Value;//获取默认值
                }

                //产品类型
                produceTypeRobot = tasks[0].GetRapidData("MainModule", "produceType");
                if (produceTypeRobot.Value is Num)
                {
                    producetypeLocal = (Num)produceTypeRobot.Value;
                }
            }
        }
Esempio n. 27
0
        private void buttonStart_Click(object sender, EventArgs e)
        {
            ///////////////////////////////////////////////////////////////
            ///starting
            ///////////////////////////////////////////////////////////////

            Signal sig = null;

            if (ioList.Count != 0)
            {
                for (int i = 0; i < ioList.Count; i++)
                {
                    sig          = ctl.IOSystem.GetSignal(ioList[i].ToString());
                    sig.Changed += new EventHandler <SignalChangedEventArgs>(SignalChanged);
                }
            }


            taskName   = comboBoxTask.Text.ToString();
            moduleName = comboBoxModule.Text.ToString();

            if (varList.Count != 0 && taskName != "" && moduleName != "")
            {
                try
                {
                    for (int i = 0; i < varList.Count; i++)
                    {
                        this.rd = this.ctl.Rapid.GetTask(taskName).GetModule(moduleName).GetRapidData(varList[i].ToString());
                        listViewData.Items[i].SubItems[1].Text = rd.Value.ToString();
                        this.rd.ValueChanged += new EventHandler <DataValueChangedEventArgs>(DataValueChanged);
                        this.rd.Subscribe(DataValueChanged, EventPriority.High);
                        this.rd.Unsubscribe(DataValueChanged);
                    }
                }
                catch
                {
                    MessageBox.Show("error,check task name,module name,PERS name");
                }
            }
        }
Esempio n. 28
0
        private void menuItem_Apply_Click(object sender, EventArgs e)
        {
            try
            {
                this.wobjCurrent.Oframe.Trans.X = (float)this.numEditor_oframeX.Value;
                this.wobjCurrent.Oframe.Trans.Y = (float)this.numEditor_oframeY.Value;
                this.wobjCurrent.Oframe.Trans.Z = (float)this.numEditor_oframeZ.Value;

                RapidData rapidData = rwSystem.Controller.Rapid.GetRapidData("T_ROB1", "CalibDataModule", "wobjCurrent");
                rapidData.Value = this.wobjCurrent;

                this.menuItem_Apply.Enabled = false;
            }
            catch (Exception ex)
            {
                GTPUMessageBox.Show(this.Parent.Parent, null
                                    , string.Format("An unexpected error occurred when applying RAPID data 'rPipeGrooveModel'. Message {0}", ex.ToString())
                                    , "System Error"
                                    , System.Windows.Forms.MessageBoxIcon.Hand
                                    , System.Windows.Forms.MessageBoxButtons.OK);
            }
        }
Esempio n. 29
0
        private void listViewData_DoubleClick(object sender, EventArgs e)
        {
            RapidData rdt  = null;
            string    temp = "0";

            try
            {
                MessageBox.Show("Zero clearing?    accept in the flexpandent after click OK");
                rdt = this.ctl.Rapid.GetTask(taskName).GetModule(moduleName).GetRapidData(listViewData.SelectedItems[0].Text.ToString());
                Mastership mas = Mastership.Request(this.ctl.Rapid);
                //Change: controller is repaced by aController
                rdt.Value = ABB.Robotics.Controllers.RapidDomain.Num.Parse(temp);
                mas.Dispose();
                MessageBox.Show("zero clearing");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Type isn't Num. error: " + ex.ToString());
            }

            //Release mastership as soon as possible
        }
Esempio n. 30
0
        public static Dictionary <string, List <string> > readTargetData(bool run, string[] controllerData)
        {
            List <string> rTargets = new List <string>();
            List <string> jTargets = new List <string>();

            if (run == true)
            {
                Guid       systemId   = new Guid(controllerData[1]);
                Controller controller = new Controller(systemId);
                controller.Logon(UserInfo.DefaultUser);

                Task newTask = controller.Rapid.GetTask("T_ROB1");
                using (Mastership.Request(controller.Rapid))
                {
                    RapidSymbolSearchProperties sProp = RapidSymbolSearchProperties.CreateDefault();
                    sProp.Types = SymbolTypes.Data;
                    RapidSymbol[] datas = newTask.GetModule("MainModule").SearchRapidSymbol(sProp);
                    foreach (RapidSymbol rs in datas)
                    {
                        RapidData rd = controller.Rapid.GetTask("T_ROB1").GetModule("MainModule").GetRapidData(rs);
                        if (rd.Value is RobTarget)
                        {
                            rTargets.Add(rd.Value.ToString());
                        }
                        if (rd.Value is JointTarget)
                        {
                            jTargets.Add(rd.Value.ToString());
                        }
                    }
                }
            }

            return(new Dictionary <string, List <string> >
            {
                { "robTargets", rTargets },
                { "jointTargets", jTargets }
            });
        }
Esempio n. 31
0
        private void RegisterForEvents()
        {
            clear_flags();
            //controller_101 RHS
            RinReadyPosAEvent = controller_101.Rapid.GetRapidData("T_ROB1", "Module1", "isRinReadyPosA");
            if (RinReadyPosAEvent != null)
            {
                RinReadyPosAEvent.ValueChanged += RinReadyPos_EventHandler;
            }
            RinCrossPosEvent = controller_101.Rapid.GetRapidData("T_ROB1", "Module1", "isRinCrossPos");
            if (RinCrossPosEvent != null)
            {
                RinCrossPosEvent.ValueChanged += RinCrossPos_EventHandler;
            }
            RGripperOpenedEvent = controller_101.Rapid.GetRapidData("T_ROB1", "Module1", "isRGripperOpened");
            if (RGripperOpenedEvent != null)
            {
                RGripperOpenedEvent.ValueChanged += RGripperOpened_EventHandler;
            }

            //controller_100 LHS
            LinCrossPosEvent = controller_100.Rapid.GetRapidData("T_ROB1", "Module1", "isLinCrossPos");
            if (LinCrossPosEvent != null)
            {
                LinCrossPosEvent.ValueChanged += LinCrossPos_EventHandler;
            }
            LGripperClosedEvent = controller_100.Rapid.GetRapidData("T_ROB1", "Module1", "isLGripperClosed");
            if (LGripperClosedEvent != null)
            {
                LGripperClosedEvent.ValueChanged += LGripperClosed_EventHandler;
            }

            //Reverse
            //controller_101 RHS
            R_RinCrossPosEvent = controller_101.Rapid.GetRapidData("T_ROB1", "Module1", "R_isRinCrossPos");
            if (R_RinCrossPosEvent != null)
            {
                R_RinCrossPosEvent.ValueChanged += R_RinCrossPos_EventHandler;
            }
            R_RGripperClosedEvent = controller_101.Rapid.GetRapidData("T_ROB1", "Module1", "R_isRGripperClosed");
            if (R_RGripperClosedEvent != null)
            {
                R_RGripperClosedEvent.ValueChanged += R_RinGripperClosed_EventHandler;
            }

            //controller_100 LHS
            R_LinReadyPosAEvent = controller_100.Rapid.GetRapidData("T_ROB1", "Module1", "R_isLinReadyPosA");
            if (R_LinReadyPosAEvent != null)
            {
                R_LinReadyPosAEvent.ValueChanged += R_LinReadyPos_EventHandler;
            }
            R_LinCrossPosEvent = controller_100.Rapid.GetRapidData("T_ROB1", "Module1", "R_isLinCrossPos");
            if (R_LinCrossPosEvent != null)
            {
                R_LinCrossPosEvent.ValueChanged += R_LinCrossPos_EventHandler;
            }
            R_LGripperOpenedEvent = controller_100.Rapid.GetRapidData("T_ROB1", "Module1", "R_isLGripperOpened");
            if (R_LGripperOpenedEvent != null)
            {
                R_LGripperOpenedEvent.ValueChanged += R_LGripperOpened_EventHandler;
            }
        }