示例#1
0
            public override byte[] BuildRequest()
            {
                var packet = new RobotPacket(PacketID);

                packet.Parameters = Data;
                return(packet.BuildPacket());
            }
示例#2
0
            public override byte[] BuildRequest()
            {
                var packet = new RobotPacket(RobotPacket.PacketID.CreateMotionPair);

                packet.Parameters = GlobalFunction.DecToLE8(MotionID);
                return(packet.BuildPacket());
            }
示例#3
0
 public override byte[] BuildRequest()
 {
     var packet = new RobotPacket(RequestID)
                      {
                          Parameters = GlobalFunction.DecToLE8(MotionID)
                      };
     return packet.BuildPacket();
 }
示例#4
0
        public override byte[] BuildRequest()
        {
            var packet = new RobotPacket(RequestID)
            {
                Parameters = GlobalFunction.DecToLE8(MotionID)
            };

            return(packet.BuildPacket());
        }
示例#5
0
        public override byte[] BuildRequest()
        {
            var packet = new RobotPacket(RequestID);

            if (volumeLevel != -1)
            {
                packet.Parameters = new[] { (byte)volumeLevel };
            }

            if (motionIDToPlay != 0)
            {
                var param = GlobalFunction.DecToLE8(motionIDToPlay);
                packet.Parameters = param;
            }
            return(packet.BuildPacket());
        }
示例#6
0
        public override byte[] BuildRequest()
        {
            var packet = new RobotPacket(RequestID);

            if (volumeLevel != -1)
            {
                packet.Parameters = new[] { (byte)volumeLevel };
            }

            if (motionIDToPlay != 0)
            {
                var param = GlobalFunction.DecToLE8(motionIDToPlay);
                packet.Parameters = param;
            }
            return packet.BuildPacket();
        }
示例#7
0
 public GetMotionInfoWithIDRequest(ulong motionID, RobotPacket.PacketID packetID)
 {
     RequestID = packetID;
     MotionID = motionID;
 }
示例#8
0
        public override byte[] BuildRequest()
        {
            var packet = new RobotPacket(RequestID);

            return(packet.BuildPacket());
        }
示例#9
0
 public RemoteRequest(RobotPacket.PacketID id, int vol = -1, ulong motionPlay = 0)
 {
     RequestID = id;
     volumeLevel = vol;
     motionIDToPlay = motionPlay;
 }
示例#10
0
 public DeleteMotionRequest(RobotPacket.PacketID packetID, ulong motionID)
 {
     RequestID = packetID;
     MotionID = motionID;
 }
示例#11
0
            public override byte[] BuildRequest()
            {
                var packet = new RobotPacket(RobotPacket.PacketID.CloseMotionFile);

                return(packet.BuildPacket());
            }
示例#12
0
 public override byte[] BuildRequest()
 {
     var packet = new RobotPacket(RequestID);
     return packet.BuildPacket();
 }
示例#13
0
 public GetMotionInfoAtIndexRequest(RobotPacket.PacketID id, int index)
 {
     RequestID = id;
     Index = index;
 }
示例#14
0
            public override byte[] BuildRequest()
            {
                var packet = new RobotPacket(RobotPacket.PacketID.CancelTransferMotionPair);

                return(packet.BuildPacket());
            }
示例#15
0
 public GetMotionCountRequest(RobotPacket.PacketID id)
 {
     RequestID = id;
 }
示例#16
0
        private int WriteData(byte[] data, RobotPacket.PacketID packetID)
        {
            crcCount++;
            if (CancelProcess)
            {
                SendCancel();
                return 2;
            }
            var writeMotionDataRequest = new WriteDataRequest(data, packetID);
            //var bytes = writeMotionDataRequest.BuildRequest();
            //SendData(bytes);
            //System.Threading.Thread.Sleep(5);
            //return 1;
            if (crcCount == WirelessConnection.MaxCrcRetry)
            {
                crcCount = 0;
                if (_writeProcess)
                {
                    DebugHelper.WriteLine("WriteData: reach max crc");
                    _logger.Error("WriteData: reach max crc");
                }

                return 0;
            }
            var reply = writeMotionDataRequest.Process() as RobotReplyData;
            if (reply == null)
            {
                if (_writeProcess)
                {
                    DebugHelper.WriteLine("WriteData: reply is null");
                    _logger.Error("WriteData: reply is null");
                }

                return 0;
            }

            // Check reply error
            if (reply.Type == RobotReplyData.ReplyType.CRC)
            {
                DebugHelper.WriteLine("WriteData: CRC error");
                _logger.Error("WriteData: CRC error");
                return WriteData(data, packetID);
            }
            else if (reply.Type != RobotReplyData.ReplyType.Success)
            {
                if (_writeProcess)
                {
                    DebugHelper.WriteLine("WriteData: reply is not success");
                    _logger.Error("WriteData: reply is not success");
                }

                return WriteData(data, packetID);
                //return 0;
            }

            if (reply.Data.Length == 0)
            {
                if (_writeProcess) _logger.Error("WriteData: reply data is null");
                return 0;
            }
            if (GlobalFunction.LE4ToDec(reply.Data) != data.Length)
            {
                if (_writeProcess)
                {
                    DebugHelper.WriteLine("WriteData: cannot write all data");
                    _logger.Error("WriteData: cannot write all data");
                }

                return 0;
            }
            crcCount = 0;
            return 1;
        }
示例#17
0
 public override byte[] BuildRequest()
 {
     var packet = new RobotPacket(PacketID);
     packet.Parameters = Data;
     return packet.BuildPacket();
 }
示例#18
0
 public WriteDataRequest(byte[] data, RobotPacket.PacketID packetID)
 {
     Data = data;
     PacketID = packetID;
     RequestID = packetID;
 }
示例#19
0
 public override byte[] BuildRequest()
 {
     var packet = new RobotPacket(RobotPacket.PacketID.CreateMotionPair);
     packet.Parameters = GlobalFunction.DecToLE8(MotionID);
     return packet.BuildPacket();
 }
示例#20
0
 public override byte[] BuildRequest()
 {
     var packet = new RobotPacket(RobotPacket.PacketID.CloseMotionPair);
     return packet.BuildPacket();
 }