private int GetMotionCount()
        {
            int motionCount = -1;
            var getMotionCountRequest = new GetMotionCountRequest(RobotPacket.PacketID.CountMotions);
            RobotReply reply = Connection.SendAndReceivePacket(getMotionCountRequest.BuildRequest());
            if (reply == null)
            {
                Debug.Fail("Reply from robot is null");
                return 0;
            }
            reply.RequestID = RobotPacket.PacketID.CountMotions;
            RobotReplyData robotReplyData = reply.Process();
            //if (robotReplyData.Type == RobotReplyData.ReplyType.Success)
            //{
            //    return (int)GlobalFunction.LE4ToDec(robotReplyData.Data);
            //}

            switch (robotReplyData.Type)
            {
                case RobotReplyData.ReplyType.Success:
                    if (robotReplyData.Data.Length!=4)
                    {
                        Debug.Fail("ListAllMotionRequest: data reply is not sufficient");
                        return -1;
                    }
                    return (int)GlobalFunction.LE4ToDec(robotReplyData.Data);
                //case RobotReplyData.ReplyType.Failed:
                //    OnProcessError(ErrorCode.ReplyFailed, "Reply error");
                //    return -2;
                case RobotReplyData.ReplyType.WrongID:
                    OnProcessError(ErrorCode.WrongSessionID, "Wrong session ID");
                    return -2;
            }
            return motionCount;
        }
Exemple #2
0
        private int GetMotionCount()
        {
            int        motionCount           = -1;
            var        getMotionCountRequest = new GetMotionCountRequest(RobotPacket.PacketID.CountMotions);
            RobotReply reply = Connection.SendAndReceivePacket(getMotionCountRequest.BuildRequest());

            if (reply == null)
            {
                Debug.Fail("Reply from robot is null");
                return(0);
            }
            reply.RequestID = RobotPacket.PacketID.CountMotions;
            RobotReplyData robotReplyData = reply.Process();

            //if (robotReplyData.Type == RobotReplyData.ReplyType.Success)
            //{
            //    return (int)GlobalFunction.LE4ToDec(robotReplyData.Data);
            //}

            switch (robotReplyData.Type)
            {
            case RobotReplyData.ReplyType.Success:
                if (robotReplyData.Data.Length != 4)
                {
                    Debug.Fail("ListAllMotionRequest: data reply is not sufficient");
                    return(-1);
                }
                return((int)GlobalFunction.LE4ToDec(robotReplyData.Data));

            //case RobotReplyData.ReplyType.Failed:
            //    OnProcessError(ErrorCode.ReplyFailed, "Reply error");
            //    return -2;
            case RobotReplyData.ReplyType.WrongID:
                OnProcessError(ErrorCode.WrongSessionID, "Wrong session ID");
                return(-2);
            }
            return(motionCount);
        }