예제 #1
0
 public static IHeldPose Create(IMyoEventGenerator myo, IEnumerable <Pose> targetPoses)
 {
     return(new HeldPose(
                myo,
                DEFAULT_INTERVAL,
                targetPoses));
 }
예제 #2
0
 public static IHeldPose Create(IMyoEventGenerator myo, TimeSpan interval, params Pose[] targetPoses)
 {
     return(Create(
                myo,
                interval,
                (IEnumerable <Pose>)targetPoses));
 }
예제 #3
0
        /// <summary>
        /// Unhooks the Myo events.
        /// </summary>
        /// <param name="myo">The myo to hook onto.</param>
        protected virtual void UnhookMyoEvents(IMyoEventGenerator myo)
        {
            Contract.Requires <ArgumentNullException>(myo != null, "myo");

            myo.Connected    -= Myo_Connected;
            myo.Disconnected -= Myo_Disconnected;
        }
예제 #4
0
 public static IHeldPose Create(IMyoEventGenerator myo, TimeSpan interval, IEnumerable <Pose> targetPoses)
 {
     return(new HeldPose(
                myo,
                interval,
                targetPoses));
 }
예제 #5
0
 public static IHeldPose Create(IMyoEventGenerator myo, Pose targetPose)
 {
     return(Create(
                myo,
                DEFAULT_INTERVAL,
                targetPose));
 }
예제 #6
0
        protected HeldPose(IMyoEventGenerator myo, TimeSpan interval, IEnumerable <Pose> targetPoses)
        {
            // Contract.Requires<ArgumentNullException>(myo != null, "myo");
            // Contract.Requires<ArgumentOutOfRangeException>(interval.TotalMilliseconds >= 0, "interval");
            // Contract.Requires<ArgumentNullException>(targetPoses != null, "targetPoses");

            _targetPoses = new List <Pose>(targetPoses);
            if (_targetPoses.Contains(Pose.Unknown))
            {
                throw new ArgumentException("All target poses must be specified.", "targetPoses");
            }

            if (_targetPoses.Count < 1)
            {
                throw new ArgumentException("At least one target pose must be specified.", "targetPoses");
            }

            _timer = new Timer()
            {
                AutoReset = true,
                Interval  = interval.TotalMilliseconds,
            };
            _timer.Elapsed += Timer_Elapsed;

            _lastPose = Pose.Unknown;

            _myo              = myo;
            _myo.PoseChanged += Myo_PoseChanged;
        }
예제 #7
0
파일: HeldPose.cs 프로젝트: rafme/MyoSharp
        protected HeldPose(IMyoEventGenerator myo, TimeSpan interval, IEnumerable<Pose> targetPoses)
        {
            Contract.Requires<ArgumentNullException>(myo != null, "myo");
            Contract.Requires<ArgumentOutOfRangeException>(interval.TotalMilliseconds >= 0, "interval");
            Contract.Requires<ArgumentNullException>(targetPoses != null, "targetPoses");

            _targetPoses = new List<Pose>(targetPoses);
            if (_targetPoses.Contains(Pose.Unknown))
            {
                throw new ArgumentException("All target poses must be specified.", "targetPoses");
            }

            if (_targetPoses.Count < 1)
            {
                throw new ArgumentException("At least one target pose must be specified.", "targetPoses");
            }

            _timer = new Timer()
            {
                AutoReset = true,
                Interval = interval.TotalMilliseconds,
            };
            _timer.Elapsed += Timer_Elapsed;

            _lastPose = Pose.Unknown;

            _myo = myo;
            _myo.PoseChanged += Myo_PoseChanged;
        }
예제 #8
0
        public static IPoseSequence Create(IMyoEventGenerator myo, params Pose[] sequence)
        {
            Contract.Requires<ArgumentNullException>(myo != null);
            Contract.Requires<ArgumentNullException>(sequence != null);
            Contract.Ensures(Contract.Result<IPoseSequence>() != null);

            return new PoseSequence(myo, sequence);
        }
예제 #9
0
        public static IPoseSequence Create(IMyoEventGenerator myo, IEnumerable <Pose> sequence)
        {
            // Contract.Requires<ArgumentNullException>(myo != null);
            // Contract.Requires<ArgumentNullException>(sequence != null);
            Contract.Ensures(Contract.Result <IPoseSequence>() != null);

            return(new PoseSequence(myo, sequence));
        }
예제 #10
0
파일: Hub.cs 프로젝트: Hellyon/MyoGame
 /// <summary>
 /// Unhooks the Myo events.
 /// </summary>
 /// <param name="myo">The myo to hook onto.</param>
 protected virtual void UnhookMyoEvents(IMyoEventGenerator myo)
 {
     myo.Connected    -= Myo_Connected;
     myo.Disconnected -= Myo_Disconnected;
     myo.Locked       -= Myo_Locked;
     myo.Unlocked     -= Myo_Unlocked;
     myo.PoseChanged  -= Myo_PoseChanged;
 }
예제 #11
0
        public static IHeldPose Create(IMyoEventGenerator myo, Pose targetPose)
        {
            var interval = DEFAULT_INTERVAL;

            return(Create(
                       myo,
                       interval,
                       targetPose));
        }
예제 #12
0
        public static IHeldPose Create(IMyoEventGenerator myo, IEnumerable <Pose> targetPoses)
        {
            var interval = DEFAULT_INTERVAL;

            return(Create(
                       myo,
                       interval,
                       targetPoses));
        }
예제 #13
0
        public static IHeldPose Create(IMyoEventGenerator myo, params Pose[] targetPoses)
        {
            // Contract.Requires<ArgumentNullException>(myo != null, "myo");
            // Contract.Requires<ArgumentNullException>(targetPoses != null, "targetPoses");
            Contract.Ensures(Contract.Result <IHeldPose>() != null);

            return(Create(
                       myo,
                       (IEnumerable <Pose>)targetPoses));
        }
예제 #14
0
        public static IHeldPose Create(IMyoEventGenerator myo, TimeSpan interval, IEnumerable <Pose> targetPoses)
        {
            // Contract.Requires<ArgumentNullException>(myo != null, "myo");
            // Contract.Requires<ArgumentOutOfRangeException>(interval.TotalMilliseconds >= 0, "interval");
            // Contract.Requires<ArgumentNullException>(targetPoses != null, "targetPoses");
            Contract.Ensures(Contract.Result <IHeldPose>() != null);

            return(new HeldPose(
                       myo,
                       interval,
                       targetPoses));
        }
예제 #15
0
        public static IHeldPose Create(IMyoEventGenerator myo, Pose targetPose)
        {
            //Contract.Requires<ArgumentNullException>(myo != null, "myo");
            Contract.Ensures(Contract.Result<IHeldPose>() != null);

            var interval = DEFAULT_INTERVAL;
            Contract.Assume(interval.TotalMilliseconds >= 0);

            return Create(
                myo, 
                interval, 
                targetPose);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PoseSequence"/> class.
        /// </summary>
        /// <param name="myo">The Myo.</param>
        /// <param name="sequence">The sequence of poses to watch for. Cannot be <c>null</c>.</param>
        protected PoseSequence(IMyoEventGenerator myo, IEnumerable <Pose> sequence)
        {
            _sequence = new List <Pose>();
            _sequence.AddRange(sequence);
            if (_sequence.Count < 2)
            {
                throw new ArgumentException("Sequence length should be at least 2 poses long.", "sequence");
            }

            _currentSequence = new List <Pose>();

            _myo              = myo;
            _myo.PoseChanged += Myo_PoseChanged;
        }
예제 #17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PoseSequence"/> class.
        /// </summary>
        /// <param name="myo">The Myo.</param>
        /// <param name="sequence">The sequence of poses to watch for. Cannot be <c>null</c>.</param>
        protected PoseSequence(IMyoEventGenerator myo, IEnumerable<Pose> sequence)
        {
            Contract.Requires<ArgumentNullException>(myo != null);
            Contract.Requires<ArgumentNullException>(sequence != null);

            _sequence = new List<Pose>();
            _sequence.AddRange(sequence);
            if (_sequence.Count < 2)
            {
                throw new ArgumentException("Sequence length should be at least 2 poses long.", "sequence");
            }

            _currentSequence = new List<Pose>();

            _myo = myo;
            _myo.PoseChanged += Myo_PoseChanged;
        }
예제 #18
0
        protected HeldPose(IMyoEventGenerator myo, TimeSpan interval, IEnumerable <Pose> targetPoses)
        {
            if (myo == null)
            {
                throw new ArgumentNullException("myo", "The Myo cannot be null.");
            }

            if (targetPoses == null)
            {
                throw new ArgumentNullException("targetPoses", "The target poses cannot be null.");
            }

            if (interval.TotalMilliseconds <= 0)
            {
                throw new ArgumentException("The interval must be a positive time value.", "interval");
            }

            _targetPoses = new List <Pose>(targetPoses);
            if (_targetPoses.Contains(Pose.Unknown))
            {
                throw new ArgumentException("All target poses must be specified.", "targetPoses");
            }

            if (_targetPoses.Count < 1)
            {
                throw new ArgumentException("At least one target pose must be specified.", "targetPoses");
            }

            _timer           = new Timer();
            _timer.AutoReset = true;
            _timer.Interval  = interval.TotalMilliseconds;
            _timer.Elapsed  += Timer_Elapsed;

            _lastPose = Pose.Unknown;

            _myo              = myo;
            _myo.PoseChanged += Myo_PoseChanged;
        }
예제 #19
0
        protected PoseSequence(IMyoEventGenerator myo, IEnumerable <Pose> sequence)
        {
            if (myo == null)
            {
                throw new ArgumentNullException("myo", "The Myo cannot be null.");
            }

            if (sequence == null)
            {
                throw new ArgumentNullException("sequence", "The sequence cannot be null.");
            }

            _sequence = new List <Pose>();
            _sequence.AddRange(sequence);
            if (_sequence.Count < 2)
            {
                throw new ArgumentException("Sequence length should be at least 2 poses long.", "sequence");
            }

            _currentSequence = new List <Pose>();

            _myo              = myo;
            _myo.PoseChanged += Myo_PoseChanged;
        }
예제 #20
0
 public static IPoseSequence Create(IMyoEventGenerator myo, params Pose[] sequence)
 {
     return(new PoseSequence(myo, sequence));
 }
예제 #21
0
 protected PoseSequence(IMyoEventGenerator myo, params Pose[] sequence)
     : this(myo, (IEnumerable <Pose>)sequence)
 {
 }
예제 #22
0
파일: Hub.cs 프로젝트: rafme/MyoSharp
        /// <summary>
        /// Unhooks the Myo events.
        /// </summary>
        /// <param name="myo">The myo to hook onto.</param>
        protected virtual void UnhookMyoEvents(IMyoEventGenerator myo)
        {
            Contract.Requires<ArgumentNullException>(myo != null, "myo");

            myo.Connected -= Myo_Connected;
            myo.Disconnected -= Myo_Disconnected;
        }
예제 #23
0
 /// <summary>
 /// Unhooks the Myo events.
 /// </summary>
 /// <param name="myo">The myo to hook onto.</param>
 protected virtual void UnhookMyoEvents(IMyoEventGenerator myo)
 {
     myo.Connected    -= Myo_Connected;
     myo.Disconnected -= Myo_Disconnected;
 }
예제 #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PoseSequence"/> class.
 /// </summary>
 /// <param name="myo">The Myo.</param>
 /// <param name="sequence">The sequence of poses to watch for. Cannot be <c>null</c>.</param>
 protected PoseSequence(IMyoEventGenerator myo, params Pose[] sequence)
     : this(myo, (IEnumerable <Pose>)sequence)
 {
     // Contract.Requires<ArgumentNullException>(myo != null);
     // Contract.Requires<ArgumentNullException>(sequence != null);
 }
예제 #25
0
파일: HeldPose.cs 프로젝트: rafme/MyoSharp
        public static IHeldPose Create(IMyoEventGenerator myo, params Pose[] targetPoses)
        {
            Contract.Requires<ArgumentNullException>(myo != null, "myo");
            Contract.Requires<ArgumentNullException>(targetPoses != null, "targetPoses");
            Contract.Ensures(Contract.Result<IHeldPose>() != null);

            return Create(
                myo,
                (IEnumerable<Pose>)targetPoses);
        }
예제 #26
0
파일: HeldPose.cs 프로젝트: rafme/MyoSharp
        public static IHeldPose Create(IMyoEventGenerator myo, TimeSpan interval, IEnumerable<Pose> targetPoses)
        {
            Contract.Requires<ArgumentNullException>(myo != null, "myo");
            Contract.Requires<ArgumentOutOfRangeException>(interval.TotalMilliseconds >= 0, "interval");
            Contract.Requires<ArgumentNullException>(targetPoses != null, "targetPoses");
            Contract.Ensures(Contract.Result<IHeldPose>() != null);

            return new HeldPose(
                myo,
                interval,
                targetPoses);
        }
예제 #27
0
 public static IPoseSequence Create(IMyoEventGenerator myo, IEnumerable <Pose> sequence)
 {
     return(new PoseSequence(myo, sequence));
 }
예제 #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PoseSequence"/> class.
 /// </summary>
 /// <param name="myo">The Myo.</param>
 /// <param name="sequence">The sequence of poses to watch for. Cannot be <c>null</c>.</param>
 protected PoseSequence(IMyoEventGenerator myo, params Pose[] sequence)
     : this(myo, (IEnumerable<Pose>)sequence)
 {
     Contract.Requires<ArgumentNullException>(myo != null);
     Contract.Requires<ArgumentNullException>(sequence != null);
 }
예제 #29
0
파일: HeldPose.cs 프로젝트: rafme/MyoSharp
        public static IHeldPose Create(IMyoEventGenerator myo, Pose targetPose)
        {
            Contract.Requires<ArgumentNullException>(myo != null, "myo");
            Contract.Ensures(Contract.Result<IHeldPose>() != null);

            var interval = DEFAULT_INTERVAL;
            Contract.Assume(interval.TotalMilliseconds >= 0);

            return Create(
                myo,
                interval,
                targetPose);
        }