Develop #10
@@ -7,6 +7,14 @@
|
|||||||
<ApplicationIcon>Images\Logo\icon1.ico</ApplicationIcon>
|
<ApplicationIcon>Images\Logo\icon1.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="Images\CoolBackground.jpg" />
|
<None Remove="Images\CoolBackground.jpg" />
|
||||||
<None Remove="Images\Icons\CheckMark.png" />
|
<None Remove="Images\Icons\CheckMark.png" />
|
||||||
|
|||||||
@@ -164,10 +164,10 @@ namespace ClientApp.Utils
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (DataParser.isRawData(messageBytes))
|
/*else if (DataParser.isRawData(messageBytes))
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Received data: {BitConverter.ToString(payloadbytes)}");
|
Console.WriteLine($"Received data: {BitConverter.ToString(payloadbytes)}");
|
||||||
}
|
}*/
|
||||||
|
|
||||||
totalBufferReceived -= expectedMessageLength;
|
totalBufferReceived -= expectedMessageLength;
|
||||||
expectedMessageLength = BitConverter.ToInt32(totalBuffer, 0);
|
expectedMessageLength = BitConverter.ToInt32(totalBuffer, 0);
|
||||||
@@ -211,7 +211,7 @@ namespace ClientApp.Utils
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException("no bytes");
|
throw new ArgumentNullException("no bytes");
|
||||||
}
|
}
|
||||||
byte[] message = DataParser.GetRawDataMessage(bytes);
|
byte[] message = DataParser.GetRawBPMDataMessageServer(bytes);
|
||||||
|
|
||||||
if (engineConnection.Connected && engineConnection.FollowingRoute)
|
if (engineConnection.Connected && engineConnection.FollowingRoute)
|
||||||
{
|
{
|
||||||
@@ -238,7 +238,7 @@ namespace ClientApp.Utils
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException("no bytes");
|
throw new ArgumentNullException("no bytes");
|
||||||
}
|
}
|
||||||
byte[] message = DataParser.GetRawDataMessage(bytes);
|
byte[] message = DataParser.GetRawBikeDataMessageServer(bytes);
|
||||||
bool canSendToEngine = engineConnection.Connected && engineConnection.FollowingRoute;
|
bool canSendToEngine = engineConnection.Connected && engineConnection.FollowingRoute;
|
||||||
switch (bytes[0])
|
switch (bytes[0])
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ namespace DoctorApp.ViewModels
|
|||||||
|
|
||||||
public string Status { get; set; }
|
public string Status { get; set; }
|
||||||
|
|
||||||
public int Speed { get; set; }
|
public double Speed { get; set; }
|
||||||
|
|
||||||
public int BPM { 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 Acc_Power { get; set; }
|
||||||
|
|
||||||
public int Curr_Power { get; set; }
|
public int Curr_Power { get; set; }
|
||||||
@@ -71,7 +71,8 @@ namespace DoctorApp.ViewModels
|
|||||||
|
|
||||||
SetResistance = new RelayCommand<object>((parameter) =>
|
SetResistance = new RelayCommand<object>((parameter) =>
|
||||||
{
|
{
|
||||||
client.sendMessage(DataParser.getSetResistanceJson(Username, float.Parse(((TextBox)parameter).Text)));
|
client.sendMessage(DataParser.getSetResistanceJson(Username, float.Parse(((TextBox)parameter).Text)));
|
||||||
|
this.Resistance = float.Parse(((TextBox)parameter).Text);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -80,12 +81,31 @@ namespace DoctorApp.ViewModels
|
|||||||
{
|
{
|
||||||
//TODO
|
//TODO
|
||||||
//Parsen van de data you fuck
|
//Parsen van de data you fuck
|
||||||
|
this.BPM = bytes[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BikeData(byte[] bytes)
|
public void BikeData(byte[] bytes)
|
||||||
{
|
{
|
||||||
//TODO
|
//TODO
|
||||||
//Parsen van de data you fuck
|
//Parsen van de data you fuck
|
||||||
|
switch (bytes[0])
|
||||||
|
{
|
||||||
|
case 0x10:
|
||||||
|
if (bytes[1] != 25)
|
||||||
|
{
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
this.Distance = bytes[3];
|
||||||
|
this.Speed = (bytes[4] | (bytes[5] << 8)) * 0.01;
|
||||||
|
break;
|
||||||
|
case 0x19:
|
||||||
|
this.Acc_Power = bytes[3] | (bytes[4] << 8);
|
||||||
|
this.Curr_Power = (bytes[5]) | (bytes[6] & 0b00001111) << 8;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace DoctorApp.ViewModels
|
|||||||
|
|
||||||
public void TransferDataToClientBike(byte[] bytes)
|
public void TransferDataToClientBike(byte[] bytes)
|
||||||
{
|
{
|
||||||
string username = DataParser.getNameFromBytes(bytes);
|
string username = DataParser.getNameFromBytesBike(bytes);
|
||||||
foreach(ClientInfoViewModel item in Tabs)
|
foreach(ClientInfoViewModel item in Tabs)
|
||||||
{
|
{
|
||||||
if(item.Username == username)
|
if(item.Username == username)
|
||||||
@@ -67,7 +67,7 @@ namespace DoctorApp.ViewModels
|
|||||||
|
|
||||||
public void TransferDataToClientBPM(byte[] bytes)
|
public void TransferDataToClientBPM(byte[] bytes)
|
||||||
{
|
{
|
||||||
string username = DataParser.getNameFromBytes(bytes);
|
string username = DataParser.getNameFromBytesBPM(bytes);
|
||||||
foreach (ClientInfoViewModel item in Tabs)
|
foreach (ClientInfoViewModel item in Tabs)
|
||||||
{
|
{
|
||||||
if (item.Username == username)
|
if (item.Username == username)
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ namespace Util
|
|||||||
return Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(json));
|
return Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(json));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static byte[] LoginAsDoctor(string mUsername, string mPassword)
|
public static byte[] LoginAsDoctor(string mUsername, string mPassword)
|
||||||
{
|
{
|
||||||
dynamic json = new
|
dynamic json = new
|
||||||
@@ -81,13 +83,9 @@ namespace Util
|
|||||||
|
|
||||||
private static string ASCIIBytesToString(byte[] bytes, int offset, int length)
|
private static string ASCIIBytesToString(byte[] bytes, int offset, int length)
|
||||||
{
|
{
|
||||||
unsafe
|
byte[] nameArray = new byte[length];
|
||||||
{
|
Array.Copy(bytes, offset, nameArray, 0, length);
|
||||||
fixed (byte* pAscii = bytes)
|
return Encoding.UTF8.GetString(nameArray);
|
||||||
{
|
|
||||||
return new String((sbyte*)pAscii, offset, length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool GetUsernamePassword(byte[] jsonbytes, out string username, out string password)
|
public static bool GetUsernamePassword(byte[] jsonbytes, out string username, out string password)
|
||||||
|
|||||||
Reference in New Issue
Block a user