diff --git a/CentralMonitorGUI/Properties/AssemblyInfo.cs b/CentralMonitorGUI/Properties/AssemblyInfo.cs index d16f307..7c2f4b9 100644 --- a/CentralMonitorGUI/Properties/AssemblyInfo.cs +++ b/CentralMonitorGUI/Properties/AssemblyInfo.cs @@ -49,5 +49,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.3.0.0")] -[assembly: AssemblyFileVersion("1.3.0.0")] +[assembly: AssemblyVersion("1.4.0.0")] +[assembly: AssemblyFileVersion("1.4.0.0")] diff --git a/CentralMonitorGUI/ViewModels/MainViewModel.cs b/CentralMonitorGUI/ViewModels/MainViewModel.cs index 49045d8..bca6a42 100644 --- a/CentralMonitorGUI/ViewModels/MainViewModel.cs +++ b/CentralMonitorGUI/ViewModels/MainViewModel.cs @@ -13,7 +13,6 @@ namespace CentralMonitorGUI.ViewModels { public class MainViewModel : ViewModelBase { - private readonly TimeSpan timeToShow = TimeSpan.FromSeconds(10); private readonly UpdateTrigger updateTrigger; private readonly FileManager fileManager; private readonly DataExplorerWindowViewModelFactory dataExplorerWindowViewModelFactory; @@ -42,8 +41,7 @@ private void Network_NewMonitorDiscovered(object sender, PatientMonitor newMonit { var viewModel = new PatientMonitorViewModel( newMonitor, - updateTrigger, - timeToShow, + updateTrigger, dataExplorerWindowViewModelFactory); Monitors.Add(viewModel); } @@ -54,7 +52,7 @@ private void Network_MonitorDisappeared(object sender, PatientMonitor disappeare monitor => monitor.Monitor.Equals(disappearedMonitor)); if(viewModelToBeRemoved == null) return; - Application.Current.Dispatcher.BeginInvoke(new Action(() => Monitors.Remove(viewModelToBeRemoved))); + Application.Current.Dispatcher?.BeginInvoke(new Action(() => Monitors.Remove(viewModelToBeRemoved))); } public ObservableCollection Monitors { get; } = new ObservableCollection(); diff --git a/CentralMonitorGUI/ViewModels/PatientMonitorViewModel.cs b/CentralMonitorGUI/ViewModels/PatientMonitorViewModel.cs index e537f3c..a822dee 100644 --- a/CentralMonitorGUI/ViewModels/PatientMonitorViewModel.cs +++ b/CentralMonitorGUI/ViewModels/PatientMonitorViewModel.cs @@ -7,6 +7,7 @@ using System.Windows.Media; using System.Windows.Threading; using CentralMonitorGUI.Views; +using Commons.Extensions; using NetworkCommunication; using NetworkCommunication.DataStorage; using NetworkCommunication.Objects; @@ -21,7 +22,6 @@ public class PatientMonitorViewModel : ViewModelBase private bool spO2Enabled = true; private EcgLead selectedEcgLead = EcgLead.II; private readonly UpdateTrigger updateTrigger; - private readonly TimeSpan timeToShow; private readonly DataExplorerWindowViewModelFactory dataExplorerWindowViewModelFactory; private readonly Dictionary waveformViewModels = new Dictionary(); private VitalSignViewModel vitalSignValues; @@ -39,20 +39,19 @@ public class PatientMonitorViewModel : ViewModelBase public PatientMonitorViewModel( PatientMonitor monitor, - UpdateTrigger updateTrigger, - TimeSpan timeToShow, + UpdateTrigger updateTrigger, DataExplorerWindowViewModelFactory dataExplorerWindowViewModelFactory) { Monitor = monitor; this.updateTrigger = updateTrigger; - this.timeToShow = timeToShow; this.dataExplorerWindowViewModelFactory = dataExplorerWindowViewModelFactory; + TimeToShow = TimeSpan.FromSeconds(10); VitalSignValues = new VitalSignViewModel(monitor); OpenDataExplorerWindowCommand = new RelayCommand(OpenDataExplorerWindow); - EcgWaveform = new WaveformViewModel(SensorType.EcgLeadII, new WaveformBuffer(SensorType.EcgLeadII, 0), updateTrigger, timeToShow); - RespirationWaveform = new WaveformViewModel(SensorType.Respiration, new WaveformBuffer(SensorType.Respiration, 0), updateTrigger, timeToShow); - SpO2Waveform = new WaveformViewModel(SensorType.SpO2, new WaveformBuffer(SensorType.SpO2, 0), updateTrigger, timeToShow); + EcgWaveform = new WaveformViewModel(SensorType.EcgLeadII, new WaveformBuffer(SensorType.EcgLeadII, 0), updateTrigger, TimeToShow); + RespirationWaveform = new WaveformViewModel(SensorType.Respiration, new WaveformBuffer(SensorType.Respiration, 0), updateTrigger, TimeToShow); + SpO2Waveform = new WaveformViewModel(SensorType.SpO2, new WaveformBuffer(SensorType.SpO2, 0), updateTrigger, TimeToShow); alarmTimeoutTimer.Elapsed += AlarmTimeoutTimer_Elapsed; monitor.NewWaveformSensorConnected += Monitor_NewWaveformSensorConnected; monitor.NewAlarm += Monitor_NewAlarm; @@ -64,10 +63,12 @@ public PatientMonitorViewModel( sensorType, waveformSource, updateTrigger, - timeToShow); + TimeToShow); waveformViewModels.Add(sensorType, waveformViewModel); SetWaveformViewModel(sensorType, waveformViewModel); } + + ExpandCommand = new RelayCommand(newState => IsExpanded = newState); } private void AlarmTimeoutTimer_Elapsed(object sender, ElapsedEventArgs e) @@ -97,7 +98,7 @@ private void Monitor_NewWaveformSensorConnected(object sender, SensorType sensor sensorType, waveformSource, updateTrigger, - timeToShow); + TimeToShow); waveformViewModels[sensorType] = waveformViewModel; SetWaveformViewModel(sensorType, waveformViewModel); } @@ -126,7 +127,16 @@ private void SetWaveformViewModel(SensorType sensorType, WaveformViewModel wavef } public PatientMonitor Monitor { get; } - + private TimeSpan timeToShow; + public TimeSpan TimeToShow + { + get => timeToShow; + private set + { + timeToShow = value; + waveformViewModels.Values.ForEach(waveFormViewModel => waveFormViewModel.TimeToShow = timeToShow); + } + } public Alarm ActiveAlarm { @@ -273,7 +283,7 @@ public EcgLead SelectedEcgLead ecgSensorType, new WaveformBuffer(ecgSensorType, 0), updateTrigger, - timeToShow); + TimeToShow); } OnPropertyChanged(); } @@ -288,6 +298,19 @@ public Brush InfoBarBackground OnPropertyChanged(); } } + private bool isExpanded; + public bool IsExpanded + { + get => isExpanded; + set + { + isExpanded = value; + TimeToShow = isExpanded ? TimeSpan.FromSeconds(30) : TimeSpan.FromSeconds(10); + OnPropertyChanged(); + } + } + + public ICommand ExpandCommand { get; } private void OpenDataExplorerWindow() { diff --git a/CentralMonitorGUI/ViewModels/WaveformViewModel.cs b/CentralMonitorGUI/ViewModels/WaveformViewModel.cs index 40d80ab..886db07 100644 --- a/CentralMonitorGUI/ViewModels/WaveformViewModel.cs +++ b/CentralMonitorGUI/ViewModels/WaveformViewModel.cs @@ -5,6 +5,7 @@ using NetworkCommunication.DataStorage; using NetworkCommunication.Objects; using OxyPlot; +using OxyPlot.Axes; using OxyPlot.Series; namespace CentralMonitorGUI.ViewModels @@ -12,10 +13,8 @@ namespace CentralMonitorGUI.ViewModels public class WaveformViewModel : ViewModelBase, IDisposable { private readonly IWaveformSource waveformSource; - private readonly TimeSpan timeToShow; private readonly UpdateTrigger updateTrigger; private readonly int sampleCountPerUpdate; - private readonly int sampleCount; private int sampleIdx; public WaveformViewModel( @@ -25,12 +24,10 @@ public WaveformViewModel( TimeSpan timeToShow) { this.waveformSource = waveformSource; - this.timeToShow = timeToShow; this.updateTrigger = updateTrigger; SensorType = sensorType; + TimeToShow = timeToShow; sampleCountPerUpdate = Informations.SensorBatchSizes[sensorType]; - var samplesPerSecond = Informations.SensorBatchesPerSecond * Informations.SensorBatchSizes[sensorType]; - sampleCount = (int) (timeToShow.TotalSeconds * samplesPerSecond); SetupPlotModel(); updateTrigger.Trig += UpdateTrigger_Trig; } @@ -56,7 +53,16 @@ private static Color MapSensorTypeToBrush(SensorType sensorType) private void SetupPlotModel() { - PlotModel = new PlotModel(); + PlotModel = new PlotModel + { + Axes = { new LinearAxis + { + Position = AxisPosition.Bottom, + IsAxisVisible = false, + IsZoomEnabled = false, + IsPanEnabled = false + }} + }; var sensorColor = MapSensorTypeToBrush(SensorType); PlotModel.Series.Add(new LineSeries @@ -72,6 +78,8 @@ private void UpdateTrigger_Trig(object sender, EventArgs e) { if(isUpdating) return; + var samplesPerSecond = Informations.SensorBatchesPerSecond * Informations.SensorBatchSizes[SensorType]; + var sampleCount = (int) (TimeToShow.TotalSeconds * samplesPerSecond); lock (PlotModel.SyncRoot) { isUpdating = true; @@ -92,6 +100,7 @@ private void UpdateTrigger_Trig(object sender, EventArgs e) } public SensorType SensorType { get; } + public TimeSpan TimeToShow { get; set; } public PlotModel PlotModel { get; private set; } public void Dispose() diff --git a/CentralMonitorGUI/Views/MainWindow.xaml b/CentralMonitorGUI/Views/MainWindow.xaml index cfd15f3..fd47757 100644 --- a/CentralMonitorGUI/Views/MainWindow.xaml +++ b/CentralMonitorGUI/Views/MainWindow.xaml @@ -25,7 +25,7 @@ - + diff --git a/CentralMonitorGUI/Views/PatientMonitorView.xaml b/CentralMonitorGUI/Views/PatientMonitorView.xaml index 6202923..91251f4 100644 --- a/CentralMonitorGUI/Views/PatientMonitorView.xaml +++ b/CentralMonitorGUI/Views/PatientMonitorView.xaml @@ -4,11 +4,14 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:views="clr-namespace:CentralMonitorGUI.Views" + xmlns:system="clr-namespace:System;assembly=mscorlib" mc:Ignorable="d" - d:DesignHeight="180" d:DesignWidth="1000" + d:DesignHeight="400" d:DesignWidth="1000" Name="Self"> + True + False @@ -18,8 +21,7 @@ - +