merged client and clientapp
This commit is contained in:
@@ -212,7 +212,7 @@ namespace ClientApp.Utils
|
|||||||
if (engineConnection.Connected && engineConnection.FollowingRoute)
|
if (engineConnection.Connected && engineConnection.FollowingRoute)
|
||||||
{
|
{
|
||||||
engineConnection.BikeBPM = bytes[1];
|
engineConnection.BikeBPM = bytes[1];
|
||||||
engineConnection.UpdateInfoPanel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -225,6 +225,7 @@ namespace ClientApp.Utils
|
|||||||
/// <param name="bytes">the message</param>
|
/// <param name="bytes">the message</param>
|
||||||
public void Bike(byte[] bytes)
|
public void Bike(byte[] bytes)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!sessionRunning)
|
if (!sessionRunning)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -234,18 +235,19 @@ namespace ClientApp.Utils
|
|||||||
throw new ArgumentNullException("no bytes");
|
throw new ArgumentNullException("no bytes");
|
||||||
}
|
}
|
||||||
byte[] message = DataParser.GetRawDataMessage(bytes);
|
byte[] message = DataParser.GetRawDataMessage(bytes);
|
||||||
|
bool canSendToEngine = engineConnection.Connected && engineConnection.FollowingRoute;
|
||||||
switch (bytes[0])
|
switch (bytes[0])
|
||||||
{
|
{
|
||||||
|
|
||||||
case 0x10:
|
case 0x10:
|
||||||
|
|
||||||
engineConnection.BikeSpeed = (bytes[4] | (bytes[5] << 8)) * 0.01f;
|
if (canSendToEngine) engineConnection.BikeSpeed = (bytes[4] | (bytes[5] << 8)) * 0.01f;
|
||||||
break;
|
break;
|
||||||
case 0x19:
|
case 0x19:
|
||||||
engineConnection.BikePower = (bytes[5]) | (bytes[6] & 0b00001111) << 8;
|
if (canSendToEngine) engineConnection.BikePower = (bytes[5]) | (bytes[6] & 0b00001111) << 8;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (engineConnection.Connected && engineConnection.FollowingRoute)
|
|
||||||
engineConnection.UpdateInfoPanel();
|
|
||||||
|
|
||||||
this.stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), null);
|
this.stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace ClientApp.Utils
|
|||||||
{
|
{
|
||||||
private static EngineConnection instance = null;
|
private static EngineConnection instance = null;
|
||||||
private static readonly object padlock = new object();
|
private static readonly object padlock = new object();
|
||||||
|
private static System.Timers.Timer updateTimer;
|
||||||
public HandleNoTunnelId OnNoTunnelId;
|
public HandleNoTunnelId OnNoTunnelId;
|
||||||
public OnSuccessfullConnection OnSuccessFullConnection;
|
public OnSuccessfullConnection OnSuccessFullConnection;
|
||||||
|
|
||||||
@@ -57,6 +58,15 @@ namespace ClientApp.Utils
|
|||||||
BikePower = 0;
|
BikePower = 0;
|
||||||
BikeBPM = 0;
|
BikeBPM = 0;
|
||||||
BikeResistance = 50;
|
BikeResistance = 50;
|
||||||
|
updateTimer = new System.Timers.Timer(1000);
|
||||||
|
updateTimer.Elapsed += UpdateTimer_Elapsed;
|
||||||
|
updateTimer.AutoReset = true;
|
||||||
|
updateTimer.Enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
UpdateInfoPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -165,6 +175,7 @@ namespace ClientApp.Utils
|
|||||||
|
|
||||||
public void initScene()
|
public void initScene()
|
||||||
{
|
{
|
||||||
|
|
||||||
Write("initializing scene...");
|
Write("initializing scene...");
|
||||||
mainCommand = new Command(tunnelId);
|
mainCommand = new Command(tunnelId);
|
||||||
|
|
||||||
@@ -180,9 +191,6 @@ namespace ClientApp.Utils
|
|||||||
string headId = JSONParser.GetIdSceneInfoChild(message, "Head");
|
string headId = JSONParser.GetIdSceneInfoChild(message, "Head");
|
||||||
string handLeftId = JSONParser.GetIdSceneInfoChild(message, "LeftHand");
|
string handLeftId = JSONParser.GetIdSceneInfoChild(message, "LeftHand");
|
||||||
string handRightId = JSONParser.GetIdSceneInfoChild(message, "RightHand");
|
string handRightId = JSONParser.GetIdSceneInfoChild(message, "RightHand");
|
||||||
|
|
||||||
//Force(stream, mainCommand.DeleteNode(handLeftId, "deleteHandL"), "deleteHandL", (message) => Console.WriteLine("Left hand deleted"));
|
|
||||||
//Force(stream, mainCommand.DeleteNode(handRightId, "deleteHandR"), "deleteHandR", (message) => Console.WriteLine("Right hand deleted"));
|
|
||||||
});
|
});
|
||||||
// add the route and set the route id
|
// add the route and set the route id
|
||||||
SendMessageAndOnResponse(mainCommand.RouteCommand("routeID"), "routeID", (message) => routeId = JSONParser.GetResponseUuid(message));
|
SendMessageAndOnResponse(mainCommand.RouteCommand("routeID"), "routeID", (message) => routeId = JSONParser.GetResponseUuid(message));
|
||||||
@@ -205,6 +213,7 @@ namespace ClientApp.Utils
|
|||||||
|
|
||||||
WriteTextMessage(mainCommand.ColorPanel(panelId));
|
WriteTextMessage(mainCommand.ColorPanel(panelId));
|
||||||
UpdateInfoPanel();
|
UpdateInfoPanel();
|
||||||
|
updateTimer.Enabled = true;
|
||||||
|
|
||||||
while (cameraId == string.Empty) { }
|
while (cameraId == string.Empty) { }
|
||||||
SetFollowSpeed(5.0f);
|
SetFollowSpeed(5.0f);
|
||||||
|
|||||||
Reference in New Issue
Block a user