Merge remote-tracking branch 'origin/develop' into dataOnTabs
This commit is contained in:
@@ -43,6 +43,7 @@ namespace ClientApp.Utils
|
||||
/// </summary>
|
||||
private void initEngine()
|
||||
{
|
||||
Debug.WriteLine("init engine");
|
||||
engineConnection = EngineConnection.INSTANCE;
|
||||
engineConnection.OnNoTunnelId = RetryEngineConnection;
|
||||
engineConnection.OnSuccessFullConnection = engineConnected;
|
||||
@@ -88,6 +89,7 @@ namespace ClientApp.Utils
|
||||
/// <param name="ar">the result of the async read</param>
|
||||
private void OnRead(IAsyncResult ar)
|
||||
{
|
||||
Debug.WriteLine("got message in client app");
|
||||
if (ar == null || (!ar.IsCompleted) || (!this.stream.CanRead))
|
||||
return;
|
||||
|
||||
@@ -136,7 +138,7 @@ namespace ClientApp.Utils
|
||||
}
|
||||
break;
|
||||
case DataParser.START_SESSION:
|
||||
Console.WriteLine("Session started!");
|
||||
Debug.WriteLine("Session started!");
|
||||
this.sessionRunning = true;
|
||||
if (engineConnection.Connected && !engineConnection.FollowingRoute) engineConnection.StartRouteFollow();
|
||||
Debug.WriteLine("start");
|
||||
@@ -147,18 +149,33 @@ namespace ClientApp.Utils
|
||||
Debug.WriteLine("stop");
|
||||
break;
|
||||
case DataParser.SET_RESISTANCE:
|
||||
Console.WriteLine("Set resistance identifier");
|
||||
Debug.WriteLine("Set resistance identifier");
|
||||
if (this.handler == null)
|
||||
{
|
||||
Console.WriteLine("handler is null");
|
||||
// send that the operation was not successful if the handler is null
|
||||
Debug.WriteLine("handler is null");
|
||||
sendMessage(DataParser.getSetResistanceResponseJson(false));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.handler.setResistance(DataParser.getResistanceFromJson(payloadbytes));
|
||||
// set the resistance in the vr scene and send that it was successful
|
||||
float resistance = DataParser.getResistanceFromJson(payloadbytes);
|
||||
Debug.WriteLine("resistance set was " + resistance);
|
||||
this.handler.setResistance(resistance);
|
||||
engineConnection.BikeResistance = resistance;
|
||||
sendMessage(DataParser.getSetResistanceResponseJson(true));
|
||||
}
|
||||
break;
|
||||
case DataParser.MESSAGE:
|
||||
Debug.WriteLine("client has received message from doctor");
|
||||
engineConnection.DoctorMessage = DataParser.getChatMessageFromJson(payloadbytes);
|
||||
break;
|
||||
case DataParser.NEW_CONNECTION:
|
||||
this.LoginViewModel.DoctorConnected(DataParser.getUsernameFromJson(payloadbytes));
|
||||
break;
|
||||
case DataParser.DISCONNECT:
|
||||
this.LoginViewModel.DoctorDisconnected(DataParser.getUsernameFromJson(payloadbytes));
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine($"Received json with identifier {identifier}:\n{Encoding.ASCII.GetString(payloadbytes)}");
|
||||
break;
|
||||
|
||||
@@ -43,8 +43,8 @@ namespace ClientApp.Utils
|
||||
private static string headId = string.Empty;
|
||||
private static string groundPlaneId = string.Empty;
|
||||
private static string terrainId = string.Empty;
|
||||
private static string lastMessage = "No message received yet";
|
||||
|
||||
public string DoctorMessage { get; set; }
|
||||
public float BikeSpeed { get; set; }
|
||||
public float BikePower { get; set; }
|
||||
public float BikeBPM { get; set; }
|
||||
@@ -65,6 +65,7 @@ namespace ClientApp.Utils
|
||||
BikePower = 0;
|
||||
BikeBPM = 0;
|
||||
BikeResistance = 50;
|
||||
DoctorMessage = "No message received yet";
|
||||
updateTimer = new System.Timers.Timer(1000);
|
||||
updateTimer.Elapsed += UpdateTimer_Elapsed;
|
||||
updateTimer.AutoReset = true;
|
||||
@@ -74,7 +75,7 @@ namespace ClientApp.Utils
|
||||
noVRResponseTimer.Elapsed += noVRResponseTimeout;
|
||||
noVRResponseTimer.AutoReset = false;
|
||||
noVRResponseTimer.Enabled = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void UpdateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
@@ -224,7 +225,6 @@ namespace ClientApp.Utils
|
||||
string handLeftId = JSONParser.GetIdSceneInfoChild(message, "LeftHand");
|
||||
string handRightId = JSONParser.GetIdSceneInfoChild(message, "RightHand");
|
||||
groundPlaneId = JSONParser.GetIdSceneInfoChild(message, "GroundPlane");
|
||||
Write("--- Ground plane id is " + groundPlaneId);
|
||||
});
|
||||
// add the route and set the route id
|
||||
CreateTerrain();
|
||||
@@ -324,7 +324,7 @@ namespace ClientApp.Utils
|
||||
{
|
||||
// TODO check if is drawn
|
||||
});
|
||||
SendMessageAndOnResponse(mainCommand.showMessage(panelId, "message", lastMessage), "message",
|
||||
SendMessageAndOnResponse(mainCommand.showMessage(panelId, "message", DoctorMessage), "message",
|
||||
(message) =>
|
||||
{
|
||||
// TODO check if is drawn
|
||||
@@ -337,6 +337,7 @@ namespace ClientApp.Utils
|
||||
|
||||
private void SetFollowSpeed(float speed)
|
||||
{
|
||||
Write("starting route follow");
|
||||
WriteTextMessage(mainCommand.RouteFollow(routeId, bikeId, speed, new float[] { 0, -(float)Math.PI / 2f, 0 }, new float[] { 0, 0, 0 }));
|
||||
WriteTextMessage(mainCommand.RouteFollow(routeId, cameraId, speed));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user