コード例 #1
0
        public void TestPreciseMoverUnnecessaryMove()
        {
            var motorMover   = MockMotorMover.Create();
            var preciseMover = new PreciseMotorMover(motorMover);

            int targetPos = 0;

            preciseMover.GoToPositionAsync(targetPos).Wait();

            Assert.AreEqual(targetPos, motorMover.Locator.Position, "Position did not end at the target position.");
        }
コード例 #2
0
        public void TestPreciseMoverOnlyFirstMove()
        {
            var motorMover   = MockMotorMover.Create();
            var preciseMover = new PreciseMotorMover(motorMover);

            int targetPos = 5;
            var moveTask  = preciseMover.GoToPositionAsync(targetPos);

            while (motorMover.motor.Information.Direction == MoveDirection.Stopped)
            {
            }
            while (motorMover.motor.Information.Direction != MoveDirection.Stopped)
            {
            }
            motorMover.Locator.ShiftPosition(targetPos - motorMover.Locator.Position);
            moveTask.Wait();

            Assert.AreEqual(targetPos, motorMover.Locator.Position, "Position did not end at the target position.");
        }
コード例 #3
0
        public void TestPreciseMoverBackwardMove()
        {
            var motorMover   = MockMotorMover.Create();
            var preciseMover = new PreciseMotorMover(motorMover);

            int targetPos = -5;
            var moveTask  = preciseMover.GoToPositionAsync(targetPos);

            while (motorMover.motor.Information.Direction == MoveDirection.Stopped)
            {
            }
            while (motorMover.motor.Information.Direction != MoveDirection.Stopped)
            {
            }
            motorMover.Locator.ShiftPosition(targetPos + targetPos);
            moveTask.Wait();

            Assert.IsTrue(Math.Abs(targetPos - motorMover.Locator.Position) < 4, "Position did not end at the target position.");
        }