//hydration yearly private void Button_Click_5(object sender, RoutedEventArgs e) { using (MasterEntities db = new MasterEntities()) { cartesianChart2.Series.Clear(); cartesianChart2.AxisX.Clear(); cartesianChart2.AxisY.Clear(); //Retrieve data from stored procedure var data = db.YearlyHydratation(); //Create columns chart ColumnSeries col = new ColumnSeries() { DataLabels = true, Values = new ChartValues <double>(), LabelPoint = point => point.Y.ToString() }; Axis ax = new Axis() { Separator = new LiveCharts.Wpf.Separator() { Step = 1, IsEnabled = false } }; ax.Labels = new List <string>(); //Add data to your chart foreach (var x in data) { col.Values.Add(x.Liters.Value); ax.Labels.Add(x.Year.ToString()); } cartesianChart2.Series.Add(col); cartesianChart2.AxisX.Add(ax); cartesianChart2.AxisY.Add(new Axis { Title = "Liters", LabelFormatter = value => value.ToString(), Separator = new LiveCharts.Wpf.Separator() }); } }
//Mobility monthly private void Button_Click_3(object sender, RoutedEventArgs e) { using (MasterEntities db = new MasterEntities()) { cartesianChart1.Series.Clear(); cartesianChart1.AxisX.Clear(); cartesianChart1.AxisY.Clear(); //Retrieve data from stored procedure var data = db.MonthlyMob(); //Create columns chart ColumnSeries col = new ColumnSeries() { DataLabels = true, Values = new ChartValues <int>(), LabelPoint = point => point.Y.ToString() }; Axis ax = new Axis() { Separator = new LiveCharts.Wpf.Separator() { Step = 1, IsEnabled = false } }; ax.Labels = new List <string>(); //Add data to your chart foreach (var x in data) { col.Values.Add(Convert.ToInt32(x.Minute.Value)); ax.Labels.Add(x.MonthName.ToString()); } cartesianChart1.Series.Add(col); cartesianChart1.AxisX.Add(ax); cartesianChart1.AxisY.Add(new Axis { Title = "Activity minutes", LabelFormatter = value => value.ToString(), Separator = new LiveCharts.Wpf.Separator() }); } }
private void SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { // Speech utterance confidence below which we treat speech as if it hadn't been heard const double ConfidenceThreshold = 0.75; //0.35 if (e.Result.Confidence >= ConfidenceThreshold) { switch (e.Result.Semantics.Value.ToString()) { case "HELP": MessageBox.Show("The patient might need HELP"); alarmCount++; this.alarmCountText.Text = Convert.ToString(alarmCount); using (MasterEntities context = new MasterEntities()) { var alarm = new TotalAlarm() { Date = DateTime.Now }; context.TotalAlarms.Add(alarm); context.SaveChanges(); //Retrieve data from stored procedure var alarms = context.GetTotalAlarms(); foreach (var x in alarms) { this.totalAlarms.Text = Convert.ToString(x.Value); } } break; case "PLEASE HELP": MessageBox.Show("Alarm!! Patient just said PLEASE HELP!!!"); alarmCount++; this.alarmCountText.Text = Convert.ToString(alarmCount); using (MasterEntities context = new MasterEntities()) { var alarm = new TotalAlarm() { Date = DateTime.Now }; context.TotalAlarms.Add(alarm); context.SaveChanges(); //Retrieve data from stored procedure var alarms = context.GetTotalAlarms(); foreach (var x in alarms) { this.totalAlarms.Text = Convert.ToString(x.Value); } } break; case "AMBULANCE": MessageBox.Show("The patient needs an AMBULANCE..."); alarmCount++; this.alarmCountText.Text = Convert.ToString(alarmCount); using (MasterEntities context = new MasterEntities()) { var alarm = new TotalAlarm() { Date = DateTime.Now }; context.TotalAlarms.Add(alarm); context.SaveChanges(); //Retrieve data from stored procedure var alarms = context.GetTotalAlarms(); foreach (var x in alarms) { this.totalAlarms.Text = Convert.ToString(x.Value); } } break; case "POLICE": MessageBox.Show("The patient calls for police..."); alarmCount++; this.alarmCountText.Text = Convert.ToString(alarmCount); using (MasterEntities context = new MasterEntities()) { var alarm = new TotalAlarm() { Date = DateTime.Now }; context.TotalAlarms.Add(alarm); context.SaveChanges(); //Retrieve data from stored procedure var alarms = context.GetTotalAlarms(); foreach (var x in alarms) { this.totalAlarms.Text = Convert.ToString(x.Value); } } break; default: Console.WriteLine("Default case"); break; } } }
/// <summary> /// Initializes a new instance of the MainWindow class /// </summary> public MainWindow() { // initialize the MainWindow this.InitializeComponent(); // only one sensor is currently supported this.kinectSensor = KinectSensor.GetDefault(); // set IsAvailableChanged event notifier this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged; // open the sensor this.kinectSensor.Open(); // set the status text this.StatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText : Properties.Resources.NoSensorStatusText; // open the reader for the body frames this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader(); // set the BodyFramedArrived event notifier this.bodyFrameReader.FrameArrived += this.Reader_BodyFrameArrived; // initialize the BodyViewer object for displaying tracked bodies in the UI this.kinectBodyView = new KinectBodyView(this.kinectSensor); // initialize the GestureDetector object this.gestureResultView = new GestureResultView(false, false, false, 0.0f, 0.0f, -1.0f); this.gestureDetector = new GestureDetector(this.kinectSensor, this.gestureResultView); this.gestureResultGrid.DataContext = this.gestureResultView; // set our data context objects for display in UI this.DataContext = this; this.kinectBodyViewbox.DataContext = this.kinectBodyView; using (MasterEntities db = new MasterEntities()) { //Retrieve data from stored procedure var data = db.TodayMob(); foreach (var x in data) { this.today_mobility.Text = Convert.ToString(x.Minute.Value) + " minutes"; } //Retrieve data from stored procedure var liters = db.TodayHydratation(); foreach (var x in liters) { this.today_hydratation.Text = Convert.ToString(x.Liters.Value) + " Liters"; } //Retrieve data from stored procedure var alarms = db.GetTotalAlarms(); foreach (var x in alarms) { this.totalAlarms.Text = Convert.ToString(x.Value); } } //SPEECH RECOGNITION // grab the audio stream IReadOnlyList <AudioBeam> audioBeamList = this.kinectSensor.AudioSource.AudioBeams; System.IO.Stream audioStream = audioBeamList[0].OpenInputStream(); // create the convert stream this.kinectAudioStream = new KinectAudioStream(audioStream); RecognizerInfo ri = TryGetKinectRecognizer(); if (null != ri) { this.speechEngine = new SpeechRecognitionEngine(ri.Id); Choices commands = new Choices(); commands.Add(new SemanticResultValue("help", "HELP")); commands.Add(new SemanticResultValue("please help", "HELP")); commands.Add(new SemanticResultValue("please", "PLEASE")); commands.Add(new SemanticResultValue("ambulance", "AMBULANCE")); commands.Add(new SemanticResultValue("police", "POLICE")); var gb = new GrammarBuilder { Culture = ri.Culture }; gb.Append(commands); var g = new Grammar(gb); this.speechEngine.LoadGrammar(g); this.speechEngine.SpeechRecognized += this.SpeechRecognized; this.kinectAudioStream.SpeechActive = true; this.speechEngine.SetInputToAudioStream( this.kinectAudioStream, new SpeechAudioFormatInfo(EncodingFormat.Pcm, 16000, 16, 1, 32000, 2, null)); this.speechEngine.RecognizeAsync(RecognizeMode.Multiple); } else { Application.Current.Shutdown(); } }
/// <summary> /// Handles the body frame data arriving from the sensor and updates the associated gesture detector object. /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void Reader_BodyFrameArrived(object sender, BodyFrameArrivedEventArgs e) { bool dataReceived = false; using (var bodyFrame = this.bodyFrameReader.AcquireLatestFrame()) { if (bodyFrame != null) { if (this.bodies == null) { // creates an array of 6 bodies, which is the max number of bodies that Kinect can track simultaneously this.bodies = new Body[bodyFrame.BodyCount]; } // The first time GetAndRefreshBodyData is called, Kinect will allocate each Body in the array. // As long as those body objects are not disposed and not set to null in the array, // those body objects will be re-used. bodyFrame.GetAndRefreshBodyData(this.bodies); if (!this.bodies[this.activeBodyIndex].IsTracked) { // we lost tracking of the active body, so update to the first tracked body in the array int bodyIndex = this.GetActiveBodyIndex(); if (bodyIndex > 0) { this.activeBodyIndex = bodyIndex; } } dataReceived = true; } } if (dataReceived) { Body activeBody = this.bodies[this.activeBodyIndex]; // visualize the new body data this.kinectBodyView.UpdateBodyFrame(activeBody); // visualize the new gesture data if (activeBody.TrackingId != this.gestureDetector.TrackingId) { // if the tracking ID changed, update the detector with the new value this.gestureDetector.TrackingId = activeBody.TrackingId; } if (this.gestureDetector.TrackingId == 0) { // the active body is not tracked, pause the detector and update the UI this.gestureDetector.IsPaused = true; this.gestureResultView.UpdateGestureResult(false, false, false, 0.0f, 0.0f, -1.0f); } else { // the active body is tracked, unpause the detector this.gestureDetector.IsPaused = false; // get the latest gesture frame from the sensor and updates the UI with the results this.gestureDetector.UpdateGestureData(); //****mobility if (activeBody.IsTracked && this.gestureDetector.GestureResultView.ConfidenceSeated > 0.8f && this.gestureDetector.GestureResultView.DetectedSeated) { using (MasterEntities context = new MasterEntities()) { var pacient = new PacientInfo() { Confidence = this.gestureDetector.GestureResultView.ConfidenceSeated, Seated = this.gestureDetector.GestureResultView.DetectedSeated.ToString(), Date = DateTime.Now }; context.PacientInfoes.Add(pacient); context.SaveChanges(); } } //****drinking if (activeBody.IsTracked && this.gestureDetector.GestureResultView.ConfidenceDrinking > 0.5f && this.gestureDetector.GestureResultView.DetectedDrinking) { using (MasterEntities context = new MasterEntities()) { var drinkinginfo = new PacientDrinkingInfo() { Confidence = this.gestureDetector.GestureResultView.ConfidenceDrinking, Drinking = this.gestureDetector.GestureResultView.DetectedDrinking.ToString(), DrinkingProgress = this.gestureDetector.GestureResultView.DrinkingProgress, Date = DateTime.Now }; context.PacientDrinkingInfoes.Add(drinkinginfo); context.SaveChanges(); } } } } }