Example #1
0
        /// <summary>
        /// Called when a device has been unpaired.
        /// </summary>
        /// <param name="myoHandle">The Myo handle.</param>
        /// <param name="eventTimeUtc">The event time in UTC.</param>
        protected virtual void OnUnpaired(IntPtr myoHandle, DateTime eventTimeUtc)
        {
            var handler = Unpaired;

            if (handler != null)
            {
                var args = new PairedEventArgs(myoHandle, eventTimeUtc);
                handler.Invoke(this, args);
            }
        }
Example #2
0
        /// <summary>
        /// Called when a device has paired.
        /// </summary>
        /// <param name="myoHandle">The Myo handle.</param>
        protected virtual void OnPaired(IntPtr myoHandle)
        {
            var handler = Paired;

            if (handler != null)
            {
                var args = new PairedEventArgs(myoHandle, DateTime.Now);
                handler.Invoke(this, args);
            }
        }
Example #3
0
        /// <summary>
        /// Called when a device has been unpaired.
        /// </summary>
        /// <param name="myoHandle">The Myo handle.</param>
        /// <param name="eventTimeUtc">The event time in UTC.</param>
        protected virtual void OnUnpaired(IntPtr myoHandle, DateTime eventTimeUtc)
        {
            Contract.Requires <ArgumentException>(myoHandle != IntPtr.Zero, "The handle to the Myo must be set.");

            var handler = Unpaired;

            if (handler != null)
            {
                var args = new PairedEventArgs(myoHandle, eventTimeUtc);
                handler.Invoke(this, args);
            }
        }
Example #4
0
        private void DeviceListener_Unpaired(object sender, PairedEventArgs e)
        {
            Contract.Requires<ArgumentNullException>(sender != null, "sender");

            IMyo myo;
            if (!_myos.TryGetValue(e.MyoHandle, out myo) || myo == null)
            {
                return;
            }

            UnhookMyoEvents(myo);
            _myos.Remove(myo.Handle);
            myo.Dispose();
        }
Example #5
0
        private void DeviceListener_Paired(object sender, PairedEventArgs e)
        {
            Contract.Requires<ArgumentNullException>(sender != null, "sender");

            if (_myos.ContainsKey(e.MyoHandle))
            {
                return;
            }

            var myoDeviceBridge = CreateMyoDeviceBridge();

            // TODO: replace this obsolete call with the one below
            #pragma warning disable 0618
            var myoDeviceDriver = CreateMyoDeviceDriver(
                e.MyoHandle,
                myoDeviceBridge);
            #pragma warning restore 0618

            // TODO: use this call once the obsolete method is removed
            ////var myoErrorHandlerDriver = MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create());
            ////var myoDeviceDriver = CreateMyoDeviceDriver(
            ////    e.MyoHandle,
            ////    myoDeviceBridge,
            ////    myoErrorHandlerDriver);

            var myo = CreateMyo(
                ((IDeviceListener)sender).ChannelListener,
                myoDeviceDriver);

            _myos[myo.Handle] = myo;
            HookMyoEvents(myo);
        }
Example #6
0
        /// <summary>
        /// Called when a device has been unpaired.
        /// </summary>
        /// <param name="myoHandle">The Myo handle.</param>
        /// <param name="eventTimeUtc">The event time in UTC.</param>
        protected virtual void OnUnpaired(IntPtr myoHandle, DateTime eventTimeUtc)
        {
            Contract.Requires<ArgumentException>(myoHandle != IntPtr.Zero, "The handle to the Myo must be set.");

            var handler = Unpaired;
            if (handler != null)
            {
                var args = new PairedEventArgs(myoHandle, eventTimeUtc);
                handler.Invoke(this, args);
            }
        }