Exemplo n.º 1
0
        /// <summary>
        /// Called when the Myo sends a <see cref="MyoEventType.Emg"/> event.
        /// </summary>
        /// <param name="evt">The pointer to the event.</param>
        /// <param name="timestamp">The timestamp of the event.</param>
        protected virtual void OnEmgData(IntPtr evt, DateTime timestamp)
        {
            const int NUMBER_OF_SENSORS = 8;
            var       rawEmgData        = new int[NUMBER_OF_SENSORS];

            for (int i = 0; i < rawEmgData.Length; i++)
            {
                rawEmgData[i] = _myoDeviceDriver.GetEventEmg(evt, i);
            }

            var emgData = Device.EmgData.Create(rawEmgData);

            this.EmgData = emgData;

            var handler = EmgDataAcquired;

            if (handler != null)
            {
                var args = new EmgDataEventArgs(
                    this,
                    timestamp,
                    emgData);
                handler.Invoke(this, args);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called when the Myo sends a <see cref="MyoEventType.Emg"/> event.
        /// </summary>
        /// <param name="evt">The pointer to the event.</param>
        /// <param name="timestamp">The timestamp of the event.</param>
        protected virtual void OnEmgData(IntPtr evt, DateTime timestamp)
        {
            // Contract.Requires<ArgumentException>(evt != IntPtr.Zero, "The event handle must be set.");

            const int NUMBER_OF_SENSORS = 8;
            var       rawEmgData        = new int[NUMBER_OF_SENSORS];

            for (int i = 0; i < rawEmgData.Length; i++)
            {
                rawEmgData[i] = _myoDeviceDriver.GetEventEmg(evt, i);
            }

            var emgData = Device.EmgData.Create(rawEmgData);

            this.EmgData = emgData;

            var handler = EmgDataAcquired;

            if (handler != null)
            {
                var args = new EmgDataEventArgs(
                    this,
                    timestamp,
                    emgData);
                handler.Invoke(this, args);
            }
        }