public static IChannelDriver Create(IChannelBridge channelBridge)
        {
            // Contract.Requires<ArgumentNullException>(channelBridge != null, "channelBridge");
            Contract.Ensures(Contract.Result <IChannelDriver>() != null);

            return(Create(channelBridge, MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())));
        }
Beispiel #2
0
        private static void Main()
        {
            // create a hub to manage Myos
            using (var channel = Channel.Create(
                       ChannelDriver.Create(ChannelBridge.Create(),
                                            MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))))
                using (var hub = Hub.Create(channel))
                {
                    // listen for when a Myo connects
                    hub.MyoConnected += (sender, e) =>
                    {
                        Console.WriteLine("Myo {0} has connected!", e.Myo.Handle);

                        // unlock the Myo so that it doesn't keep locking between our poses
                        e.Myo.Unlock(UnlockType.Hold);

                        // setup for the pose we want to watch for
                        var pose = HeldPose.Create(e.Myo, Pose.Fist, Pose.FingersSpread);

                        // set the interval for the event to be fired as long as
                        // the pose is held by the user
                        pose.Interval = TimeSpan.FromSeconds(0.5);

                        pose.Start();
                        pose.Triggered += Pose_Triggered;
                    };

                    // start listening for Myo data
                    channel.StartListening();

                    ConsoleHelper.UserInputLoop(hub);
                }
        }
        public void InitMyoManagerHub(MainWindow m)
        {
            this.mWindow = m;
            channel      = Channel.Create(
                ChannelDriver.Create(ChannelBridge.Create(),
                                     MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())));
            hub = Hub.Create(channel);

            // listen for when the Myo connects
            hub.MyoConnected += (sender, e) =>
            {
                Debug.WriteLine("Myo {0} has connected!", e.Myo.Handle);
                e.Myo.Vibrate(VibrationType.Short);
                e.Myo.EmgDataAcquired         += Myo_EmgDataAcquired;
                e.Myo.OrientationDataAcquired += Myo_OrientationAcquired;
                e.Myo.PoseChanged             += Myo_PoseChanged;
                e.Myo.SetEmgStreaming(true);
            };

            // listen for when the Myo disconnects
            hub.MyoDisconnected += (sender, e) =>
            {
                Debug.WriteLine("Oh no! It looks like {0} arm Myo has disconnected!", e.Myo.Arm);
                e.Myo.SetEmgStreaming(false);
                e.Myo.EmgDataAcquired -= Myo_EmgDataAcquired;
            };

            // start listening for Myo data
            channel.StartListening();
        }
Beispiel #4
0
        //Button Event that calls all necessary methods to connect to everything
        private void btnConnect_Click(object sender, RoutedEventArgs e)
        { // communication, device, exceptions, poses
            Disconnect.Visibility = Visibility.Visible;
            btnConnect.Visibility = Visibility.Collapsed;
            // Create the channel
            try
            {
                _MyoChannel = Channel.Create(ChannelDriver.Create(ChannelBridge.Create(),
                                                                  MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())));
            }
            catch (Exception)
            {
                UpdateUi("Myo Connect Must Be Turned On");
            }

            // Create the hub with the channel
            _MyoHub = MyoSharp.Device.Hub.Create(_MyoChannel);

            // Create the event handlers for connect and disconnect
            _MyoHub.MyoConnected    += _myoHub_MyoConnected;
            _MyoHub.MyoDisconnected += _myoHub_MyoDisconnected;

            // Start listening
            _MyoChannel.StartListening();
        }
Beispiel #5
0
        private static void Main()
        {
            // create a hub that will manage Myo devices for us
            using (var channel = Channel.Create(
                       ChannelDriver.Create(ChannelBridge.Create(),
                                            MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))))
                using (var hub = Hub.Create(channel))
                {
                    // listen for when the Myo connects
                    hub.MyoConnected += (sender, e) =>
                    {
                        Console.WriteLine("Myo {0} has connected!", e.Myo.Handle);
                        e.Myo.Vibrate(VibrationType.Short);
                        e.Myo.PoseChanged += Myo_PoseChanged;
                        e.Myo.Locked      += Myo_Locked;
                        e.Myo.Unlocked    += Myo_Unlocked;
                    };

                    // listen for when the Myo disconnects
                    hub.MyoDisconnected += (sender, e) =>
                    {
                        Console.WriteLine("Oh no! It looks like {0} arm Myo has disconnected!", e.Myo.Arm);
                        e.Myo.PoseChanged -= Myo_PoseChanged;
                        e.Myo.Locked      -= Myo_Locked;
                        e.Myo.Unlocked    -= Myo_Unlocked;
                    };

                    // start listening for Myo data
                    channel.StartListening();

                    // wait on user input
                    ConsoleHelper.UserInputLoop(hub);
                }
        }
Beispiel #6
0
        private static void Main()
        {
            // create a hub to manage Myos
            using (var channel = Channel.Create(
                       ChannelDriver.Create(ChannelBridge.Create(),
                                            MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))))
                using (var hub = Hub.Create(channel))
                {
                    // listen for when a Myo connects
                    hub.MyoConnected += (sender, e) =>
                    {
                        Console.WriteLine("Myo {0} has connected!", e.Myo.Handle);

                        // for every Myo that connects, listen for special sequences
                        var sequence = PoseSequence.Create(
                            e.Myo,
                            Pose.WaveOut,
                            Pose.WaveIn);
                        sequence.PoseSequenceCompleted += Sequence_PoseSequenceCompleted;
                    };

                    // start listening for Myo data
                    channel.StartListening();

                    ConsoleHelper.UserInputLoop(hub);
                }
        }
 protected virtual IMyoDeviceDriver CreateMyoDeviceDriver(IntPtr myoHandle, IMyoDeviceBridge myoDeviceBridge)
 {
     return(CreateMyoDeviceDriver(
                myoHandle,
                myoDeviceBridge,
                MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())));
 }
        private void initMyo()
        {
            IsEnabledMyo = true;
            try
            {
                var channel = Channel.Create(
                    ChannelDriver.Create(ChannelBridge.Create(),
                                         MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())));
                var hub = MyoSharp.Device.Hub.Create(channel);

                // listen for when the Myo connects
                hub.MyoConnected += (sender, e1) =>
                {
                    Debug.WriteLine("Myo {0} has connected!", e1.Myo.Handle);
                    e1.Myo.Vibrate(VibrationType.Short);
                    e1.Myo.Unlock(UnlockType.Hold);

                    e1.Myo.PoseChanged += Myo_PoseChanged;
                };

                // listen for when the Myo disconnects
                hub.MyoDisconnected += (sender, e1) =>
                {
                    Debug.WriteLine("It looks like {0} arm Myo has disconnected!", e1.Myo.Arm);
                    e1.Myo.PoseChanged -= Myo_PoseChanged;
                };

                channel.StartListening();
            }
            catch (Exception ex)
            {
                Debug.Write($"Myo Error : {ex}");
            }
        }
Beispiel #9
0
        public void InitMyoManagerHub()
        {
            LastExecution = DateTime.Now;
            channel       = Channel.Create(ChannelDriver.Create(ChannelBridge.Create(),
                                                                MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())));
            hub = Hub.Create(channel);

            // listen for when the Myo connects
            hub.MyoConnected += (sender, e) =>
            {
                Debug.WriteLine("Myo {0} has connected!", e.Myo.Handle);
                e.Myo.Vibrate(VibrationType.Short);
                e.Myo.EmgDataAcquired           += Myo_EmgDataAcquired;
                e.Myo.AccelerometerDataAcquired += Myo_AccelerometerDataAcquired;
                e.Myo.GyroscopeDataAcquired     += Myo_GyroscopeDataAcquired;
                e.Myo.OrientationDataAcquired   += Myo_OrientationDataAcquired;
                e.Myo.SetEmgStreaming(true);
            };

            // listen for when the Myo disconnects
            hub.MyoDisconnected += (sender, e) =>
            {
                Debug.WriteLine("Oh no! It looks like {0} arm Myo has disconnected!", e.Myo.Arm);
                e.Myo.SetEmgStreaming(false);
                e.Myo.EmgDataAcquired           -= Myo_EmgDataAcquired;
                e.Myo.AccelerometerDataAcquired -= Myo_AccelerometerDataAcquired;
                e.Myo.GyroscopeDataAcquired     -= Myo_GyroscopeDataAcquired;
                e.Myo.OrientationDataAcquired   -= Myo_OrientationDataAcquired;
            };

            // start listening for Myo data
            channel.StartListening();
        }
Beispiel #10
0
        public void btnCheckConnection_Click(object sender, RoutedEventArgs e)
        {
            // communication, device, exceptions, poses
            // create the channel
            _myoChannel = Channel.Create(ChannelDriver.Create(ChannelBridge.Create(),
                                                              MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())));

            // create the hub with the channel
            _myoHub = MyoSharp.Device.Hub.Create(_myoChannel);
            // create the event handlers for connect and disconnect
            _myoHub.MyoConnected    += _myoHub_MyoConnected;
            _myoHub.MyoDisconnected += _myoHub_MyoDisconnected;

            // start listening
            _myoChannel.StartListening();


            // create the channel
            _myoChannel1 = Channel.Create(ChannelDriver.Create(ChannelBridge.Create(),
                                                               MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())));

            // create the hub with the channel
            _myoHub1 = MyoSharp.Device.Hub.Create(_myoChannel1);
            // create the event handlers for connect and disconnect
            _myoHub1.MyoConnected    += _myoHub_MyoConnected;
            _myoHub1.MyoDisconnected += _myoHub_MyoDisconnected;

            // start listening
            _myoChannel1.StartListening();
        }
Beispiel #11
0
 public void Init()
 {
     HeldPoseInterval = TimeSpan.FromMilliseconds(500);
     _Channel         = Channel.Create(
         ChannelDriver.Create(ChannelBridge.Create(),
                              MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())));
     _Hub = Hub.Create(_Channel);
 }
Beispiel #12
0
        public static IMyoDeviceDriver Create(IntPtr handle, IMyoDeviceBridge myoDeviceBridge)
        {
            //Contract.Requires<ArgumentException>(handle != IntPtr.Zero, "handle");
            //Contract.Requires<ArgumentNullException>(myoDeviceBridge != null, "myoDeviceBridge");
            Contract.Ensures(Contract.Result <IMyoDeviceDriver>() != null);

            return(Create(handle, myoDeviceBridge, MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())));
        }
Beispiel #13
0
 public void InitializeMyo()
 {
     myoChannel = Channel.Create(ChannelDriver.Create
                                     (ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))
                                 );
     myoHub = Hub.Create(myoChannel);
     myoHub.MyoConnected    += myoHub_MyoConnected;
     myoHub.MyoDisconnected += myoHub_MyoDisconnected;
 }
Beispiel #14
0
        /// <summary>
        /// Creates the Myo channel.
        /// </summary>
        /// <returns>The Myo channel.</returns>
        private static IChannelListener CreateChannel()
        {
            var bridge             = MyoErrorHandlerBridge.Create();
            var errorHandlerDriver = MyoErrorHandlerDriver.Create(bridge);
            var channelBridge      = ChannelBridge.Create();
            var channelDriver      = ChannelDriver.Create(channelBridge, errorHandlerDriver);

            return(Channel.Create(channelDriver));
        }
Beispiel #15
0
        // Creates a channel and hub for the MYO to connect to
        private void InitializeMyo()
        {
            myoChannel = Channel.Create(ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())));
            myoHub     = Hub.Create(myoChannel);

            myoHub.MyoConnected    += myoHub_MyoConnected;    // runs method when MYO connects
            myoHub.MyoDisconnected -= myoHub_MyoDisconnected; // runs method when MYO disconnects

            myoChannel.StartListening();
        }
Beispiel #16
0
        public void Create_ValidParameters_NewInstance()
        {
            // Setup
            var bridge = new Mock <IMyoErrorHandlerBridge>(MockBehavior.Strict);

            // Execute
            var result = MyoErrorHandlerDriver.Create(bridge.Object);

            // Assert
            Assert.NotNull(result);
        }
Beispiel #17
0
        protected virtual IMyoDeviceDriver CreateMyoDeviceDriver(IntPtr myoHandle, IMyoDeviceBridge myoDeviceBridge)
        {
            Contract.Requires <ArgumentException>(myoHandle != IntPtr.Zero, "The handle to the Myo must be set.");
            Contract.Requires <ArgumentNullException>(myoDeviceBridge != null, "myoDeviceBridge");
            Contract.Ensures(Contract.Result <IMyoDeviceDriver>() != null);

            return(CreateMyoDeviceDriver(
                       myoHandle,
                       myoDeviceBridge,
                       MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())));
        }
Beispiel #18
0
        public void Create_NullMyoErrorHandlerBridge_ThrowsNullArgumentException()
        {
            // Setup

            // Execute
            Assert.ThrowsDelegate method = () => MyoErrorHandlerDriver.Create(null);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(method);

            Assert.Equal("myoErrorHandlerBridge", exception.ParamName);
        }
        public Form1()
        {
            InitializeComponent();

            // we'll calculate all of our incoming data relative to this point in time
            _startTime = DateTime.UtcNow;


            // construct our graph
            _graphControl = new ZedGraphControl()
            {
                Dock = DockStyle.Fill
            };


            _graphControl.MouseClick          += GraphControl_MouseClick;
            _graphControl.GraphPane.Title.Text = "Myo EMG Data vs Time";
            MasterPane Main_Pane = _graphControl.MasterPane;

            Main_Pane.PaneList.Clear();

            _pointPairs = new PointPairList[NUMBER_OF_SENSORS];
            _sortOrderZ = new List <LineItem>();
            Panes       = new PaneList();

            for (int i = 0; i < 8; i++)
            {
                Panes.Add(new GraphPane());
                Main_Pane.Add(Panes[i]);
                Panes[i].XAxis.Scale.MajorStep = 100;

                Panes[i].YAxis.Scale.Max = 200;
                Panes[i].YAxis.Scale.Min = -200;
                _pointPairs[i]           = new PointPairList();

                var dataPointLine = Panes[i].AddCurve("Sensor " + i, _pointPairs[i], DATA_SERIES_COLORS[i]);
                dataPointLine.Line.IsVisible = true;

                _sortOrderZ.Add(dataPointLine);
            }


            Controls.Add(_graphControl);

            // get set up to listen for Myo events
            _channel = Channel.Create(ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())));

            _hub = Hub.Create(_channel);
            _hub.MyoConnected    += Hub_MyoConnected;
            _hub.MyoDisconnected += Hub_MyoDisconnected;
        }
Beispiel #20
0
        static void Main(string[] args)
        {
            Console.WriteLine("Make sure that Myo is worn, warmed up, and synced...");
            Console.WriteLine("Connecting to Myo and starting stream...");

            // Create a hub to manage Myo devices
            using (IChannel channel = Channel.Create(
                       ChannelDriver.Create(ChannelBridge.Create(),
                                            MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))))
                using (IHub myoHub = Hub.Create(channel))
                {
                    // Listen for when Myo connects
                    myoHub.MyoConnected += (sender, e) =>
                    {
                        Console.WriteLine("Connected to Myo {0}.", e.Myo.Handle);

                        // Unlock Myo so it doesn't keep locking between poses
                        e.Myo.Unlock(UnlockType.Hold);

                        // Say hello to Myo
                        e.Myo.Vibrate(VibrationType.Long);

                        // Listen for pose changes
                        e.Myo.PoseChanged += Myo_PoseChanged;

                        // Listen for lock/unlock
                        e.Myo.Locked   += Myo_Locked;
                        e.Myo.Unlocked += Myo_Unlocked;
                    };

                    // Listen for when Myo disconnects
                    myoHub.MyoDisconnected += (sender, e) =>
                    {
                        Console.WriteLine("Disconnected from Myo {0}.", e.Myo.Handle);
                        e.Myo.PoseChanged -= Myo_PoseChanged;
                        e.Myo.Locked      -= Myo_Locked;
                        e.Myo.Unlocked    -= Myo_Unlocked;
                    };

                    channel.StartListening();

                    // Keep running
                    Console.WriteLine("Press ESC to quit.");
                    if (Console.ReadKey(true).Key == ConsoleKey.Escape)
                    {
                        myoHub.Dispose();
                        return;
                    }
                }
        }
Beispiel #21
0
        public void FreeMyoError_ErrorHandleNotSet_NoBridgeCalls()
        {
            // Setup
            var errorHandle = IntPtr.Zero;
            var bridge      = new Mock <IMyoErrorHandlerBridge>(MockBehavior.Strict);
            var driver      = MyoErrorHandlerDriver.Create(bridge.Object);

            // Execute
            driver.FreeMyoError(errorHandle);

            // Assert
            bridge.Verify(x => x.LibmyoFreeErrorDetails32(errorHandle), Times.Never());
            bridge.Verify(x => x.LibmyoFreeErrorDetails64(errorHandle), Times.Never());
        }
Beispiel #22
0
        private static void Main()
        {
            //list initialisation
            for (int i = 0; i < 8; i++)
            {
                emgList.Add(new List <int>());
            }
            for (int i = 0; i < 3; i++)
            {
                deltaList.Add(new List <double>());
            }
            //M2X initialisation
            M2XDevice device = m2x.Device("7787671fb86b9e2bc3ccaa23ad934bf6");

            movement     = device.Stream("patientMove");
            streamFall   = device.Stream("hasFallen");
            patientState = device.Stream("patientState");
            // Myo initialisation from SDK
            using (var channel = Channel.Create(
                       ChannelDriver.Create(ChannelBridge.Create(),
                                            MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))))
                using (var hub = Hub.Create(channel))
                {
                    // listenin and register event handlers
                    hub.MyoConnected += (sender, e) =>
                    {
                        //e.Myo.Lock();
                        Console.WriteLine("Myo has been connected!", e.Myo.Handle);
                        //e.Myo.OrientationDataAcquired += Myo_OrientationDataAcquired;
                        e.Myo.AccelerometerDataAcquired += Myo_Accelerometer;
                        e.Myo.EmgDataAcquired           += MyoEmgDataHandler;
                        e.Myo.SetEmgStreaming(true);
                        e.Myo.Lock();
                    };

                    // disabling myo listening and handlers
                    hub.MyoDisconnected += (sender, e) =>
                    {
                        Console.WriteLine("Myo was disconnected, data logging wont work.", e.Myo.Arm);
                        e.Myo.AccelerometerDataAcquired -= Myo_Accelerometer;
                        e.Myo.EmgDataAcquired           -= MyoEmgDataHandler;
                    };

                    // start listening for Myo data
                    channel.StartListening();

                    // wait on user input
                    ConsoleHelper.UserInputLoop(hub);
                }
        }
Beispiel #23
0
        private int btam = 10;//tamanho borracha


        #endregion

        public Pyo()
        {
            InitializeComponent();

            //Criação do canal de comunicação com o Myo
            _channel = Channel.Create(ChannelDriver.Create(ChannelBridge.Create(),
                                                           MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())));

            //Hub que irá utilizar o canal
            _hub = Hub.Create(_channel);

            //Envento de conexão quando o Myo é conectado
            _hub.MyoConnected += (sender, e) =>
            {
                MethodInvoker inv2 = delegate
                {
                    this.buttonState.Image = Image.FromFile("C:\\Users\\Leandro\\OneDrive\\Documentos\\7 Periodo\\CG\\MyoSharp\\icon\\check-mark-8-16.png");
                    this.btnTam.Text       = $"{this.tam}";
                };
                this.Invoke(inv2);
                e.Myo.Unlock(UnlockType.Hold);
                e.Myo.Vibrate(VibrationType.Short);
                e.Myo.PoseChanged += Myo_PoseChanged;
                e.Myo.Locked      += Myo_Locked;
                e.Myo.Unlocked    += Myo_Unlocked;
                e.Myo.AccelerometerDataAcquired += Myo_AccelerometerDataAcquired;
                e.Myo.GyroscopeDataAcquired     += Myo_GyroscopeDataAcquired;
                e.Myo.OrientationDataAcquired   += Myo_OrientationDataAcquired;
                InicializaListaOrientacao(e.Myo.Orientation);
            };

            //Envento de conexão quando o Myo é conectado
            _hub.MyoDisconnected += (sender, e) =>
            {
                MethodInvoker inv2 = delegate
                {
                    this.buttonState.Image = Image.FromFile("C:\\Users\\Leandro\\OneDrive\\Documentos\\7 Periodo\\CG\\MyoSharp\\icon\\cross - 25x25.png");
                    this.btnTam.Text       = $"{this.tam}";
                };
                this.Invoke(inv2);
                e.Myo.PoseChanged -= Myo_PoseChanged;
                e.Myo.Locked      -= Myo_Locked;
                e.Myo.Unlocked    -= Myo_Unlocked;
                e.Myo.AccelerometerDataAcquired -= Myo_AccelerometerDataAcquired;
                e.Myo.GyroscopeDataAcquired     -= Myo_GyroscopeDataAcquired;
                e.Myo.OrientationDataAcquired   -= Myo_OrientationDataAcquired;
            };
        }
Beispiel #24
0
        private void MyoSetup()
        { // communication, device, exceptions, poses
            // create the channel
            _myoChannel = Channel.Create(ChannelDriver.Create(ChannelBridge.Create(),
                                                              MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())));

            // create the hub with the channel
            _myoHub = MyoSharp.Device.Hub.Create(_myoChannel);
            // create the event handlers for connect and disconnect
            _myoHub.MyoDisconnected -= _myoHub_MyoDisconnected;
            _myoHub.MyoConnected    += _myoHub_MyoConnected;



            // start listening
            _myoChannel.StartListening();
        }
        public MyoSoundControl(MainWindow Gui)
        {
            this.Window = Gui;
            //Channel und Hub (Schnittstelle) erzeugen
            this.Channel = MyoSharp.Communication.Channel.Create(
                ChannelDriver.Create(ChannelBridge.Create(),
                                     MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())));
            this.Hub          = MyoSharp.Device.Hub.Create(Channel);
            Hub.MyoConnected += (sender, e) =>
            {
                this.myo = e.Myo;
                e.Myo.Vibrate(VibrationType.Long);
                e.Myo.PoseChanged += Myo_PoseChanged;
                e.Myo.Locked      += Myo_Locked;
                e.Myo.Unlocked    += Myo_Unlocked;

                this.myo.Unlock(UnlockType.Hold);

                //Pose in Dictionary mit Sound verbinden (Soundplayerklasse extra)
                this.PoseToSound[Pose.Fist]    = new SoundPlayer("./Sound/Mario.wav");
                this.PoseToSound[Pose.WaveIn]  = new SoundPlayer("./Sound/Glass.wav");
                this.PoseToSound[Pose.WaveOut] = new SoundPlayer("./Sound/Slap.wav");

                //Sequence

                //IPoseSequence sequence0 = PoseSequence.Create(e.Myo, Pose.Fist, Pose.FingersSpread);
                //sequence0.PoseSequenceCompleted += PoseSequenceCompleted;
                //this.PoseSequenceToSound[sequence0] = new SoundPlayer("./Sound/Mario.wav");

                //IPoseSequence sequence1 = PoseSequence.Create(e.Myo, Pose.WaveIn, Pose.WaveOut);
                //sequence1.PoseSequenceCompleted += PoseSequenceCompleted;
                //this.PoseSequenceToSound[sequence1] = new SoundPlayer("./Sound/Slap.wav");

                //IPoseSequence sequence2 = PoseSequence.Create(e.Myo, Pose.WaveOut, Pose.WaveIn);
                //sequence2.PoseSequenceCompleted += PoseSequenceCompleted;
                //this.PoseSequenceToSound[sequence2] = new SoundPlayer("./Sound/Glass.wav");
            };

            Hub.MyoDisconnected += (sender, e) =>
            {
                e.Myo.PoseChanged -= Myo_PoseChanged;
                e.Myo.Locked      -= Myo_Locked;
                e.Myo.Unlocked    -= Myo_Unlocked;
            };
        }
Beispiel #26
0
 private static void Main()
 {
     Console.SetCursorPosition(0, 0);
     Console.WriteLine("--- Estado ---");
     Player.Init();
     Console.SetCursorPosition(0, 2);
     Console.WriteLine("El reproductor ha sido inicializado");
     Console.SetCursorPosition(0, 3);
     Console.WriteLine("--- Controles ---");
     Console.SetCursorPosition(0, 6);
     Console.WriteLine("--- Posicionamiento ---");
     Console.SetCursorPosition(0, 10);
     Console.WriteLine("--- Gestos ---");
     Console.SetCursorPosition(0, 12);
     Console.WriteLine("Musica parada");
     Console.SetCursorPosition(0, 13);
     Console.WriteLine("--- Bloqueo ---");
     Console.SetCursorPosition(0, 1);
     using (var channel = Channel.Create(
                ChannelDriver.Create(ChannelBridge.Create(),
                                     MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))))
         using (var hub = Hub.Create(channel))
         {
             hub.MyoConnected += (sender, e) =>
             {
                 Console.WriteLine("Myo {0} está conectado!", e.Myo.Handle);
                 e.Myo.Vibrate(VibrationType.Short);
                 e.Myo.OrientationDataAcquired += Myo_OrientationDataAcquired;
                 e.Myo.PoseChanged             += Myo_PoseChanged;
                 e.Myo.Locked   += Myo_Locked;
                 e.Myo.Unlocked += Myo_Unlocked;
             };
             hub.MyoDisconnected += (sender, e) =>
             {
                 Console.WriteLine("Oh no!, parece que el Myo del brazo {0} se ha desconectado!", e.Myo.Arm);
                 e.Myo.OrientationDataAcquired += Myo_OrientationDataAcquired;
                 e.Myo.PoseChanged             += Myo_PoseChanged;
                 e.Myo.Locked   -= Myo_Locked;
                 e.Myo.Unlocked -= Myo_Unlocked;
             };
             channel.StartListening();
             ConsoleHelper.UserInputLoop(hub);
         }
 }
Beispiel #27
0
        public void InitMyoManagerHub(MainWindow m)
        {
            lastExecutionEmg     = DateTime.Now;
            lastExecutionVibrate = DateTime.Now;
            this.mWindow         = m;
            channel = Channel.Create(ChannelDriver.Create(ChannelBridge.Create(),
                                                          MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())));
            hub = Hub.Create(channel);

            // listen for when the Myo connects
            hub.MyoConnected += (sender, e) =>
            {
                Debug.WriteLine("Myo {0} has connected!", e.Myo.Handle);
                e.Myo.Vibrate(VibrationType.Short);
                e.Myo.EmgDataAcquired           += Myo_EmgDataAcquired;
                e.Myo.OrientationDataAcquired   += Myo_OrientationAcquired;
                e.Myo.AccelerometerDataAcquired += Myo_AccelerometerAcquired;
                e.Myo.GyroscopeDataAcquired     += Myo_GyroscopeAcquired;
                e.Myo.SetEmgStreaming(true);
            };

            // listen for when the Myo disconnects
            hub.MyoDisconnected += (sender, e) =>
            {
                Debug.WriteLine("Oh no! It looks like {0} arm Myo has disconnected!", e.Myo.Arm);
                e.Myo.SetEmgStreaming(false);
                e.Myo.EmgDataAcquired -= Myo_EmgDataAcquired;
            };

            try
            {
                setValueNames();
                myFeedback.feedbackReceivedEvent += MyFeedback_feedbackReceivedEvent;
            }
            catch (Exception e)
            {
                Debug.WriteLine("MyoManager error at connecting the hub");
            }

            // start listening for Myo data
            channel.StartListening();
        }
Beispiel #28
0
        public Form1()
        {
            InitializeComponent();
            //comentário
            // get set up to listen for Myo events
            _channel = Channel.Create(ChannelDriver.Create(ChannelBridge.Create(),
                                                           MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())));

            _hub = Hub.Create(_channel);

            _hub.MyoConnected += (sender, e) =>
            {
                MethodInvoker inv = delegate { this.label1.Text = $"Myo {e.Myo.Handle} conectado"; };
                this.Invoke(inv);

                e.Myo.Unlock(UnlockType.Hold);

                e.Myo.Vibrate(VibrationType.Short);
                e.Myo.PoseChanged += Myo_PoseChanged;
                e.Myo.Locked      += Myo_Locked;
                e.Myo.Unlocked    += Myo_Unlocked;
                e.Myo.AccelerometerDataAcquired += Myo_AccelerometerDataAcquired;
                e.Myo.GyroscopeDataAcquired     += Myo_GyroscopeDataAcquired;
                e.Myo.OrientationDataAcquired   += Myo_OrientationDataAcquired;
                InicializaListaOrientacao(e.Myo.Orientation);
            };

            // listen for when the Myo disconnects
            _hub.MyoDisconnected += (sender, e) =>
            {
                var           braco = e.Myo.Arm == Arm.Right ? "Direito" : e.Myo.Arm == Arm.Left ? "Esquerdo" : "Desconhecido";
                MethodInvoker inv   = delegate { this.label2.Text = $"Parece que o braco {braco} desconectou"; };
                this.Invoke(inv);
                e.Myo.PoseChanged -= Myo_PoseChanged;
                e.Myo.Locked      -= Myo_Locked;
                e.Myo.Unlocked    -= Myo_Unlocked;
                e.Myo.AccelerometerDataAcquired -= Myo_AccelerometerDataAcquired;
                e.Myo.GyroscopeDataAcquired     -= Myo_GyroscopeDataAcquired;
                e.Myo.OrientationDataAcquired   -= Myo_OrientationDataAcquired;
            };
        }
Beispiel #29
0
        public void FreeMyoError_ValidParameters_ExpectedBridgeCalls()
        {
            // Setup
            var errorHandle = new IntPtr(123);

            var bridge = new Mock <IMyoErrorHandlerBridge>(MockBehavior.Strict);

            bridge
            .Setup(x => x.LibmyoFreeErrorDetails32(errorHandle));
            bridge
            .Setup(x => x.LibmyoFreeErrorDetails64(errorHandle));

            var driver = MyoErrorHandlerDriver.Create(bridge.Object);

            // Execute
            driver.FreeMyoError(errorHandle);

            // Assert
            bridge.Verify(x => x.LibmyoFreeErrorDetails32(errorHandle), PlatformInvocation.Running32Bit ? Times.Once() : Times.Never());
            bridge.Verify(x => x.LibmyoFreeErrorDetails64(errorHandle), PlatformInvocation.Running32Bit ? Times.Never() : Times.Once());
        }
Beispiel #30
0
        //Modified code from the Myo Sharp tutorial on GitHub
        //Available at: https://github.com/tayfuzun/MyoSharp
        public static void Myo_Start()
        {
            //Create a hub that will manage Myo devices for us
            var channel = Channel.Create(
                ChannelDriver.Create(ChannelBridge.Create(),
                                     MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())));

            IHub hub = Hub.Create(channel);

            //Listen for when the Myo connects
            hub.MyoConnected += (sender, e) =>
            {
                Console.WriteLine("Myo {0} has connected!", e.Myo.Handle);
                e.Myo.Vibrate(VibrationType.Short);
                e.Myo.PoseChanged             += Myo_PoseChanged;
                e.Myo.OrientationDataAcquired += Myo_OrientationDataAcquired;

                var pose = HeldPose.Create(e.Myo, Pose.Fist);
                pose.Interval = TimeSpan.FromSeconds(0.5);

                //For every Myo that connects, listen for special sequences
                var sequence = PoseSequence.Create(e.Myo, Pose.WaveOut, Pose.WaveIn);
                sequence.PoseSequenceCompleted += Sequence_PoseSequenceCompleted;
            };

            //Listen for when the Myo disconnects
            hub.MyoDisconnected += (sender, e) =>
            {
                Console.WriteLine("Oh no! It looks like {0} arm Myo has disconnected!", e.Myo.Arm);
                e.Myo.PoseChanged             -= Myo_PoseChanged;
                e.Myo.OrientationDataAcquired -= Myo_OrientationDataAcquired;
            };

            //Start listening for Myo data
            channel.StartListening();
            Console.WriteLine("Listening to channel...");

            //Wait on user input
            ConsoleHelper.UserInputLoop(hub);
        }