fix conflicts
This commit is contained in:
28
DokterApp/ITab.cs
Normal file
28
DokterApp/ITab.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace DokterApp
|
||||
{
|
||||
public interface ITab
|
||||
{
|
||||
string Name { get; set; }
|
||||
ICommand CloseCommand { get; }
|
||||
event EventHandler CloseRequested;
|
||||
}
|
||||
|
||||
public abstract class Tab : ITab
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public ICommand CloseCommand { get; }
|
||||
public event EventHandler CloseRequested;
|
||||
|
||||
public Tab()
|
||||
{
|
||||
//CloseCommand =
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,8 +5,25 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:DokterApp"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="450" Width="800">
|
||||
<Grid>
|
||||
WindowState="Maximized"
|
||||
Title="Dokter App" >
|
||||
<Grid RenderTransformOrigin="0.499,0.49">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="23*"/>
|
||||
<RowDefinition Height="31*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="0"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.ColumnSpan="2" Grid.RowSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,0,0" Orientation="Vertical">
|
||||
<Label Content="Sensei" Margin="0,0,0,20" HorizontalAlignment="Center"/>
|
||||
<Label Content="Username" HorizontalContentAlignment="Center"/>
|
||||
<TextBox x:Name="Username" TextWrapping="Wrap" Width="120"/>
|
||||
<Label Content="Password" HorizontalContentAlignment="Center"/>
|
||||
<TextBox x:Name="Password" TextWrapping="Wrap" Width="120"/>
|
||||
<Button x:Name="Login" Content="Login" Margin="0,20,0,0" Click="Login_Click_1" />
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -24,5 +24,17 @@ namespace DokterApp
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void Login_Click_1(object sender, RoutedEventArgs e)
|
||||
{
|
||||
WindowTabs windowTabs = new WindowTabs();
|
||||
windowTabs.Show();
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
67
DokterApp/UserControlForTab.xaml
Normal file
67
DokterApp/UserControlForTab.xaml
Normal file
@@ -0,0 +1,67 @@
|
||||
<UserControl x:Class="DokterApp.UserControlForTab"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:DokterApp"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid Margin="15,5,15,15">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="5*"/>
|
||||
<ColumnDefinition Width="3*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="43*"/>
|
||||
<RowDefinition Height="47*"/>
|
||||
<RowDefinition Height="180*"/>
|
||||
<RowDefinition Height="180*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Orientation="Horizontal" Grid.RowSpan="2" Margin="0,0,0,22">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="{x:Type Label}">
|
||||
<Setter Property="Margin" Value="0,0,20,0"/>
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
<Label Content="UserName" Name="Username_Label"/>
|
||||
<Label Content="Status: " Name="Status_Label"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,10,0,0" Grid.RowSpan="2" Grid.Row="1">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="{x:Type DockPanel}">
|
||||
<Setter Property="Margin" Value="0,20,0,0"/>
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
<DockPanel Height="26" LastChildFill="False" HorizontalAlignment="Stretch">
|
||||
<Label Content="Resistance" Width="110" DockPanel.Dock="Right"/>
|
||||
<Label Content="Current Speed" Width="110" DockPanel.Dock="Left"/>
|
||||
<Label Content="Current BPM" Width="110" DockPanel.Dock="Top"/>
|
||||
</DockPanel>
|
||||
<DockPanel Height="26" LastChildFill="False" HorizontalAlignment="Stretch">
|
||||
<TextBox Name="textBox_Resistance" Text="" TextWrapping="Wrap" Width="110" DockPanel.Dock="Right" IsReadOnly="true"/>
|
||||
<TextBox Name="textBox_CurrentSpeed" Text="" TextWrapping="Wrap" Width="110" DockPanel.Dock="Left" IsReadOnly="true"/>
|
||||
<TextBox Name="textBox_CurrentBPM" Text="" TextWrapping="Wrap" Width="110" DockPanel.Dock="Top" Height="26" IsReadOnly="true"/>
|
||||
</DockPanel>
|
||||
<DockPanel Height="26" LastChildFill="False">
|
||||
<Label Content="Distance Covered" Width="110" DockPanel.Dock="Right"/>
|
||||
<Label Content="Current Power" Width="110" DockPanel.Dock="Left"/>
|
||||
<Label Content="Acc. Power" Width="110" DockPanel.Dock="Top"/>
|
||||
</DockPanel>
|
||||
<DockPanel Height="26" LastChildFill="False">
|
||||
<TextBox Name="textBox_DistanceCovered" Text="" TextWrapping="Wrap" Width="110" DockPanel.Dock="Right" IsReadOnly="true"/>
|
||||
<TextBox Name="textBox_CurrentPower" Text="" TextWrapping="Wrap" Width="110" DockPanel.Dock="Left" IsReadOnly="true"/>
|
||||
<TextBox Name="textBox_AccPower" Text="" TextWrapping="Wrap" Width="110" DockPanel.Dock="Top" Height="26" IsReadOnly="true"/>
|
||||
</DockPanel>
|
||||
</StackPanel>
|
||||
<ListBox Name="ChatBox" Grid.Column="1" Margin="59,41,0,0" SelectionChanged="ListBox_SelectionChanged" Grid.RowSpan="3"/>
|
||||
<TextBox Name="textBox_Chat" Grid.Column="1" HorizontalAlignment="Left" Margin="59,10,0,0" Grid.Row="3" Text="TextBox" TextWrapping="Wrap" VerticalAlignment="Top" Width="235"/>
|
||||
<Button Content="Button" Grid.Column="1" HorizontalAlignment="Left" Margin="59,33,0,0" Grid.Row="3" VerticalAlignment="Top" Click="Button_Click"/>
|
||||
<Button Content="Start Session" Grid.Column="1" HorizontalAlignment="Left" Margin="69,86,0,0" Grid.Row="3" VerticalAlignment="Top" Width="97" Click="StartSession_Click"/>
|
||||
<Button Content="Stop Session" Grid.Column="1" HorizontalAlignment="Left" Margin="187,86,0,0" Grid.Row="3" VerticalAlignment="Top" Width="97" Click="StopSession_Click"/>
|
||||
<TextBox x:Name="textBox_SetResistance" Grid.Column="1" HorizontalAlignment="Left" Margin="69,128,0,0" Grid.Row="3" TextWrapping="Wrap" VerticalAlignment="Top" Width="97"/>
|
||||
<Button Content="Set Resistance" Grid.Column="1" HorizontalAlignment="Left" Margin="187,128,0,0" Grid.Row="3" VerticalAlignment="Top" Width="97" Height="18" Click="SetResistance_Click"/>
|
||||
<Canvas Grid.Row="3" Background="White" Margin="0,33,0,0"/>
|
||||
<ComboBox Name="DropBox" HorizontalAlignment="Left" Margin="0,6,0,0" Grid.Row="3" VerticalAlignment="Top" Width="190"/>
|
||||
<Button Content="Client Info" Grid.Column="1" HorizontalAlignment="Left" Margin="207,6,0,0" VerticalAlignment="Top" Height="26" Width="82" Click="ClientInfo_Click"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
59
DokterApp/UserControlForTab.xaml.cs
Normal file
59
DokterApp/UserControlForTab.xaml.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace DokterApp
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for UserControlForTab.xaml
|
||||
/// </summary>
|
||||
public partial class UserControlForTab : UserControl
|
||||
{
|
||||
public UserControlForTab()
|
||||
{
|
||||
InitializeComponent();
|
||||
Username_Label.Content = "Bob";
|
||||
Status_Label.Content = "Status: Dead";
|
||||
}
|
||||
|
||||
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ChatBox.Items.Add(textBox_Chat.Text);
|
||||
}
|
||||
|
||||
private void StartSession_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void StopSession_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void SetResistance_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void ClientInfo_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBox.Show("firstname:\tBob\n" +
|
||||
"surname:\t\tde Bouwer");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
14
DokterApp/UserTab.cs
Normal file
14
DokterApp/UserTab.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DokterApp
|
||||
{
|
||||
class UserTab : Tab
|
||||
{
|
||||
public UserTab()
|
||||
{
|
||||
Name = "Piet";
|
||||
}
|
||||
}
|
||||
}
|
||||
16
DokterApp/WindowTabs.xaml
Normal file
16
DokterApp/WindowTabs.xaml
Normal file
@@ -0,0 +1,16 @@
|
||||
<Window x:Class="DokterApp.WindowTabs"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:DokterApp"
|
||||
mc:Ignorable="d"
|
||||
WindowState="Maximized"
|
||||
Title="WindowTabs" Height="450" Width="800">
|
||||
<Grid>
|
||||
<TabControl x:Name="tabControl" Loaded="tabControl_Load" TabStripPlacement="Left" Margin="0,23,0,0" />
|
||||
<Button Content="Button" HorizontalAlignment="Left" Margin="578,125,0,0" VerticalAlignment="Top" Click="Button_Click"/>
|
||||
<Button Content="Button" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Top"/>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
44
DokterApp/WindowTabs.xaml.cs
Normal file
44
DokterApp/WindowTabs.xaml.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace DokterApp
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for WindowTabs.xaml
|
||||
/// </summary>
|
||||
public partial class WindowTabs : Window
|
||||
{
|
||||
public TabControl tbControl;
|
||||
public WindowTabs()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void tabControl_Load(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.tbControl = (sender as TabControl);
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
TabItem newTabItem = new TabItem
|
||||
{
|
||||
Header = "Test",
|
||||
Width = 110,
|
||||
Height = 40
|
||||
};
|
||||
newTabItem.Content = new UserControlForTab();
|
||||
this.tbControl.Items.Add(newTabItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,11 +83,12 @@ namespace RH_Engine
|
||||
return JsonConvert.SerializeObject(Payload(payload));
|
||||
}
|
||||
|
||||
public string DeleteNode(string uuid)
|
||||
public string DeleteNode(string uuid, string serialCode)
|
||||
{
|
||||
dynamic payload = new
|
||||
{
|
||||
id = "scene/node/delete",
|
||||
serial = serialCode,
|
||||
data = new
|
||||
{
|
||||
id = uuid,
|
||||
@@ -105,14 +106,13 @@ namespace RH_Engine
|
||||
data = new
|
||||
{
|
||||
name = "dashboard",
|
||||
parent = uuidBike,
|
||||
components = new
|
||||
{
|
||||
panel = new
|
||||
{
|
||||
size = new int[] { 1, 1 },
|
||||
resolution = new int[] { 512, 512 },
|
||||
background = new int[] { 1, 0, 0, 0 },
|
||||
background = new int[] { 1, 1, 1, 1 },
|
||||
castShadow = false
|
||||
}
|
||||
}
|
||||
@@ -151,17 +151,18 @@ namespace RH_Engine
|
||||
return JsonConvert.SerializeObject(Payload(payload));
|
||||
}
|
||||
|
||||
public string bikeSpeed(string uuidPanel, double speed)
|
||||
public string bikeSpeed(string uuidPanel, string serialCode, double speed)
|
||||
{
|
||||
dynamic payload = new
|
||||
{
|
||||
id = "scene/panel/drawtext",
|
||||
serial = serialCode,
|
||||
data = new
|
||||
{
|
||||
id = uuidPanel,
|
||||
text = "Bike speed placeholder",
|
||||
position = new int[] { 0, 0 },
|
||||
size = 32.0,
|
||||
text = "Speed: " + speed.ToString(),
|
||||
position = new int[] { 4, 24 },
|
||||
size = 36.0,
|
||||
color = new int[] { 0, 0, 0, 1 },
|
||||
font = "segoeui"
|
||||
}
|
||||
@@ -250,16 +251,17 @@ namespace RH_Engine
|
||||
return JsonConvert.SerializeObject(Payload(payload));
|
||||
}
|
||||
|
||||
public string MoveTo(string uuid, float[] positionVector, float rotateValue, float speedValue, float timeValue)
|
||||
public string MoveTo(string uuid, string serial, float[] positionVector, string rotateValue, int speedValue, int timeValue)
|
||||
{
|
||||
return MoveTo(uuid, "idk", positionVector, rotateValue, "linear", false, speedValue, timeValue);
|
||||
return MoveTo(uuid, serial, "stop", positionVector, rotateValue, "linear", false, speedValue, timeValue);
|
||||
}
|
||||
|
||||
private string MoveTo(string uuid, string stopValue, float[] positionVector, float rotateValue, string interpolateValue, bool followHeightValue, float speedValue, float timeValue)
|
||||
private string MoveTo(string uuid, string serialCode, string stopValue, float[] positionVector, string rotateValue, string interpolateValue, bool followHeightValue, int speedValue, int timeValue)
|
||||
{
|
||||
dynamic payload = new
|
||||
{
|
||||
id = "scene/node/moveto",
|
||||
serial = serialCode,
|
||||
data = new
|
||||
{
|
||||
id = uuid,
|
||||
@@ -319,7 +321,7 @@ namespace RH_Engine
|
||||
}
|
||||
}
|
||||
};
|
||||
Console.WriteLine("route command: " + JsonConvert.SerializeObject(Payload(payload)));
|
||||
//Console.WriteLine("route command: " + JsonConvert.SerializeObject(Payload(payload)));
|
||||
return JsonConvert.SerializeObject(Payload(payload));
|
||||
}
|
||||
|
||||
@@ -350,7 +352,7 @@ namespace RH_Engine
|
||||
{
|
||||
return RouteFollow(routeID, nodeID, speedValue, 0, "XYZ", 1, true, new float[] { 0, 0, 0 }, positionOffsetVector);
|
||||
}
|
||||
private string RouteFollow(string routeID, string nodeID, float speedValue, float offsetValue, string rotateValue, float smoothingValue, bool followHeightValue, float[] rotateOffsetVector, float[] positionOffsetVector)
|
||||
public string RouteFollow(string routeID, string nodeID, float speedValue, float offsetValue, string rotateValue, float smoothingValue, bool followHeightValue, float[] rotateOffsetVector, float[] positionOffsetVector)
|
||||
{
|
||||
dynamic payload = new
|
||||
{
|
||||
|
||||
@@ -25,6 +25,20 @@ namespace RH_Engine
|
||||
return res;
|
||||
}
|
||||
|
||||
public static string GetIdSceneInfoChild(string msg, string nodeName)
|
||||
{
|
||||
dynamic jsonData = JsonConvert.DeserializeObject(msg);
|
||||
Newtonsoft.Json.Linq.JArray children = jsonData.data.data.data.children;
|
||||
foreach (dynamic d in children)
|
||||
{
|
||||
if (d.name == nodeName)
|
||||
{
|
||||
return d.uuid;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetSessionID(string msg, PC[] PCs)
|
||||
{
|
||||
dynamic jsonData = JsonConvert.DeserializeObject(msg);
|
||||
@@ -45,6 +59,12 @@ namespace RH_Engine
|
||||
return null;
|
||||
}
|
||||
|
||||
public static bool GetStatus(string json)
|
||||
{
|
||||
dynamic jsonData = JsonConvert.DeserializeObject(json);
|
||||
return jsonData.data.data.status == "ok";
|
||||
}
|
||||
|
||||
public static string GetSerial(string json)
|
||||
{
|
||||
dynamic jsonData = JsonConvert.DeserializeObject(json);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using LibNoise.Primitive;
|
||||
using Microsoft.VisualBasic.FileIO;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
@@ -16,7 +17,7 @@ namespace RH_Engine
|
||||
//new PC("DESKTOP-M2CIH87", "Fabian"),
|
||||
//new PC("T470S", "Shinichi"),
|
||||
//new PC("DESKTOP-DHS478C", "semme"),
|
||||
new PC("HP-ZBOOK-SEM", "Sem"),
|
||||
//new PC("HP-ZBOOK-SEM", "Sem"),
|
||||
//new PC("DESKTOP-TV73FKO", "Wouter"),
|
||||
new PC("DESKTOP-SINMKT1", "Ralf van Aert"),
|
||||
//new PC("NA", "Bart")
|
||||
@@ -25,9 +26,11 @@ namespace RH_Engine
|
||||
private static ServerResponseReader serverResponseReader;
|
||||
private static string sessionId = string.Empty;
|
||||
private static string tunnelId = string.Empty;
|
||||
private static string cameraId = string.Empty;
|
||||
private static string routeId = string.Empty;
|
||||
private static string panelId = string.Empty;
|
||||
private static string bikeId = string.Empty;
|
||||
private static string headId = string.Empty;
|
||||
|
||||
private static Dictionary<string, HandleSerial> serialResponses = new Dictionary<string, HandleSerial>();
|
||||
|
||||
@@ -55,6 +58,7 @@ namespace RH_Engine
|
||||
/// <param name="message">the response message from the server</param>
|
||||
public static void HandleResponse(string message)
|
||||
{
|
||||
//Console.WriteLine(message);
|
||||
string id = JSONParser.GetID(message);
|
||||
|
||||
// because the first messages don't have a serial, we need to check on the id
|
||||
@@ -109,7 +113,7 @@ namespace RH_Engine
|
||||
|
||||
stream.Write(res);
|
||||
|
||||
Console.WriteLine("sent message " + message);
|
||||
//Console.WriteLine("sent message " + message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -144,23 +148,106 @@ namespace RH_Engine
|
||||
{
|
||||
Command mainCommand = new Command(tunnelID);
|
||||
|
||||
// Reset scene
|
||||
WriteTextMessage(stream, mainCommand.ResetScene());
|
||||
//headId = GetId("Root", stream, mainCommand);
|
||||
//while (headId == string.Empty) { }
|
||||
|
||||
//Get sceneinfo
|
||||
SendMessageAndOnResponse(stream, mainCommand.GetSceneInfoCommand("sceneinfo"), "sceneinfo",
|
||||
(message) =>
|
||||
{
|
||||
//Console.WriteLine("\r\n\r\n\r\nscene info" + message);
|
||||
cameraId = JSONParser.GetIdSceneInfoChild(message, "Camera");
|
||||
string headId = JSONParser.GetIdSceneInfoChild(message, "Head");
|
||||
string handLeftId = JSONParser.GetIdSceneInfoChild(message, "LeftHand");
|
||||
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 route, bike and put camera and bike to follow route at same speed.
|
||||
SendMessageAndOnResponse(stream, mainCommand.RouteCommand("routeID"), "routeID", (message) => routeId = JSONParser.GetResponseUuid(message));
|
||||
SendMessageAndOnResponse(stream, mainCommand.AddBikeModel("bikeID"), "bikeID",
|
||||
(message) =>
|
||||
{
|
||||
bikeId = JSONParser.GetResponseUuid(message);
|
||||
SendMessageAndOnResponse(stream, mainCommand.addPanel("panelAdd", bikeId), "panelAdd",
|
||||
(message) =>
|
||||
{
|
||||
bool speedReplied = false;
|
||||
bool moveReplied = true;
|
||||
panelId = JSONParser.getPanelID(message);
|
||||
WriteTextMessage(stream, mainCommand.ClearPanel(panelId));
|
||||
|
||||
|
||||
SendMessageAndOnResponse(stream, mainCommand.MoveTo(panelId, "panelMove", new float[] { 0f, 0f, 0f }, "Z", 1, 5), "panelMove",
|
||||
(message) =>
|
||||
{
|
||||
Console.WriteLine(message);
|
||||
SendMessageAndOnResponse(stream, mainCommand.bikeSpeed(panelId, "bikeSpeed", 5.0), "bikeSpeed",
|
||||
(message) =>
|
||||
{
|
||||
WriteTextMessage(stream, mainCommand.SwapPanel(panelId));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//while (!(speedReplied && moveReplied)) { }
|
||||
|
||||
while (cameraId == string.Empty) { }
|
||||
SetFollowSpeed(5.0f, stream, mainCommand);
|
||||
});
|
||||
});
|
||||
|
||||
//Force(stream, mainCommand.addPanel("panelID", bikeId), "panelID",
|
||||
// (message) =>
|
||||
// {
|
||||
// Console.WriteLine("panel response: " + message);
|
||||
// panelId = JSONParser.GetResponseUuid(message);
|
||||
// while(bikeId == string.Empty) { }
|
||||
// SetFollowSpeed(5.0f, stream, mainCommand);
|
||||
// });
|
||||
//SendMessageAndOnResponse(stream, maincommand.addpanel("panelid", bikeid), "panelid",
|
||||
// (message) =>
|
||||
// {
|
||||
// console.writeline("panelid: " + message);
|
||||
// //panelid = jsonparser.getpanelid(message);
|
||||
// panelid = jsonparser.getresponseuuid(message);
|
||||
// while (bikeid == string.empty) { }
|
||||
// setfollowspeed(5.0f, stream, maincommand);
|
||||
// });
|
||||
|
||||
|
||||
|
||||
//WriteTextMessage(stream, mainCommand.TerrainCommand(new int[] { 256, 256 }, null));
|
||||
//string command;
|
||||
|
||||
SendMessageAndOnResponse(stream, mainCommand.AddBikeModel("bikeID"), "bikeID", (message) => bikeId = JSONParser.GetResponseUuid(message));
|
||||
|
||||
SendMessageAndOnResponse(stream, mainCommand.addPanel("panelID", bikeId), "panelID",
|
||||
(message) =>
|
||||
{
|
||||
panelId = JSONParser.GetResponseUuid(message);
|
||||
while (bikeId == string.Empty) { }
|
||||
WriteTextMessage(stream, mainCommand.RouteFollow(routeId, bikeId, 5, new float[] { 0, -(float)Math.PI / 2f, 0 }, new float[] { 0, 0, 0 }));
|
||||
});
|
||||
|
||||
<<<<<<< HEAD
|
||||
//Console.WriteLine("id of head " + GetId(Command.STANDARD_HEAD, stream, mainCommand));
|
||||
|
||||
//command = mainCommand.AddModel("car", "data\\customModels\\TeslaRoadster.fbx");
|
||||
//WriteTextMessage(stream, command);
|
||||
|
||||
//command = mainCommand.addPanel();
|
||||
// WriteTextMessage(stream, command);
|
||||
// string response = ReadPrefMessage(stream);
|
||||
// Console.WriteLine("add Panel response: \n\r" + response);
|
||||
// string uuidPanel = JSONParser.getPanelID(response);
|
||||
// WriteTextMessage(stream, mainCommand.ClearPanel(uuidPanel));
|
||||
// Console.WriteLine(ReadPrefMessage(stream));
|
||||
// WriteTextMessage(stream, mainCommand.bikeSpeed(uuidPanel, 2.42));
|
||||
// Console.WriteLine(ReadPrefMessage(stream));
|
||||
// WriteTextMessage(stream, mainCommand.ColorPanel(uuidPanel));
|
||||
// Console.WriteLine("Color panel: " + ReadPrefMessage(stream));
|
||||
// WriteTextMessage(stream, mainCommand.SwapPanel(uuidPanel));
|
||||
// Console.WriteLine("Swap panel: " + ReadPrefMessage(stream));
|
||||
=======
|
||||
Console.WriteLine("id of head " + GetId(Command.STANDARD_HEAD, stream, mainCommand));
|
||||
>>>>>>> develop
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -238,6 +325,30 @@ namespace RH_Engine
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private static void SetFollowSpeed(float speed, NetworkStream stream, Command mainCommand)
|
||||
{
|
||||
WriteTextMessage(stream, mainCommand.RouteFollow(routeId, bikeId, speed, new float[] { 0, -(float)Math.PI / 2f, 0 }, new float[] { 0, 0, 0 }));
|
||||
WriteTextMessage(stream, mainCommand.RouteFollow(routeId, cameraId, speed));
|
||||
WriteTextMessage(stream, mainCommand.RouteFollow(routeId, panelId, speed, 0, "XYZ", 1, false, new float[] { 0, 0, 0 }, new float[] { 0f, 0f, 150f }));
|
||||
}
|
||||
//string routeID, string nodeID, float speedValue, float offsetValue, string rotateValue, float smoothingValue, bool followHeightValue, float[] rotateOffsetVector, float[] positionOffsetVector)
|
||||
private static void Force(NetworkStream stream, string message, string serial, HandleSerial action)
|
||||
{
|
||||
SendMessageAndOnResponse(stream, message, serial,
|
||||
(message) =>
|
||||
{
|
||||
if (!JSONParser.GetStatus(message))
|
||||
{
|
||||
serialResponses.Remove(serial);
|
||||
Force(stream, message, serial,action);
|
||||
} else
|
||||
{
|
||||
action(message);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
8
RH-Engine/Properties/launchSettings.json
Normal file
8
RH-Engine/Properties/launchSettings.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"profiles": {
|
||||
"RH-Engine": {
|
||||
"commandName": "Project",
|
||||
"nativeDebugging": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ namespace Server
|
||||
private SaveData saveData;
|
||||
private string username = null;
|
||||
private DateTime sessionStart;
|
||||
private const string fileName = "userInfo.dat";
|
||||
private string fileName;
|
||||
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Server
|
||||
this.communication = communication;
|
||||
this.tcpClient = tcpClient;
|
||||
this.stream = this.tcpClient.GetStream();
|
||||
this.fileName = Directory.GetCurrentDirectory() + "/userInfo.dat";
|
||||
stream.BeginRead(buffer, 0, buffer.Length, new AsyncCallback(OnRead), null);
|
||||
}
|
||||
|
||||
@@ -137,7 +138,7 @@ namespace Server
|
||||
|
||||
Array.Copy(message, 5, payloadbytes, 0, message.Length - 5);
|
||||
dynamic json = JsonConvert.DeserializeObject(Encoding.ASCII.GetString(payloadbytes));
|
||||
|
||||
|
||||
}
|
||||
else if (DataParser.isRawData(message))
|
||||
{
|
||||
@@ -167,8 +168,8 @@ namespace Server
|
||||
private bool verifyLogin(string username, string password)
|
||||
{
|
||||
Console.WriteLine("got hashes " + username + "\n" + password);
|
||||
|
||||
|
||||
|
||||
|
||||
if (!File.Exists(fileName))
|
||||
{
|
||||
File.Create(fileName);
|
||||
@@ -176,7 +177,8 @@ namespace Server
|
||||
newUsers(username, password);
|
||||
Console.WriteLine("true");
|
||||
return true;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("file exists, located at " + Path.GetFullPath(fileName));
|
||||
string[] usernamesPasswords = File.ReadAllLines(fileName);
|
||||
@@ -206,7 +208,7 @@ namespace Server
|
||||
|
||||
private void newUsers(string username, string password)
|
||||
{
|
||||
|
||||
|
||||
Console.WriteLine("creating new entry in file");
|
||||
using (StreamWriter sw = File.AppendText(fileName))
|
||||
{
|
||||
|
||||
@@ -2,12 +2,16 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
class SaveData
|
||||
{
|
||||
private string path;
|
||||
private const string jsonFilename = "/json.txt";
|
||||
private const string rawBikeFilename = "/rawBike.bin";
|
||||
private const string rawBPMFilename = "/rawBPM.bin";
|
||||
public SaveData(string path)
|
||||
{
|
||||
this.path = path;
|
||||
@@ -23,7 +27,7 @@ namespace Server
|
||||
|
||||
public void WriteDataJSON(string data)
|
||||
{
|
||||
using (StreamWriter sw = File.AppendText(this.path + "/json" + ".txt"))
|
||||
using (StreamWriter sw = File.AppendText(this.path + jsonFilename))
|
||||
{
|
||||
sw.WriteLine(data);
|
||||
}
|
||||
@@ -35,7 +39,7 @@ namespace Server
|
||||
{
|
||||
throw new ArgumentException("data should have length of 2");
|
||||
}
|
||||
WriteRawData(data, this.path + "/rawBPM" + ".bin");
|
||||
WriteRawData(data, this.path + rawBPMFilename);
|
||||
}
|
||||
|
||||
public void WriteDataRAWBike(byte[] data)
|
||||
@@ -44,7 +48,7 @@ namespace Server
|
||||
{
|
||||
throw new ArgumentException("data should have length of 8");
|
||||
}
|
||||
WriteRawData(data, this.path + "/rawBike" + ".bin");
|
||||
WriteRawData(data, this.path + rawBikeFilename);
|
||||
}
|
||||
|
||||
private void WriteRawData(byte[] data, string fileLocation)
|
||||
@@ -67,6 +71,56 @@ namespace Server
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// gets BPM graph data out of file.
|
||||
/// if you want 100 datapoints but here are onlny 50, de last 50 datapoint will be 0
|
||||
/// if you want 100 datapoints where it takes the average of 2, the last 75 will be 0
|
||||
/// if the file isn't created yet it will retun null
|
||||
/// </summary>
|
||||
/// <param name="outputSize">the amount of data points for the output</param>
|
||||
/// <param name="averageOver">the amount of data points form the file for one data point in the output</param>
|
||||
/// <returns>byte array with data points from file</returns>
|
||||
public byte[] getBPMgraphData(int outputSize, int averageOver)
|
||||
{
|
||||
if (File.Exists(this.path + rawBPMFilename))
|
||||
{
|
||||
FileInfo fi = new FileInfo(this.path + rawBPMFilename);
|
||||
int length = (int)fi.Length;
|
||||
|
||||
byte[] output = new byte[outputSize];
|
||||
|
||||
int messageSize = 2;
|
||||
int readSize = messageSize * averageOver;
|
||||
byte[] readBuffer = new byte[readSize];
|
||||
|
||||
using (FileStream fileStream = new FileStream(this.path + rawBPMFilename, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
for (int i = 1; i >= outputSize; i++)
|
||||
{
|
||||
if (length - (i * readSize) < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
fileStream.Read(readBuffer, length - (i * readSize), readSize);
|
||||
|
||||
//handling data
|
||||
int total = 0;
|
||||
for (int j = 0; j < averageOver; j++)
|
||||
{
|
||||
total += readBuffer[j * messageSize + 1];
|
||||
}
|
||||
output[i - 1] = (byte)(total / averageOver);
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user