Exemple #1
0
        private static libmyo.HandlerResult HandleEvent(IntPtr userData, IntPtr evt)
        {
            GCHandle handle = (GCHandle)userData;
            Hub      self   = (Hub)handle.Target;

            var type      = libmyo.event_get_type(evt);
            var timestamp = TIMESTAMP_EPOCH.AddMilliseconds(libmyo.event_get_timestamp(evt) / 1000);
            var myoHandle = libmyo.event_get_myo(evt);

            switch (type)
            {
            case libmyo.EventType.Paired:
                var myo = new Myo(self, myoHandle);
                self._myos.Add(myoHandle, myo);
                if (self.Paired != null)
                {
                    self.Paired(self, new MyoEventArgs(myo, DateTime.Now));
                }
                break;

            default:
                Debug.Assert(self._myos[myoHandle] != null);
                self._myos[myoHandle].HandleEvent(type, timestamp, evt);
                break;
            }

            return(libmyo.HandlerResult.Continue);
        }
 internal TrainingData(Myo myo)
 {
     _myo = myo;
     //TODO/NOTE: leak this until we move ownership of the training data to libmyo's Myo
     if (libmyo.training_create_dataset(_myo.Handle, out _handle, IntPtr.Zero) != libmyo.Result.Success)
     {
         throw new InvalidOperationException("Unable to create training data.");
     }
 }
Exemple #3
0
 internal TrainingData(Myo myo)
 {
     _myo = myo;
     //TODO/NOTE: leak this until we move ownership of the training data to libmyo's Myo
     if (libmyo.training_create_dataset(_myo.Handle, out _handle, IntPtr.Zero) != libmyo.Result.Success)
     {
         throw new InvalidOperationException("Unable to create training data.");
     }
 }
 public RssiEventArgs(Myo myo, DateTime timestamp, sbyte rssi)
     : base(myo, timestamp)
 {
     this.Rssi = rssi;
 }
 public PoseEventArgs(Myo myo, DateTime timestamp, Pose pose)
     : base(myo, timestamp)
 {
     this.Pose = pose;
 }
Exemple #6
0
 public TrainingEventArgs(Myo myo, DateTime timestamp, byte value, byte progress)
     : base(myo, timestamp)
 {
     this.Value    = value;
     this.Progress = progress;
 }
Exemple #7
0
 public RssiEventArgs(Myo myo, DateTime timestamp, sbyte rssi)
     : base(myo, timestamp)
 {
     this.Rssi = rssi;
 }
Exemple #8
0
 public PoseEventArgs(Myo myo, DateTime timestamp, Pose pose)
     : base(myo, timestamp)
 {
     this.Pose = pose;
 }
Exemple #9
0
 public GyroscopeDataEventArgs(Myo myo, DateTime timestamp, Vector3 gyroscope)
     : base(myo, timestamp)
 {
     this.Gyroscope = gyroscope;
 }
Exemple #10
0
 public ArmSyncedEventArgs(Myo myo, DateTime timestamp, Arm arm, XDirection xDirection)
     : base(myo, timestamp)
 {
     this.Arm        = arm;
     this.XDirection = xDirection;
 }
Exemple #11
0
 public EmgDataEventArgs(Myo myo, DateTime timestamp, int[] emg)
     : base(myo, timestamp)
 {
     this.Emg = emg;
 }
 public EmgEventArgs(Myo myo, DateTime timestamp, sbyte[] emg)
     : base(myo, timestamp)
 {
     this.Emg = emg;
 }
 public EmgDataEventArgs(Myo myo, DateTime timestamp, int[] emg)
     : base(myo, timestamp)
 {
     this.Emg = emg;
 }
Exemple #14
0
 public EmgEventArgs(Myo myo, DateTime timestamp, Dictionary <int, sbyte> emg)
     : base(myo, timestamp)
 {
     this.Emg = emg;
 }
 public MyoEventArgs(Myo myo, DateTime timestamp)
 {
     this.Myo = myo;
     this.Timestamp = timestamp;
 }
		public EmgEventArgs (Myo myo, DateTime timestamp, Dictionary<int, sbyte> emg)
			: base (myo, timestamp)
		{
			this.Emg = emg;
		}
 public ArmSyncedEventArgs(Myo myo, DateTime timestamp, Arm arm, XDirection xDirection)
     : base(myo, timestamp)
 {
     this.Arm = arm;
     this.XDirection = xDirection;
 }
Exemple #18
0
 public AccelerometerDataEventArgs(Myo myo, DateTime timestamp, Vector3 accelerometer)
     : base(myo, timestamp)
 {
     this.Accelerometer = accelerometer;
 }
 public AccelerometerDataEventArgs(Myo myo, DateTime timestamp, Vector3 accelerometer)
     : base(myo, timestamp)
 {
     this.Accelerometer = accelerometer;
 }
Exemple #20
0
 public OrientationDataEventArgs(Myo myo, DateTime timestamp, Quaternion orientation)
     : base(myo, timestamp)
 {
     this.Orientation = orientation;
 }
 public GyroscopeDataEventArgs(Myo myo, DateTime timestamp, Vector3 gyroscope)
     : base(myo, timestamp)
 {
     this.Gyroscope = gyroscope;
 }
Exemple #22
0
 public MyoEventArgs(Myo myo, DateTime timestamp)
 {
     this.Myo       = myo;
     this.Timestamp = timestamp;
 }
 public OrientationDataEventArgs(Myo myo, DateTime timestamp, Quaternion orientation)
     : base(myo, timestamp)
 {
     this.Orientation = orientation;
 }
Exemple #24
0
        private static libmyo.HandlerResult HandleEvent(IntPtr userData, IntPtr evt)
        {
            GCHandle handle = (GCHandle)userData;
            Hub self = (Hub)handle.Target;

            var type = libmyo.event_get_type(evt);
            var timestamp = TIMESTAMP_EPOCH.AddMilliseconds(libmyo.event_get_timestamp(evt) / 1000);
            var myoHandle = libmyo.event_get_myo(evt);

            switch (type)
            {
                case libmyo.EventType.Paired:
                    var myo = new Myo(self, myoHandle);
                    self._myos.Add(myoHandle, myo);
                    if (self.Paired != null)
                    {
                        self.Paired(self, new MyoEventArgs(myo, DateTime.Now));
                    }
                    break;

                default:
                    Debug.Assert(self._myos[myoHandle] != null);
                    self._myos[myoHandle].HandleEvent(type, timestamp, evt);
                    break;
            }

            return libmyo.HandlerResult.Continue;
        }
 public EmgEventArgs(Myo myo, DateTime timestamp, sbyte[] emg)
     : base(myo, timestamp)
 {
     this.Emg = emg;
 }