コード例 #1
0
        public void Execute(McNxtBrick brick, SortRail sortRail, BallPosition position)
        {
            int tacho = sortRail.GetTachoToPosition(position);
            MotorDirection motorDirection = MotorDirection.Forward;

            if (tacho < 0)
            {
                motorDirection = MotorDirection.Backward;
            }

            var absTacho = (uint)Math.Abs(tacho);

            if (absTacho != 0)
            {

                Debug.WriteLine("Heading for position {0} with tacho {1}",
                                position,
                                tacho);

                int resultTacho = MotorHelper.RunAndWaitOnCompletion(
                    (McNxtMotor)brick.MotorA,
                    absTacho,
                    motorDirection);

                sortRail.CurrentTacho += resultTacho;
            }
        }
コード例 #2
0
            public void ShouldFailOnPosition15()
            {
                // Arange
                var sortRail = new SortRail();

                // Act
                sortRail.GetTachoToPosition((BallPosition) 15);

                // Assert
                // Expected exception thrown
            }
コード例 #3
0
            public void ShouldReturn1000ForBall6ByCurrentTacho1640()
            {
                // Arange
                var sortRail = new SortRail {CurrentTacho = 1640};
                const int expected = 1000;

                // Act
                int result = sortRail.GetTachoToPosition(BallPosition.Six);

                // Assert
                Assert.AreEqual(expected, result);
            }
コード例 #4
0
            public void ShouldReturn0ForBallPivotByCurrentTacho4950()
            {
                // Arange
                var sortRail = new SortRail {CurrentTacho = 4950};
                const int expected = 0;

                // Act
                int result = sortRail.GetTachoToPosition(BallPosition.Swap);

                // Assert
                Assert.AreEqual(expected, result);
            }