Compare commits
5 Commits
unittest-s
...
sendmessag
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f163325cf | ||
|
|
1c7f9cf70a | ||
|
|
5f2e325cb1 | ||
|
|
cda8b47ca3 | ||
|
|
fab3ed7705 |
@@ -43,7 +43,7 @@ namespace ClientApp.Utils
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void initEngine()
|
private void initEngine()
|
||||||
{
|
{
|
||||||
Debug.WriteLine("init engine");
|
Debug.WriteLine("[CLIENT] init engine");
|
||||||
engineConnection = EngineConnection.INSTANCE;
|
engineConnection = EngineConnection.INSTANCE;
|
||||||
engineConnection.OnNoTunnelId = RetryEngineConnection;
|
engineConnection.OnNoTunnelId = RetryEngineConnection;
|
||||||
engineConnection.OnSuccessFullConnection = engineConnected;
|
engineConnection.OnSuccessFullConnection = engineConnected;
|
||||||
@@ -190,6 +190,9 @@ namespace ClientApp.Utils
|
|||||||
expectedMessageLength = BitConverter.ToInt32(totalBuffer, 0);
|
expectedMessageLength = BitConverter.ToInt32(totalBuffer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ar == null || (!ar.IsCompleted) || (!this.stream.CanRead) || !this.client.Connected)
|
||||||
|
return;
|
||||||
|
ar.AsyncWaitHandle.WaitOne();
|
||||||
this.stream.BeginRead(this.buffer, 0, this.buffer.Length, new AsyncCallback(OnRead), null);
|
this.stream.BeginRead(this.buffer, 0, this.buffer.Length, new AsyncCallback(OnRead), null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace ClientApp.Utils
|
|||||||
//new PC("DESKTOP-M2CIH87", "Fabian"),
|
//new PC("DESKTOP-M2CIH87", "Fabian"),
|
||||||
//new PC("T470S", "Shinichi"),
|
//new PC("T470S", "Shinichi"),
|
||||||
//new PC("DESKTOP-DHS478C", "semme"),
|
//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-TV73FKO", "Wouter"),
|
||||||
//new PC("DESKTOP-SINMKT1", "Ralf van Aert"),
|
//new PC("DESKTOP-SINMKT1", "Ralf van Aert"),
|
||||||
//new PC("NA", "Bart")
|
//new PC("NA", "Bart")
|
||||||
@@ -71,7 +71,7 @@ namespace ClientApp.Utils
|
|||||||
updateTimer.AutoReset = true;
|
updateTimer.AutoReset = true;
|
||||||
updateTimer.Enabled = false;
|
updateTimer.Enabled = false;
|
||||||
|
|
||||||
noVRResponseTimer = new System.Timers.Timer(15000);
|
noVRResponseTimer = new System.Timers.Timer(30000);
|
||||||
noVRResponseTimer.Elapsed += noVRResponseTimeout;
|
noVRResponseTimer.Elapsed += noVRResponseTimeout;
|
||||||
noVRResponseTimer.AutoReset = false;
|
noVRResponseTimer.AutoReset = false;
|
||||||
noVRResponseTimer.Enabled = false;
|
noVRResponseTimer.Enabled = false;
|
||||||
@@ -236,14 +236,14 @@ namespace ClientApp.Utils
|
|||||||
Write("Starting route follow...");
|
Write("Starting route follow...");
|
||||||
FollowingRoute = true;
|
FollowingRoute = true;
|
||||||
|
|
||||||
SendMessageAndOnResponse(mainCommand.AddBikeModelAnim("bikeID", 0.01f), "bikeID",
|
SendMessageAndOnResponse(mainCommand.AddBikeModel("bikeID"), "bikeID",
|
||||||
(message) =>
|
(message) =>
|
||||||
{
|
{
|
||||||
bikeId = JSONParser.GetResponseUuid(message);
|
bikeId = JSONParser.GetResponseUuid(message);
|
||||||
SendMessageAndOnResponse(mainCommand.addPanel("panelAdd", bikeId), "panelAdd",
|
SendMessageAndOnResponse(mainCommand.addPanel("panelAdd", bikeId), "panelAdd",
|
||||||
(message) =>
|
(message) =>
|
||||||
{
|
{
|
||||||
|
Write("got panel id");
|
||||||
panelId = JSONParser.getPanelID(message);
|
panelId = JSONParser.getPanelID(message);
|
||||||
|
|
||||||
WriteTextMessage(mainCommand.ColorPanel(panelId));
|
WriteTextMessage(mainCommand.ColorPanel(panelId));
|
||||||
@@ -295,6 +295,7 @@ namespace ClientApp.Utils
|
|||||||
|
|
||||||
public void UpdateInfoPanel()
|
public void UpdateInfoPanel()
|
||||||
{
|
{
|
||||||
|
Write("updating info panel");
|
||||||
ShowPanel(BikeSpeed, (int)BikeBPM, (int)BikePower, (int)BikeResistance);
|
ShowPanel(BikeSpeed, (int)BikeBPM, (int)BikePower, (int)BikeResistance);
|
||||||
WriteTextMessage(mainCommand.RouteSpeed(BikeSpeed, bikeId));
|
WriteTextMessage(mainCommand.RouteSpeed(BikeSpeed, bikeId));
|
||||||
WriteTextMessage(mainCommand.RouteSpeed(BikeSpeed, cameraId));
|
WriteTextMessage(mainCommand.RouteSpeed(BikeSpeed, cameraId));
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ namespace DoctorApp.Utils
|
|||||||
{
|
{
|
||||||
MainViewModel.TransferDataToClientBPM(payloadbytes);
|
MainViewModel.TransferDataToClientBPM(payloadbytes);
|
||||||
}
|
}
|
||||||
Array.Copy(totalBuffer, expectedMessageLength, totalBuffer, 0, (totalBufferReceived - expectedMessageLength)); //maybe unsafe idk
|
Array.Copy(totalBuffer, expectedMessageLength, totalBuffer, 0, (totalBufferReceived - expectedMessageLength)); //maybe unsafe idk
|
||||||
totalBufferReceived -= expectedMessageLength;
|
totalBufferReceived -= expectedMessageLength;
|
||||||
expectedMessageLength = BitConverter.ToInt32(totalBuffer, 0);
|
expectedMessageLength = BitConverter.ToInt32(totalBuffer, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,12 +43,14 @@ namespace DoctorApp.ViewModels
|
|||||||
|
|
||||||
public MainWindowViewModel MainWindowViewModel { get; set; }
|
public MainWindowViewModel MainWindowViewModel { get; set; }
|
||||||
private Client client;
|
private Client client;
|
||||||
|
private MainViewModel parent;
|
||||||
|
|
||||||
public Chart Chart { get; set; }
|
public Chart Chart { get; set; }
|
||||||
|
|
||||||
public ClientInfoViewModel(MainWindowViewModel mainWindowViewModel, string username)
|
public ClientInfoViewModel(MainViewModel parent,MainWindowViewModel mainWindowViewModel, string username)
|
||||||
{
|
{
|
||||||
MainWindowViewModel = mainWindowViewModel;
|
MainWindowViewModel = mainWindowViewModel;
|
||||||
|
this.parent = parent;
|
||||||
this.PatientInfo = new PatientInfo() { Username = username, Status = "Waiting to start" };
|
this.PatientInfo = new PatientInfo() { Username = username, Status = "Waiting to start" };
|
||||||
this.Chart = new Chart(this.PatientInfo);
|
this.Chart = new Chart(this.PatientInfo);
|
||||||
PatientInfo.ChatLog = new ObservableCollection<string>();
|
PatientInfo.ChatLog = new ObservableCollection<string>();
|
||||||
@@ -68,12 +70,17 @@ namespace DoctorApp.ViewModels
|
|||||||
|
|
||||||
Chat = new RelayCommand<object>((parameter) =>
|
Chat = new RelayCommand<object>((parameter) =>
|
||||||
{
|
{
|
||||||
client.sendMessage(DataParser.getChatJson(PatientInfo.Username, ((TextBox)parameter).Text));
|
SendMessageToClient(PatientInfo.Username, ((TextBox)parameter).Text);
|
||||||
PatientInfo.ChatLog.Add(DateTime.Now + ": " + ((TextBox)parameter).Text);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//TODO RelayCommand ChatToAll
|
//TODO RelayCommand ChatToAll
|
||||||
|
|
||||||
|
ChatToAll = new RelayCommand<object>((parameter) =>
|
||||||
|
{
|
||||||
|
Debug.WriteLine("[CLIENTINFOVIEWMODEL] sending message to all clients");
|
||||||
|
this.parent?.SendToAllClients(((TextBox)parameter).Text);
|
||||||
|
});
|
||||||
|
|
||||||
SetResistance = new RelayCommand<object>((parameter) =>
|
SetResistance = new RelayCommand<object>((parameter) =>
|
||||||
{
|
{
|
||||||
Debug.WriteLine("resistance");
|
Debug.WriteLine("resistance");
|
||||||
@@ -83,6 +90,12 @@ namespace DoctorApp.ViewModels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SendMessageToClient(string username, string text)
|
||||||
|
{
|
||||||
|
client.sendMessage(DataParser.getChatJson(username, text));
|
||||||
|
PatientInfo.ChatLog.Add(DateTime.Now + ": " + text);
|
||||||
|
}
|
||||||
|
|
||||||
public void BPMData(byte [] bytes)
|
public void BPMData(byte [] bytes)
|
||||||
{
|
{
|
||||||
//TODO
|
//TODO
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace DoctorApp.ViewModels
|
|||||||
Debug.WriteLine("new tab with name " + username);
|
Debug.WriteLine("new tab with name " + username);
|
||||||
App.Current.Dispatcher.Invoke((Action)delegate
|
App.Current.Dispatcher.Invoke((Action)delegate
|
||||||
{
|
{
|
||||||
Tabs.Add(new ClientInfoViewModel(MainWindowViewModel, username));
|
Tabs.Add(new ClientInfoViewModel(this,MainWindowViewModel, username));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,6 +72,15 @@ namespace DoctorApp.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void SendToAllClients(string text)
|
||||||
|
{
|
||||||
|
Debug.WriteLine("[MAINVIEWMODEL] Sending message to all clients: " + text);
|
||||||
|
foreach (ClientInfoViewModel item in Tabs)
|
||||||
|
{
|
||||||
|
item.SendMessageToClient(item.PatientInfo.Username, text);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using System.Windows.Input;
|
|||||||
using DoctorApp.Models;
|
using DoctorApp.Models;
|
||||||
using DoctorApp.Utils;
|
using DoctorApp.Utils;
|
||||||
using Util.MagicCode;
|
using Util.MagicCode;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace DoctorApp.ViewModels
|
namespace DoctorApp.ViewModels
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -57,6 +57,7 @@
|
|||||||
<ListBox Name="ChatBox" ItemsSource="{Binding PatientInfo.ChatLog}" Grid.Column="1" Margin="59,41,0,0" Grid.RowSpan="3"/>
|
<ListBox Name="ChatBox" ItemsSource="{Binding PatientInfo.ChatLog}" Grid.Column="1" Margin="59,41,0,0" Grid.RowSpan="3"/>
|
||||||
<TextBox Name="textBox_Chat" Grid.Column="1" HorizontalAlignment="Left" Margin="59,10,0,0" Grid.Row="3" Text="" TextWrapping="Wrap" VerticalAlignment="Top" Width="235"/>
|
<TextBox Name="textBox_Chat" Grid.Column="1" HorizontalAlignment="Left" Margin="59,10,0,0" Grid.Row="3" Text="" TextWrapping="Wrap" VerticalAlignment="Top" Width="235"/>
|
||||||
<Button x:Name="Send" Content="Send" Grid.Column="1" HorizontalAlignment="Left" Margin="59,33,0,0" Grid.Row="3" VerticalAlignment="Top" Command="{Binding Chat}" CommandParameter="{Binding ElementName=textBox_Chat}"/>
|
<Button x:Name="Send" Content="Send" Grid.Column="1" HorizontalAlignment="Left" Margin="59,33,0,0" Grid.Row="3" VerticalAlignment="Top" Command="{Binding Chat}" CommandParameter="{Binding ElementName=textBox_Chat}"/>
|
||||||
|
<Button x:Name="SendToAll" Content="Send to all clients" Grid.Column="1" HorizontalAlignment="Left" Margin="107,33,0,0" Grid.Row="3" VerticalAlignment="Top" Command="{Binding ChatToAll}" CommandParameter="{Binding ElementName=textBox_Chat}"/>
|
||||||
<Button Content="Start Session" Grid.Column="1" HorizontalAlignment="Left" Margin="69,86,0,0" Grid.Row="3" VerticalAlignment="Top" Width="97" Command="{Binding StartSession}" CommandParameter=""/>
|
<Button Content="Start Session" Grid.Column="1" HorizontalAlignment="Left" Margin="69,86,0,0" Grid.Row="3" VerticalAlignment="Top" Width="97" Command="{Binding StartSession}" CommandParameter=""/>
|
||||||
<Button Content="Stop Session" Grid.Column="1" HorizontalAlignment="Left" Margin="187,86,0,0" Grid.Row="3" VerticalAlignment="Top" Width="97" Command="{Binding StopSession}" CommandParameter=""/>
|
<Button Content="Stop Session" Grid.Column="1" HorizontalAlignment="Left" Margin="187,86,0,0" Grid.Row="3" VerticalAlignment="Top" Width="97" Command="{Binding StopSession}" CommandParameter=""/>
|
||||||
<TextBox x:Name="textBox_SetResistance" Grid.Column="1" HorizontalAlignment="Left" Margin="69,128,0,0" Grid.Row="3" TextWrapping="Wrap" VerticalAlignment="Top" Width="97"/>
|
<TextBox x:Name="textBox_SetResistance" Grid.Column="1" HorizontalAlignment="Left" Margin="69,128,0,0" Grid.Row="3" TextWrapping="Wrap" VerticalAlignment="Top" Width="97"/>
|
||||||
|
|||||||
@@ -4,11 +4,9 @@ using System;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Printing.IndexedProperties;
|
|
||||||
using System.Runtime.InteropServices.WindowsRuntime;
|
using System.Runtime.InteropServices.WindowsRuntime;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Media.Animation;
|
|
||||||
|
|
||||||
namespace Util
|
namespace Util
|
||||||
{
|
{
|
||||||
@@ -291,12 +289,8 @@ namespace Util
|
|||||||
|
|
||||||
private static byte[] GetRawDataDoctor(byte[] payload, string username, byte messageID)
|
private static byte[] GetRawDataDoctor(byte[] payload, string username, byte messageID)
|
||||||
{
|
{
|
||||||
Debug.WriteLine(BitConverter.ToString(Encoding.ASCII.GetBytes(username)));
|
|
||||||
byte[] nameArray = Encoding.ASCII.GetBytes(username);
|
return getMessage(payload.Concat(Encoding.ASCII.GetBytes(username)).ToArray(), messageID);
|
||||||
byte[] total = new byte[nameArray.Length + payload.Length];
|
|
||||||
Array.Copy(payload, 0, total, 0, payload.Length);
|
|
||||||
Array.Copy(nameArray,0,total,payload.Length,nameArray.Length);
|
|
||||||
return getMessage(total,messageID);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -15,18 +15,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server", "..\Server\Server.
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DoctorApp", "..\DoctorApp\DoctorApp.csproj", "{A232F2D5-AF98-4777-BF3A-FBDDFBC02994}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DoctorApp", "..\DoctorApp\DoctorApp.csproj", "{A232F2D5-AF98-4777-BF3A-FBDDFBC02994}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTestRH", "..\UnitTestRH\UnitTestRH.csproj", "{0B6CCC1D-5E76-420E-B54D-EB3E5FFEA6CB}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{BECC2E56-E65C-42A0-AF80-DDE32DCD5E0B} = {BECC2E56-E65C-42A0-AF80-DDE32DCD5E0B}
|
|
||||||
{7D751284-17E8-434C-A7F6-2EB37572E7AE} = {7D751284-17E8-434C-A7F6-2EB37572E7AE}
|
|
||||||
{7EF854C1-73EB-4099-A7D7-057CCEEE6F8F} = {7EF854C1-73EB-4099-A7D7-057CCEEE6F8F}
|
|
||||||
{A232F2D5-AF98-4777-BF3A-FBDDFBC02994} = {A232F2D5-AF98-4777-BF3A-FBDDFBC02994}
|
|
||||||
{C1A3CCE4-5FBB-4655-BFE1-7AF2B7D58CA3} = {C1A3CCE4-5FBB-4655-BFE1-7AF2B7D58CA3}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||||
..\Hashing\Hashing.projitems*{0b6ccc1d-5e76-420e-b54d-eb3e5ffea6cb}*SharedItemsImports = 5
|
|
||||||
..\Hashing\Hashing.projitems*{70277749-d423-4871-b692-2efc5a6ed932}*SharedItemsImports = 13
|
..\Hashing\Hashing.projitems*{70277749-d423-4871-b692-2efc5a6ed932}*SharedItemsImports = 13
|
||||||
..\Hashing\Hashing.projitems*{7d751284-17e8-434c-a7f6-2eb37572e7ae}*SharedItemsImports = 5
|
..\Hashing\Hashing.projitems*{7d751284-17e8-434c-a7f6-2eb37572e7ae}*SharedItemsImports = 5
|
||||||
..\Hashing\Hashing.projitems*{7ef854c1-73eb-4099-a7d7-057cceee6f8f}*SharedItemsImports = 5
|
..\Hashing\Hashing.projitems*{7ef854c1-73eb-4099-a7d7-057cceee6f8f}*SharedItemsImports = 5
|
||||||
@@ -57,10 +47,6 @@ Global
|
|||||||
{A232F2D5-AF98-4777-BF3A-FBDDFBC02994}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{A232F2D5-AF98-4777-BF3A-FBDDFBC02994}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{A232F2D5-AF98-4777-BF3A-FBDDFBC02994}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{A232F2D5-AF98-4777-BF3A-FBDDFBC02994}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{A232F2D5-AF98-4777-BF3A-FBDDFBC02994}.Release|Any CPU.Build.0 = Release|Any CPU
|
{A232F2D5-AF98-4777-BF3A-FBDDFBC02994}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{0B6CCC1D-5E76-420E-B54D-EB3E5FFEA6CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{0B6CCC1D-5E76-420E-B54D-EB3E5FFEA6CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{0B6CCC1D-5E76-420E-B54D-EB3E5FFEA6CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{0B6CCC1D-5E76-420E-B54D-EB3E5FFEA6CB}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -124,11 +124,13 @@ namespace RH_Engine
|
|||||||
position = new float[]
|
position = new float[]
|
||||||
{
|
{
|
||||||
-1.5f, 1f, 0f
|
-1.5f, 1f, 0f
|
||||||
|
//0f,0f,0f
|
||||||
},
|
},
|
||||||
scale = 1,
|
scale = 1,
|
||||||
rotation = new int[]
|
rotation = new int[]
|
||||||
{
|
{
|
||||||
-30, 90,0
|
-30, 90,0
|
||||||
|
//0,0,0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
panel = new
|
panel = new
|
||||||
@@ -174,7 +176,7 @@ namespace RH_Engine
|
|||||||
return JsonConvert.SerializeObject(Payload(payload));
|
return JsonConvert.SerializeObject(Payload(payload));
|
||||||
}
|
}
|
||||||
|
|
||||||
public string showOnPanel(string uuidPanel, string serialCode, string mText, int index)
|
private string showOnPanel(string uuidPanel, string serialCode, string mText, int index)
|
||||||
{
|
{
|
||||||
dynamic payload = new
|
dynamic payload = new
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ namespace RH_Engine
|
|||||||
//new PC("DESKTOP-M2CIH87", "Fabian"),
|
//new PC("DESKTOP-M2CIH87", "Fabian"),
|
||||||
//new PC("T470S", "Shinichi"),
|
//new PC("T470S", "Shinichi"),
|
||||||
//new PC("DESKTOP-DHS478C", "semme"),
|
//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-TV73FKO", "Wouter"),
|
||||||
new PC("DESKTOP-SINMKT1", "Ralf van Aert"),
|
//new PC("DESKTOP-SINMKT1", "Ralf van Aert"),
|
||||||
//new PC("NA", "Bart")
|
//new PC("NA", "Bart")
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ namespace RH_Engine
|
|||||||
if (serialResponses.ContainsKey(serial))
|
if (serialResponses.ContainsKey(serial))
|
||||||
{
|
{
|
||||||
serialResponses[serial].Invoke(message);
|
serialResponses[serial].Invoke(message);
|
||||||
serialResponses.Remove(serial);
|
//serialResponses.Remove(serial);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,39 +181,41 @@ namespace RH_Engine
|
|||||||
//Force(stream, mainCommand.DeleteNode(handRightId, "deleteHandR"), "deleteHandR", (message) => Console.WriteLine("Right hand deleted"));
|
//Force(stream, mainCommand.DeleteNode(handRightId, "deleteHandR"), "deleteHandR", (message) => Console.WriteLine("Right hand deleted"));
|
||||||
});
|
});
|
||||||
|
|
||||||
CreateTerrain(stream, mainCommand);
|
//CreateTerrain(stream, mainCommand);
|
||||||
|
|
||||||
//Add route, bike and put camera and bike to follow route at same speed.
|
//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.RouteCommand("routeID"), "routeID", (message) => routeId = JSONParser.GetResponseUuid(message));
|
||||||
SendMessageAndOnResponse(stream, mainCommand.AddBikeModelAnim("bikeID", 0.01f), "bikeID",
|
SendMessageAndOnResponse(stream, mainCommand.AddBikeModelAnim("bikeID",0.01f), "bikeID",
|
||||||
(message) =>
|
(message) =>
|
||||||
{
|
{
|
||||||
bikeId = JSONParser.GetResponseUuid(message);
|
bikeId = JSONParser.GetResponseUuid(message);
|
||||||
|
Console.WriteLine("got bike id " + bikeId);
|
||||||
SendMessageAndOnResponse(stream, mainCommand.addPanel("panelAdd", bikeId), "panelAdd",
|
SendMessageAndOnResponse(stream, mainCommand.addPanel("panelAdd", bikeId), "panelAdd",
|
||||||
(message) =>
|
(message) =>
|
||||||
{
|
{
|
||||||
bool speedReplied = false;
|
bool speedReplied = false;
|
||||||
bool moveReplied = true;
|
bool moveReplied = true;
|
||||||
|
Console.WriteLine(message);
|
||||||
panelId = JSONParser.getPanelID(message);
|
panelId = JSONParser.getPanelID(message);
|
||||||
|
Console.WriteLine("got panel id " + panelId);
|
||||||
showPanel(stream, mainCommand);
|
showPanel(stream, mainCommand);
|
||||||
|
|
||||||
|
|
||||||
//while (!(speedReplied && moveReplied)) { }
|
//while (!(speedReplied && moveReplied)) { }
|
||||||
|
|
||||||
while (cameraId == string.Empty) { }
|
//while (cameraId == string.Empty) { }
|
||||||
SetFollowSpeed(5.0f, stream, mainCommand);
|
//SetFollowSpeed(5.0f, stream, mainCommand);
|
||||||
WriteTextMessage(stream, mainCommand.RoadCommand(routeId, "road"));
|
//WriteTextMessage(stream, mainCommand.RoadCommand(routeId, "road"));
|
||||||
WriteTextMessage(stream, mainCommand.ShowRoute("showRouteFalse", false));
|
//WriteTextMessage(stream, mainCommand.ShowRoute("showRouteFalse", false));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
string groundplaneId = GetId("GroundPlane", stream, mainCommand);
|
//string groundplaneId = GetId("GroundPlane", stream, mainCommand);
|
||||||
WriteTextMessage(stream, mainCommand.DeleteNode(groundplaneId, "none"));
|
//WriteTextMessage(stream, mainCommand.DeleteNode(groundplaneId, "none"));
|
||||||
|
|
||||||
PlaceHouses(stream, mainCommand);
|
//PlaceHouses(stream, mainCommand);
|
||||||
|
|
||||||
WriteTextMessage(stream, mainCommand.SkyboxCommand(DateTime.Now.Hour));
|
//WriteTextMessage(stream, mainCommand.SkyboxCommand(DateTime.Now.Hour));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,31 +345,36 @@ namespace RH_Engine
|
|||||||
|
|
||||||
private static void showPanel(NetworkStream stream, Command mainCommand)
|
private static void showPanel(NetworkStream stream, Command mainCommand)
|
||||||
{
|
{
|
||||||
WriteTextMessage(stream, mainCommand.ColorPanel(panelId));
|
//WriteTextMessage(stream, mainCommand.ColorPanel(panelId));
|
||||||
WriteTextMessage(stream, mainCommand.ClearPanel(panelId));
|
WriteTextMessage(stream, mainCommand.ClearPanel(panelId));
|
||||||
SendMessageAndOnResponse(stream, mainCommand.showBikespeed(panelId, "bikeSpeed", bikeSpeed), "bikeSpeed",
|
SendMessageAndOnResponse(stream, mainCommand.showBikespeed(panelId, "bikeSpeed", bikeSpeed), "bikeSpeed",
|
||||||
(message) =>
|
(message) =>
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(message);
|
||||||
// TODO check if is drawn
|
// TODO check if is drawn
|
||||||
});
|
});
|
||||||
SendMessageAndOnResponse(stream, mainCommand.showHeartrate(panelId, "bpm", bpm), "bpm",
|
SendMessageAndOnResponse(stream, mainCommand.showHeartrate(panelId, "bpm", bpm), "bpm",
|
||||||
(message) =>
|
(message) =>
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(message);
|
||||||
// TODO check if is drawn
|
// TODO check if is drawn
|
||||||
});
|
});
|
||||||
SendMessageAndOnResponse(stream, mainCommand.showPower(panelId, "power", power), "power",
|
SendMessageAndOnResponse(stream, mainCommand.showPower(panelId, "power", power), "power",
|
||||||
(message) =>
|
(message) =>
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(message);
|
||||||
// TODO check if is drawn
|
// TODO check if is drawn
|
||||||
});
|
});
|
||||||
SendMessageAndOnResponse(stream, mainCommand.showResistance(panelId, "resistance", resistance), "resistance",
|
SendMessageAndOnResponse(stream, mainCommand.showResistance(panelId, "resistance", resistance), "resistance",
|
||||||
(message) =>
|
(message) =>
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(message);
|
||||||
// TODO check if is drawn
|
// TODO check if is drawn
|
||||||
});
|
});
|
||||||
SendMessageAndOnResponse(stream, mainCommand.showMessage(panelId, "message", lastMessage), "message",
|
SendMessageAndOnResponse(stream, mainCommand.showMessage(panelId, "message", lastMessage), "message",
|
||||||
(message) =>
|
(message) =>
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(message);
|
||||||
// TODO check if is drawn
|
// TODO check if is drawn
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
@@ -24,11 +23,8 @@ namespace Server
|
|||||||
private DateTime sessionStart;
|
private DateTime sessionStart;
|
||||||
private string fileName;
|
private string fileName;
|
||||||
private Timer timer;
|
private Timer timer;
|
||||||
private volatile byte[] BikeDataBuffer;
|
private byte[] BikeDataBuffer;
|
||||||
private volatile byte[] BPMDataBuffer;
|
private byte[] BPMDataBuffer;
|
||||||
private bool BPMdata = false;
|
|
||||||
private bool Bikedata = false;
|
|
||||||
private object token = new object { };
|
|
||||||
|
|
||||||
public Client(Communication communication, TcpClient tcpClient)
|
public Client(Communication communication, TcpClient tcpClient)
|
||||||
{
|
{
|
||||||
@@ -41,9 +37,8 @@ namespace Server
|
|||||||
this.BikeDataBuffer = new byte[16];
|
this.BikeDataBuffer = new byte[16];
|
||||||
this.BPMDataBuffer = new byte[2];
|
this.BPMDataBuffer = new byte[2];
|
||||||
this.timer.Interval = 1000;
|
this.timer.Interval = 1000;
|
||||||
this.timer.AutoReset = false;
|
this.timer.AutoReset = true;
|
||||||
this.timer.Elapsed += SendDataToDoctor;
|
this.timer.Elapsed += SendDataToDoctor;
|
||||||
Console.WriteLine("token is " + token);
|
|
||||||
stream.BeginRead(buffer, 0, buffer.Length, new AsyncCallback(OnRead), null);
|
stream.BeginRead(buffer, 0, buffer.Length, new AsyncCallback(OnRead), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,24 +154,14 @@ namespace Server
|
|||||||
}
|
}
|
||||||
else if (DataParser.isRawDataBikeServer(message))
|
else if (DataParser.isRawDataBikeServer(message))
|
||||||
{
|
{
|
||||||
//Bikedata = true;
|
|
||||||
saveData?.WriteDataRAWBike(payloadbytes);
|
saveData?.WriteDataRAWBike(payloadbytes);
|
||||||
lock (token)
|
Array.Copy(this.BikeDataBuffer, 0, this.BikeDataBuffer, 8, 8);
|
||||||
{
|
Array.Copy(payloadbytes, 0, this.BikeDataBuffer, 0, 8);
|
||||||
Array.Copy(this.BikeDataBuffer, 0, this.BikeDataBuffer, 8, 8);
|
|
||||||
Array.Copy(payloadbytes, 0, this.BikeDataBuffer, 0, 8);
|
|
||||||
}
|
|
||||||
//this.communication.Doctor?.sendMessage(DataParser.GetRawBikeDataDoctor(payloadbytes, this.username));
|
|
||||||
}
|
}
|
||||||
else if (DataParser.isRawDataBPMServer(message))
|
else if (DataParser.isRawDataBPMServer(message))
|
||||||
{
|
{
|
||||||
//BPMdata = true;
|
|
||||||
saveData?.WriteDataRAWBPM(payloadbytes);
|
saveData?.WriteDataRAWBPM(payloadbytes);
|
||||||
lock (token)
|
Array.Copy(payloadbytes, 0, this.BikeDataBuffer, 0, 2);
|
||||||
{
|
|
||||||
Array.Copy(payloadbytes, 0, this.BPMDataBuffer, 0, 2);
|
|
||||||
}
|
|
||||||
//this.communication.Doctor?.sendMessage(DataParser.GetRawBPMDataDoctor(payloadbytes, this.username));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -279,13 +264,9 @@ namespace Server
|
|||||||
|
|
||||||
private void SendDataToDoctor(object sender, ElapsedEventArgs e)
|
private void SendDataToDoctor(object sender, ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
lock (token)
|
this.communication.Doctor?.sendMessage(DataParser.GetRawBikeDataDoctor(this.BikeDataBuffer.Take(8).ToArray(), this.username));
|
||||||
{
|
this.communication.Doctor?.sendMessage(DataParser.GetRawBikeDataDoctor(this.BikeDataBuffer.Skip(8).ToArray(), this.username));
|
||||||
this.communication.Doctor?.sendMessage(DataParser.GetRawBikeDataDoctor(this.BikeDataBuffer.Take(8).ToArray(), this.username));
|
this.communication.Doctor?.sendMessage(DataParser.GetRawBikeDataDoctor(this.BikeDataBuffer, this.username));
|
||||||
this.communication.Doctor?.sendMessage(DataParser.GetRawBikeDataDoctor(this.BikeDataBuffer.Skip(8).ToArray(), this.username));
|
|
||||||
this.communication.Doctor?.sendMessage(DataParser.GetRawBPMDataDoctor(this.BPMDataBuffer, this.username));
|
|
||||||
}
|
|
||||||
this.timer.Start();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,418 +0,0 @@
|
|||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using ProftaakRH;
|
|
||||||
using RH_Engine;
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace UnitTestRH
|
|
||||||
{
|
|
||||||
[TestClass]
|
|
||||||
public class CommandTest
|
|
||||||
{
|
|
||||||
[TestMethod]
|
|
||||||
public void TerrainAdd_TestMethod()
|
|
||||||
{
|
|
||||||
string testTunnelID = "dummyTunnelID";
|
|
||||||
string testSerial = "dummySerialCode";
|
|
||||||
|
|
||||||
string payloadId = "tunnel/send";
|
|
||||||
string messageId = "scene/terrain/add";
|
|
||||||
|
|
||||||
Command command = new Command(testTunnelID);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int[] terrainSizeArray = new int[2] { 4, 4 };
|
|
||||||
float[] terrainHeightsArray = new float[16] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
||||||
string terrainAddCommand = command.TerrainAdd(terrainSizeArray, terrainHeightsArray, testSerial);
|
|
||||||
|
|
||||||
dynamic json = JsonConvert.DeserializeObject(terrainAddCommand);
|
|
||||||
|
|
||||||
//Test payload
|
|
||||||
Assert.AreEqual(payloadId, (string)json.id);
|
|
||||||
Assert.AreEqual(testTunnelID, (string)json.data.dest);
|
|
||||||
|
|
||||||
//Test message
|
|
||||||
Assert.AreEqual(messageId, (string)json.data.data.id);
|
|
||||||
Assert.AreEqual(testSerial, (string)json.data.data.serial);
|
|
||||||
|
|
||||||
//Test terrain
|
|
||||||
JArray jArrayTerrainSize = (JArray)json.data.data.data.size;
|
|
||||||
JArray jArrayTerrainHeights = (JArray)json.data.data.data.heights;
|
|
||||||
|
|
||||||
int[] outSizeArray = jArrayTerrainSize.Select(ja => (int)ja).ToArray();
|
|
||||||
float[] outHeightsArray = jArrayTerrainHeights.Select(ja => (float)ja).ToArray();
|
|
||||||
|
|
||||||
CollectionAssert.AreEqual(terrainSizeArray, outSizeArray);
|
|
||||||
CollectionAssert.AreEqual(terrainHeightsArray, json.data.data.data.heights.ToObject<float[]>());
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void AddLayer_TestMethod()
|
|
||||||
{
|
|
||||||
string testTunnelID = "dummyTunnelID";
|
|
||||||
string testSerial = "dummySerialCode";
|
|
||||||
|
|
||||||
string payloadId = "tunnel/send";
|
|
||||||
string messageId = "scene/node/addlayer";
|
|
||||||
|
|
||||||
|
|
||||||
string testUuid = "dummyUuid";
|
|
||||||
string diffuseExpected = @"data\NetworkEngine\textures\terrain\grass_green_d.jpg";
|
|
||||||
string normalExpected = @"data\NetworkEngine\textures\terrain\grass_green_n.jpg";
|
|
||||||
int minHeightExpected = 0;
|
|
||||||
int maxHeightExpected = 10;
|
|
||||||
int fadeDistExpected = 1;
|
|
||||||
|
|
||||||
|
|
||||||
Command command = new Command(testTunnelID);
|
|
||||||
|
|
||||||
string terrainAddCommand = command.AddLayer(testUuid, testSerial);
|
|
||||||
|
|
||||||
dynamic json = JsonConvert.DeserializeObject(terrainAddCommand);
|
|
||||||
|
|
||||||
//Test payload
|
|
||||||
Assert.AreEqual(payloadId, (string)json.id);
|
|
||||||
Assert.AreEqual(testTunnelID, (string)json.data.dest);
|
|
||||||
|
|
||||||
//Test message
|
|
||||||
Assert.AreEqual(messageId, (string)json.data.data.id);
|
|
||||||
Assert.AreEqual(testSerial, (string)json.data.data.serial);
|
|
||||||
|
|
||||||
//Test AddLayer
|
|
||||||
Assert.AreEqual(testUuid, (string)json.data.data.data.id);
|
|
||||||
Assert.AreEqual(diffuseExpected, (string)json.data.data.data.diffuse);
|
|
||||||
Assert.AreEqual(normalExpected, (string)json.data.data.data.normal);
|
|
||||||
Assert.AreEqual(minHeightExpected, (int)json.data.data.data.minHeight);
|
|
||||||
Assert.AreEqual(maxHeightExpected, (int)json.data.data.data.maxHeight);
|
|
||||||
Assert.AreEqual(fadeDistExpected, (int)json.data.data.data.fadeDist);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void UpdateTerrain_TestMethod()
|
|
||||||
{
|
|
||||||
string testTunnelID = "dummyTunnelID";
|
|
||||||
|
|
||||||
string payloadId = "tunnel/send";
|
|
||||||
string messageId = "scene/terrain/update";
|
|
||||||
|
|
||||||
Command command = new Command(testTunnelID);
|
|
||||||
|
|
||||||
string terrainAddCommand = command.UpdateTerrain();
|
|
||||||
|
|
||||||
dynamic json = JsonConvert.DeserializeObject(terrainAddCommand);
|
|
||||||
|
|
||||||
//Test payload
|
|
||||||
Assert.AreEqual(payloadId, (string)json.id);
|
|
||||||
Assert.AreEqual(testTunnelID, (string)json.data.dest);
|
|
||||||
|
|
||||||
//Test message
|
|
||||||
Assert.AreEqual(messageId, (string)json.data.data.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void renderTerrain_TestMethod()
|
|
||||||
{
|
|
||||||
string testTunnelID = "dummyTunnelID";
|
|
||||||
string testSerial = "dummySerialCode";
|
|
||||||
|
|
||||||
string payloadId = "tunnel/send";
|
|
||||||
string messageId = "scene/node/add";
|
|
||||||
|
|
||||||
|
|
||||||
string nameExpected = "newNode";
|
|
||||||
int[] positionExpected = new int[] { -80, 0, -80 };
|
|
||||||
float scaleExpected = 1f;
|
|
||||||
int[] rotationExpected = new int[] { 0, 0, 0 };
|
|
||||||
|
|
||||||
bool smoothnormalsExpected = true;
|
|
||||||
|
|
||||||
|
|
||||||
Command command = new Command(testTunnelID);
|
|
||||||
|
|
||||||
string terrainAddCommand = command.renderTerrain(testSerial);
|
|
||||||
|
|
||||||
dynamic json = JsonConvert.DeserializeObject(terrainAddCommand);
|
|
||||||
|
|
||||||
|
|
||||||
//Test payload
|
|
||||||
Assert.AreEqual(payloadId, (string)json.id);
|
|
||||||
Assert.AreEqual(testTunnelID, (string)json.data.dest);
|
|
||||||
|
|
||||||
//Test message
|
|
||||||
Assert.AreEqual(messageId, (string)json.data.data.id);
|
|
||||||
Assert.AreEqual(testSerial, (string)json.data.data.serial);
|
|
||||||
|
|
||||||
//Test data
|
|
||||||
Assert.AreEqual(nameExpected, (string)json.data.data.data.name);
|
|
||||||
|
|
||||||
//Test data components
|
|
||||||
|
|
||||||
//Test transform
|
|
||||||
JArray jArrayPosition = (JArray)json.data.data.data.components.transform.position;
|
|
||||||
JArray jArrayRotation = (JArray)json.data.data.data.components.transform.rotation;
|
|
||||||
|
|
||||||
int[] outPositionArray = jArrayPosition.Select(ja => (int)ja).ToArray();
|
|
||||||
int[] outRotationArray = jArrayRotation.Select(ja => (int)ja).ToArray();
|
|
||||||
|
|
||||||
CollectionAssert.AreEqual(positionExpected, outPositionArray);
|
|
||||||
CollectionAssert.AreEqual(rotationExpected, outRotationArray);
|
|
||||||
|
|
||||||
|
|
||||||
//Test terrain
|
|
||||||
Assert.AreEqual(smoothnormalsExpected, (bool)json.data.data.data.components.terrain.smoothnormals);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void DeleteNode_TestMethod()
|
|
||||||
{
|
|
||||||
string testTunnelID = "dummyTunnelID";
|
|
||||||
string testSerial = "dummySerialCode";
|
|
||||||
|
|
||||||
string payloadId = "tunnel/send";
|
|
||||||
string messageId = "scene/node/delete";
|
|
||||||
|
|
||||||
string uuid = "dummyUuid";
|
|
||||||
|
|
||||||
|
|
||||||
Command command = new Command(testTunnelID);
|
|
||||||
|
|
||||||
string terrainAddCommand = command.DeleteNode(uuid, testSerial);
|
|
||||||
|
|
||||||
dynamic json = JsonConvert.DeserializeObject(terrainAddCommand);
|
|
||||||
|
|
||||||
//Test payload
|
|
||||||
Assert.AreEqual(payloadId, (string)json.id);
|
|
||||||
Assert.AreEqual(testTunnelID, (string)json.data.dest);
|
|
||||||
|
|
||||||
//Test message
|
|
||||||
Assert.AreEqual(messageId, (string)json.data.data.id);
|
|
||||||
Assert.AreEqual(testSerial, (string)json.data.data.serial);
|
|
||||||
|
|
||||||
//Test data
|
|
||||||
Assert.AreEqual(uuid, (string)json.data.data.data.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void addPanel_TestMethod()
|
|
||||||
{
|
|
||||||
string testTunnelID = "dummyTunnelID";
|
|
||||||
string testSerial = "dummySerialCode";
|
|
||||||
|
|
||||||
string payloadId = "tunnel/send";
|
|
||||||
string messageId = "scene/node/add";
|
|
||||||
|
|
||||||
string uuidBike = "dummyUuidBike";
|
|
||||||
|
|
||||||
string nameExpected = "dashboard";
|
|
||||||
|
|
||||||
//components
|
|
||||||
//transform
|
|
||||||
float[] positionExpected = new float[] { -1.5f, 1f, 0f };
|
|
||||||
int scaleExpected = 1;
|
|
||||||
int[] rotationExpected = new int[] { -30, 90, 0 };
|
|
||||||
|
|
||||||
//panel
|
|
||||||
int[] sizeExpected = new int[] { 1, 1 };
|
|
||||||
int[] resolutionExpected = new int[] { 512, 512 };
|
|
||||||
int[] backgroundExpected = new int[] { 1, 1, 1, 1 };
|
|
||||||
bool castShadowExpected = false;
|
|
||||||
|
|
||||||
Command command = new Command(testTunnelID);
|
|
||||||
|
|
||||||
string terrainAddCommand = command.addPanel(testSerial, uuidBike);
|
|
||||||
|
|
||||||
dynamic json = JsonConvert.DeserializeObject(terrainAddCommand);
|
|
||||||
|
|
||||||
//Test payload
|
|
||||||
Assert.AreEqual(payloadId, (string)json.id);
|
|
||||||
Assert.AreEqual(testTunnelID, (string)json.data.dest);
|
|
||||||
|
|
||||||
//Test message
|
|
||||||
Assert.AreEqual(messageId, (string)json.data.data.id);
|
|
||||||
Assert.AreEqual(testSerial, (string)json.data.data.serial);
|
|
||||||
|
|
||||||
//Test data
|
|
||||||
Assert.AreEqual(nameExpected, (string)json.data.data.data.name);
|
|
||||||
Assert.AreEqual(uuidBike, (string)json.data.data.data.parent);
|
|
||||||
|
|
||||||
//Test components
|
|
||||||
|
|
||||||
//Test transform
|
|
||||||
JArray jArrayPosition = (JArray)json.data.data.data.components.transform.position;
|
|
||||||
JArray jArrayRotation = (JArray)json.data.data.data.components.transform.rotation;
|
|
||||||
|
|
||||||
float[] outPositionArray = jArrayPosition.Select(ja => (float)ja).ToArray();
|
|
||||||
int[] outRotationArray = jArrayRotation.Select(ja => (int)ja).ToArray();
|
|
||||||
|
|
||||||
CollectionAssert.AreEqual(positionExpected, outPositionArray);
|
|
||||||
CollectionAssert.AreEqual(rotationExpected, outRotationArray);
|
|
||||||
|
|
||||||
Assert.AreEqual(scaleExpected, (int)json.data.data.data.components.transform.scale);
|
|
||||||
|
|
||||||
//Test panel
|
|
||||||
CollectionAssert.AreEqual(sizeExpected, ((JArray)json.data.data.data.components.panel.size).Select(ja => (int)ja).ToArray());
|
|
||||||
CollectionAssert.AreEqual(resolutionExpected, ((JArray)json.data.data.data.components.panel.resolution).Select(ja => (int)ja).ToArray());
|
|
||||||
CollectionAssert.AreEqual(backgroundExpected, ((JArray)json.data.data.data.components.panel.background).Select(ja => (int)ja).ToArray());
|
|
||||||
Assert.AreEqual(castShadowExpected, (bool)json.data.data.data.components.panel.castShadow);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void ColorPanel_TestMethod()
|
|
||||||
{
|
|
||||||
string testTunnelID = "dummyTunnelID";
|
|
||||||
|
|
||||||
string payloadId = "tunnel/send";
|
|
||||||
string messageId = "scene/panel/setclearcolor";
|
|
||||||
|
|
||||||
string uuidPanel = "dummyUuidPanel";
|
|
||||||
|
|
||||||
float[] colorExpected = new float[] { 0f, 0f, 0f, 0f };
|
|
||||||
|
|
||||||
|
|
||||||
Command command = new Command(testTunnelID);
|
|
||||||
|
|
||||||
string terrainAddCommand = command.ColorPanel(uuidPanel);
|
|
||||||
|
|
||||||
dynamic json = JsonConvert.DeserializeObject(terrainAddCommand);
|
|
||||||
|
|
||||||
//Test payload
|
|
||||||
Assert.AreEqual(payloadId, (string)json.id);
|
|
||||||
Assert.AreEqual(testTunnelID, (string)json.data.dest);
|
|
||||||
|
|
||||||
//Test message
|
|
||||||
Assert.AreEqual(messageId, (string)json.data.data.id);
|
|
||||||
|
|
||||||
//Test data
|
|
||||||
Assert.AreEqual(uuidPanel, (string)json.data.data.data.id);
|
|
||||||
CollectionAssert.AreEqual(colorExpected, ((JArray)json.data.data.data.color).Select(ja => (float)ja).ToArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void SwapPanel_TestMethod()
|
|
||||||
{
|
|
||||||
string testTunnelID = "dummyTunnelID";
|
|
||||||
|
|
||||||
string payloadId = "tunnel/send";
|
|
||||||
string messageId = "scene/panel/swap";
|
|
||||||
|
|
||||||
string uuid = "dummyUuid";
|
|
||||||
|
|
||||||
|
|
||||||
Command command = new Command(testTunnelID);
|
|
||||||
|
|
||||||
string terrainAddCommand = command.SwapPanel(uuid);
|
|
||||||
|
|
||||||
dynamic json = JsonConvert.DeserializeObject(terrainAddCommand);
|
|
||||||
|
|
||||||
//Test payload
|
|
||||||
Assert.AreEqual(payloadId, (string)json.id);
|
|
||||||
Assert.AreEqual(testTunnelID, (string)json.data.dest);
|
|
||||||
|
|
||||||
//Test message
|
|
||||||
Assert.AreEqual(messageId, (string)json.data.data.id);
|
|
||||||
|
|
||||||
//Test data
|
|
||||||
Assert.AreEqual(uuid, (string)json.data.data.data.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void showOnPanel_TestMethod()
|
|
||||||
{
|
|
||||||
string testTunnelID = "dummyTunnelID";
|
|
||||||
string testSerial = "dummySerialCode";
|
|
||||||
|
|
||||||
string payloadId = "tunnel/send";
|
|
||||||
string messageId = "scene/panel/drawtext";
|
|
||||||
|
|
||||||
string uuidPanel = "dummyUuidPanel";
|
|
||||||
string text = "dummyText";
|
|
||||||
int index = 3;
|
|
||||||
int[] positionExpected = new int[] { 4, 24 + index * 32 };
|
|
||||||
double sizeExpected = 32.0;
|
|
||||||
int[] colorExpected = new int[] { 0, 0, 0, 1 };
|
|
||||||
string fontExpected = "segoeui";
|
|
||||||
|
|
||||||
|
|
||||||
Command command = new Command(testTunnelID);
|
|
||||||
|
|
||||||
string terrainAddCommand = command.showOnPanel(uuidPanel, testSerial, text, index);
|
|
||||||
|
|
||||||
dynamic json = JsonConvert.DeserializeObject(terrainAddCommand);
|
|
||||||
|
|
||||||
//Test payload
|
|
||||||
Assert.AreEqual(payloadId, (string)json.id);
|
|
||||||
Assert.AreEqual(testTunnelID, (string)json.data.dest);
|
|
||||||
|
|
||||||
//Test message
|
|
||||||
Assert.AreEqual(messageId, (string)json.data.data.id);
|
|
||||||
Assert.AreEqual(testSerial, (string)json.data.data.serial);
|
|
||||||
|
|
||||||
//Test data
|
|
||||||
Assert.AreEqual(uuidPanel, (string)json.data.data.data.id);
|
|
||||||
Assert.AreEqual(text, (string)json.data.data.data.text);
|
|
||||||
CollectionAssert.AreEqual(positionExpected, ((JArray)json.data.data.data.position).Select(ja => (int)ja).ToArray());
|
|
||||||
Assert.AreEqual(sizeExpected, (double)json.data.data.data.size);
|
|
||||||
CollectionAssert.AreEqual(colorExpected, ((JArray)json.data.data.data.color).Select(ja => (int)ja).ToArray());
|
|
||||||
Assert.AreEqual(fontExpected, (string)json.data.data.data.font);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void SwapPanelCommand_TestMethod()
|
|
||||||
{
|
|
||||||
string testTunnelID = "dummyTunnelID";
|
|
||||||
|
|
||||||
string payloadId = "tunnel/send";
|
|
||||||
string messageId = "scene/panel/swap";
|
|
||||||
|
|
||||||
string uuid = "dummyUuid";
|
|
||||||
|
|
||||||
|
|
||||||
Command command = new Command(testTunnelID);
|
|
||||||
|
|
||||||
string terrainAddCommand = command.SwapPanelCommand(uuid);
|
|
||||||
|
|
||||||
dynamic json = JsonConvert.DeserializeObject(terrainAddCommand);
|
|
||||||
|
|
||||||
//Test payload
|
|
||||||
Assert.AreEqual(payloadId, (string)json.id);
|
|
||||||
Assert.AreEqual(testTunnelID, (string)json.data.dest);
|
|
||||||
|
|
||||||
//Test message
|
|
||||||
Assert.AreEqual(messageId, (string)json.data.data.id);
|
|
||||||
|
|
||||||
//Test data
|
|
||||||
Assert.AreEqual(uuid, (string)json.data.data.data.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void ClearPanel_TestMethod()
|
|
||||||
{
|
|
||||||
string testTunnelID = "dummyTunnelID";
|
|
||||||
|
|
||||||
string payloadId = "tunnel/send";
|
|
||||||
string messageId = "scene/panel/clear";
|
|
||||||
|
|
||||||
string uuid = "dummyUuid";
|
|
||||||
|
|
||||||
|
|
||||||
Command command = new Command(testTunnelID);
|
|
||||||
|
|
||||||
string terrainAddCommand = command.ClearPanel(uuid);
|
|
||||||
|
|
||||||
dynamic json = JsonConvert.DeserializeObject(terrainAddCommand);
|
|
||||||
|
|
||||||
//Test payload
|
|
||||||
Assert.AreEqual(payloadId, (string)json.id);
|
|
||||||
Assert.AreEqual(testTunnelID, (string)json.data.dest);
|
|
||||||
|
|
||||||
//Test terrain
|
|
||||||
Assert.AreEqual(messageId, (string)json.data.data.id);
|
|
||||||
|
|
||||||
//Test data
|
|
||||||
Assert.AreEqual(uuid, (string)json.data.data.data.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using RH_Engine;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using Util;
|
|
||||||
|
|
||||||
namespace UnitTestRH
|
|
||||||
{
|
|
||||||
[TestClass]
|
|
||||||
public class DataParserTest
|
|
||||||
{
|
|
||||||
|
|
||||||
public byte[] GetPayload(byte[] message)
|
|
||||||
{
|
|
||||||
byte[] payload = new byte[message.Length - 5];
|
|
||||||
Array.Copy(message, 5, payload, 0, message.Length - 5);
|
|
||||||
return payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void TestGetMessageToSend()
|
|
||||||
{
|
|
||||||
byte[] toTest = DataParser.GetMessageToSend("test");
|
|
||||||
|
|
||||||
dynamic res = JsonConvert.DeserializeObject(Encoding.ASCII.GetString((toTest)));
|
|
||||||
Assert.AreEqual("MESSAGE", (string)res.identifier);
|
|
||||||
Assert.AreEqual("test", (string)res.data.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void TestIsRawDataBikeServer()
|
|
||||||
{
|
|
||||||
byte[] testArr = { 0x34,0x00,0x00,0x00,0x02};
|
|
||||||
byte[] testArr2 = { 0x34, 0x00, 0x00, 0x00, 0x02,0x49,0x65 };
|
|
||||||
Assert.ThrowsException<ArgumentException>(() => DataParser.isRawDataBikeServer(testArr));
|
|
||||||
Assert.IsTrue(DataParser.isRawDataBikeServer(testArr2));
|
|
||||||
}
|
|
||||||
[TestMethod]
|
|
||||||
public void TestIsRawDataBikeDoctor()
|
|
||||||
{
|
|
||||||
byte[] testArr = { 0x34, 0x00, 0x00, 0x00, 0x04 };
|
|
||||||
byte[] testArr2 = { 0x34, 0x00, 0x00, 0x00, 0x04, 0x49, 0x65 };
|
|
||||||
Assert.ThrowsException<ArgumentException>(() => DataParser.isRawDataBikeDoctor(testArr));
|
|
||||||
Assert.IsTrue(DataParser.isRawDataBikeDoctor(testArr2));
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void TestIsRawDataBPMServer()
|
|
||||||
{
|
|
||||||
byte[] testArr = { 0x34, 0x00, 0x00, 0x00, 0x03};
|
|
||||||
byte[] testArr2 = { 0x34, 0x00, 0x00, 0x00, 0x03, 0x49, 0x65 };
|
|
||||||
Assert.ThrowsException<ArgumentException>(() => DataParser.isRawDataBPMServer(testArr));
|
|
||||||
Assert.IsTrue(DataParser.isRawDataBPMServer(testArr2));
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void TestIsRawDataBPMDoctor()
|
|
||||||
{
|
|
||||||
byte[] testArr = { 0x34, 0x00, 0x00, 0x00, 0x05 };
|
|
||||||
byte[] testArr2 = { 0x34, 0x00, 0x00, 0x00, 0x05, 0x49, 0x65 };
|
|
||||||
Assert.ThrowsException<ArgumentException>(() => DataParser.isRawDataBPMDoctor(testArr));
|
|
||||||
Assert.IsTrue(DataParser.isRawDataBPMDoctor(testArr2));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
|
||||||
|
|
||||||
<IsPackable>false</IsPackable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
|
||||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.0" />
|
|
||||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.0" />
|
|
||||||
<PackageReference Include="coverlet.collector" Version="1.2.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\ClientApp\ClientApp.csproj" />
|
|
||||||
<ProjectReference Include="..\DoctorApp\DoctorApp.csproj" />
|
|
||||||
<ProjectReference Include="..\ProftaakRH\ProftaakRH.csproj" />
|
|
||||||
<ProjectReference Include="..\RH-Engine\RH-Engine.csproj" />
|
|
||||||
<ProjectReference Include="..\Server\Server.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<Import Project="..\Hashing\Hashing.projitems" Label="Shared" />
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
Reference in New Issue
Block a user