Merge branch 'develop' into try-refactor-to-page
This commit is contained in:
@@ -10,5 +10,7 @@ namespace ClientApp.Models
|
|||||||
public bool ConnectedToServer { get; set; }
|
public bool ConnectedToServer { get; set; }
|
||||||
public bool ConnectedToVREngine { get; set; }
|
public bool ConnectedToVREngine { get; set; }
|
||||||
public bool DoctorConnected { get; set; }
|
public bool DoctorConnected { get; set; }
|
||||||
|
|
||||||
|
public bool CanConnectToVR { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,15 +8,18 @@ using ProftaakRH;
|
|||||||
|
|
||||||
namespace ClientApp.Utils
|
namespace ClientApp.Utils
|
||||||
{
|
{
|
||||||
|
public delegate void EngineCallback();
|
||||||
public class Client : IDataReceiver
|
public class Client : IDataReceiver
|
||||||
{
|
{
|
||||||
|
public EngineCallback engineConnectFailed;
|
||||||
|
public EngineCallback engineConnectSuccess;
|
||||||
private TcpClient client;
|
private TcpClient client;
|
||||||
private NetworkStream stream;
|
private NetworkStream stream;
|
||||||
private byte[] buffer = new byte[1024];
|
private byte[] buffer = new byte[1024];
|
||||||
private bool connected;
|
private bool connected;
|
||||||
private byte[] totalBuffer = new byte[1024];
|
private byte[] totalBuffer = new byte[1024];
|
||||||
private int totalBufferReceived = 0;
|
private int totalBufferReceived = 0;
|
||||||
private EngineConnection engineConnection;
|
public EngineConnection engineConnection;
|
||||||
private bool sessionRunning = false;
|
private bool sessionRunning = false;
|
||||||
private IHandler handler = null;
|
private IHandler handler = null;
|
||||||
private LoginViewModel LoginViewModel;
|
private LoginViewModel LoginViewModel;
|
||||||
@@ -40,7 +43,7 @@ namespace ClientApp.Utils
|
|||||||
private void initEngine()
|
private void initEngine()
|
||||||
{
|
{
|
||||||
engineConnection = EngineConnection.INSTANCE;
|
engineConnection = EngineConnection.INSTANCE;
|
||||||
engineConnection.OnNoTunnelId = retryEngineConnection;
|
engineConnection.OnNoTunnelId = RetryEngineConnection;
|
||||||
engineConnection.OnSuccessFullConnection = engineConnected;
|
engineConnection.OnSuccessFullConnection = engineConnected;
|
||||||
if (!engineConnection.Connected) engineConnection.Connect();
|
if (!engineConnection.Connected) engineConnection.Connect();
|
||||||
}
|
}
|
||||||
@@ -48,24 +51,16 @@ namespace ClientApp.Utils
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// retries to connect to the VR engine if no tunnel id was found
|
/// retries to connect to the VR engine if no tunnel id was found
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void retryEngineConnection()
|
public void RetryEngineConnection()
|
||||||
{
|
{
|
||||||
Console.WriteLine("-- Could not connect to the VR engine. Please make sure you are running the simulation!");
|
engineConnectFailed?.Invoke();
|
||||||
Console.WriteLine("-- Press ENTER to retry connecting to the VR engine.");
|
|
||||||
Console.WriteLine("-- Press 'q' and then ENTER to not connect to the VR engine");
|
|
||||||
string input = Console.ReadLine();
|
|
||||||
if (input == string.Empty) engineConnection.CreateConnection();
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("Skipping connecting to VR engine...");
|
|
||||||
engineConnection.Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void engineConnected()
|
private void engineConnected()
|
||||||
{
|
{
|
||||||
Console.WriteLine("successfully connected to VR engine");
|
Console.WriteLine("successfully connected to VR engine");
|
||||||
|
engineConnectSuccess?.Invoke();
|
||||||
engineConnection.initScene();
|
engineConnection.initScene();
|
||||||
if (engineConnection.Connected && sessionRunning && !engineConnection.FollowingRoute) engineConnection.StartRouteFollow();
|
if (engineConnection.Connected && sessionRunning && !engineConnection.FollowingRoute) engineConnection.StartRouteFollow();
|
||||||
}
|
}
|
||||||
@@ -126,6 +121,7 @@ namespace ClientApp.Utils
|
|||||||
this.LoginViewModel.setLoginStatus(true);
|
this.LoginViewModel.setLoginStatus(true);
|
||||||
this.connected = true;
|
this.connected = true;
|
||||||
initEngine();
|
initEngine();
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,7 +14,11 @@ namespace ClientApp.ViewModels
|
|||||||
{
|
{
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
public ICommand LoginCommand { get; set; }
|
public ICommand LoginCommand { get; set; }
|
||||||
|
|
||||||
|
public bool LoginStatus { get; set; }
|
||||||
|
|
||||||
public bool InvertedLoginStatus { get; set; }
|
public bool InvertedLoginStatus { get; set; }
|
||||||
|
|
||||||
private MainWindowViewModel mainWindowViewModel;
|
private MainWindowViewModel mainWindowViewModel;
|
||||||
public LoginViewModel(MainWindowViewModel mainWindowViewModel)
|
public LoginViewModel(MainWindowViewModel mainWindowViewModel)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,10 +11,14 @@ namespace ClientApp.ViewModels
|
|||||||
public ICommand RetryVREngineCommand { get; set; }
|
public ICommand RetryVREngineCommand { get; set; }
|
||||||
public MainWindowViewModel MainWindowViewModel { get; set; }
|
public MainWindowViewModel MainWindowViewModel { get; set; }
|
||||||
|
|
||||||
|
private Client client;
|
||||||
|
|
||||||
public MainViewModel(MainWindowViewModel mainWindowViewModel)
|
public MainViewModel(MainWindowViewModel mainWindowViewModel)
|
||||||
{
|
{
|
||||||
this.MainWindowViewModel = mainWindowViewModel;
|
this.MainWindowViewModel = mainWindowViewModel;
|
||||||
|
client = this.MainWindowViewModel.client;
|
||||||
|
client.engineConnectFailed = retryEngineConnection;
|
||||||
|
client.engineConnectSuccess = succesEngineConnection;
|
||||||
this.RetryServerCommand = new RelayCommand(() =>
|
this.RetryServerCommand = new RelayCommand(() =>
|
||||||
{
|
{
|
||||||
//try connect server
|
//try connect server
|
||||||
@@ -23,8 +27,28 @@ namespace ClientApp.ViewModels
|
|||||||
this.RetryVREngineCommand = new RelayCommand(() =>
|
this.RetryVREngineCommand = new RelayCommand(() =>
|
||||||
{
|
{
|
||||||
//try connect vr-engine
|
//try connect vr-engine
|
||||||
|
|
||||||
this.MainWindowViewModel.InfoModel.ConnectedToVREngine = true;
|
this.MainWindowViewModel.InfoModel.ConnectedToVREngine = true;
|
||||||
|
this.MainWindowViewModel.InfoModel.CanConnectToVR = false;
|
||||||
|
client.engineConnection.CreateConnection();
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void retryEngineConnection()
|
||||||
|
{
|
||||||
|
this.MainWindowViewModel.InfoModel.ConnectedToVREngine = false;
|
||||||
|
this.MainWindowViewModel.InfoModel.CanConnectToVR = true;
|
||||||
|
client.engineConnection.CreateConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void succesEngineConnection()
|
||||||
|
{
|
||||||
|
this.MainWindowViewModel.InfoModel.ConnectedToVREngine = true;
|
||||||
|
this.MainWindowViewModel.InfoModel.CanConnectToVR = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
</Button.Content>
|
</Button.Content>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button Grid.Column="1" Grid.Row="1" Command="{Binding RetryVREngineCommand}" Width="50" Height="20">
|
<Button Grid.Column="1" Grid.Row="1" Command="{Binding RetryVREngineCommand}" Width="50" Height="20" IsEnabled="{Binding MainWindowViewModel.InfoModel.CanConnectToVR}">
|
||||||
<Button.Content>
|
<Button.Content>
|
||||||
<TextBlock TextWrapping="Wrap" Text="retry"/>
|
<TextBlock TextWrapping="Wrap" Text="retry"/>
|
||||||
</Button.Content>
|
</Button.Content>
|
||||||
|
|||||||
@@ -215,6 +215,11 @@ namespace RH_Engine
|
|||||||
return showOnPanel(uuidPanel, serialCode, "Resistance: " + resistance + " %", 3);
|
return showOnPanel(uuidPanel, serialCode, "Resistance: " + resistance + " %", 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string showMessage(string uuidPanel, string serialCode, string message)
|
||||||
|
{
|
||||||
|
return showOnPanel(uuidPanel, serialCode, "Last message: " + message, 5);
|
||||||
|
}
|
||||||
|
|
||||||
public string SwapPanelCommand(string uuid)
|
public string SwapPanelCommand(string uuid)
|
||||||
{
|
{
|
||||||
dynamic payload = new
|
dynamic payload = new
|
||||||
|
|||||||
@@ -36,6 +36,12 @@ namespace RH_Engine
|
|||||||
private static string bikeId = string.Empty;
|
private static string bikeId = string.Empty;
|
||||||
private static string headId = string.Empty;
|
private static string headId = string.Empty;
|
||||||
|
|
||||||
|
private static double bikeSpeed = 6.66;
|
||||||
|
private static int bpm = 6;
|
||||||
|
private static int power = 6;
|
||||||
|
private static int resistance = 6;
|
||||||
|
private static string lastMessage = "No message received yet";
|
||||||
|
|
||||||
private static Dictionary<string, HandleSerial> serialResponses = new Dictionary<string, HandleSerial>();
|
private static Dictionary<string, HandleSerial> serialResponses = new Dictionary<string, HandleSerial>();
|
||||||
|
|
||||||
private static void Main(string[] args)
|
private static void Main(string[] args)
|
||||||
@@ -189,11 +195,8 @@ namespace RH_Engine
|
|||||||
bool speedReplied = false;
|
bool speedReplied = false;
|
||||||
bool moveReplied = true;
|
bool moveReplied = true;
|
||||||
panelId = JSONParser.getPanelID(message);
|
panelId = JSONParser.getPanelID(message);
|
||||||
WriteTextMessage(stream, mainCommand.ColorPanel(panelId));
|
|
||||||
WriteTextMessage(stream, mainCommand.ClearPanel(panelId));
|
showPanel(stream, mainCommand);
|
||||||
|
|
||||||
|
|
||||||
showPanel(stream, mainCommand, 5.3, 83, 52, 53);
|
|
||||||
|
|
||||||
|
|
||||||
//while (!(speedReplied && moveReplied)) { }
|
//while (!(speedReplied && moveReplied)) { }
|
||||||
@@ -338,8 +341,10 @@ namespace RH_Engine
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void showPanel(NetworkStream stream, Command mainCommand, double bikeSpeed, int bpm, int power, int resistance)
|
private static void showPanel(NetworkStream stream, Command mainCommand)
|
||||||
{
|
{
|
||||||
|
WriteTextMessage(stream, mainCommand.ColorPanel(panelId));
|
||||||
|
WriteTextMessage(stream, mainCommand.ClearPanel(panelId));
|
||||||
SendMessageAndOnResponse(stream, mainCommand.showBikespeed(panelId, "bikeSpeed", bikeSpeed), "bikeSpeed",
|
SendMessageAndOnResponse(stream, mainCommand.showBikespeed(panelId, "bikeSpeed", bikeSpeed), "bikeSpeed",
|
||||||
(message) =>
|
(message) =>
|
||||||
{
|
{
|
||||||
@@ -360,6 +365,11 @@ namespace RH_Engine
|
|||||||
{
|
{
|
||||||
// TODO check if is drawn
|
// TODO check if is drawn
|
||||||
});
|
});
|
||||||
|
SendMessageAndOnResponse(stream, mainCommand.showMessage(panelId, "message", lastMessage), "message",
|
||||||
|
(message) =>
|
||||||
|
{
|
||||||
|
// TODO check if is drawn
|
||||||
|
});
|
||||||
|
|
||||||
// Check if every text is drawn!
|
// Check if every text is drawn!
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user