//need to refactor //have a split for analysis between last frame and all other frames public bool Handle(MyoDataAnalyzer analyzer) { this.Analyzer = analyzer; //check to see if this is the last frame or not if (ToMatchFrameIndex + 1 == ToMatch.Count) { var result = GestureMatchingEngine.LastFrameAnalyze(this); if (result == LastFrameResult.Matched) { return(MatchingSuccess()); } else if (result == LastFrameResult.Failed) { return(MatchingFailed()); } else { return(false); } } else { if (GestureMatchingEngine.FrameAnalyze(this)) { return(false); } else { return(MatchingFailed()); } } }
public bool Handle(MyoDataAnalyzer analyzer) { this._analyzer = analyzer; this._dataFrames = new List <MyoData>(); if (ReadyState() && _enabled && !_finished) { _finished = true; _enabled = false; Myo.Vibrate(VibrationType.Short); return(false); } else if (ReadyState() && !_enabled && !_finished) { _enabled = true; Myo.Vibrate(VibrationType.Short); return(true); } else if (_enabled) { _dataFrames.Add((MyoData)_analyzer.Data.Clone()); return(false); } else { return(false); } }
public bool Handle(MyoDataAnalyzer analyzer) { this._analyzer = analyzer; //first, we analyze which ones we are removing due to not matching the criteria this._gestureStates.RemoveAll(MatchingAnalysis); //now, depending on the setting, we will see what gets done if (this._gestureStates.Count == 1) { if (Context.Instance.CurrentProfile.Options.FastActivation || this._gestureStates.First().Matched) { this._gestureStates.First().ToMatchAction.ExecuteAction(); PopulateGestures(); } } else if (this._gestureStates.Count == 0) { PopulateGestures(); } else { //the first one to be matched will have its actions executed var matched = this._gestureStates.Find(gesture => gesture.Matched); matched.ToMatchAction.ExecuteAction(); PopulateGestures(); } return(false); }
public bool Handle(MyoDataAnalyzer analyzer) { this._analyzer = analyzer; var rawData = analyzer.RawData; switch (_calibrating) { case Calibrating.FastAccel: _collectedValues.Add(rawData.Accel.Normal); break; case Calibrating.SlowAccel: _collectedValues.Add(rawData.Accel.Normal); break; case Calibrating.FastGyro: _collectedValues.Add(rawData.Gyro.Normal); break; case Calibrating.SlowGyro: _collectedValues.Add(rawData.Gyro.Normal); break; case Calibrating.Arm: _arm = Myo.GetCurrentArm(); break; default: //should never reach here break; } return(false); }
public void Handle(MyoDataAnalyzer analyzer) { this._analyzer = analyzer; }
private void Analyze() { var instanceAnalyzer = new MyoDataAnalyzer(_myo.GetCurrentData()); this.StopExecution = _handler.Handle(instanceAnalyzer); }