Exemplo n.º 1
0
    public void Submit(DateTime start, DateTime end, string name, string desc, int amount, bool spineCheckbox, bool leftArmCheckbox, bool rightArmCheckbox, bool leftLegCheckbox, bool rightLegCheckbox)
    {
        ExerciseRecording exerciseRecording = new ExerciseRecording();

        // Add right jointsmappings to recording
        if (spineCheckbox)
        {
            exerciseRecording.JointMappings.Add(HomeReval.Validator.Map.Mappings.Spine);
        }

        if (leftArmCheckbox)
        {
            exerciseRecording.JointMappings.Add(HomeReval.Validator.Map.Mappings.LeftArm);
        }

        if (rightArmCheckbox)
        {
            exerciseRecording.JointMappings.Add(HomeReval.Validator.Map.Mappings.RightArm);
        }

        if (leftLegCheckbox)
        {
            exerciseRecording.JointMappings.Add(HomeReval.Validator.Map.Mappings.LeftLeg);
        }

        if (rightLegCheckbox)
        {
            exerciseRecording.JointMappings.Add(HomeReval.Validator.Map.Mappings.RightLeg);
        }

        hrs.CurrentRecording = new Exercise
        {
            StartDate         = start,
            EndDate           = end,
            Name              = name,
            Description       = desc,
            Amount            = amount,
            ExerciseRecording = exerciseRecording
        };
    }
Exemplo n.º 2
0
        void Start()
        {
            TimerText.text          = "";
            TimerCountdownText.text = "";

            _sensor = KinectSensor.GetDefault();

            if (_sensor != null)
            {
                _reader = _sensor.BodyFrameSource.OpenReader();

                if (!_sensor.IsOpen)
                {
                    _sensor.Open();
                }
            }

            StartCoroutine(HandGesture());

            state = PractiseState.KinectPaused;

            // Create bodyDrawer and body from prefab
            GameObject body = (GameObject)Instantiate(Resources.Load("Prefabs/Body"));

            bodyDrawer = new BodyDrawer(body);

            // Create bodyDrawer for exercise example
            GameObject bodyRed = (GameObject)Instantiate(Resources.Load("Prefabs/BodyRed"));

            exampleBodyDrawer = new BodyDrawer(bodyRed);

            // Get singleton session instance
            hrs = HomeRevalSession.Instance;

            StartCoroutine(requestService.Get("/exercise/" + hrs.Exercises[hrs.currentExerciseIdx].Id,
                                              success =>
            {
                // Decompress response and create ExerciseRecording
                Debug.Log(success);
                JObject response = JObject.Parse(success);

                Debug.Log("Recording: " + response.GetValue("recording").ToString());

                string exerciseRecordingJson = Gzip.DeCompress(Convert.FromBase64String(response.GetValue("recording").ToString()));

                ExerciseRecording exerciseRecording = JsonConvert.DeserializeObject <ExerciseRecording>(exerciseRecordingJson);

                jsonExercise = new Exercise
                {
                    Id                = Int32.Parse(response.GetValue("id").ToString()),
                    Amount            = hrs.Exercises[hrs.currentExerciseIdx].Amount,
                    ExerciseRecording = exerciseRecording,
                    Description       = response.GetValue("description").ToString(),
                    Name              = response.GetValue("name").ToString()
                };

                exerciseService.StartNewExercise(jsonExercise, exampleBodyDrawer);

                exerciseResultRecording = new List <ConvertedBody>();
                exerciseResultScores    = new List <ExerciseScore>();
            },
                                              error =>
            {
                Debug.Log(error);
            }
                                              ));
            Debug.Log(hrs.Exercises[hrs.currentExerciseIdx].PlanningId);
            hrs.currentPlanningId = hrs.Exercises[hrs.currentExerciseIdx].PlanningId;

            // Maak exercise object met recording opgehaald vanuit database

            // Set exercise for service temp
            //string json = File.ReadAllText(@"C:\Users\Stefan\Documents\exercise.json");
            //Exercise jsonExercise = JsonConvert.DeserializeObject<Exercise>(json);
        }