public async Task Test(int param)
        {
            await Task.WhenAll(_handler1.ReturnToOriginAsync(), _handler2.ReturnToOriginAsync());

            var positions = await Task.WhenAll(_handler1.GetPositionAsync(), _handler2.GetPositionAsync());

            CollectionAssert.AreEquivalent(new[] { 0, 0 }, positions);

            var responses = await Task.WhenAll(
                _handler1.SendCommandAsync(Command.MoveToPosition, param, CommandParam.MoveType.Absolute),
                _handler2.SendCommandAsync(Command.MoveToPosition, param, CommandParam.MoveType.Absolute));

            CollectionAssert.AreEquivalent(new[] { true, true }, responses.Select(x => x.Status == ReturnStatus.Success));

            await Task.WhenAll(_handler1.WaitForPositionReachedAsync(), _handler2.WaitForPositionReachedAsync());

            positions = await Task.WhenAll(_handler1.GetPositionAsync(), _handler2.GetPositionAsync());

            CollectionAssert.AreEquivalent(new[] { param, param }, positions);

            await Task.WhenAll(_handler1.ReturnToOriginAsync(), _handler2.ReturnToOriginAsync());

            positions = await Task.WhenAll(_handler1.GetPositionAsync(), _handler2.GetPositionAsync());

            CollectionAssert.AreEquivalent(new[] { 0, 0 }, positions);
        }
Ejemplo n.º 2
0
        public async Task Test_Rotation()
        {
            // ReSharper disable once RedundantArgumentDefaultValue
            var reply = await _motor.SendCommandAsync(Command.MoveToPosition, 10000, CommandParam.MoveType.Absolute);

            Assert.AreEqual(ReturnStatus.Success, reply.Status);

            await Task.Delay(TimeSpan.FromMilliseconds(500));

            reply = await _motor.SendCommandAsync(Command.GetAxisParameter, 1, CommandParam.Default);

            Assert.AreEqual(ReturnStatus.Success, reply.Status);
            Assert.AreEqual(10000, reply.ReturnValue);

            await _motor.ReturnToOriginAsync(CancellationToken.None);


            reply = await _motor.SendCommandAsync(Command.GetAxisParameter, 1, CommandParam.Default);

            Assert.AreEqual(ReturnStatus.Success, reply.Status);
            Assert.AreEqual(0, reply.ReturnValue);
        }
Ejemplo n.º 3
0
 public async Task SetUp()
 {
     _port  = new SerialPort("COM1");
     _motor = await new StepMotorProvider <SynchronizedMotor>(NUnitLogger.Instance).CreateFirstOrFromAddressAsync(_port, 1);
     await _motor.ReturnToOriginAsync();
 }