Ejemplo n.º 1
0
 public void Cleanup()
 {
     if (this.key != null)
     {
         Delete(this.key);
         this.key = null;
     }
     if (this.stream != null)
     {
         Delete(this.stream);
         this.stream = null;
     }
     if (this.device != null)
     {
         Delete(this.device);
         this.device = null;
     }
     if (this.distribution != null)
     {
         Delete(this.distribution);
         this.distribution = null;
     }
     if (this.collection != null)
     {
         Delete(this.collection);
         this.collection = null;
     }
     if (this.m2x != null)
     {
         this.m2x.Dispose();
         this.m2x = null;
     }
 }
Ejemplo n.º 2
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);
                }
        }