コード例 #1
0
        public void GetMyo_ValidState_EqualsConstructorParameter()
        {
            // Setup
            var myo = new Mock<IMyo>();

            var args = new ArmRecognizedEventArgs(
                myo.Object,
                DateTime.UtcNow,
                Arm.Unknown,
                XDirection.Unknown);

            // Execute
            var result = args.Myo;

            // Assert
            Assert.Equal(myo.Object, result);
        }
コード例 #2
0
        public void GetArm_ValidState_EqualsConstructorParameter()
        {
            // Setup
            var arm = Arm.Left;

            var args = new ArmRecognizedEventArgs(
                new Mock<IMyo>().Object,
                DateTime.UtcNow,
                arm,
                XDirection.Unknown);

            // Execute
            var result = args.Arm;

            // Assert
            Assert.Equal(arm, result);
        }
コード例 #3
0
        /// <summary>
        /// Called when the Myo has recognized which arm it is on.
        /// </summary>
        /// <param name="evt">The pointer to the event.</param>
        /// <param name="timestamp">The timestamp of the event.</param>
        protected virtual void OnArmRecognized(IntPtr evt, DateTime timestamp)
        {
            var arm = _myoDeviceDriver.GetArm(evt);

            this.Arm = arm;

            var xDirection = _myoDeviceDriver.GetEventDirectionX(evt);

            this.XDirectionOnArm = xDirection;

            var handler = ArmRecognized;

            if (handler != null)
            {
                var args = new ArmRecognizedEventArgs(
                    this,
                    timestamp,
                    arm,
                    xDirection);
                handler.Invoke(this, args);
            }
        }
コード例 #4
0
ファイル: Myo.cs プロジェクト: Tineler/Myo-Car-Control
        /// <summary>
        /// Called when the Myo has recognized which arm it is on.
        /// </summary>
        /// <param name="evt">The pointer to the event.</param>
        /// <param name="timestamp">The timestamp of the event.</param>
        protected virtual void OnArmRecognized(IntPtr evt, DateTime timestamp)
        {
            // Contract.Requires<ArgumentException>(evt != IntPtr.Zero, "The event handle must be set.");

            var arm = _myoDeviceDriver.GetArm(evt);

            this.Arm = arm;

            var xDirection = _myoDeviceDriver.GetEventDirectionX(evt);

            this.XDirectionOnArm = xDirection;

            var handler = ArmRecognized;

            if (handler != null)
            {
                var args = new ArmRecognizedEventArgs(
                    this,
                    timestamp,
                    arm,
                    xDirection);
                handler.Invoke(this, args);
            }
        }
コード例 #5
0
        public void GetTimestamp_ValidState_EqualsConstructorParameter()
        {
            // Setup
            var timestamp = DateTime.UtcNow;

            var args = new ArmRecognizedEventArgs(
                new Mock<IMyo>().Object,
                timestamp,
                Arm.Unknown,
                XDirection.Unknown);

            // Execute
            var result = args.Timestamp;

            // Assert
            Assert.Equal(timestamp, result);
        }
コード例 #6
0
        public void GetXDirection_ValidState_EqualsConstructorParameter()
        {
            // Setup
            var directionX = XDirection.TowardElbow;

            var args = new ArmRecognizedEventArgs(
                new Mock<IMyo>().Object,
                DateTime.UtcNow,
                Arm.Unknown,
                directionX);

            // Execute
            var result = args.XDirection;

            // Assert
            Assert.Equal(directionX, result);
        }