Ejemplo n.º 1
0
 /// <summary>
 /// 取放电池线路,分组收料机专用
 /// </summary>
 /// <param name="model">
 /// 取电池运动模式:
 /// 1.正常流程:待机位->抓取位->抓电池->摆放位->放下电池->待机位
 /// 2.取电池遇到换料盘的情况=>取电池到待机位等待
 /// 3.避让位的情况暂不考虑
 /// </param>
 /// <param name="zAxisSafePosition">为0时使用默认安全位</param>
 /// <returns></returns>
 public int ROBOT_CatchAndPutBattery(int model, SixAxisPose sourcePosition, SixAxisPose targetPosition, double zAxisSafePosition = 0)
 {
     if (_simulate)
     {
         return(0);
     }
     try
     {
         string sendMessage = string.Format("CatchAndPutBattery,{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18}",
                                            model,                 //0
                                            sourcePosition.xAxis,  //1
                                            sourcePosition.yAxis,  //2
                                            sourcePosition.zAxis,  //3
                                            sourcePosition.rxAxis, //4
                                            sourcePosition.ryAxis, //5
                                            sourcePosition.rzAxis, //6
                                            sourcePosition.fig,    //7
                                            sourcePosition.remark, //8
                                            targetPosition.xAxis,  //9
                                            targetPosition.yAxis,  //10
                                            targetPosition.zAxis,  //11
                                            targetPosition.rxAxis, //12
                                            targetPosition.ryAxis, //13
                                            targetPosition.rzAxis, //14
                                            targetPosition.fig,    //15
                                            targetPosition.remark, //16
                                            zAxisSafePosition,     //17
                                            ",\r\n");              //18
         byte[] ReceiveData = new byte[1024];
         var    mut         = new Mutex(false, "CatchAndPutBattery");
         mut.WaitOne();
         _clientSocket.Send(Encoding.UTF8.GetBytes(sendMessage));
         int receiveLength = _clientSocket.Receive(ReceiveData);
         mut.ReleaseMutex();
         //TODO:处理异常
         if (0 == receiveLength)
         {
             return(1);
         }
         return(0);
     }
     catch (Exception ex)
     {
         //TODO:保存日志
         Console.WriteLine("CatchAndPutBattery()异常" + ex);
         throw ex;
     }
 }
Ejemplo n.º 2
0
        public int ROBOT_MoveToPos1(int moveType, SixAxisPose sixAxisPose, double zAxisSafePosition = 0)
        {
            if (_simulate)
            {
                return(0);
            }
            try
            {
                string sendMessage = string.Format("MoveToPos,{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}",
                                                   moveType,           //0
                                                   sixAxisPose.xAxis,  //1
                                                   sixAxisPose.yAxis,  //2
                                                   sixAxisPose.zAxis,  //3
                                                   sixAxisPose.rxAxis, //4
                                                   sixAxisPose.ryAxis, //5
                                                   sixAxisPose.rzAxis, //6
                                                   sixAxisPose.fig,    //7
                                                   sixAxisPose.remark, //8
                                                   zAxisSafePosition,  //9
                                                   ",\r\n");           //10
                byte[] ReceiveData = new byte[1024];
                int    receiveLength;
                lock (obj)
                {
                    _clientSocket.Send(Encoding.UTF8.GetBytes(sendMessage));
                    receiveLength = _clientSocket.Receive(ReceiveData);
                }


                //TODO:处理异常
                if (0 == receiveLength)
                {
                    return(1);
                }
                return(0);
            }
            catch (Exception ex)
            {
                //TODO:保存日志
                Console.WriteLine("MoveToPos()异常" + ex);
                throw ex;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 获取机械手位置
 /// </summary>
 /// <returns></returns>
 public SixAxisPose ROBOT_GetRobotPosition()
 {
     if (_simulate)
     {
         return(new SixAxisPose());
     }
     try
     {
         string sendMessage = "GetRobotPosition," + ",\r\n";
         byte[] ReceiveData = new byte[1024];
         var    mut         = new Mutex(false, "GetRobotPosition");
         mut.WaitOne();
         _clientSocket.Send(Encoding.UTF8.GetBytes(sendMessage));
         int receiveLength = _clientSocket.Receive(ReceiveData);
         mut.ReleaseMutex();
         //TODO:处理异常
         if (0 == receiveLength)
         {
             return(null);
         }
         string recData = Encoding.UTF8.GetString(ReceiveData).Trim('\0', ' ');
         //TODO:解析数据返回
         SixAxisPose sixAxisPose = new SixAxisPose();
         //TODO
         var data = recData.Split(',');
         sixAxisPose.xAxis  = Convert.ToDouble(data[0]);
         sixAxisPose.yAxis  = Convert.ToDouble(data[1]);
         sixAxisPose.zAxis  = Convert.ToDouble(data[2]);
         sixAxisPose.rxAxis = Convert.ToDouble(data[3]);
         sixAxisPose.ryAxis = Convert.ToDouble(data[4]);
         sixAxisPose.rzAxis = Convert.ToDouble(data[0]);
         sixAxisPose.fig    = data[6];
         return(sixAxisPose);
     }
     catch (Exception ex)
     {
         //TODO
         Console.WriteLine("GetRobotPosition()异常" + ex);
         throw ex;
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 将特殊位置变量存到机械手
 /// </summary>
 /// <param name="poseType">
 /// 1=>待机位1;
 /// 2=>待机位2;
 /// 3=>NG位;
 /// 4=>默认Z轴安全位
 /// 5=>避让位1
 /// 6=>避让位2
 /// 等等
 /// </param>
 /// <param name="sixAxisPose">位姿</param>
 /// <returns></returns>
 public int ROBOT_SetPositionParam(int poseType, SixAxisPose sixAxisPose, double zAxisSafePosition)
 {
     if (_simulate)
     {
         return(0);
     }
     try
     {
         string sendMessage = string.Format("SetPositionParam,{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}",
                                            poseType,           //0
                                            sixAxisPose.xAxis,  //1
                                            sixAxisPose.yAxis,  //2
                                            sixAxisPose.zAxis,  //3
                                            sixAxisPose.rxAxis, //4
                                            sixAxisPose.ryAxis, //5
                                            sixAxisPose.rzAxis, //6
                                            sixAxisPose.fig,    //7
                                            sixAxisPose.remark, //8
                                            zAxisSafePosition,  //9
                                            ",\r\n");           //10
         byte[] ReceiveData = new byte[1024];
         var    mut         = new Mutex(false, "SetPositionParam");
         mut.WaitOne();
         _clientSocket.Send(Encoding.UTF8.GetBytes(sendMessage));
         int receiveLength = _clientSocket.Receive(ReceiveData);
         mut.ReleaseMutex();
         //TODO:处理异常
         if (0 == receiveLength)
         {
             return(1);
         }
         return(0);
     }
     catch (Exception ex)
     {
         //TODO:保存日志
         Console.WriteLine("SetPositionParam()异常" + ex);
         throw ex;
     }
 }