diff --git a/ClientApp/Utils/Client.cs b/ClientApp/Utils/Client.cs
index 438ccca..5dc8291 100644
--- a/ClientApp/Utils/Client.cs
+++ b/ClientApp/Utils/Client.cs
@@ -185,7 +185,7 @@ namespace ClientApp.Utils
else if (DataParser.isRawDataBikeServer(messageBytes))
{
Console.WriteLine($"Received data: {BitConverter.ToString(payloadbytes)}");
- }
+ }
totalBufferReceived -= expectedMessageLength;
expectedMessageLength = BitConverter.ToInt32(totalBuffer, 0);
diff --git a/ClientApp/ViewModels/LoginViewModel.cs b/ClientApp/ViewModels/LoginViewModel.cs
index 0ec1488..3ca025d 100644
--- a/ClientApp/ViewModels/LoginViewModel.cs
+++ b/ClientApp/ViewModels/LoginViewModel.cs
@@ -16,7 +16,7 @@ namespace ClientApp.ViewModels
public string Username { get; set; }
public ICommand LoginCommand { get; set; }
- public bool LoginStatus { get; set; }
+ public bool LoginStatus { get; set; } = false;
public bool InvertedLoginStatus { get; set; }
diff --git a/ClientApp/Views/LoginView.xaml b/ClientApp/Views/LoginView.xaml
index ed554b4..c00a1e3 100644
--- a/ClientApp/Views/LoginView.xaml
+++ b/ClientApp/Views/LoginView.xaml
@@ -19,9 +19,7 @@
-
-
-
+
diff --git a/DoctorApp/DoctorApp.csproj b/DoctorApp/DoctorApp.csproj
index 86a6834..9cd21db 100644
--- a/DoctorApp/DoctorApp.csproj
+++ b/DoctorApp/DoctorApp.csproj
@@ -25,6 +25,7 @@
+
diff --git a/DoctorApp/Utils/Client.cs b/DoctorApp/Utils/Client.cs
index a991343..777be1d 100644
--- a/DoctorApp/Utils/Client.cs
+++ b/DoctorApp/Utils/Client.cs
@@ -1,9 +1,11 @@
using System;
using System.Diagnostics;
+using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using DoctorApp.ViewModels;
+using Microsoft.Win32;
using ProftaakRH;
using Util;
@@ -129,6 +131,23 @@ namespace DoctorApp.Utils
{
MainViewModel.TransferDataToClientBPM(payloadbytes);
}
+ else if (DataParser.IsHistoricBikeData(messageBytes))
+ {
+
+
+ // todo change to name of patient
+ string name = MainViewModel.Tabs[0].PatientInfo.Username;
+ string result = "PATIENT INFO FOR " + name + "\n\n";
+ for (int i = 0; i < payloadbytes.Length; i += 8)
+ {
+ byte[] res = new byte[8];
+ Array.Copy(payloadbytes, i, res, 0, 8);
+ result += handleBikeHistory(res);
+ }
+
+ string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/" + name + ".txt";
+ File.WriteAllText(path,result);
+ }
Array.Copy(totalBuffer, expectedMessageLength, totalBuffer, 0, (totalBufferReceived - expectedMessageLength)); //maybe unsafe idk
totalBufferReceived -= expectedMessageLength;
expectedMessageLength = BitConverter.ToInt32(totalBuffer, 0);
@@ -140,11 +159,40 @@ namespace DoctorApp.Utils
}
- ///
- /// starts sending a message to the server
- ///
- /// the message to send
- public void sendMessage(byte[] message)
+ private string handleBikeHistory(byte[] bytes)
+ {
+ string res = string.Empty;
+ switch (bytes[0])
+ {
+ case 0x10:
+ res += "Time elapsed: " + bytes[2] / 4 + "s\n";
+ res += "Distance traveled: " + bytes[3] + "\n";
+ int input = bytes[4] | (bytes[5] << 8);
+ res += $"Speed {input * 0.01}m/s\n";
+ res += $"Heart rate: { Convert.ToString(bytes[6], 10)}";
+ break;
+ case 0x19:
+ res += $"RPM: {bytes[2]}\n";
+ int accumPower = bytes[3] | (bytes[4] << 8);
+ res += $"Accumulated power: {accumPower} watt\n";
+ int instantPower = (bytes[5]) | (bytes[6] & 0b00001111) << 8;
+ if (instantPower != 0xFFF)
+ {
+ res += $"Instant power: {instantPower} watt\n";
+ }
+ break;
+
+ }
+ return res + "\n";
+
+
+ }
+
+ ///
+ /// starts sending a message to the server
+ ///
+ /// the message to send
+ public void sendMessage(byte[] message)
{
stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), null);
}
diff --git a/DoctorApp/ViewModels/ClientInfoViewModel.cs b/DoctorApp/ViewModels/ClientInfoViewModel.cs
index 7cda6a4..655c04f 100644
--- a/DoctorApp/ViewModels/ClientInfoViewModel.cs
+++ b/DoctorApp/ViewModels/ClientInfoViewModel.cs
@@ -41,6 +41,8 @@ namespace DoctorApp.ViewModels
public ICommand SetResistance { get; set; }
+ public ICommand SaveHistoricData { get; set; }
+
public MainWindowViewModel MainWindowViewModel { get; set; }
private Client client;
@@ -81,13 +83,23 @@ namespace DoctorApp.ViewModels
PatientInfo.Resistance = float.Parse(((TextBox)parameter).Text);
});
+ // request the historic data from the server
+ this.SaveHistoricData = new RelayCommand