Esempio 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;
     }
 }
Esempio n. 2
0
        public String getData()
        {
            stream = device.Stream("hasFallen");
            string a = "";

            response = stream.Values(new ATTM2X.Classes.StreamValuesFilter {
                start = M2XClient.DateTimeToString(DateTime.UtcNow.AddMinutes(-3))
            }, M2XStreamValuesFormat.Json).Result;
            var data = response.Json <StreamValues>();

            if (DateTime.Compare(limit, Convert.ToDateTime(data.end)) < 0)
            {
                if (data.values.Length != 0)
                {
                    TimeSpan span = (Convert.ToDateTime(data.values[0].timestamp) - lastFall);
                    if (span.Seconds > 30)
                    {
                        a = data.values[0].value;
                        if (a == "fall")
                        {
                            lastFall = Convert.ToDateTime(data.values[0].timestamp);
                        }
                        System.Console.WriteLine("FALLLL---------------------------------/////////");
                    }
                }
            }
            else
            {
                a = "";
            }

            limit = Convert.ToDateTime(data.end);

            return(a);
        }
Esempio n. 3
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);
                }
        }