Merge branch 'develop' into Client-GUI
This commit is contained in:
@@ -208,6 +208,14 @@ namespace Client
|
|||||||
throw new ArgumentNullException("no bytes");
|
throw new ArgumentNullException("no bytes");
|
||||||
}
|
}
|
||||||
byte[] message = DataParser.GetRawDataMessage(bytes);
|
byte[] message = DataParser.GetRawDataMessage(bytes);
|
||||||
|
|
||||||
|
if (engineConnection.Connected && engineConnection.FollowingRoute)
|
||||||
|
{
|
||||||
|
engineConnection.BikeBPM = bytes[1];
|
||||||
|
engineConnection.UpdateInfoPanel();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
this.stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), null);
|
this.stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,6 +234,19 @@ namespace Client
|
|||||||
throw new ArgumentNullException("no bytes");
|
throw new ArgumentNullException("no bytes");
|
||||||
}
|
}
|
||||||
byte[] message = DataParser.GetRawDataMessage(bytes);
|
byte[] message = DataParser.GetRawDataMessage(bytes);
|
||||||
|
switch (bytes[0])
|
||||||
|
{
|
||||||
|
case 0x10:
|
||||||
|
|
||||||
|
engineConnection.BikeSpeed = (bytes[4] | (bytes[5] << 8)) * 0.01f;
|
||||||
|
break;
|
||||||
|
case 0x19:
|
||||||
|
engineConnection.BikePower = (bytes[5]) | (bytes[6] & 0b00001111) << 8;
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ namespace Client
|
|||||||
private static string bikeId = string.Empty;
|
private static string bikeId = string.Empty;
|
||||||
private static string headId = string.Empty;
|
private static string headId = string.Empty;
|
||||||
|
|
||||||
|
public float BikeSpeed { get; set; }
|
||||||
|
public float BikePower { get; set; }
|
||||||
|
public float BikeBPM { get; set; }
|
||||||
|
public float BikeResistance { get; set; }
|
||||||
|
|
||||||
public bool FollowingRoute = false;
|
public bool FollowingRoute = false;
|
||||||
|
|
||||||
private static NetworkStream stream;
|
private static NetworkStream stream;
|
||||||
@@ -48,7 +53,10 @@ namespace Client
|
|||||||
|
|
||||||
EngineConnection()
|
EngineConnection()
|
||||||
{
|
{
|
||||||
|
BikeSpeed = 0;
|
||||||
|
BikePower = 0;
|
||||||
|
BikeBPM = 0;
|
||||||
|
BikeResistance = 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -193,11 +201,9 @@ namespace Client
|
|||||||
{
|
{
|
||||||
|
|
||||||
panelId = JSONParser.getPanelID(message);
|
panelId = JSONParser.getPanelID(message);
|
||||||
|
|
||||||
WriteTextMessage(mainCommand.ColorPanel(panelId));
|
WriteTextMessage(mainCommand.ColorPanel(panelId));
|
||||||
WriteTextMessage(mainCommand.ClearPanel(panelId));
|
UpdateInfoPanel();
|
||||||
|
|
||||||
|
|
||||||
showPanel(mainCommand, 5.3, 83, 52, 53);
|
|
||||||
|
|
||||||
while (cameraId == string.Empty) { }
|
while (cameraId == string.Empty) { }
|
||||||
SetFollowSpeed(5.0f);
|
SetFollowSpeed(5.0f);
|
||||||
@@ -205,8 +211,17 @@ namespace Client
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showPanel(Command mainCommand, double bikeSpeed, int bpm, int power, int resistance)
|
public void UpdateInfoPanel()
|
||||||
{
|
{
|
||||||
|
ShowPanel(BikeSpeed, (int)BikeBPM, (int)BikePower, (int)BikeResistance);
|
||||||
|
WriteTextMessage(mainCommand.RouteSpeed(BikeSpeed, bikeId));
|
||||||
|
WriteTextMessage(mainCommand.RouteSpeed(BikeSpeed, cameraId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowPanel(double bikeSpeed, int bpm, int power, int resistance)
|
||||||
|
{
|
||||||
|
WriteTextMessage(mainCommand.ClearPanel(panelId));
|
||||||
|
|
||||||
SendMessageAndOnResponse(mainCommand.showBikespeed(panelId, "bikeSpeed", bikeSpeed), "bikeSpeed",
|
SendMessageAndOnResponse(mainCommand.showBikespeed(panelId, "bikeSpeed", bikeSpeed), "bikeSpeed",
|
||||||
(message) =>
|
(message) =>
|
||||||
{
|
{
|
||||||
@@ -252,7 +267,13 @@ namespace Client
|
|||||||
/// <param name="action">the code to be executed upon reveiving a reply from the server with the specified serial</param>
|
/// <param name="action">the code to be executed upon reveiving a reply from the server with the specified serial</param>
|
||||||
public void SendMessageAndOnResponse(string message, string serial, HandleSerial action)
|
public void SendMessageAndOnResponse(string message, string serial, HandleSerial action)
|
||||||
{
|
{
|
||||||
serialResponses.Add(serial, action);
|
if (serialResponses.ContainsKey(serial))
|
||||||
|
{
|
||||||
|
serialResponses[serial] = action;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
serialResponses.Add(serial, action);
|
||||||
|
}
|
||||||
WriteTextMessage(message);
|
WriteTextMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -424,6 +424,20 @@ namespace RH_Engine
|
|||||||
return JsonConvert.SerializeObject(Payload(payload));
|
return JsonConvert.SerializeObject(Payload(payload));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string RouteSpeed(float speedValue,string nodeID)
|
||||||
|
{
|
||||||
|
dynamic payload = new
|
||||||
|
{
|
||||||
|
id = "route/follow/speed",
|
||||||
|
data = new
|
||||||
|
{
|
||||||
|
node = nodeID,
|
||||||
|
speed = speedValue
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return JsonConvert.SerializeObject(Payload(payload));
|
||||||
|
}
|
||||||
|
|
||||||
public string RoadCommand(string uuid_route)
|
public string RoadCommand(string uuid_route)
|
||||||
{
|
{
|
||||||
Console.WriteLine("road");
|
Console.WriteLine("road");
|
||||||
|
|||||||
Reference in New Issue
Block a user