private async void PartPlot(CancellationToken token) { _timer.Stop(); if (Pacient != null) { try { if (!Equals(Range, null)) { HumanData data = await PatientUtilities.LoadHumanData(Pacient, new Tuple <DateTime, DateTime>(Range.Item1, Range.Item2)); string dis = "Normal"; string emo = (await PatientUtilities.GetEmotion(Pacient))?.LastOrDefault()?.Emotion; if (data != null && data.Data?.Count > 0 && dis != null && emo != null) { Plot(data, token); Disease = dis; RaisePropertyChanged(nameof(Disease)); Emotion = emo; RaisePropertyChanged(nameof(Emotion)); } } } catch (Exception ex) { MessageBox.Show($"An unhandled exception just occurred: {ex.Message}", "Part Plot", MessageBoxButton.OK, MessageBoxImage.Warning); } } }
private void Plot(HumanData hd, CancellationToken token) { CardioPlotLst.Clear(); TemperaturePlotLst.Clear(); HeartRatePlotLst.Clear(); if (token.IsCancellationRequested) { _timer.Stop(); Range = null; if (Ranges?.Count > 0) { Ranges.Clear(); } CardioPlotLst.Clear(); RaisePropertyChanged(nameof(CardioPlotLst)); TemperaturePlotLst.Clear(); RaisePropertyChanged(nameof(TemperaturePlotLst)); HeartRatePlotLst.Clear(); RaisePropertyChanged(nameof(HeartRatePlotLst)); HR = 0; return; } for (int i = 0; i < hd.Data.Count; i++) { for (int j = 0; j < hd.Data[i].Cardio.Count; j++) { CardioPlotLst.Add(new CardioPlot { EventTime = PatientUtilities.UnixTimeStampToDateTime(hd.Data[i].Ticks[j]), Cardio = hd.Data[i].Cardio[j] }); RaisePropertyChanged(nameof(CardioPlotLst)); HeartRatePlotLst.Add(new HeartRatePlot { EventTime = PatientUtilities.UnixTimeStampToDateTime(hd.Data[i].Ticks[j]), HeartRate = hd.Data[i].HR[j] }); RaisePropertyChanged(nameof(HeartRatePlotLst)); TemperaturePlotLst.Add(new TemperaturePlot { EventTime = PatientUtilities.UnixTimeStampToDateTime(hd.Data[i].Ticks[j]), Temperature = hd.Data[i].Temperature[j] }); RaisePropertyChanged(nameof(TemperaturePlotLst)); } } if (hd.Data?.Count > 0) { HR = hd.Data.LastOrDefault().HR.LastOrDefault(); } RaisePropertyChanged(nameof(HR)); }
private async void LoadRanges(CancellationToken token) { if (Pacient != null && !token.IsCancellationRequested) { Ranges = new ObservableCollection <Tuple <DateTime, DateTime> >(await PatientUtilities.GetRanges(Pacient)); if (Ranges?.Count > 0) { RaisePropertyChanged(nameof(Ranges)); Range = new Tuple <DateTime, DateTime>(Ranges.FirstOrDefault().Item1, Ranges.FirstOrDefault().Item2); _timer.Start(); } } }