示例#1
0
        /// <summary>
        /// Converts a <see cref="MotorIndex"/> to an <see cref="int"/> and checks the range.
        /// </summary>
        /// <param name="motorIndex"> The motor index. </param>
        /// <returns> The <see cref="int"/>. </returns>
        /// <exception cref="ArgumentOutOfRangeException"> In case of invalid index values. </exception>
        public static int ToInt(this MotorIndex motorIndex)
        {
            var index = (int)motorIndex;

            index.EnsureRange(0, 3, "motorIndex");
            return(index);
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BrickMotor"/> class.
 /// </summary>
 /// <param name="brickPiRaw"> The raw BrickPi communication object. </param>
 /// <param name="motorIndex"> The motor index. </param>
 public BrickMotor(IBrickPiRaw brickPiRaw, MotorIndex motorIndex)
 {
     this.brickPiRaw = brickPiRaw;
     this.motorIndex = motorIndex.ToInt();
     this.brickPiRaw.MotorEnable[this.motorIndex] = 1;
 }