public BaseJointBehaviour(string unityObjectName, StatisticType statisticType, PatientJoint affectedJoint, PatientJoint activeJoint, Models.PatientJoint passiveJoint, SettingsManager settingsManager, Feedback feedback, PitchType pitchType, FulFillable previous, int repetitions, WriteStatisticManager statisticManager) : base(settingsManager, feedback, pitchType, unityObjectName, statisticType, affectedJoint, previous, repetitions, statisticManager)
        {
            this.type         = Types.behaviour;
            this.activeJoint  = activeJoint;
            this.passiveJoint = passiveJoint;

            this.information = Models.Model.GetModel <Models.ExerciseInformation>(unityObjectName).Order;
        }
示例#2
0
        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);
        }