fix
This commit is contained in:
@@ -87,11 +87,20 @@ namespace DoctorApp.ViewModels
|
|||||||
{
|
{
|
||||||
//TODO
|
//TODO
|
||||||
//Parsen van de data you fuck
|
//Parsen van de data you fuck
|
||||||
PatientInfo.BPM = bytes[1];
|
if(bytes[0] == 0x00)
|
||||||
if (MySelectedItem == "BPM")
|
|
||||||
{
|
{
|
||||||
Chart.NewValue(PatientInfo.BPM);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PatientInfo.BPM = bytes[1];
|
||||||
|
if (MySelectedItem == "BPM")
|
||||||
|
{
|
||||||
|
Chart.NewValue(PatientInfo.BPM);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,17 +117,18 @@ namespace DoctorApp.ViewModels
|
|||||||
}
|
}
|
||||||
PatientInfo.Distance = bytes[3];
|
PatientInfo.Distance = bytes[3];
|
||||||
PatientInfo.Speed = (bytes[4] | (bytes[5] << 8)) * 0.01;
|
PatientInfo.Speed = (bytes[4] | (bytes[5] << 8)) * 0.01;
|
||||||
|
if (MySelectedItem == "Speed")
|
||||||
|
{
|
||||||
|
Chart.NewValue(PatientInfo.Speed);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 0x19:
|
case 0x19:
|
||||||
PatientInfo.Acc_Power = bytes[3] | (bytes[4] << 8);
|
PatientInfo.Acc_Power = bytes[3] | (bytes[4] << 8);
|
||||||
PatientInfo.Curr_Power = (bytes[5]) | (bytes[6] & 0b00001111) << 8;
|
PatientInfo.Curr_Power = (bytes[5]) | (bytes[6] & 0b00001111) << 8;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Exception();
|
Debug.WriteLine("rip");
|
||||||
}
|
break;
|
||||||
if (MySelectedItem == "Speed")
|
|
||||||
{
|
|
||||||
Chart.NewValue(PatientInfo.Speed);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace DoctorApp.ViewModels
|
|||||||
{
|
{
|
||||||
if(item.PatientInfo.Username == username)
|
if(item.PatientInfo.Username == username)
|
||||||
{
|
{
|
||||||
item.BikeData(bytes);
|
item.BikeData(DataParser.getDataWithoutName(bytes,0,8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ namespace DoctorApp.ViewModels
|
|||||||
{
|
{
|
||||||
if (item.PatientInfo.Username == username)
|
if (item.PatientInfo.Username == username)
|
||||||
{
|
{
|
||||||
item.BikeData(bytes);
|
item.BikeData(DataParser.getDataWithoutName(bytes, 0,2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,12 @@ namespace Util
|
|||||||
|
|
||||||
return Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(json));
|
return Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(json));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static string getNameFromBytesBike(byte[] bytes)
|
||||||
|
{
|
||||||
|
return getName(bytes, 8, bytes.Length - 8);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// converts the given string parameter into a message using our protocol.
|
/// converts the given string parameter into a message using our protocol.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -59,6 +65,18 @@ namespace Util
|
|||||||
return Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(json));
|
return Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(json));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static string getNameFromBytesBPM(byte[] bytes)
|
||||||
|
{
|
||||||
|
return getName(bytes, 2, bytes.Length - 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string getName(byte[] bytes , int offset, int lenght)
|
||||||
|
{
|
||||||
|
byte[] nameArray = new byte[lenght];
|
||||||
|
Array.Copy(bytes, offset, nameArray, 0, lenght);
|
||||||
|
return Encoding.UTF8.GetString(nameArray);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// creates a message for when the doctor wants to log in.
|
/// creates a message for when the doctor wants to log in.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -441,6 +459,13 @@ namespace Util
|
|||||||
return getJsonMessage(MESSAGE, data);
|
return getJsonMessage(MESSAGE, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static byte[] getDataWithoutName(byte[] bytes, int offset, int length)
|
||||||
|
{
|
||||||
|
byte[] data = new byte[length];
|
||||||
|
Array.Copy(bytes, offset, data, 0, length);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user