private void WorkoutDetected(object sender, WorkoutControllerEventArgs e) { Body[] bodies = this.bodies; foreach (Body body in bodies) { if (body.IsTracked && body != null) { //Initialize PostureAnalyzer object postureAnalyzer = new PostureAnalyzer(); //Analyze this frame's data and return a bit vector containing information about which posture checks failed BitVector32 postureFlag = postureAnalyzer.AnalyzeWorkout(body, e.gestureName, e.ContinuousResult.Progress); if ((DateTime.Now - lastPublishTime).TotalSeconds >= 3.0) { eventPipeLine.EnqueuePipeline(new PhotonPackage(postureFlag)); bool isEventPublished = publishEvent("shoulder", eventPipeLine.queue.Peek().postureFlagBits.Data.ToString()); if (isEventPublished) { //Since the publish event operation is async, wait until it returns true, once its confirmed that the event is published, then empty eventPipeLine.DequeuePipeline(); } else { Debug.WriteLine("Publishing did not occur properly"); } lastPublishTime = DateTime.Now; } break; } } }
public void checkStatus() { if (this.workoutDiscrete != null && this.workoutContinuous != null) { //This double checks whether the gesture is occuring, if its true, it fires an event if (this.workoutDiscrete.Detected && this.workoutContinuous.Progress >= 0) { WorkoutControllerEventArgs args = new WorkoutControllerEventArgs(); args.DiscreteResult = this.workoutDiscrete; args.ContinuousResult = this.workoutContinuous; args.gestureName = this.gestureName; InitiateWorkoutEvent(args); } } }
protected virtual void InitiateWorkoutEvent(WorkoutControllerEventArgs e) { OnWorkoutDetected?.Invoke(this, e); }