public void Init() { //Load test exercise from XML XmlSerializer serializer = new XmlSerializer(typeof(Exercise)); StreamReader reader = new StreamReader(Directory + "EXELAE.xml"); // deserialize the xml and create an Exercise Exercise = (Exercise)serializer.Deserialize(reader); testEgc = new ExerciseGameComponent(new Game(), Exercise); }
public void Init() { //Load test exercise from XML XmlSerializer serializer = new XmlSerializer(typeof(Exercise)); StreamReader reader = new StreamReader(Directory + "EXELAE.xml"); // deserialize the xml and create an Exercise Exercise = (Exercise)serializer.Deserialize(reader); testRepetition = new Repetition(Exercise); }
public ExerciseGameComponent(Game game,Exercise exercise) : base(game) { ExerciseStarted = false; CountdownStarted = false; RepetitionComplete = false; RepetitionStarted = false; Repetitions = 0; _exercise = exercise; Name = exercise.Name; repetition = new Repetition(exercise); RepetitionToFileId = new List<string>(); }
public void TestLoadEvents() { List<string> receivedEvents = new List<String>(); // call load exercises method and make sure loadstarted and loadcomplete events are thrown eq.LoadIsStarted += delegate (object sender, EventArgs e) { receivedEvents.Add(e.ToString()); }; eq.LoadIsDone += delegate(object sender, EventArgs e) { receivedEvents.Add(e.ToString()); }; Exercise[] exercises = new Exercise[1]; exercises[0] = new Exercise(); exercises[0].Id = "EXELAE"; eq.LoadExercises(this, new CatalogCompleteEventArg(exercises)); Assert.AreEqual(2, receivedEvents.Count); }
public void Init() { //Load test exercise from XML XmlSerializer serializer = new XmlSerializer(typeof(Exercise)); StreamReader reader = new StreamReader(Directory + "EXELAE.xml"); // deserialize the xml and create an Exercise Exercise = (Exercise)serializer.Deserialize(reader); // create vertical alignment criterion XmlJointType[] RightHipAndAnkle = new XmlJointType[2]; RightHipAndAnkle[0] = new XmlJointType(JointType.HipRight.ToString()); RightHipAndAnkle[1] = new XmlJointType(JointType.AnkleRight.ToString()); VerticalAlignmentCriterion = new AlignmentCriterion(RightHipAndAnkle, Alignment.Vertical, TestVariance); // create horizontal alignment criterion HorizontalAlignmentCriterion = new AlignmentCriterion(RightHipAndAnkle, Alignment.Horizontal, TestVariance); // create three joint alignment criterion XmlJointType RightKnee = new XmlJointType(JointType.KneeRight.ToString()); ThreeJointAlignmentCriterion = new AlignmentCriterion(RightKnee, RightHipAndAnkle, TestVariance); // create angle criterion AngleCriterion = new AngleCriterion(90, RightKnee, RightHipAndAnkle, TestVariance); }
public CatalogCompleteEventArg(Exercise[] exercises) { Exercises = exercises; }
public void SetExerciseOptions(Exercise exerciseUpdate) { for (int i = 0; i < _workoutList.Count; i = i +1) { if (_workoutList[i].Id == exerciseUpdate.Id) { _workoutList[i].Repetitions = exerciseUpdate.Repetitions; _workoutList[i].Variance = exerciseUpdate.Variance; } } }
public void TestAlignmentCheckForm() { #region Setup Skeleton Skeleton[] skeletonData = new Skeleton[1]; Skeleton skeleton = new Skeleton(); skeleton.TrackingState = SkeletonTrackingState.Tracked; /* this needs to be done because you can't set properties directly on the skelton's Joint object: * you must create a new joint, * set the properties, * then set the new joint on the skeleton */ SkeletonPoint sp = new SkeletonPoint(); sp.X = 1.0F; sp.Y = 1.0F; sp.Z = 1.0F; Joint hip = skeleton.Joints[JointType.HipRight]; hip.Position = sp; skeleton.Joints[JointType.HipRight] = hip; Joint knee = skeleton.Joints[JointType.KneeRight]; knee.Position = sp; skeleton.Joints[JointType.KneeRight] = knee; Joint ankle = skeleton.Joints[JointType.AnkleRight]; ankle.Position = sp; skeleton.Joints[JointType.AnkleRight] = ankle; skeletonData[0] = skeleton; System.Console.WriteLine("Hip Position X: " + hip.Position.X); System.Console.WriteLine("Skel Hip Position X: " + skeleton.Joints[JointType.HipRight].Position.X); SkeletonStamp skeletonStamp = new SkeletonStamp(skeletonData,1); #endregion Exercise alignmentExercise = new Exercise(); #region Check Vertical Alignment alignmentExercise.TrackingCriteria = new Criterion[] { VerticalAlignmentCriterion }; double[] percentBad = alignmentExercise.CheckForm(skeletonStamp); /* check the hip and ankle percent bad */ Assert.AreEqual(0, percentBad[(int)JointType.HipRight]); Assert.IsNaN(percentBad[(int)JointType.KneeRight]); /* this is not part of the criteria and should not be set */; Assert.AreEqual(0, percentBad[(int)JointType.AnkleRight]); #endregion #region Check Horizontal Alignment alignmentExercise.TrackingCriteria = new Criterion[] { HorizontalAlignmentCriterion }; percentBad = alignmentExercise.CheckForm(skeletonStamp); /* check the hip and ankle percent bad */ Assert.AreEqual(0, percentBad[(int)JointType.HipRight]); Assert.IsNaN(percentBad[(int)JointType.KneeRight]); /* this is not part of the criteria and should not be set */; Assert.AreEqual(0, percentBad[(int)JointType.AnkleRight]); #endregion #region Check Three Joint Alignment alignmentExercise.TrackingCriteria = new Criterion[] { ThreeJointAlignmentCriterion }; percentBad = alignmentExercise.CheckForm(skeletonStamp); /* check the hip and ankle percent bad */ Assert.AreEqual(0, percentBad[(int)JointType.HipRight]); Assert.AreEqual(0,percentBad[(int)JointType.KneeRight]); /* this is NOW part of the criteria and should be set */; Assert.AreEqual(0, percentBad[(int)JointType.AnkleRight]); #endregion }
public void TestAngleMatchesCriteria() { #region Setup Skeleton Skeleton[] skeletonData = new Skeleton[1]; Skeleton skeleton = new Skeleton(); skeleton.TrackingState = SkeletonTrackingState.Tracked; /* this needs to be done because you can't set properties directly on the skelton's Joint object: * you must create a new joint, * set the properties, * then set the new joint on the skeleton */ SkeletonPoint hipPoint = new SkeletonPoint(); hipPoint.X = 1.0F; hipPoint.Y = 1.0F; hipPoint.Z = 1.0F; Joint hip = skeleton.Joints[JointType.HipRight]; hip.Position = hipPoint; skeleton.Joints[JointType.HipRight] = hip; SkeletonPoint kneePoint = new SkeletonPoint(); kneePoint.X = 2.0F; kneePoint.Y = 1.0F; kneePoint.Z = 1.0F; Joint knee = skeleton.Joints[JointType.KneeRight]; knee.Position = kneePoint; // slightly off 90 but should still match SkeletonPoint anklePoint = new SkeletonPoint(); anklePoint.X = 2.0F; anklePoint.Y = 0.01F; anklePoint.Z = 1.0F; skeleton.Joints[JointType.KneeRight] = knee; Joint ankle = skeleton.Joints[JointType.AnkleRight]; ankle.Position = anklePoint; skeleton.Joints[JointType.AnkleRight] = ankle; skeletonData[0] = skeleton; SkeletonStamp skeletonStamp = new SkeletonStamp(skeletonData, 1); #endregion Exercise angleExercise = new Exercise(); #region Angle Matches angleExercise.StartingCriteria = new Criterion[1] { AngleCriterion }; Assert.IsTrue(angleExercise.matchesCriteria(skeletonStamp,angleExercise.StartingCriteria)); #endregion #region Angle Does Not Match SkeletonPoint misalignedPoint = new SkeletonPoint(); misalignedPoint.X = 2.0F; misalignedPoint.Y = 0.0F; misalignedPoint.Z = 1.0F; hip = skeleton.Joints[JointType.HipRight]; hip.Position = misalignedPoint; skeleton.Joints[JointType.HipRight] = hip; Assert.IsFalse(angleExercise.matchesCriteria(skeletonStamp, angleExercise.StartingCriteria)); #endregion }
public void TestAngleCheckForm() { #region Setup Skeleton Skeleton[] skeletonData = new Skeleton[1]; Skeleton skeleton = new Skeleton(); skeleton.TrackingState = SkeletonTrackingState.Tracked; /* this needs to be done because you can't set properties directly on the skelton's Joint object: * you must create a new joint, * set the properties, * then set the new joint on the skeleton */ SkeletonPoint hipPoint = new SkeletonPoint(); hipPoint.X = 1.0F; hipPoint.Y = 1.0F; hipPoint.Z = 1.0F; Joint hip = skeleton.Joints[JointType.HipRight]; hip.Position = hipPoint; skeleton.Joints[JointType.HipRight] = hip; SkeletonPoint kneePoint = new SkeletonPoint(); kneePoint.X = 2.0F; kneePoint.Y = 1.0F; kneePoint.Z = 1.0F; Joint knee = skeleton.Joints[JointType.KneeRight]; knee.Position = kneePoint; SkeletonPoint anklePoint = new SkeletonPoint(); anklePoint.X = 2.0F; anklePoint.Y = 0.0F; anklePoint.Z = 1.0F; skeleton.Joints[JointType.KneeRight] = knee; Joint ankle = skeleton.Joints[JointType.AnkleRight]; ankle.Position = anklePoint; skeleton.Joints[JointType.AnkleRight] = ankle; skeletonData[0] = skeleton; SkeletonStamp skeletonStamp = new SkeletonStamp(skeletonData, 1); #endregion Exercise angleExercise = new Exercise(); #region Angle In Range angleExercise.TrackingCriteria = new Criterion[1] { AngleCriterion }; double[] jointImperfection = angleExercise.CheckForm(skeletonStamp); // should be exactly 90 degrees Assert.AreEqual(0, jointImperfection[(int)JointType.KneeRight]); Assert.AreEqual(0, jointImperfection[(int)JointType.HipRight]); Assert.AreEqual(0, jointImperfection[(int)JointType.AnkleRight]); #endregion #region Angle Out Of Range // change the skeleton to be out of range SkeletonPoint misalignedPoint = new SkeletonPoint(); misalignedPoint.X = 2.0F; misalignedPoint.Y = 0.0F; misalignedPoint.Z = 1.0F; hip = skeleton.Joints[JointType.HipRight]; hip.Position = misalignedPoint; skeleton.Joints[JointType.HipRight] = hip; jointImperfection = angleExercise.CheckForm(skeletonStamp); Assert.AreNotEqual(0, jointImperfection[(int)JointType.KneeRight]); Assert.AreNotEqual(0, jointImperfection[(int)JointType.HipRight]); Assert.AreNotEqual(0, jointImperfection[(int)JointType.AnkleRight]); #endregion }
public void TestAlignmentMatchesCriteria() { #region Setup Skeleton Skeleton[] skeletonData = new Skeleton[1]; Skeleton skeleton = new Skeleton(); skeleton.TrackingState = SkeletonTrackingState.Tracked; /* this needs to be done because you can't set properties directly on the skelton's Joint object: * you must create a new joint, * set the properties, * then set the new joint on the skeleton */ SkeletonPoint sp = new SkeletonPoint(); sp.X = 1.0F; sp.Y = 1.0F; sp.Z = 1.0F; Joint hip = skeleton.Joints[JointType.HipRight]; hip.Position = sp; skeleton.Joints[JointType.HipRight] = hip; Joint knee = skeleton.Joints[JointType.KneeRight]; knee.Position = sp; skeleton.Joints[JointType.KneeRight] = knee; Joint ankle = skeleton.Joints[JointType.AnkleRight]; ankle.Position = sp; skeleton.Joints[JointType.AnkleRight] = ankle; skeletonData[0] = skeleton; System.Console.WriteLine("Hip Position X: " + hip.Position.X); System.Console.WriteLine("Skel Hip Position X: " + skeleton.Joints[JointType.HipRight].Position.X); SkeletonStamp skeletonStamp = new SkeletonStamp(skeletonData, 1); #endregion Exercise alignmentExercise = new Exercise(); #region Matches Alignment alignmentExercise.StartingCriteria = new Criterion[] { VerticalAlignmentCriterion }; Assert.IsTrue(alignmentExercise.matchesCriteria(skeletonStamp,alignmentExercise.StartingCriteria)); #endregion #region Does Not Match Alignment SkeletonPoint misalignedPoint = new SkeletonPoint(); misalignedPoint.X = 100.0F; misalignedPoint.Y = 1.0F; misalignedPoint.Z = 1.0F; hip = skeleton.Joints[JointType.HipRight]; hip.Position = misalignedPoint; skeleton.Joints[JointType.HipRight] = hip; System.Console.WriteLine("Hip Position X: " + hip.Position.X); System.Console.WriteLine("Skel Hip Position X: " + skeleton.Joints[JointType.HipRight].Position.X); System.Console.WriteLine("Skel Knee Position X: " + skeleton.Joints[JointType.KneeRight].Position.X); Assert.IsFalse(alignmentExercise.matchesCriteria(skeletonStamp,alignmentExercise.StartingCriteria)); #endregion }
/// <summary> /// Pass back the data to the CatalogManager /// </summary> private void saveChanges() { int tempInt = 0; float tempFloat = 0; _exercise = new Exercise(); _exercise.Id = _itemId; /** Check the validity of the data first for the Repitition value */ GuiInputBox guiInputBox = (GuiInputBox)_guiDrawable[_repetitionIndex]; if (int.TryParse(guiInputBox.Value, out tempInt)) { _exercise.Repetitions = tempInt; } /** Check the validity of the data first for the Variance value */ guiInputBox = (GuiInputBox)_guiDrawable[_varianceIndex]; if (float.TryParse(guiInputBox.Value, out tempFloat)) { _exercise.Variance = tempFloat; } _catalogManager.SetExerciseOptions(_exercise); }
/// <summary> /// Update the input boxes with the saved data from the CatalogManager. /// </summary> /// <param name="id">Exercise ID</param> public void OpenScreen(string id) { _exercise = _catalogManager.GetExercise(id); _itemId = _exercise.Id; GuiInputBox guiInputBox = (GuiInputBox)_guiDrawable[_repetitionIndex]; guiInputBox.Value = _exercise.Repetitions.ToString(); guiInputBox = (GuiInputBox)_guiDrawable[_varianceIndex]; guiInputBox.Value = _exercise.Variance.ToString(); }
//*********************************** public Repetition(Exercise criteria) { this.Exercise = criteria; this.Checkpoint = 0; }