Develop #10

Merged
SemvdH merged 229 commits from develop into master 2020-10-29 22:50:49 +00:00
7 changed files with 30 additions and 11 deletions
Showing only changes of commit 8e48fe7902 - Show all commits

View File

@@ -9,7 +9,7 @@ namespace ClientApp.ViewModels
{ {
public ICommand RetryServerCommand { get; set; } public ICommand RetryServerCommand { get; set; }
public ICommand RetryVREngineCommand { get; set; } public ICommand RetryVREngineCommand { get; set; }
public MainWindowViewModel MainWindowViewModel; public MainWindowViewModel MainWindowViewModel { get; set; }
public MainViewModel(MainWindowViewModel mainWindowViewModel) public MainViewModel(MainWindowViewModel mainWindowViewModel)

View File

@@ -21,7 +21,7 @@
<StackPanel Grid.Column="0" Grid.Row="0" Orientation="Horizontal" Margin="10"> <StackPanel Grid.Column="0" Grid.Row="0" Orientation="Horizontal" Margin="10">
<Label Content="Connected to server:"/> <Label Content="Connected to server:"/>
<Label Content="{Binding Path=MainWindowViewModel.InfoModel.ConnectedToServer}"/> <Label Content="true"/>
</StackPanel> </StackPanel>
<StackPanel Grid.Column="1" Grid.Row="0" Orientation="Horizontal" Margin="10"> <StackPanel Grid.Column="1" Grid.Row="0" Orientation="Horizontal" Margin="10">

View File

@@ -16,6 +16,7 @@ using System.Windows.Shapes;
using ClientApp.Utils; using ClientApp.Utils;
using Hardware.Simulators; using Hardware.Simulators;
using System.Threading; using System.Threading;
using ProftaakRH;
namespace ClientApp namespace ClientApp
{ {
@@ -24,31 +25,33 @@ namespace ClientApp
/// </summary> /// </summary>
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
private IHandler handler;
public MainWindow() public MainWindow()
{ {
Client client = new Client(); Client client = new Client();
InitializeComponent(); InitializeComponent();
DataContext = new MainWindowViewModel(client); DataContext = new MainWindowViewModel(client);
//BLEHandler bLEHandler = new BLEHandler(client); //BLEHandler bLEHandler = new BLEHandler(client);
//bLEHandler.Connect(); //bLEHandler.Connect();
//client.setHandler(bLEHandler); //client.setHandler(bLEHandler);
BikeSimulator bikeSimulator = new BikeSimulator(client); BikeSimulator bikeSimulator = new BikeSimulator(client);
Thread newThread = new Thread(new ThreadStart(bikeSimulator.StartSimulation)); Thread newThread = new Thread(new ThreadStart(bikeSimulator.StartSimulation));
newThread.Start(); newThread.Start();
client.SetHandler(bikeSimulator); client.SetHandler(bikeSimulator);
handler = bikeSimulator;
}
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
handler.stop();
} }
} }
} }

View File

@@ -203,5 +203,11 @@ namespace Hardware
bleBike.WriteCharacteristic("6e40fec3-b5a3-f393-e0a9-e50e24dcca9e", antMessage); bleBike.WriteCharacteristic("6e40fec3-b5a3-f393-e0a9-e50e24dcca9e", antMessage);
} }
public void stop()
{
bleBike.SubscriptionValueChanged -= BleBike_SubscriptionValueChanged;
bleHeart.SubscriptionValueChanged -= BleBike_SubscriptionValueChanged;
}
} }
} }

View File

@@ -28,6 +28,8 @@ namespace Hardware.Simulators
byte[] powerArray; byte[] powerArray;
byte[] accPowerArray; byte[] accPowerArray;
bool running = false;
public BikeSimulator(IDataReceiver dataReceiver) public BikeSimulator(IDataReceiver dataReceiver)
@@ -51,12 +53,14 @@ namespace Hardware.Simulators
//Example BLE Message //Example BLE Message
//4A-09-4E-05-19-16-00-FF-28-00-00-20-F0 //4A-09-4E-05-19-16-00-FF-28-00-00-20-F0
this.running = true;
float x = 0.0f; float x = 0.0f;
//Perlin for Random values //Perlin for Random values
ImprovedPerlin improvedPerlin = new ImprovedPerlin(0, LibNoise.NoiseQuality.Best); ImprovedPerlin improvedPerlin = new ImprovedPerlin(0, LibNoise.NoiseQuality.Best);
while (true) while (this.running)
{ {
CalculateVariables(improvedPerlin.GetValue(x) + 1); CalculateVariables(improvedPerlin.GetValue(x) + 1);
@@ -124,6 +128,10 @@ namespace Hardware.Simulators
this.resistance = (byte)Math.Max(Math.Min(Math.Round(percentage / 0.5), 255), 0); this.resistance = (byte)Math.Max(Math.Min(Math.Round(percentage / 0.5), 255), 0);
} }
public void stop()
{
this.running = false;
}
} }
} }

View File

@@ -7,5 +7,7 @@ namespace ProftaakRH
public interface IHandler public interface IHandler
{ {
void setResistance(float percentage); void setResistance(float percentage);
void stop();
} }
} }

View File

@@ -1,4 +1,4 @@
using Client; using ClientApp.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO.Pipes; using System.IO.Pipes;