コード例 #1
0
        public override bool IsFulfilled(Body body)
        {
            isFulfilled = currentJointBehaviour.IsFulfilled(body);
            currentJointBehaviour.ActiveJoint.KinectJoint.ActiveInExercise = true;

            if (isFulfilled)
            {
                currentJointBehaviour.Clear();

                currentJointBehaviour.Fulfilled();

                currentJointBehaviour.ActiveJoint.KinectJoint.ActiveInExercise = false;

                if (currentJointBehaviour.Next == null)
                {
                    isFulfilled = true;
                }
                else
                {
                    currentJointBehaviour = currentJointBehaviour.Next as BaseJointBehaviour;
                    currentJointBehaviour.Unfulfilled();
                    isFulfilled = false;
                }
            }

            return(isFulfilled);
        }
コード例 #2
0
ファイル: REMLManager.cs プロジェクト: festeraddams/rahagame
        public Exercise ParseRGML()
        {
            IList <RelNodeTypes> nodeTypes = new List <RelNodeTypes>();

            Step lastStep  = null;
            Step firstStep = null;

            BaseJointBehaviour lastBehaviour  = null;
            BaseJointBehaviour firstBehaviour = null;

            Informable lastInformable  = null;
            Informable firstInformable = null;

            using (XmlReader reader = XmlReader.Create(new StringReader(rel)))
            {
                RelNodeTypes nodeType     = RelNodeTypes.none;
                RelNodeTypes lastNodeType = RelNodeTypes.none;

                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        nodeType = (RelNodeTypes)Enum.Parse(typeof(RelNodeTypes), reader.Name);

                        switch (nodeType)
                        {
                        case RelNodeTypes.exercise:
                            exercise = CreateExercise(reader);
                            break;

                        case RelNodeTypes.stepGroup:
                            break;

                        case RelNodeTypes.step:
                            var newStep = CreateStep(reader, lastStep);

                            if (firstStep == null)
                            {
                                firstStep = newStep;
                            }

                            lastStep = newStep;
                            break;

                        case RelNodeTypes.joint:
                            var newJoint = CreateJoint(reader, lastInformable);

                            if (firstInformable == null)
                            {
                                firstInformable = newJoint;
                            }

                            lastInformable = newJoint;
                            break;

                        case RelNodeTypes.action:
                            var newAction = CreateAction(reader, lastInformable);

                            if (firstInformable == null)
                            {
                                firstInformable = newAction;
                            }

                            lastInformable = newAction;
                            break;

                        case RelNodeTypes.behaviour:
                            var newBehaviour = CreateJointBehaviour(reader, lastInformable, lastBehaviour);

                            if (firstBehaviour == null)
                            {
                                firstBehaviour = newBehaviour;
                            }

                            lastBehaviour = newBehaviour;
                            break;
                        }

                        if (nodeType != lastNodeType)
                        {
                            lastNodeType = nodeType;
                            nodeTypes.Add(nodeType);
                        }

                        break;

                    //case XmlNodeType.Whitespace:
                    case XmlNodeType.EndElement:
                        switch (lastNodeType)
                        {
                        case RelNodeTypes.behaviour:
                            break;

                        case RelNodeTypes.action:
                            break;

                        case RelNodeTypes.exercise:
                            break;

                        case RelNodeTypes.step:
                            lastStep.SetFirstInformable(firstInformable as Informable);
                            firstInformable = lastInformable = null;
                            break;

                        case RelNodeTypes.stepGroup:
                            break;

                        case RelNodeTypes.joint:
                            lastInformable.Convert <Joint>().SetFirstBehaviour(firstBehaviour);
                            firstBehaviour = lastBehaviour = null;
                            break;
                        }

                        nodeTypes.RemoveAt(nodeTypes.Count - 1);

                        if (nodeTypes.Count > 0)
                        {
                            lastNodeType = nodeTypes[nodeTypes.Count - 1];
                        }
                        break;
                    }
                }
            }

            exercise.SetFirstStep(firstStep);

            return(exercise);
        }
コード例 #3
0
 public void SetFirstBehaviour(BaseJointBehaviour behaviour)
 {
     this.currentJointBehaviour = behaviour;
 }
コード例 #4
0
ファイル: REMLManager.cs プロジェクト: festeraddams/rahagame
        private BaseJointBehaviour CreateJointBehaviour(XmlReader reader, FulFillable lastToDoAble, BaseJointBehaviour lastBehaviour)
        {
            BaseJointBehaviour behaviour = null;

            var attributes    = GetAttributes(reader);
            var behaviourName = attributes["is"];

            var active = patient.GetJointByName(((Joint)lastToDoAble).Name);

            int repititions = 1;

            if (attributes.ContainsKey("repititions"))
            {
                repititions = int.Parse(attributes["repititions"]);
            }

            if (attributes.ContainsKey("joint"))
            {
                var passive = patient.GetJointByName(attributes["joint"]);

                if (attributes.ContainsKey("value"))
                {
                    var value = double.Parse(attributes["value"]);

                    if (behaviourName == "distance")
                    {
                        behaviour = new DistanceValueBehaviour(value, behaviourName, DB.StatisticType.behaviour, active, active, passive, settingsManager, feedback, PitchType.pitchDistance, lastBehaviour, repititions, statisticManager);
                    }

                    else if (behaviourName == "on")
                    {
                        behaviour = new OnJointValueBehaviour(value, behaviourName, DB.StatisticType.behaviour, active, active, passive, settingsManager, feedback, PitchType.pitchOnJoint, lastBehaviour, repititions, statisticManager);
                    }
                }
                else
                {
                    if (behaviourName == "above")
                    {
                        behaviour = new AboveBehaviour(behaviourName, DB.StatisticType.behaviour, active, active, passive, settingsManager, feedback, PitchType.pitchHeight, lastBehaviour, repititions, statisticManager);
                    }
                    else if (behaviourName == "below")
                    {
                        behaviour = new BelowBehaviour(behaviourName, DB.StatisticType.behaviour, active, active, passive, settingsManager, feedback, PitchType.pitchHeight, lastBehaviour, repititions, statisticManager);
                    }
                    else if (behaviourName == "behind")
                    {
                        behaviour = new BehindBehaviour(behaviourName, DB.StatisticType.behaviour, active, active, passive, settingsManager, feedback, PitchType.pitchDepth, lastBehaviour, repititions, statisticManager);
                    }
                    else if (behaviourName == "before")
                    {
                        behaviour = new BeforeBehaviour(behaviourName, DB.StatisticType.behaviour, active, active, passive, settingsManager, feedback, PitchType.pitchDepth, lastBehaviour, repititions, statisticManager);
                    }
                    else if (behaviourName == "equalHeight")
                    {
                        behaviour = new EqualHeightBehaviour(behaviourName, DB.StatisticType.behaviour, active, active, passive, settingsManager, feedback, PitchType.pitchHeight, lastBehaviour, repititions, statisticManager);
                    }
                }
            }
            else if (attributes.ContainsKey("value"))
            {
                DB.PatientJoint childJoint = null;
                var             value      = double.Parse(attributes["value"]);

                if (attributes.ContainsKey("toChild"))
                {
                    childJoint = patient.GetJointByName(attributes["toChild"]);
                }
                else
                {
                    childJoint = patient.GetJointByName(active.KinectJoint.Children.First().Value.Name);
                }

                if (behaviourName == "angle")
                {
                    behaviour = new AngleValueBehaviour(value, behaviourName, DB.StatisticType.behaviour, active, active, childJoint, settingsManager, feedback, PitchType.pitchAngleValue, lastBehaviour, repititions, statisticManager);
                }
            }

            if (lastBehaviour != null)
            {
                lastBehaviour.AddNext(behaviour);
            }

            return(behaviour);
        }