diff --git a/ClientApp/Utils/Client.cs b/ClientApp/Utils/Client.cs
index bebc366..367fe2d 100644
--- a/ClientApp/Utils/Client.cs
+++ b/ClientApp/Utils/Client.cs
@@ -164,10 +164,10 @@ namespace ClientApp.Utils
break;
}
}
- /*else if (DataParser.isRawData(messageBytes))
+ else if (DataParser.isRawDataBikeServer(messageBytes))
{
Console.WriteLine($"Received data: {BitConverter.ToString(payloadbytes)}");
- }*/
+ }
totalBufferReceived -= expectedMessageLength;
expectedMessageLength = BitConverter.ToInt32(totalBuffer, 0);
diff --git a/ClientApp/Utils/EngineConnection.cs b/ClientApp/Utils/EngineConnection.cs
index c852058..9ff92e6 100644
--- a/ClientApp/Utils/EngineConnection.cs
+++ b/ClientApp/Utils/EngineConnection.cs
@@ -27,7 +27,7 @@ namespace ClientApp.Utils
//new PC("DESKTOP-M2CIH87", "Fabian"),
//new PC("T470S", "Shinichi"),
//new PC("DESKTOP-DHS478C", "semme"),
- new PC("HP-ZBOOK-SEM", "Sem")
+ //new PC("HP-ZBOOK-SEM", "Sem")
//new PC("DESKTOP-TV73FKO", "Wouter"),
//new PC("DESKTOP-SINMKT1", "Ralf van Aert"),
//new PC("NA", "Bart")
diff --git a/DoctorApp/DoctorApp.csproj b/DoctorApp/DoctorApp.csproj
index 2ff8d95..64333af 100644
--- a/DoctorApp/DoctorApp.csproj
+++ b/DoctorApp/DoctorApp.csproj
@@ -19,6 +19,7 @@
+
diff --git a/DoctorApp/Models/Chart.cs b/DoctorApp/Models/Chart.cs
new file mode 100644
index 0000000..1bab873
--- /dev/null
+++ b/DoctorApp/Models/Chart.cs
@@ -0,0 +1,127 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using LiveCharts;
+using LiveCharts.Configurations;
+using Util;
+
+namespace DoctorApp.Models
+{
+ class Chart : ObservableObject,INotifyPropertyChanged
+ {
+
+ private double _axisMax;
+ private double _axisMin;
+ private double _trend;
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ public ChartValues ChartValues { get; set; }
+ public Func DateTimeFormatter { get; set; }
+
+ public PatientInfo PatientInfo { get; set; }
+ public double AxisStep { get; set; }
+ public double AxisUnit { get; set; }
+
+ public double AxisMax
+ {
+ get { return _axisMax; }
+ set
+ {
+ _axisMax = value;
+ OnPropertyChanged("AxisMax");
+ }
+ }
+
+ public double AxisMin
+ {
+ get { return _axisMin; }
+ set
+ {
+ _axisMin = value;
+ OnPropertyChanged("AxisMin");
+ }
+ }
+
+ public bool IsReading { get; set; }
+
+
+
+
+ public Chart(PatientInfo patientInfo)
+ {
+ var mapper = Mappers.Xy()
+ .X(model => model.DateTime.Ticks)
+ .Y(model => model.Value);
+
+ Charting.For(mapper);
+
+ ChartValues = new ChartValues();
+
+ DateTimeFormatter = value => new DateTime((long)value).ToString("mm:ss");
+
+ AxisStep = TimeSpan.FromSeconds(1).Ticks;
+
+ AxisUnit = TimeSpan.TicksPerSecond;
+
+ SetAxisLimits(DateTime.Now);
+
+ IsReading = true;
+
+ ChartValues.Add(new MeasureModel
+ {
+ DateTime = DateTime.Now,
+ Value = 8
+ });
+
+ }
+
+ private void SetAxisLimits(DateTime now)
+ {
+ AxisMax = now.Ticks + TimeSpan.FromSeconds(1).Ticks; // lets force the axis to be 1 second ahead
+ AxisMin = now.Ticks - TimeSpan.FromSeconds(8).Ticks; // and 8 seconds behind
+ }
+
+ protected virtual void OnPropertyChanged(string propertyName = null)
+ {
+ if (PropertyChanged != null)
+ PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+
+
+ public void NewValue(double value)
+ {
+ var now = DateTime.Now;
+ _trend = value;
+ ChartValues.Add(new MeasureModel
+ {
+ DateTime = now,
+ Value = _trend
+ });
+
+ SetAxisLimits(now);
+
+ if (ChartValues.Count > 150) ChartValues.RemoveAt(0);
+ }
+
+ public void Clear()
+ {
+ Debug.WriteLine("clear");
+ ChartValues.Clear();
+ }
+
+
+
+ }
+
+ public class MeasureModel
+ {
+ public DateTime DateTime { get; set; }
+ public double Value { get; set; }
+ }
+}
diff --git a/DoctorApp/Models/PatientInfo.cs b/DoctorApp/Models/PatientInfo.cs
index c7ed295..e2ea0d0 100644
--- a/DoctorApp/Models/PatientInfo.cs
+++ b/DoctorApp/Models/PatientInfo.cs
@@ -10,11 +10,11 @@ namespace DoctorApp.Models
public string Status { get; set; }
- public int Speed { get; set; }
+ public double Speed { get; set; }
public int BPM { get; set; }
- public int Resistance { get; set; }
+ public float Resistance { get; set; }
public int Acc_Power { get; set; }
public int Curr_Power { get; set; }
diff --git a/DoctorApp/Utils/Client.cs b/DoctorApp/Utils/Client.cs
index bbd3674..dcb56f8 100644
--- a/DoctorApp/Utils/Client.cs
+++ b/DoctorApp/Utils/Client.cs
@@ -90,7 +90,7 @@ namespace DoctorApp.Utils
string responseStatus = DataParser.getResponseStatus(payloadbytes);
if (responseStatus == "OK")
{
- Debug.WriteLine("Username and password correct!");
+ Debug.WriteLine("Doctor Username and password correct!");
this.LoginViewModel.setLoginStatus(true);
this.connected = true;
@@ -130,6 +130,9 @@ namespace DoctorApp.Utils
{
MainViewModel.TransferDataToClientBPM(payloadbytes);
}
+
+ totalBufferReceived -= expectedMessageLength;
+ expectedMessageLength = BitConverter.ToInt32(totalBuffer, 0);
}
this.stream.BeginRead(this.buffer, 0, this.buffer.Length, new AsyncCallback(OnRead), null);
diff --git a/DoctorApp/ViewModels/ClientInfoViewModel.cs b/DoctorApp/ViewModels/ClientInfoViewModel.cs
index c36f590..6a81617 100644
--- a/DoctorApp/ViewModels/ClientInfoViewModel.cs
+++ b/DoctorApp/ViewModels/ClientInfoViewModel.cs
@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
+using System.Diagnostics;
using System.Text;
using System.Windows.Controls;
using System.Windows.Input;
@@ -18,6 +19,17 @@ namespace DoctorApp.ViewModels
public PatientInfo PatientInfo { get; set; }
public ObservableCollection ChatLog { get; set; }
+ private string _mySelectedItem;
+ public string MySelectedItem
+ {
+ get { return _mySelectedItem; }
+ set
+ {
+ Chart.Clear();
+ _mySelectedItem = value;
+ }
+ }
+
public ICommand StartSession { get; set; }
public ICommand StopSession { get; set; }
@@ -33,10 +45,13 @@ namespace DoctorApp.ViewModels
public MainWindowViewModel MainWindowViewModel { get; set; }
private Client client;
+ public Chart Chart { get; set; }
+
public ClientInfoViewModel(MainWindowViewModel mainWindowViewModel, string username)
{
MainWindowViewModel = mainWindowViewModel;
this.PatientInfo = new PatientInfo() { Username = username, Status = "Waiting to start" };
+ this.Chart = new Chart(this.PatientInfo);
PatientInfo.ChatLog = new ObservableCollection();
ChatLog = new ObservableCollection();
client = mainWindowViewModel.client;
@@ -66,8 +81,9 @@ namespace DoctorApp.ViewModels
SetResistance = new RelayCommand