Exemplo n.º 1
0
        public ReportWindow(int pID)
        {
            this.DataContext = this;
            InitializeComponent();

            ReportService rs = new ReportService();

            ReportData report = rs.getPatientReport(pID);

            exerciseDataList = report.ExerciseDataList;
            patientData = report.PatientData;

           patientNameTextBox.DataContext = PatientData;
           patientIDTextBox.DataContext = PatientData;
           exerciseListBox.ItemsSource = ExerciseDataList;

            
        }
Exemplo n.º 2
0
        /// <summary>
        /// Logic for the exercise. Check if user1 has reached user2
        /// </summary>
        private void determineUserReach()
        {

            CameraSpacePoint lHandPositionUser1 = userBody1.Joints[JointType.HandLeft].Position;
            CameraSpacePoint lHandPositionUser2 = userBody2.Joints[JointType.HandLeft].Position;
            CameraSpacePoint rHandPositionUser1 = userBody1.Joints[JointType.HandRight].Position;
            CameraSpacePoint rHandPositionUser2 = userBody2.Joints[JointType.HandRight].Position;
            

            if (lHandPositionUser1.Z < 0)
            {
                lHandPositionUser1.Z = InferredZPositionClamp;
            }

            if (lHandPositionUser2.Z < 0)
            {
                lHandPositionUser2.Z = InferredZPositionClamp;
            }

            if (rHandPositionUser1.Z < 0)
            {
                rHandPositionUser1.Z = InferredZPositionClamp;
            }

            if (rHandPositionUser2.Z < 0)
            {
                rHandPositionUser2.Z = InferredZPositionClamp;
            }

            DepthSpacePoint lDepth1 = this.coordinateMapper.MapCameraPointToDepthSpace(lHandPositionUser1);
            DepthSpacePoint lDepth2 = this.coordinateMapper.MapCameraPointToDepthSpace(lHandPositionUser2);
            DepthSpacePoint rDepth1 = this.coordinateMapper.MapCameraPointToDepthSpace(rHandPositionUser1);
            DepthSpacePoint rDepth2 = this.coordinateMapper.MapCameraPointToDepthSpace(rHandPositionUser2);

            Point lHandUser1 = new Point(lDepth1.X, lDepth1.Y);
            Point lHandUser2 = new Point(lDepth2.X, lDepth2.Y);
            Point rHandUser1 = new Point(rDepth1.X, rDepth1.Y);
            Point rHandUser2 = new Point(rDepth2.X, rDepth2.Y);

            //Vars for data to be collected. Will be filled in when a success is met
            /*
            Time and distance values will have to be dealt with with something global I suppose? 
            Maybe we can have a global variable for the starting positions of the child's hands that stats null
            and will be recorded when the exercise starts, the same time as the stopwatch, and then set back to null 
            upon the success. I think that should work. -HTC
            */
            double angle = -1;
            string hands = null;
            double time = -1;
            
               /*
               Equation for points x,y that fall within a circle: (x - center_x)^2 + (y - center_y)^2 < radius^2.
               Here, points x,y are set to user1 (the patient). The centers are taken from the hand of user2 (conductor)
               The radius is predefined via a constant
               */

            //first step in if statements should be to stop the stopwatch!
            if ( ( Math.Pow( (lHandUser1.X - lHandUser2.X), 2) + Math.Pow( (lHandUser1.Y - lHandUser2.Y), 2) ) < Math.Pow(cirRadius,2) )
            {
                stopWatch.Stop();
                isEventStarted = false;
                angle = ReachAngle(userBody1.Joints[JointType.ElbowLeft]);
                hands = "ll";
                time = stopWatch.Elapsed.TotalSeconds;
                stopWatch.Reset();

                //MessageBox.Show("Patient Reached Hand - L->L");
                this.Start_Reach.IsEnabled = true;
                this.Start_Reach.Visibility = System.Windows.Visibility.Visible;

            } else if ((Math.Pow((lHandUser1.X - rHandUser2.X), 2) + Math.Pow((lHandUser1.Y - rHandUser2.Y), 2)) < Math.Pow(cirRadius, 2))
            {
                stopWatch.Stop();
                isEventStarted = false;
                angle = ReachAngle(userBody1.Joints[JointType.ElbowLeft]);
                hands = "lr";
                time = stopWatch.Elapsed.TotalSeconds;
                stopWatch.Reset();

              //  MessageBox.Show("Patient Reached Hand - L->R");
                this.Start_Reach.IsEnabled = true;
                this.Start_Reach.Visibility = System.Windows.Visibility.Visible;

            } else if ((Math.Pow((rHandUser1.X - lHandUser2.X), 2) + Math.Pow((rHandUser1.Y - lHandUser2.Y), 2)) < Math.Pow(cirRadius, 2))
            {
                stopWatch.Stop();
                isEventStarted = false;
                angle = ReachAngle(userBody1.Joints[JointType.ElbowRight]);
                hands = "rl";
                time = stopWatch.Elapsed.TotalSeconds;
                stopWatch.Reset();

               // MessageBox.Show("Patient Reached Hand - R->L");
                this.Start_Reach.IsEnabled = true;
                this.Start_Reach.Visibility = System.Windows.Visibility.Visible;

            } else if ((Math.Pow((rHandUser1.X - rHandUser2.X), 2) + Math.Pow((rHandUser1.Y - rHandUser2.Y), 2)) < Math.Pow(cirRadius, 2))
            {
                stopWatch.Stop();
                isEventStarted = false;
                angle = ReachAngle(userBody1.Joints[JointType.ElbowRight]);
                hands = "rr";
                time = stopWatch.Elapsed.TotalSeconds;
                stopWatch.Reset();

            //    MessageBox.Show("Patient Reached Hand - R->R");
                this.Start_Reach.IsEnabled = true;
                this.Start_Reach.Visibility = System.Windows.Visibility.Visible;


            }

            //only record if time doesn't equal 0, this removes most outlying entries such as holding the start gesture and touching their hand at the same time
            if (!isEventStarted  && (time > 0))
            {
                //convert stopwatch data, write data to database
                //Remember to add time and distance next!
                ReportService service = new ReportService();
                service.writeReachData(patientnDummyID, employeeDummyID, sessionDummyID, hands, angle, exerciseDate, time);
            }
        }