public void TestLinearCmd() { void CheckMsg(LinearCmd aMsg) { aMsg.Id.Should().Be(4); aMsg.DeviceIndex.Should().Be(2); aMsg.Vectors.Count.Should().Be(1); aMsg.Vectors[0].Index.Should().Be(0); aMsg.Vectors[0].Duration.Should().Be(100); aMsg.Vectors[0].Position.Should().Be(0.5); } var msg = new LinearCmd(2, new List <LinearCmd.VectorSubcommand> { new LinearCmd.VectorSubcommand(0, 100, 0.5) }, 4); CheckMsg(msg); var newMsg = CheckParsedVersion <LinearCmd>(msg, 1, "[{\"LinearCmd\":{\"Vectors\":[{\"Duration\":100,\"Index\":0,\"Position\":0.5}],\"DeviceIndex\":2,\"Id\":4}}]"); CheckMsg(newMsg); _parser.Invoking(x => x.Serialize(msg, 0)).Should().Throw <ButtplugMessageException>(); }
private Task <ButtplugMessage> HandleFleshlightLaunchFW12Cmd([NotNull] ButtplugDeviceMessage aMsg, CancellationToken aToken) { var cmdMsg = CheckMessageHandler <FleshlightLaunchFW12Cmd>(aMsg); var pos = Convert.ToDouble(cmdMsg.Position) / 99.0; var dur = Convert.ToUInt32(FleshlightHelper.GetDuration(Math.Abs((1 - pos) - _currentPosition), cmdMsg.Speed / 99.0)); return(HandleLinearCmd(LinearCmd.Create(cmdMsg.DeviceIndex, cmdMsg.Id, dur, pos, 1), aToken)); }
public void TestInvalidVectorCmdWrongFeatures() { var msg = new LinearCmd(4, new List <LinearCmd.VectorSubcommand> { new LinearCmd.VectorSubcommand(0xffffffff, 500, 0.75), }); testUtil.TestInvalidDeviceMessage(msg); }
public async Task TestVectorCmd() { var msg = new LinearCmd(4, new List <LinearCmd.VectorSubcommand> { new LinearCmd.VectorSubcommand(0, 500, 0.5), }); await testUtil.TestDeviceMessage(msg, new List <(byte[], uint)>() { (new byte[] { 50, 20 }, (uint)KiirooOnyx2BluetoothInfo.Chrs.Tx), }, false); }
public async Task TestVectorCmd() { var msg = new LinearCmd(4, new List <LinearCmd.VectorSubcommand> { new LinearCmd.VectorSubcommand(0, 500, 0.5), }); await testUtil.TestDeviceMessage(msg, new List <(byte[], string)>() { (new byte[] { 50, 20 }, Endpoints.Tx), }, false); }
public void TestVectorCmd() { var msg = new LinearCmd(4, new List <LinearCmd.VectorSubcommand> { new LinearCmd.VectorSubcommand(0, 500, 0.5), }); testUtil.TestDeviceMessage(msg, new List <(byte[], uint)>() { (new byte[2] { 50, 20 }, (uint)FleshlightLaunchBluetoothInfo.Chrs.Tx), }, false); }
private async Task <ButtplugMessage> HandleFleshlightLaunchFW12Cmd(ButtplugDeviceMessage aMsg, CancellationToken aToken) { var cmdMsg = CheckMessageHandler <FleshlightLaunchFW12Cmd>(aMsg); // We'll need to figure out the duration of the Fleshlight move, in // order to translate to a LinearCmd message. var position = (cmdMsg.Position / 99.0); var distance = Math.Abs(_currentPosition - position); var duration = FleshlightHelper.GetDuration(distance, (cmdMsg.Speed / 99.0)); var vectors = new List <LinearCmd.VectorSubcommand>(); vectors.Add(new LinearCmd.VectorSubcommand(0, (uint)duration, position)); var msg = new LinearCmd(aMsg.DeviceIndex, vectors, aMsg.Id); return(await HandleLinearCmd(msg, aToken)); }
public async Task TestVectorCmd() { var msg = new LinearCmd(4, new List <LinearCmd.VectorSubcommand> { new LinearCmd.VectorSubcommand(0, 500, 0.25), }); await testUtil.TestDeviceMessageDelayed(msg, new List <(byte[], string)>() { (Encoding.ASCII.GetBytes("1,\n"), Endpoints.Tx), (Encoding.ASCII.GetBytes("2,\n"), Endpoints.Tx), (Encoding.ASCII.GetBytes("3,\n"), Endpoints.Tx), }, false, 500); msg = new LinearCmd(4, new List <LinearCmd.VectorSubcommand> { new LinearCmd.VectorSubcommand(0, 400, 0.5), }); await testUtil.TestDeviceMessageDelayed(msg, new List <(byte[], string)>() { (Encoding.ASCII.GetBytes("2,\n"), Endpoints.Tx), }, false, 500); }
public void TestInvalidVectorNotEnoughFeatures() { var msg = LinearCmd.Create(4, 0, 500, 0.75, 0); testUtil.TestInvalidDeviceMessage(msg); }
public void TestInvalidVectorCmdTooManyFeatures() { var msg = LinearCmd.Create(4, 0, 500, 0.75, 2); testUtil.TestInvalidDeviceMessage(msg); }