示例#1
0
 public ExerciseStepStatusInfo(ExerciseStepStatus exStepStatus, string statusMsg)
 {
     this.exerciseStepStatus = exStepStatus; this.statusMessage = statusMsg;
 }
示例#2
0
        public ExerciseStep(Pose initialPose, Pose finalPose, TimeSpan expectedDuration, ExerciseStepType stepType, string stepName)
        {
            this.initialPose = initialPose;
            this.finalPose = finalPose;
            this.expectedDuration = expectedDuration;
            this.stepType = stepType;
            this.stepName = stepName;

            stepStatus = ExerciseStepStatus.NotInInitialPose;
        }
示例#3
0
        public ExerciseStepStatusInfo PerformStep(SkeletonData userData)
        {
            string statusMessage = "Status message not set";
            switch (this.stepStatus)
            {
                case ExerciseStepStatus.NotInInitialPose:
                    if (initialPose.IsInPose(userData))
                    {
                        this.stepStatus = ExerciseStepStatus.ReadyToStart;
                        statusMessage = "Waiting for user to start performing the exercise step";
                    }
                    else
                    {
                        statusMessage = "Waiting for user to assume the starting pose of the exercise step";
                    }
                    break;
                case ExerciseStepStatus.ReadyToStart:
                    if (this.stepType == ExerciseStepType.Hold || !initialPose.IsInPose(userData))
                    {
                        //User leaving the initial pose equates to starting the exercise
                        startTime = DateTime.Now;
                        this.stepStatus = ExerciseStepStatus.InProgress;
                        statusMessage = "Detected the user starting to perform the exercise step";
                    }
                    else
                    {
                        statusMessage = "Waiting for user to start performing the exercise step";
                    }
                    break;
                case ExerciseStepStatus.InProgress:
                    statusMessage = "Analyzing user's performance of the exercise step...";
                    bool userInFinalPose = finalPose.IsInPose(userData);
                    if (this.stepType == ExerciseStepType.Hold)
                    {
                        if (!userInFinalPose)
                        {
                            this.stepStatus = ExerciseStepStatus.Failed;
                            statusMessage = "User left the pose that they are supposed to be holding";
                        }
                        else
                        {
                            //If the pose has been held for a sufficiently long time...
                            if (DateTime.Now >= this.GetExpectedCompletionTime() - new TimeSpan(0, 0, 0, 0, (int)(this.expectedDuration.TotalMilliseconds * (SharedContent.GetAllowableDeviationInPercent() / 100.0))))
                            {
                                //We check whether it has not been held for too long
                                if (DateTime.Now <= this.GetExpectedCompletionTime() + new TimeSpan(0, 0, 0, 0, (int)(this.expectedDuration.TotalMilliseconds * (SharedContent.GetAllowableDeviationInPercent() / 100.0))))
                                {
                                    this.stepStatus = ExerciseStepStatus.Complete;
                                    statusMessage = "Completed the hold of the pose for the appropriate length of time";
                                }
                                else
                                {
                                    //Held for too long
                                    this.stepStatus = ExerciseStepStatus.Failed;
                                    statusMessage = "User held the pose for too long";
                                }
                            }
                        }
                    }
                    else if (userInFinalPose)
                    {
                        this.stepStatus = ExerciseStepStatus.Complete;
                        statusMessage = "User completed the exercise step";
                    }
                    else
                    {
                        UserPerformanceAnalysisInfo performanceInfo = this.IsUserPerformingStepCorrectly(userData);
                        if (performanceInfo.failed)
                        {
                            this.stepStatus = ExerciseStepStatus.Failed;
                            statusMessage = performanceInfo.failureMessage;
                        }
                        else
                        {
                            statusMessage += String.Format("User is {0} % complete the exercise step", performanceInfo.percentComplete);
                        }
                    }
                    break;
            }

            return new ExerciseStepStatusInfo(this.stepStatus, statusMessage);
        }