Compare commits
14 Commits
dataOnTabs
...
sendmessag
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f163325cf | ||
|
|
1c7f9cf70a | ||
|
|
5f2e325cb1 | ||
|
|
cda8b47ca3 | ||
|
|
fab3ed7705 | ||
|
|
aeb5d59ce9 | ||
|
|
ab1662f0fe | ||
|
|
f07c3f9484 | ||
|
|
2adfcc5bd7 | ||
|
|
3acdc942bc | ||
|
|
84cbcb4a6d | ||
|
|
8385f09313 | ||
|
|
3ea42b65ed | ||
|
|
55d3dd4eee |
@@ -19,11 +19,11 @@
|
|||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="Styles/Fonts.xaml"/>
|
<ResourceDictionary Source="WPFStuff/Styles/Fonts.xaml"/>
|
||||||
<ResourceDictionary Source="Styles/Colors.xaml"/>
|
<ResourceDictionary Source="WPFStuff/Styles/Colors.xaml"/>
|
||||||
<ResourceDictionary Source="Styles/Buttons.xaml"/>
|
<ResourceDictionary Source="WPFStuff/Styles/Buttons.xaml"/>
|
||||||
<ResourceDictionary Source="Styles/Texts.xaml"/>
|
<ResourceDictionary Source="WPFStuff/Styles/Texts.xaml"/>
|
||||||
<ResourceDictionary Source="Styles/Windows.xaml"/>
|
<ResourceDictionary Source="WPFStuff/Styles/Windows.xaml"/>
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace ClientApp.Utils
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void initEngine()
|
private void initEngine()
|
||||||
{
|
{
|
||||||
Debug.WriteLine("init engine");
|
Debug.WriteLine("[CLIENT] init engine");
|
||||||
engineConnection = EngineConnection.INSTANCE;
|
engineConnection = EngineConnection.INSTANCE;
|
||||||
engineConnection.OnNoTunnelId = RetryEngineConnection;
|
engineConnection.OnNoTunnelId = RetryEngineConnection;
|
||||||
engineConnection.OnSuccessFullConnection = engineConnected;
|
engineConnection.OnSuccessFullConnection = engineConnected;
|
||||||
@@ -190,6 +190,9 @@ namespace ClientApp.Utils
|
|||||||
expectedMessageLength = BitConverter.ToInt32(totalBuffer, 0);
|
expectedMessageLength = BitConverter.ToInt32(totalBuffer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ar == null || (!ar.IsCompleted) || (!this.stream.CanRead) || !this.client.Connected)
|
||||||
|
return;
|
||||||
|
ar.AsyncWaitHandle.WaitOne();
|
||||||
this.stream.BeginRead(this.buffer, 0, this.buffer.Length, new AsyncCallback(OnRead), null);
|
this.stream.BeginRead(this.buffer, 0, this.buffer.Length, new AsyncCallback(OnRead), null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using RH_Engine;
|
using RH_Engine;
|
||||||
@@ -27,7 +27,7 @@ namespace ClientApp.Utils
|
|||||||
//new PC("DESKTOP-M2CIH87", "Fabian"),
|
//new PC("DESKTOP-M2CIH87", "Fabian"),
|
||||||
//new PC("T470S", "Shinichi"),
|
//new PC("T470S", "Shinichi"),
|
||||||
//new PC("DESKTOP-DHS478C", "semme"),
|
//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-TV73FKO", "Wouter"),
|
||||||
//new PC("DESKTOP-SINMKT1", "Ralf van Aert"),
|
//new PC("DESKTOP-SINMKT1", "Ralf van Aert"),
|
||||||
//new PC("NA", "Bart")
|
//new PC("NA", "Bart")
|
||||||
@@ -71,7 +71,7 @@ namespace ClientApp.Utils
|
|||||||
updateTimer.AutoReset = true;
|
updateTimer.AutoReset = true;
|
||||||
updateTimer.Enabled = false;
|
updateTimer.Enabled = false;
|
||||||
|
|
||||||
noVRResponseTimer = new System.Timers.Timer(15000);
|
noVRResponseTimer = new System.Timers.Timer(30000);
|
||||||
noVRResponseTimer.Elapsed += noVRResponseTimeout;
|
noVRResponseTimer.Elapsed += noVRResponseTimeout;
|
||||||
noVRResponseTimer.AutoReset = false;
|
noVRResponseTimer.AutoReset = false;
|
||||||
noVRResponseTimer.Enabled = false;
|
noVRResponseTimer.Enabled = false;
|
||||||
@@ -243,7 +243,7 @@ namespace ClientApp.Utils
|
|||||||
SendMessageAndOnResponse(mainCommand.addPanel("panelAdd", bikeId), "panelAdd",
|
SendMessageAndOnResponse(mainCommand.addPanel("panelAdd", bikeId), "panelAdd",
|
||||||
(message) =>
|
(message) =>
|
||||||
{
|
{
|
||||||
|
Write("got panel id");
|
||||||
panelId = JSONParser.getPanelID(message);
|
panelId = JSONParser.getPanelID(message);
|
||||||
|
|
||||||
WriteTextMessage(mainCommand.ColorPanel(panelId));
|
WriteTextMessage(mainCommand.ColorPanel(panelId));
|
||||||
@@ -295,6 +295,7 @@ namespace ClientApp.Utils
|
|||||||
|
|
||||||
public void UpdateInfoPanel()
|
public void UpdateInfoPanel()
|
||||||
{
|
{
|
||||||
|
Write("updating info panel");
|
||||||
ShowPanel(BikeSpeed, (int)BikeBPM, (int)BikePower, (int)BikeResistance);
|
ShowPanel(BikeSpeed, (int)BikeBPM, (int)BikePower, (int)BikeResistance);
|
||||||
WriteTextMessage(mainCommand.RouteSpeed(BikeSpeed, bikeId));
|
WriteTextMessage(mainCommand.RouteSpeed(BikeSpeed, bikeId));
|
||||||
WriteTextMessage(mainCommand.RouteSpeed(BikeSpeed, cameraId));
|
WriteTextMessage(mainCommand.RouteSpeed(BikeSpeed, cameraId));
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:ClientApp.Views"
|
xmlns:local="clr-namespace:ClientApp.Views"
|
||||||
xmlns:viewModels="clr-namespace:ClientApp.ViewModels"
|
xmlns:viewModels="clr-namespace:ClientApp.ViewModels"
|
||||||
|
xmlns:Util="clr-namespace:Util.MagicCode"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
ShowsNavigationUI="False"
|
ShowsNavigationUI="False"
|
||||||
d:DesignHeight="450" d:DesignWidth="800">
|
d:DesignHeight="450" d:DesignWidth="800">
|
||||||
@@ -14,9 +15,9 @@
|
|||||||
</DockPanel.Background>
|
</DockPanel.Background>
|
||||||
<StackPanel VerticalAlignment="Center" Width="auto">
|
<StackPanel VerticalAlignment="Center" Width="auto">
|
||||||
<Label Content="Username" HorizontalContentAlignment="Center" />
|
<Label Content="Username" HorizontalContentAlignment="Center" />
|
||||||
<TextBox x:Name="Username" Text="{Binding Username}" TextWrapping="Wrap" Width="120"/>
|
<TextBox x:Name="Username" Text="{Binding Username}" TextWrapping="Wrap" Width="120" Util:FocusAdvancement.AdvancesByEnterKey="True" />
|
||||||
<Label Content="Password" HorizontalContentAlignment="Center"/>
|
<Label Content="Password" HorizontalContentAlignment="Center"/>
|
||||||
<PasswordBox x:Name="Password" Width="120"/>
|
<PasswordBox x:Name="Password" Width="120" Util:FocusAdvancement.AdvancesByEnterKey="True"/>
|
||||||
<Button x:Name="Login" Content="Login" Command="{Binding LoginCommand}" CommandParameter="{Binding ElementName=Password}" Margin="0,20,0,0" Width="120"/>
|
<Button x:Name="Login" Content="Login" Command="{Binding LoginCommand}" CommandParameter="{Binding ElementName=Password}" Margin="0,20,0,0" Width="120"/>
|
||||||
<Popup IsOpen="{Binding InvertedLoginStatus}" PopupAnimation = "Slide" HorizontalAlignment="Center">
|
<Popup IsOpen="{Binding InvertedLoginStatus}" PopupAnimation = "Slide" HorizontalAlignment="Center">
|
||||||
<Label Content="Login failed" Foreground="Red" HorizontalAlignment="Center" HorizontalContentAlignment="Center" Background="Transparent"/>
|
<Label Content="Login failed" Foreground="Red" HorizontalAlignment="Center" HorizontalContentAlignment="Center" Background="Transparent"/>
|
||||||
|
|||||||
@@ -20,11 +20,11 @@
|
|||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="Styles/Fonts.xaml"/>
|
<ResourceDictionary Source="WPFStuff/Styles/Fonts.xaml"/>
|
||||||
<ResourceDictionary Source="Styles/Colors.xaml"/>
|
<ResourceDictionary Source="WPFStuff/Styles/Colors.xaml"/>
|
||||||
<ResourceDictionary Source="Styles/Buttons.xaml"/>
|
<ResourceDictionary Source="WPFStuff/Styles/Buttons.xaml"/>
|
||||||
<ResourceDictionary Source="Styles/Texts.xaml"/>
|
<ResourceDictionary Source="WPFStuff/Styles/Texts.xaml"/>
|
||||||
<ResourceDictionary Source="Styles/Windows.xaml"/>
|
<ResourceDictionary Source="WPFStuff/Styles/Windows.xaml"/>
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ namespace DoctorApp.Utils
|
|||||||
{
|
{
|
||||||
MainViewModel.TransferDataToClientBPM(payloadbytes);
|
MainViewModel.TransferDataToClientBPM(payloadbytes);
|
||||||
}
|
}
|
||||||
|
Array.Copy(totalBuffer, expectedMessageLength, totalBuffer, 0, (totalBufferReceived - expectedMessageLength)); //maybe unsafe idk
|
||||||
totalBufferReceived -= expectedMessageLength;
|
totalBufferReceived -= expectedMessageLength;
|
||||||
expectedMessageLength = BitConverter.ToInt32(totalBuffer, 0);
|
expectedMessageLength = BitConverter.ToInt32(totalBuffer, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,12 +43,14 @@ namespace DoctorApp.ViewModels
|
|||||||
|
|
||||||
public MainWindowViewModel MainWindowViewModel { get; set; }
|
public MainWindowViewModel MainWindowViewModel { get; set; }
|
||||||
private Client client;
|
private Client client;
|
||||||
|
private MainViewModel parent;
|
||||||
|
|
||||||
public Chart Chart { get; set; }
|
public Chart Chart { get; set; }
|
||||||
|
|
||||||
public ClientInfoViewModel(MainWindowViewModel mainWindowViewModel, string username)
|
public ClientInfoViewModel(MainViewModel parent,MainWindowViewModel mainWindowViewModel, string username)
|
||||||
{
|
{
|
||||||
MainWindowViewModel = mainWindowViewModel;
|
MainWindowViewModel = mainWindowViewModel;
|
||||||
|
this.parent = parent;
|
||||||
this.PatientInfo = new PatientInfo() { Username = username, Status = "Waiting to start" };
|
this.PatientInfo = new PatientInfo() { Username = username, Status = "Waiting to start" };
|
||||||
this.Chart = new Chart(this.PatientInfo);
|
this.Chart = new Chart(this.PatientInfo);
|
||||||
PatientInfo.ChatLog = new ObservableCollection<string>();
|
PatientInfo.ChatLog = new ObservableCollection<string>();
|
||||||
@@ -68,12 +70,17 @@ namespace DoctorApp.ViewModels
|
|||||||
|
|
||||||
Chat = new RelayCommand<object>((parameter) =>
|
Chat = new RelayCommand<object>((parameter) =>
|
||||||
{
|
{
|
||||||
client.sendMessage(DataParser.getChatJson(PatientInfo.Username, ((TextBox)parameter).Text));
|
SendMessageToClient(PatientInfo.Username, ((TextBox)parameter).Text);
|
||||||
PatientInfo.ChatLog.Add(DateTime.Now + ": " + ((TextBox)parameter).Text);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//TODO RelayCommand ChatToAll
|
//TODO RelayCommand ChatToAll
|
||||||
|
|
||||||
|
ChatToAll = new RelayCommand<object>((parameter) =>
|
||||||
|
{
|
||||||
|
Debug.WriteLine("[CLIENTINFOVIEWMODEL] sending message to all clients");
|
||||||
|
this.parent?.SendToAllClients(((TextBox)parameter).Text);
|
||||||
|
});
|
||||||
|
|
||||||
SetResistance = new RelayCommand<object>((parameter) =>
|
SetResistance = new RelayCommand<object>((parameter) =>
|
||||||
{
|
{
|
||||||
Debug.WriteLine("resistance");
|
Debug.WriteLine("resistance");
|
||||||
@@ -83,15 +90,30 @@ namespace DoctorApp.ViewModels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SendMessageToClient(string username, string text)
|
||||||
|
{
|
||||||
|
client.sendMessage(DataParser.getChatJson(username, text));
|
||||||
|
PatientInfo.ChatLog.Add(DateTime.Now + ": " + text);
|
||||||
|
}
|
||||||
|
|
||||||
public void BPMData(byte [] bytes)
|
public void BPMData(byte [] bytes)
|
||||||
{
|
{
|
||||||
//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 +130,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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace DoctorApp.ViewModels
|
|||||||
Debug.WriteLine("new tab with name " + username);
|
Debug.WriteLine("new tab with name " + username);
|
||||||
App.Current.Dispatcher.Invoke((Action)delegate
|
App.Current.Dispatcher.Invoke((Action)delegate
|
||||||
{
|
{
|
||||||
Tabs.Add(new ClientInfoViewModel(MainWindowViewModel, username));
|
Tabs.Add(new ClientInfoViewModel(this,MainWindowViewModel, username));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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,10 +68,19 @@ namespace DoctorApp.ViewModels
|
|||||||
{
|
{
|
||||||
if (item.PatientInfo.Username == username)
|
if (item.PatientInfo.Username == username)
|
||||||
{
|
{
|
||||||
item.BikeData(bytes);
|
item.BikeData(DataParser.getDataWithoutName(bytes, 0,2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void SendToAllClients(string text)
|
||||||
|
{
|
||||||
|
Debug.WriteLine("[MAINVIEWMODEL] Sending message to all clients: " + text);
|
||||||
|
foreach (ClientInfoViewModel item in Tabs)
|
||||||
|
{
|
||||||
|
item.SendMessageToClient(item.PatientInfo.Username, text);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using System.Windows.Input;
|
|||||||
using DoctorApp.Models;
|
using DoctorApp.Models;
|
||||||
using DoctorApp.Utils;
|
using DoctorApp.Utils;
|
||||||
using Util.MagicCode;
|
using Util.MagicCode;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace DoctorApp.ViewModels
|
namespace DoctorApp.ViewModels
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -57,6 +57,7 @@
|
|||||||
<ListBox Name="ChatBox" ItemsSource="{Binding PatientInfo.ChatLog}" Grid.Column="1" Margin="59,41,0,0" Grid.RowSpan="3"/>
|
<ListBox Name="ChatBox" ItemsSource="{Binding PatientInfo.ChatLog}" Grid.Column="1" Margin="59,41,0,0" Grid.RowSpan="3"/>
|
||||||
<TextBox Name="textBox_Chat" Grid.Column="1" HorizontalAlignment="Left" Margin="59,10,0,0" Grid.Row="3" Text="" TextWrapping="Wrap" VerticalAlignment="Top" Width="235"/>
|
<TextBox Name="textBox_Chat" Grid.Column="1" HorizontalAlignment="Left" Margin="59,10,0,0" Grid.Row="3" Text="" TextWrapping="Wrap" VerticalAlignment="Top" Width="235"/>
|
||||||
<Button x:Name="Send" Content="Send" Grid.Column="1" HorizontalAlignment="Left" Margin="59,33,0,0" Grid.Row="3" VerticalAlignment="Top" Command="{Binding Chat}" CommandParameter="{Binding ElementName=textBox_Chat}"/>
|
<Button x:Name="Send" Content="Send" Grid.Column="1" HorizontalAlignment="Left" Margin="59,33,0,0" Grid.Row="3" VerticalAlignment="Top" Command="{Binding Chat}" CommandParameter="{Binding ElementName=textBox_Chat}"/>
|
||||||
|
<Button x:Name="SendToAll" Content="Send to all clients" Grid.Column="1" HorizontalAlignment="Left" Margin="107,33,0,0" Grid.Row="3" VerticalAlignment="Top" Command="{Binding ChatToAll}" CommandParameter="{Binding ElementName=textBox_Chat}"/>
|
||||||
<Button Content="Start Session" Grid.Column="1" HorizontalAlignment="Left" Margin="69,86,0,0" Grid.Row="3" VerticalAlignment="Top" Width="97" Command="{Binding StartSession}" CommandParameter=""/>
|
<Button Content="Start Session" Grid.Column="1" HorizontalAlignment="Left" Margin="69,86,0,0" Grid.Row="3" VerticalAlignment="Top" Width="97" Command="{Binding StartSession}" CommandParameter=""/>
|
||||||
<Button Content="Stop Session" Grid.Column="1" HorizontalAlignment="Left" Margin="187,86,0,0" Grid.Row="3" VerticalAlignment="Top" Width="97" Command="{Binding StopSession}" CommandParameter=""/>
|
<Button Content="Stop Session" Grid.Column="1" HorizontalAlignment="Left" Margin="187,86,0,0" Grid.Row="3" VerticalAlignment="Top" Width="97" Command="{Binding StopSession}" CommandParameter=""/>
|
||||||
<TextBox x:Name="textBox_SetResistance" Grid.Column="1" HorizontalAlignment="Left" Margin="69,128,0,0" Grid.Row="3" TextWrapping="Wrap" VerticalAlignment="Top" Width="97"/>
|
<TextBox x:Name="textBox_SetResistance" Grid.Column="1" HorizontalAlignment="Left" Margin="69,128,0,0" Grid.Row="3" TextWrapping="Wrap" VerticalAlignment="Top" Width="97"/>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:DoctorApp.Views"
|
xmlns:local="clr-namespace:DoctorApp.Views"
|
||||||
xmlns:viewModels="clr-namespace:DoctorApp.ViewModels"
|
xmlns:viewModels="clr-namespace:DoctorApp.ViewModels"
|
||||||
|
xmlns:Util="clr-namespace:Util.MagicCode"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="450" d:DesignWidth="800"
|
d:DesignHeight="450" d:DesignWidth="800"
|
||||||
>
|
>
|
||||||
@@ -12,9 +13,9 @@
|
|||||||
<DockPanel>
|
<DockPanel>
|
||||||
<StackPanel VerticalAlignment="Center" Width="auto">
|
<StackPanel VerticalAlignment="Center" Width="auto">
|
||||||
<Label Content="Username" HorizontalContentAlignment="Center" />
|
<Label Content="Username" HorizontalContentAlignment="Center" />
|
||||||
<TextBox x:Name="Username" Text="{Binding Username}" TextWrapping="Wrap" Width="120"/>
|
<TextBox x:Name="Username" Text="{Binding Username}" TextWrapping="Wrap" Width="120" Util:FocusAdvancement.AdvancesByEnterKey="True"/>
|
||||||
<Label Content="Password" HorizontalContentAlignment="Center"/>
|
<Label Content="Password" HorizontalContentAlignment="Center"/>
|
||||||
<PasswordBox x:Name="Password" Width="120"/>
|
<PasswordBox x:Name="Password" Width="120" Util:FocusAdvancement.AdvancesByEnterKey="True"/>
|
||||||
<Button x:Name="Login" Content="Login" Command="{Binding LoginCommand}" CommandParameter="{Binding ElementName=Password}" Margin="0,20,0,0" Width="120"/>
|
<Button x:Name="Login" Content="Login" Command="{Binding LoginCommand}" CommandParameter="{Binding ElementName=Password}" Margin="0,20,0,0" Width="120"/>
|
||||||
<Popup IsOpen="{Binding InvertedLoginStatus}" PopupAnimation = "Fade" HorizontalAlignment="Left">
|
<Popup IsOpen="{Binding InvertedLoginStatus}" PopupAnimation = "Fade" HorizontalAlignment="Left">
|
||||||
<Label Content="Login failed" Foreground="Red" Background="#FFFF" />
|
<Label Content="Login failed" Foreground="Red" Background="#FFFF" />
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,27 +11,28 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)DataParser.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)DataParser.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Hasher.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Hasher.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)MagicCode\WindowResizer.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)WPFStuff\MagicCode\FocusAdvancement.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)ObservableObject.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)WPFStuff\MagicCode\WindowResizer.cs" />
|
||||||
|
<Compile Include="$(MSBuildThisFileDirectory)WPFStuff\ObservableObject.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Page Include="$(MSBuildThisFileDirectory)Styles\Buttons.xaml">
|
<Page Include="$(MSBuildThisFileDirectory)WPFStuff\Styles\Buttons.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="$(MSBuildThisFileDirectory)Styles\Colors.xaml">
|
<Page Include="$(MSBuildThisFileDirectory)WPFStuff\Styles\Colors.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="$(MSBuildThisFileDirectory)Styles\Fonts.xaml">
|
<Page Include="$(MSBuildThisFileDirectory)WPFStuff\Styles\Fonts.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="$(MSBuildThisFileDirectory)Styles\Texts.xaml">
|
<Page Include="$(MSBuildThisFileDirectory)WPFStuff\Styles\Texts.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="$(MSBuildThisFileDirectory)Styles\Windows.xaml">
|
<Page Include="$(MSBuildThisFileDirectory)WPFStuff\Styles\Windows.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
|||||||
40
Hashing/WPFStuff/MagicCode/FocusAdvancement.cs
Normal file
40
Hashing/WPFStuff/MagicCode/FocusAdvancement.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
|
namespace Util.MagicCode
|
||||||
|
{
|
||||||
|
public static class FocusAdvancement
|
||||||
|
{
|
||||||
|
public static bool GetAdvancesByEnterKey(DependencyObject obj)
|
||||||
|
{
|
||||||
|
return (bool)obj.GetValue(AdvancesByEnterKeyProperty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetAdvancesByEnterKey(DependencyObject obj, bool value)
|
||||||
|
{
|
||||||
|
obj.SetValue(AdvancesByEnterKeyProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty AdvancesByEnterKeyProperty =
|
||||||
|
DependencyProperty.RegisterAttached("AdvancesByEnterKey", typeof(bool), typeof(FocusAdvancement),
|
||||||
|
new UIPropertyMetadata(OnAdvancesByEnterKeyPropertyChanged));
|
||||||
|
|
||||||
|
static void OnAdvancesByEnterKeyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
var element = d as UIElement;
|
||||||
|
if (element == null) return;
|
||||||
|
|
||||||
|
if ((bool)e.NewValue) element.KeyDown += Keydown;
|
||||||
|
else element.KeyDown -= Keydown;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Keydown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (!e.Key.Equals(Key.Enter)) return;
|
||||||
|
|
||||||
|
var element = sender as UIElement;
|
||||||
|
if (element != null) element.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
65
Hashing/WPFStuff/Styles/Buttons.xaml
Normal file
65
Hashing/WPFStuff/Styles/Buttons.xaml
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:ClientApp">
|
||||||
|
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="Colors.xaml"/>
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
|
||||||
|
<Style TargetType="{x:Type Button}" x:Key="Hoverless">
|
||||||
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type Button}">
|
||||||
|
<Border Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}">
|
||||||
|
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style TargetType="{x:Type Button}" x:Key="SystemIconButton" BasedOn="{StaticResource Hoverless}" >
|
||||||
|
<Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True"/>
|
||||||
|
<Setter Property="Padding" Value="4"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style TargetType="{x:Type Button}" x:Key="WindowControlButton">
|
||||||
|
<Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True"/>
|
||||||
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||||
|
<Setter Property="Foreground" Value="{StaticResource ForegroundMainBrush}"/>
|
||||||
|
<Setter Property="Padding" Value="6"/>
|
||||||
|
|
||||||
|
<Setter Property="LayoutTransform">
|
||||||
|
<Setter.Value>
|
||||||
|
<ScaleTransform ScaleX="2"/>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type Button}">
|
||||||
|
<Border Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}">
|
||||||
|
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter Property="Background" Value="{StaticResource BackgroundSemiLightBrush}"/>
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style TargetType="{x:Type Button}" x:Key="WindowCloseButton" BasedOn="{StaticResource WindowControlButton}">
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter Property="Background" Value="Red"/>
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</ResourceDictionary>
|
||||||
25
Hashing/WPFStuff/Styles/Colors.xaml
Normal file
25
Hashing/WPFStuff/Styles/Colors.xaml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:ClientApp">
|
||||||
|
|
||||||
|
<Color x:Key="BackgroundLight">#efefef</Color>
|
||||||
|
<SolidColorBrush x:Key="BackgroundLightBrush" Color="{StaticResource BackgroundLight}"/>
|
||||||
|
|
||||||
|
|
||||||
|
<Color x:Key="BackgroundVeryLight">#fafafa</Color>
|
||||||
|
<SolidColorBrush x:Key="BackgroundVeryLightBrush" Color="{StaticResource BackgroundVeryLight}"/>
|
||||||
|
|
||||||
|
<Color x:Key="BackgroundSemiLight">#d7d7d7</Color>
|
||||||
|
<SolidColorBrush x:Key="BackgroundSemiLightBrush" Color="{StaticResource BackgroundSemiLight}"/>
|
||||||
|
|
||||||
|
<Color x:Key="ForegroundMain">#686868</Color>
|
||||||
|
<SolidColorBrush x:Key="ForegroundMainBrush" Color="{StaticResource ForegroundMain}"/>
|
||||||
|
|
||||||
|
<Color x:Key="ForegroundVeryDark">#000</Color>
|
||||||
|
<SolidColorBrush x:Key="ForegroundVeryDarkBrush" Color="{StaticResource ForegroundVeryDark}"/>
|
||||||
|
|
||||||
|
<Color x:Key="ForegroundWhite">#fff</Color>
|
||||||
|
<SolidColorBrush x:Key="ForegroundWhiteBrush" Color="{StaticResource ForegroundWhite}"/>
|
||||||
|
|
||||||
|
|
||||||
|
</ResourceDictionary>
|
||||||
5
Hashing/WPFStuff/Styles/Fonts.xaml
Normal file
5
Hashing/WPFStuff/Styles/Fonts.xaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:ClientApp">
|
||||||
|
|
||||||
|
</ResourceDictionary>
|
||||||
11
Hashing/WPFStuff/Styles/Texts.xaml
Normal file
11
Hashing/WPFStuff/Styles/Texts.xaml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:ClientApp">
|
||||||
|
|
||||||
|
<Style TargetType="{x:Type TextBlock}" x:Key="HeaderText">
|
||||||
|
<Setter Property="Foreground" Value="{StaticResource ForegroundMainBrush}"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||||
|
<Setter Property="Margin" Value="0 4"/>
|
||||||
|
</Style>
|
||||||
|
</ResourceDictionary>
|
||||||
5
Hashing/WPFStuff/Styles/Windows.xaml
Normal file
5
Hashing/WPFStuff/Styles/Windows.xaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:ClientApp">
|
||||||
|
|
||||||
|
</ResourceDictionary>
|
||||||
@@ -109,7 +109,8 @@ namespace Hardware.Simulators
|
|||||||
|
|
||||||
private byte check(int value)
|
private byte check(int value)
|
||||||
{
|
{
|
||||||
return value > 255 ? Convert.ToByte(255) : Convert.ToByte(value);
|
|
||||||
|
return value > 255 ? Convert.ToByte(255) : value < 0 ? Convert.ToByte(0) : Convert.ToByte(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Generate an ANT message for BPM
|
//Generate an ANT message for BPM
|
||||||
|
|||||||
@@ -124,11 +124,13 @@ namespace RH_Engine
|
|||||||
position = new float[]
|
position = new float[]
|
||||||
{
|
{
|
||||||
-1.5f, 1f, 0f
|
-1.5f, 1f, 0f
|
||||||
|
//0f,0f,0f
|
||||||
},
|
},
|
||||||
scale = 1,
|
scale = 1,
|
||||||
rotation = new int[]
|
rotation = new int[]
|
||||||
{
|
{
|
||||||
-30, 90,0
|
-30, 90,0
|
||||||
|
//0,0,0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
panel = new
|
panel = new
|
||||||
@@ -253,6 +255,11 @@ namespace RH_Engine
|
|||||||
return AddModel("bike", serial, "data\\NetworkEngine\\models\\bike\\bike.fbx");
|
return AddModel("bike", serial, "data\\NetworkEngine\\models\\bike\\bike.fbx");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string AddBikeModelAnim(string serial, float scalar)
|
||||||
|
{
|
||||||
|
return AddModel("bike", serial, "data\\NetworkEngine\\models\\bike\\bike_anim.fbx", "Armature|Fietsen", new float[] { 0, 0, 0 }, scalar, new float[] { 0, 0, 0 });
|
||||||
|
}
|
||||||
|
|
||||||
public string AddModel(string nodeName, string serial, string fileLocation)
|
public string AddModel(string nodeName, string serial, string fileLocation)
|
||||||
{
|
{
|
||||||
return AddModel(nodeName, serial, fileLocation, null, new float[] { 0, 0, 0 }, 1, new float[] { 0, 0, 0 });
|
return AddModel(nodeName, serial, fileLocation, null, new float[] { 0, 0, 0 }, 1, new float[] { 0, 0, 0 });
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ namespace RH_Engine
|
|||||||
if (serialResponses.ContainsKey(serial))
|
if (serialResponses.ContainsKey(serial))
|
||||||
{
|
{
|
||||||
serialResponses[serial].Invoke(message);
|
serialResponses[serial].Invoke(message);
|
||||||
serialResponses.Remove(serial);
|
//serialResponses.Remove(serial);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,39 +181,41 @@ namespace RH_Engine
|
|||||||
//Force(stream, mainCommand.DeleteNode(handRightId, "deleteHandR"), "deleteHandR", (message) => Console.WriteLine("Right hand deleted"));
|
//Force(stream, mainCommand.DeleteNode(handRightId, "deleteHandR"), "deleteHandR", (message) => Console.WriteLine("Right hand deleted"));
|
||||||
});
|
});
|
||||||
|
|
||||||
CreateTerrain(stream, mainCommand);
|
//CreateTerrain(stream, mainCommand);
|
||||||
|
|
||||||
//Add route, bike and put camera and bike to follow route at same speed.
|
//Add route, bike and put camera and bike to follow route at same speed.
|
||||||
SendMessageAndOnResponse(stream, mainCommand.RouteCommand("routeID"), "routeID", (message) => routeId = JSONParser.GetResponseUuid(message));
|
//SendMessageAndOnResponse(stream, mainCommand.RouteCommand("routeID"), "routeID", (message) => routeId = JSONParser.GetResponseUuid(message));
|
||||||
SendMessageAndOnResponse(stream, mainCommand.AddBikeModel("bikeID"), "bikeID",
|
SendMessageAndOnResponse(stream, mainCommand.AddBikeModelAnim("bikeID",0.01f), "bikeID",
|
||||||
(message) =>
|
(message) =>
|
||||||
{
|
{
|
||||||
bikeId = JSONParser.GetResponseUuid(message);
|
bikeId = JSONParser.GetResponseUuid(message);
|
||||||
|
Console.WriteLine("got bike id " + bikeId);
|
||||||
SendMessageAndOnResponse(stream, mainCommand.addPanel("panelAdd", bikeId), "panelAdd",
|
SendMessageAndOnResponse(stream, mainCommand.addPanel("panelAdd", bikeId), "panelAdd",
|
||||||
(message) =>
|
(message) =>
|
||||||
{
|
{
|
||||||
bool speedReplied = false;
|
bool speedReplied = false;
|
||||||
bool moveReplied = true;
|
bool moveReplied = true;
|
||||||
|
Console.WriteLine(message);
|
||||||
panelId = JSONParser.getPanelID(message);
|
panelId = JSONParser.getPanelID(message);
|
||||||
|
Console.WriteLine("got panel id " + panelId);
|
||||||
showPanel(stream, mainCommand);
|
showPanel(stream, mainCommand);
|
||||||
|
|
||||||
|
|
||||||
//while (!(speedReplied && moveReplied)) { }
|
//while (!(speedReplied && moveReplied)) { }
|
||||||
|
|
||||||
while (cameraId == string.Empty) { }
|
//while (cameraId == string.Empty) { }
|
||||||
SetFollowSpeed(5.0f, stream, mainCommand);
|
//SetFollowSpeed(5.0f, stream, mainCommand);
|
||||||
WriteTextMessage(stream, mainCommand.RoadCommand(routeId, "road"));
|
//WriteTextMessage(stream, mainCommand.RoadCommand(routeId, "road"));
|
||||||
WriteTextMessage(stream, mainCommand.ShowRoute("showRouteFalse", false));
|
//WriteTextMessage(stream, mainCommand.ShowRoute("showRouteFalse", false));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
string groundplaneId = GetId("GroundPlane", stream, mainCommand);
|
//string groundplaneId = GetId("GroundPlane", stream, mainCommand);
|
||||||
WriteTextMessage(stream, mainCommand.DeleteNode(groundplaneId, "none"));
|
//WriteTextMessage(stream, mainCommand.DeleteNode(groundplaneId, "none"));
|
||||||
|
|
||||||
PlaceHouses(stream, mainCommand);
|
//PlaceHouses(stream, mainCommand);
|
||||||
|
|
||||||
WriteTextMessage(stream, mainCommand.SkyboxCommand(DateTime.Now.Hour));
|
//WriteTextMessage(stream, mainCommand.SkyboxCommand(DateTime.Now.Hour));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,31 +345,36 @@ namespace RH_Engine
|
|||||||
|
|
||||||
private static void showPanel(NetworkStream stream, Command mainCommand)
|
private static void showPanel(NetworkStream stream, Command mainCommand)
|
||||||
{
|
{
|
||||||
WriteTextMessage(stream, mainCommand.ColorPanel(panelId));
|
//WriteTextMessage(stream, mainCommand.ColorPanel(panelId));
|
||||||
WriteTextMessage(stream, mainCommand.ClearPanel(panelId));
|
WriteTextMessage(stream, mainCommand.ClearPanel(panelId));
|
||||||
SendMessageAndOnResponse(stream, mainCommand.showBikespeed(panelId, "bikeSpeed", bikeSpeed), "bikeSpeed",
|
SendMessageAndOnResponse(stream, mainCommand.showBikespeed(panelId, "bikeSpeed", bikeSpeed), "bikeSpeed",
|
||||||
(message) =>
|
(message) =>
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(message);
|
||||||
// TODO check if is drawn
|
// TODO check if is drawn
|
||||||
});
|
});
|
||||||
SendMessageAndOnResponse(stream, mainCommand.showHeartrate(panelId, "bpm", bpm), "bpm",
|
SendMessageAndOnResponse(stream, mainCommand.showHeartrate(panelId, "bpm", bpm), "bpm",
|
||||||
(message) =>
|
(message) =>
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(message);
|
||||||
// TODO check if is drawn
|
// TODO check if is drawn
|
||||||
});
|
});
|
||||||
SendMessageAndOnResponse(stream, mainCommand.showPower(panelId, "power", power), "power",
|
SendMessageAndOnResponse(stream, mainCommand.showPower(panelId, "power", power), "power",
|
||||||
(message) =>
|
(message) =>
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(message);
|
||||||
// TODO check if is drawn
|
// TODO check if is drawn
|
||||||
});
|
});
|
||||||
SendMessageAndOnResponse(stream, mainCommand.showResistance(panelId, "resistance", resistance), "resistance",
|
SendMessageAndOnResponse(stream, mainCommand.showResistance(panelId, "resistance", resistance), "resistance",
|
||||||
(message) =>
|
(message) =>
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(message);
|
||||||
// TODO check if is drawn
|
// TODO check if is drawn
|
||||||
});
|
});
|
||||||
SendMessageAndOnResponse(stream, mainCommand.showMessage(panelId, "message", lastMessage), "message",
|
SendMessageAndOnResponse(stream, mainCommand.showMessage(panelId, "message", lastMessage), "message",
|
||||||
(message) =>
|
(message) =>
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(message);
|
||||||
// TODO check if is drawn
|
// TODO check if is drawn
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Timers;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Util;
|
using Util;
|
||||||
|
|
||||||
@@ -21,6 +22,9 @@ namespace Server
|
|||||||
public string username = null;
|
public string username = null;
|
||||||
private DateTime sessionStart;
|
private DateTime sessionStart;
|
||||||
private string fileName;
|
private string fileName;
|
||||||
|
private Timer timer;
|
||||||
|
private byte[] BikeDataBuffer;
|
||||||
|
private byte[] BPMDataBuffer;
|
||||||
|
|
||||||
public Client(Communication communication, TcpClient tcpClient)
|
public Client(Communication communication, TcpClient tcpClient)
|
||||||
{
|
{
|
||||||
@@ -29,6 +33,12 @@ namespace Server
|
|||||||
this.tcpClient = tcpClient;
|
this.tcpClient = tcpClient;
|
||||||
this.stream = this.tcpClient.GetStream();
|
this.stream = this.tcpClient.GetStream();
|
||||||
this.fileName = Directory.GetCurrentDirectory() + "/userInfo.dat";
|
this.fileName = Directory.GetCurrentDirectory() + "/userInfo.dat";
|
||||||
|
this.timer = new Timer();
|
||||||
|
this.BikeDataBuffer = new byte[16];
|
||||||
|
this.BPMDataBuffer = new byte[2];
|
||||||
|
this.timer.Interval = 1000;
|
||||||
|
this.timer.AutoReset = true;
|
||||||
|
this.timer.Elapsed += SendDataToDoctor;
|
||||||
stream.BeginRead(buffer, 0, buffer.Length, new AsyncCallback(OnRead), null);
|
stream.BeginRead(buffer, 0, buffer.Length, new AsyncCallback(OnRead), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,9 +124,11 @@ namespace Server
|
|||||||
break;
|
break;
|
||||||
case DataParser.START_SESSION:
|
case DataParser.START_SESSION:
|
||||||
this.communication.StartSessionUser(DataParser.getUsernameFromJson(payloadbytes));
|
this.communication.StartSessionUser(DataParser.getUsernameFromJson(payloadbytes));
|
||||||
|
this.timer.Start();
|
||||||
break;
|
break;
|
||||||
case DataParser.STOP_SESSION:
|
case DataParser.STOP_SESSION:
|
||||||
this.communication.StopSessionUser(DataParser.getUsernameFromJson(payloadbytes));
|
this.communication.StopSessionUser(DataParser.getUsernameFromJson(payloadbytes));
|
||||||
|
this.timer.Stop();
|
||||||
break;
|
break;
|
||||||
case DataParser.SET_RESISTANCE:
|
case DataParser.SET_RESISTANCE:
|
||||||
//bool worked = DataParser.getResistanceFromResponseJson(payloadbytes);
|
//bool worked = DataParser.getResistanceFromResponseJson(payloadbytes);
|
||||||
@@ -143,13 +155,15 @@ namespace Server
|
|||||||
else if (DataParser.isRawDataBikeServer(message))
|
else if (DataParser.isRawDataBikeServer(message))
|
||||||
{
|
{
|
||||||
saveData?.WriteDataRAWBike(payloadbytes);
|
saveData?.WriteDataRAWBike(payloadbytes);
|
||||||
|
Array.Copy(this.BikeDataBuffer, 0, this.BikeDataBuffer, 8, 8);
|
||||||
|
Array.Copy(payloadbytes, 0, this.BikeDataBuffer, 0, 8);
|
||||||
}
|
}
|
||||||
else if (DataParser.isRawDataBPMServer(message))
|
else if (DataParser.isRawDataBPMServer(message))
|
||||||
{
|
{
|
||||||
saveData?.WriteDataRAWBPM(payloadbytes);
|
saveData?.WriteDataRAWBPM(payloadbytes);
|
||||||
|
Array.Copy(payloadbytes, 0, this.BikeDataBuffer, 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool handleLogin(byte[] payloadbytes)
|
private bool handleLogin(byte[] payloadbytes)
|
||||||
@@ -247,5 +261,12 @@ namespace Server
|
|||||||
{
|
{
|
||||||
this.saveData = null;
|
this.saveData = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SendDataToDoctor(object sender, ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
this.communication.Doctor?.sendMessage(DataParser.GetRawBikeDataDoctor(this.BikeDataBuffer.Take(8).ToArray(), this.username));
|
||||||
|
this.communication.Doctor?.sendMessage(DataParser.GetRawBikeDataDoctor(this.BikeDataBuffer.Skip(8).ToArray(), this.username));
|
||||||
|
this.communication.Doctor?.sendMessage(DataParser.GetRawBikeDataDoctor(this.BikeDataBuffer, this.username));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user