示例#1
0
        public void CanMoveServo(byte id, CommunicationObject sender)
        {
            var movment1 = new MovmentComandAX12(id, 0x0ff, 0x150);
            var movment2 = new MovmentComandAX12(id, 0x1ff, 0x150);
            var instructionPacket = new InstructionPacketSyncMovment(sender, movment1);
            instructionPacket.Send();

            Thread.Sleep(2000);
            instructionPacket = new InstructionPacketSyncMovment(sender, movment2);
            instructionPacket.Send();

            sender.Dispose();
        }
示例#2
0
        public void CanCreateInstructionPacketForSyncedMovment()
        {
            ISender sender = new FakeSender();
            var movment1 = new MovmentComandAX12(0, 0x010, 0x150);
            var movment2 = new MovmentComandAX12(1, 0x220, 0x360);
            var movment3 = new MovmentComandAX12(2, 0x030, 0x170);
            var movment4 = new MovmentComandAX12(3, 0x220, 0x380);
            var instructionPacket = new InstructionPacketSyncMovment(sender, movment1, movment2, movment3, movment4);

            var corectResult = new byte[]
                                   {
                                       0XFF, 0XFF, 0XFE, 0X18, 0X83, 0X1E, 0X04, 0X00, 0X10, 0X00, 0X50, 0X01, 0X01,
                                       0X20, 0X02, 0X60, 0X03, 0X02, 0X30, 0X00, 0X70, 0X01, 0X03, 0X20, 0X02, 0X80,
                                       0X03, 0X12
                                   };
            Assert.AreEqual(corectResult, instructionPacket.ToByte());
            // Console.WriteLine(BitConverter.ToString(corectResult));
            // Console.WriteLine(BitConverter.ToString(instructionPacket.ToByte()));
        }
示例#3
0
        public void CanMoveServo5()
        {
            ISender sender = new CommunicationObject("COM4");
            var movment1 = new MovmentComandAX12(5, 0x0ff, 0x150);
            var movment2 = new MovmentComandAX12(3, 0x0ff, 0x150);

            var instructionPacket = new InstructionPacketSyncMovment(sender, movment1, movment2);
            instructionPacket.Send();

            ((CommunicationObject) sender).Dispose();
        }