From 5d14d53df58c6df7640c99ecb779d9c8eb7c069d Mon Sep 17 00:00:00 2001 From: shinichi Date: Fri, 2 Oct 2020 16:29:11 +0200 Subject: [PATCH 01/20] wip --- Server/Client.cs | 7 +++++++ Server/SaveData.cs | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Server/Client.cs b/Server/Client.cs index 0151e87..34cae9f 100644 --- a/Server/Client.cs +++ b/Server/Client.cs @@ -21,6 +21,7 @@ namespace Server private string username = null; private DateTime sessionStart; private string fileName; + private int temp; @@ -150,6 +151,12 @@ namespace Server else if (payloadbytes.Length == 2) { saveData?.WriteDataRAWBPM(payloadbytes); + temp++; + if (temp > 50) + { + Console.WriteLine(BitConverter.ToString(this.saveData?.getBPMgraphData(100, 1))); + temp = 0; + } } else { diff --git a/Server/SaveData.cs b/Server/SaveData.cs index bcabb1f..d8e1401 100644 --- a/Server/SaveData.cs +++ b/Server/SaveData.cs @@ -86,6 +86,7 @@ namespace Server { FileInfo fi = new FileInfo(this.path + rawBPMFilename); int length = (int)fi.Length; + Console.WriteLine("length " + length); byte[] output = new byte[outputSize]; @@ -95,13 +96,14 @@ namespace Server using (FileStream fileStream = new FileStream(this.path + rawBPMFilename, FileMode.Open, FileAccess.Read)) { - for (int i = 1; i >= outputSize; i++) + for (int i = 1; i <= outputSize; i++) { if (length - (i * readSize) < 0) { break; } - fileStream.Read(readBuffer, length - (i * readSize), readSize); + Console.WriteLine("reading " + (length - (i * readSize) - 1) + " and size " + readSize); + fileStream.Read(readBuffer, length - (i * readSize) - 1, readSize); //handling data int total = 0; From c2b4b259a3481d97a189c91359d602db40cc8588 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Wed, 7 Oct 2020 11:23:09 +0200 Subject: [PATCH 02/20] comment --- Server/Client.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Server/Client.cs b/Server/Client.cs index 6219992..b0a43ad 100644 --- a/Server/Client.cs +++ b/Server/Client.cs @@ -75,7 +75,7 @@ namespace Server /// - /// TODO + /// handles all incoming data from the client /// /// including message length and messageId (can be changed) private void HandleData(byte[] message) @@ -214,10 +214,6 @@ namespace Server } } - - - - public static string ByteArrayToString(byte[] ba) { StringBuilder hex = new StringBuilder(ba.Length * 2); From f6c2b3c662a405ebfec46c8f72d7e4ccd4cefe22 Mon Sep 17 00:00:00 2001 From: Logophilist Date: Wed, 7 Oct 2020 11:51:02 +0200 Subject: [PATCH 03/20] Panel fixed --- RH-Engine/Command.cs | 15 ++++++++++++++- RH-Engine/Program.cs | 28 +++------------------------- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/RH-Engine/Command.cs b/RH-Engine/Command.cs index 110965f..3875448 100644 --- a/RH-Engine/Command.cs +++ b/RH-Engine/Command.cs @@ -106,8 +106,21 @@ namespace RH_Engine data = new { name = "dashboard", + parent = uuidBike, components = new { + transform = new + { + position = new float[] + { + -1.5f, 1f, 0f + }, + scale = 1, + rotation = new int[] + { + -30, 90,0 + } + }, panel = new { size = new int[] { 1, 1 }, @@ -130,7 +143,7 @@ namespace RH_Engine data = new { id = uuidPanel, - color = new int[] { 1, 1, 1, 1 } + color = new float[] { 0f, 0f, 0f, 0f } } }; diff --git a/RH-Engine/Program.cs b/RH-Engine/Program.cs index 52c29a6..bfac8c8 100644 --- a/RH-Engine/Program.cs +++ b/RH-Engine/Program.cs @@ -179,6 +179,7 @@ namespace RH_Engine bool speedReplied = false; bool moveReplied = true; panelId = JSONParser.getPanelID(message); + WriteTextMessage(stream, mainCommand.ColorPanel(panelId)); WriteTextMessage(stream, mainCommand.ClearPanel(panelId)); @@ -186,6 +187,7 @@ namespace RH_Engine (message) => { Console.WriteLine(message); + SendMessageAndOnResponse(stream, mainCommand.bikeSpeed(panelId, "bikeSpeed", 5.0), "bikeSpeed", (message) => { @@ -223,31 +225,7 @@ namespace RH_Engine //WriteTextMessage(stream, mainCommand.TerrainCommand(new int[] { 256, 256 }, null)); //string command; - - - -<<<<<<< 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 } /// @@ -330,7 +308,7 @@ namespace RH_Engine { 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 })); + //WriteTextMessage(stream, mainCommand.RouteFollow(routeId, panelId, speed, 1f, "XYZ", 1, false, new float[] { 0, 0, 0 }, new float[] { 0f, 5f, 5f })); } //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) From f31cdeb4679734bc92ea904614bf3ec7f2ea1fb0 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Wed, 7 Oct 2020 11:52:14 +0200 Subject: [PATCH 04/20] some writelines --- Client/Client.cs | 3 +++ RH-Engine/Program.cs | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Client/Client.cs b/Client/Client.cs index 1a3392a..b4e605d 100644 --- a/Client/Client.cs +++ b/Client/Client.cs @@ -103,14 +103,17 @@ namespace Client } break; case DataParser.START_SESSION: + Console.WriteLine("Start session identifier"); this.sessionRunning = true; sendMessage(DataParser.getStartSessionJson()); break; case DataParser.STOP_SESSION: + Console.WriteLine("Stop session identifier"); this.sessionRunning = false; sendMessage(DataParser.getStopSessionJson()); break; case DataParser.SET_RESISTANCE: + Console.WriteLine("Set resistance identifier"); if (this.handler == null) { Console.WriteLine("handler is null"); diff --git a/RH-Engine/Program.cs b/RH-Engine/Program.cs index 52c29a6..7bd7770 100644 --- a/RH-Engine/Program.cs +++ b/RH-Engine/Program.cs @@ -226,7 +226,6 @@ namespace RH_Engine -<<<<<<< HEAD //Console.WriteLine("id of head " + GetId(Command.STANDARD_HEAD, stream, mainCommand)); //command = mainCommand.AddModel("car", "data\\customModels\\TeslaRoadster.fbx"); @@ -245,9 +244,8 @@ namespace RH_Engine // 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 + } /// From 7c943f4f733dee1f00f00853a5132f48fecaac4c Mon Sep 17 00:00:00 2001 From: shinichi Date: Wed, 7 Oct 2020 11:54:47 +0200 Subject: [PATCH 05/20] fix --- Server/Client.cs | 2 +- Server/SaveData.cs | 28 ++++++++++++++++++++-------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Server/Client.cs b/Server/Client.cs index 34cae9f..ccf39fd 100644 --- a/Server/Client.cs +++ b/Server/Client.cs @@ -154,7 +154,7 @@ namespace Server temp++; if (temp > 50) { - Console.WriteLine(BitConverter.ToString(this.saveData?.getBPMgraphData(100, 1))); + Console.WriteLine(BitConverter.ToString(this.saveData?.getBPMgraphData(10, 2))); temp = 0; } } diff --git a/Server/SaveData.cs b/Server/SaveData.cs index d8e1401..2e78392 100644 --- a/Server/SaveData.cs +++ b/Server/SaveData.cs @@ -63,12 +63,20 @@ namespace Server { // do nothing } - using (BinaryWriter sw = new BinaryWriter(File.Open(fileLocation, FileMode.Create))) + using (var fileStream = new FileStream(fileLocation, FileMode.Append, FileAccess.Write, FileShare.None)) + using (var bw = new BinaryWriter(fileStream)) { - sw.Seek(length, SeekOrigin.End); - sw.Write(data); - sw.Flush(); + //sw.BaseStream.Seek(length, SeekOrigin.Begin); + bw.Write(data); + bw.Flush(); + //Console.WriteLine("wrote at " + bw.BaseStream.Position); } + //using (BinaryReader binaryReader = new BinaryReader(File.Open(fileLocation, FileMode.Open))) + //{ + // byte[] totalArray = new byte[binaryReader.BaseStream.Length]; + // binaryReader.BaseStream.Read(totalArray, 0, (int)binaryReader.BaseStream.Length); + // Console.WriteLine("all data is " + BitConverter.ToString(totalArray)); + //} } /// @@ -86,7 +94,7 @@ namespace Server { FileInfo fi = new FileInfo(this.path + rawBPMFilename); int length = (int)fi.Length; - Console.WriteLine("length " + length); + //Console.WriteLine("length " + length); byte[] output = new byte[outputSize]; @@ -94,16 +102,20 @@ namespace Server int readSize = messageSize * averageOver; byte[] readBuffer = new byte[readSize]; - using (FileStream fileStream = new FileStream(this.path + rawBPMFilename, FileMode.Open, FileAccess.Read)) + using (BinaryReader binaryReader = new BinaryReader(File.Open(this.path + rawBPMFilename, FileMode.Open))) { + //byte[] totalArray = new byte[binaryReader.BaseStream.Length]; + //binaryReader.BaseStream.Read(totalArray, 0, (int)binaryReader.BaseStream.Length); + //Console.WriteLine("all data is " + BitConverter.ToString(totalArray)); for (int i = 1; i <= outputSize; i++) { if (length - (i * readSize) < 0) { break; } - Console.WriteLine("reading " + (length - (i * readSize) - 1) + " and size " + readSize); - fileStream.Read(readBuffer, length - (i * readSize) - 1, readSize); + binaryReader.BaseStream.Seek(length - (i * readSize), SeekOrigin.Begin); + binaryReader.BaseStream.Read(readBuffer, 0, readSize); + //Console.WriteLine("read " + binaryReader.BaseStream.Position + " and size " + readSize + " with value " + BitConverter.ToString(readBuffer)); //handling data int total = 0; From 472c5142757740c916190123dcfb5773b9fa193f Mon Sep 17 00:00:00 2001 From: shinichi Date: Wed, 7 Oct 2020 11:55:49 +0200 Subject: [PATCH 06/20] removed debugging --- Server/Client.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Server/Client.cs b/Server/Client.cs index ccf39fd..0151e87 100644 --- a/Server/Client.cs +++ b/Server/Client.cs @@ -21,7 +21,6 @@ namespace Server private string username = null; private DateTime sessionStart; private string fileName; - private int temp; @@ -151,12 +150,6 @@ namespace Server else if (payloadbytes.Length == 2) { saveData?.WriteDataRAWBPM(payloadbytes); - temp++; - if (temp > 50) - { - Console.WriteLine(BitConverter.ToString(this.saveData?.getBPMgraphData(10, 2))); - temp = 0; - } } else { From bff4718d3f9cf314964b1b169b46505e421a8112 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Wed, 7 Oct 2020 12:51:09 +0200 Subject: [PATCH 07/20] added route to client vr scene --- Client/Client.cs | 9 ++++- Client/EngineConnection.cs | 75 ++++++++++++++++++++++++++++++++------ Client/Program.cs | 2 +- Server/Client.cs | 2 + 4 files changed, 73 insertions(+), 15 deletions(-) diff --git a/Client/Client.cs b/Client/Client.cs index 9115f01..e4d1d77 100644 --- a/Client/Client.cs +++ b/Client/Client.cs @@ -38,6 +38,7 @@ namespace Client { engineConnection = EngineConnection.INSTANCE; engineConnection.OnNoTunnelId = retryEngineConnection; + engineConnection.OnSuccessFullConnection = engineConnected; if (!engineConnection.Connected) engineConnection.Connect(); } @@ -53,6 +54,12 @@ namespace Client engineConnection.CreateConnection(); } + private void engineConnected() + { + engineConnection.initScene(); + if (this.sessionRunning) engineConnection.StartRouteFollow(); + } + /// /// callback method for when the TCP client is connected /// @@ -193,7 +200,6 @@ namespace Client throw new ArgumentNullException("no bytes"); } byte[] message = DataParser.GetRawDataMessage(bytes); - Console.WriteLine("got bpm message: " + message); this.stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), null); } @@ -212,7 +218,6 @@ namespace Client throw new ArgumentNullException("no bytes"); } byte[] message = DataParser.GetRawDataMessage(bytes); - Console.WriteLine("got bike message: " + message); this.stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), null); } diff --git a/Client/EngineConnection.cs b/Client/EngineConnection.cs index 4905911..a0222a1 100644 --- a/Client/EngineConnection.cs +++ b/Client/EngineConnection.cs @@ -8,12 +8,14 @@ namespace Client { public delegate void HandleSerial(string message); public delegate void HandleNoTunnelId(); + public delegate void OnSuccessfullConnection(); public sealed class EngineConnection { private static EngineConnection instance = null; private static readonly object padlock = new object(); public HandleNoTunnelId OnNoTunnelId; + public OnSuccessfullConnection OnSuccessFullConnection; private static PC[] PCs = { @@ -29,9 +31,11 @@ namespace Client 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 NetworkStream stream; @@ -45,6 +49,9 @@ namespace Client } + /// + /// Singleton constructor + /// public static EngineConnection INSTANCE { get @@ -60,6 +67,11 @@ namespace Client } } + + + /// + /// connects to the vr engine and initalizes the serverResponseReader + /// public void Connect() { TcpClient client = new TcpClient("145.48.6.10", 6666); @@ -68,6 +80,19 @@ namespace Client CreateConnection(); } + /// + /// initializes and starts the reading of the responses from the vr server + /// + /// the networkstream + private void initReader() + { + serverResponseReader = new ServerResponseReader(stream); + serverResponseReader.callback = HandleResponse; + serverResponseReader.StartRead(); + Connected = true; + } + + #region VR Message traffic /// /// connects to the server and creates the tunnel /// @@ -89,20 +114,10 @@ namespace Client if (tunnelId != null) { Write("got tunnel id! " + tunnelId); + OnSuccessFullConnection?.Invoke(); } - mainCommand = new Command(tunnelId); - } - /// - /// initializes and starts the reading of the responses from the vr server - /// - /// the networkstream - private void initReader() - { - serverResponseReader = new ServerResponseReader(stream); - serverResponseReader.callback = HandleResponse; - serverResponseReader.StartRead(); - Connected = true; + } /// @@ -117,6 +132,7 @@ namespace Client if (id == "session/list") { sessionId = JSONParser.GetSessionID(message, PCs); + Write("got session id"); } else if (id == "tunnel/create") { @@ -139,6 +155,39 @@ namespace Client } } + public void initScene() + { + mainCommand = new Command(tunnelId); + + // reset the scene + WriteTextMessage(mainCommand.ResetScene()); + + //Get sceneinfo and set the id's + SendMessageAndOnResponse(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 the route and set the route id + SendMessageAndOnResponse(mainCommand.RouteCommand("routeID"), "routeID", (message) => routeId = JSONParser.GetResponseUuid(message)); + } + + internal void StartRouteFollow() + { + throw new NotImplementedException(); + } + + #endregion + + #region message send/receive + /// /// method that sends the speciefied message with the specified serial, and executes the given action upon receivind a reply from the server with this serial. /// @@ -169,6 +218,8 @@ namespace Client //Write("sent message " + message); } + + #endregion public void Write(string msg) { Console.WriteLine( "[ENGINECONNECT] " + msg); diff --git a/Client/Program.cs b/Client/Program.cs index 303b929..80b7fd8 100644 --- a/Client/Program.cs +++ b/Client/Program.cs @@ -11,7 +11,7 @@ namespace Client { static void Main(string[] args) { - Console.WriteLine("Hello World!"); + Console.WriteLine("// Connecting... //"); //connect fiets? Client client = new Client(); diff --git a/Server/Client.cs b/Server/Client.cs index a38f747..3fa7ba0 100644 --- a/Server/Client.cs +++ b/Server/Client.cs @@ -142,7 +142,9 @@ namespace Server } else if (DataParser.isRawData(message)) { + // print the raw data Console.WriteLine(BitConverter.ToString(payloadbytes)); + // TODO change, checking for length is not that safe if (payloadbytes.Length == 8) { saveData?.WriteDataRAWBike(payloadbytes); From 26a784277ac7f1867a4265cd1ba21f575bf9d613 Mon Sep 17 00:00:00 2001 From: Logophilist Date: Wed, 7 Oct 2020 12:58:50 +0200 Subject: [PATCH 08/20] Panel now shows more data --- RH-Engine/Command.cs | 45 ++++++++++++++++++++++++++++++++++++---- RH-Engine/Program.cs | 49 ++++++++++++++++++++++++++++++++------------ 2 files changed, 77 insertions(+), 17 deletions(-) diff --git a/RH-Engine/Command.cs b/RH-Engine/Command.cs index 3875448..ba8a6c0 100644 --- a/RH-Engine/Command.cs +++ b/RH-Engine/Command.cs @@ -164,7 +164,7 @@ namespace RH_Engine return JsonConvert.SerializeObject(Payload(payload)); } - public string bikeSpeed(string uuidPanel, string serialCode, double speed) + private string showOnPanel(string uuidPanel, string serialCode, string mText, int index) { dynamic payload = new { @@ -173,9 +173,9 @@ namespace RH_Engine data = new { id = uuidPanel, - text = "Speed: " + speed.ToString(), - position = new int[] { 4, 24 }, - size = 36.0, + text = mText, + position = new int[] { 4, 24 + index * 32 }, + size = 32.0, color = new int[] { 0, 0, 0, 1 }, font = "segoeui" } @@ -184,6 +184,43 @@ namespace RH_Engine return JsonConvert.SerializeObject(Payload(payload)); } + + public string showBikespeed(string uuidPanel, string serialCode, double speed) + { + //dynamic payload = new + //{ + // id = "scene/panel/drawtext", + // serial = serialCode, + // data = new + // { + // id = uuidPanel, + // text = "Speed: " + speed + " m/s", + // position = new int[] { 4, 24 }, + // size = 36.0, + // color = new int[] { 0, 0, 0, 1 }, + // font = "segoeui" + // } + //}; + + //return JsonConvert.SerializeObject(Payload(payload)); + return showOnPanel(uuidPanel, serialCode, "Speed: " + speed + " m/s", 0); + } + + public string showHeartrate(string uuidPanel, string serialCode, int bpm) + { + return showOnPanel(uuidPanel, serialCode, "Heartrate: " + bpm + " bpm", 1); + } + + public string showPower(string uuidPanel, string serialCode, double power) + { + return showOnPanel(uuidPanel, serialCode, "Inst. Power: " + power + " W", 2); + } + + public string showResistance(string uuidPanel, string serialCode, double resistance) + { + return showOnPanel(uuidPanel, serialCode, "Resistance: " + resistance + " %", 3); + } + public string SwapPanelCommand(string uuid) { dynamic payload = new diff --git a/RH-Engine/Program.cs b/RH-Engine/Program.cs index ae25339..4d11703 100644 --- a/RH-Engine/Program.cs +++ b/RH-Engine/Program.cs @@ -81,7 +81,11 @@ namespace RH_Engine //Console.WriteLine("GOT MESSAGE WITH SERIAL: " + message + "\n\n\n"); string serial = JSONParser.GetSerial(message); //Console.WriteLine("Got serial " + serial); - if (serialResponses.ContainsKey(serial)) serialResponses[serial].Invoke(message); + if (serialResponses.ContainsKey(serial)) + { + serialResponses[serial].Invoke(message); + serialResponses.Remove(serial); + } } } @@ -181,19 +185,9 @@ namespace RH_Engine panelId = JSONParser.getPanelID(message); WriteTextMessage(stream, mainCommand.ColorPanel(panelId)); 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)); - }); - }); + + showPanel(stream, mainCommand, 5.3, 83, 52, 53); //while (!(speedReplied && moveReplied)) { } @@ -325,6 +319,35 @@ namespace RH_Engine return res; } + + private static void showPanel(NetworkStream stream, Command mainCommand, double bikeSpeed, int bpm, int power, int resistance) + { + SendMessageAndOnResponse(stream, mainCommand.showBikespeed(panelId, "bikeSpeed", bikeSpeed), "bikeSpeed", + (message) => + { + // TODO check if is drawn + }); + SendMessageAndOnResponse(stream, mainCommand.showHeartrate(panelId, "bpm", bpm), "bpm", + (message) => + { + // TODO check if is drawn + }); + SendMessageAndOnResponse(stream, mainCommand.showPower(panelId, "power", power), "power", + (message) => + { + // TODO check if is drawn + }); + SendMessageAndOnResponse(stream, mainCommand.showResistance(panelId, "resistance", resistance), "resistance", + (message) => + { + // TODO check if is drawn + }); + + // Check if every text is drawn! + + WriteTextMessage(stream, mainCommand.SwapPanel(panelId)); + } + 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 })); From 6e2b3a80b3a8ec8a23ff5e11a259a0e8ea0a7b21 Mon Sep 17 00:00:00 2001 From: shinichi Date: Wed, 7 Oct 2020 13:17:40 +0200 Subject: [PATCH 09/20] wip --- ClientApp/App.xaml | 18 +++++++ ClientApp/App.xaml.cs | 17 ++++++ ClientApp/AssemblyInfo.cs | 10 ++++ ClientApp/ClientApp.csproj | 15 ++++++ ClientApp/FodyWeavers.xml | 3 ++ ClientApp/FodyWeavers.xsd | 74 ++++++++++++++++++++++++++ ClientApp/Models/ClientInfo.cs | 13 +++++ ClientApp/Utils/ObservableObject.cs | 12 +++++ ClientApp/ViewModels/LoginViewModel.cs | 11 ++++ ClientApp/ViewModels/MainViewModel.cs | 18 +++++++ ClientApp/Views/LoginView.xaml | 18 +++++++ ClientApp/Views/LoginView.xaml.cs | 26 +++++++++ ClientApp/Views/MainView.xaml | 13 +++++ ClientApp/Views/MainView.xaml.cs | 27 ++++++++++ ClientApp/Views/MainWindow.xaml | 18 +++++++ ClientApp/Views/MainWindow.xaml.cs | 30 +++++++++++ ProftaakRH/ProftaakRH.sln | 6 +++ 17 files changed, 329 insertions(+) create mode 100644 ClientApp/App.xaml create mode 100644 ClientApp/App.xaml.cs create mode 100644 ClientApp/AssemblyInfo.cs create mode 100644 ClientApp/ClientApp.csproj create mode 100644 ClientApp/FodyWeavers.xml create mode 100644 ClientApp/FodyWeavers.xsd create mode 100644 ClientApp/Models/ClientInfo.cs create mode 100644 ClientApp/Utils/ObservableObject.cs create mode 100644 ClientApp/ViewModels/LoginViewModel.cs create mode 100644 ClientApp/ViewModels/MainViewModel.cs create mode 100644 ClientApp/Views/LoginView.xaml create mode 100644 ClientApp/Views/LoginView.xaml.cs create mode 100644 ClientApp/Views/MainView.xaml create mode 100644 ClientApp/Views/MainView.xaml.cs create mode 100644 ClientApp/Views/MainWindow.xaml create mode 100644 ClientApp/Views/MainWindow.xaml.cs diff --git a/ClientApp/App.xaml b/ClientApp/App.xaml new file mode 100644 index 0000000..1400927 --- /dev/null +++ b/ClientApp/App.xaml @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/ClientApp/App.xaml.cs b/ClientApp/App.xaml.cs new file mode 100644 index 0000000..03d8e97 --- /dev/null +++ b/ClientApp/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace ClientApp +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/ClientApp/AssemblyInfo.cs b/ClientApp/AssemblyInfo.cs new file mode 100644 index 0000000..8b5504e --- /dev/null +++ b/ClientApp/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/ClientApp/ClientApp.csproj b/ClientApp/ClientApp.csproj new file mode 100644 index 0000000..c66ed7c --- /dev/null +++ b/ClientApp/ClientApp.csproj @@ -0,0 +1,15 @@ + + + + WinExe + netcoreapp3.1 + true + + + + + + + + + \ No newline at end of file diff --git a/ClientApp/FodyWeavers.xml b/ClientApp/FodyWeavers.xml new file mode 100644 index 0000000..d5abfed --- /dev/null +++ b/ClientApp/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/ClientApp/FodyWeavers.xsd b/ClientApp/FodyWeavers.xsd new file mode 100644 index 0000000..69dbe48 --- /dev/null +++ b/ClientApp/FodyWeavers.xsd @@ -0,0 +1,74 @@ + + + + + + + + + + + Used to control if the On_PropertyName_Changed feature is enabled. + + + + + Used to control if the Dependent properties feature is enabled. + + + + + Used to control if the IsChanged property feature is enabled. + + + + + Used to change the name of the method that fires the notify event. This is a string that accepts multiple values in a comma separated form. + + + + + Used to control if equality checks should be inserted. If false, equality checking will be disabled for the project. + + + + + Used to control if equality checks should use the Equals method resolved from the base class. + + + + + Used to control if equality checks should use the static Equals method resolved from the base class. + + + + + Used to turn off build warnings from this weaver. + + + + + Used to turn off build warnings about mismatched On_PropertyName_Changed methods. + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/ClientApp/Models/ClientInfo.cs b/ClientApp/Models/ClientInfo.cs new file mode 100644 index 0000000..c048917 --- /dev/null +++ b/ClientApp/Models/ClientInfo.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; +using ClientApp.Utils; + +namespace ClientApp.Models +{ + class ClientInfo : ObservableObject + { + public string FirstName { get; set; } + public string LastName { get; set; } + } +} diff --git a/ClientApp/Utils/ObservableObject.cs b/ClientApp/Utils/ObservableObject.cs new file mode 100644 index 0000000..3809fa1 --- /dev/null +++ b/ClientApp/Utils/ObservableObject.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Text; + +namespace ClientApp.Utils +{ + public abstract class ObservableObject : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + } +} diff --git a/ClientApp/ViewModels/LoginViewModel.cs b/ClientApp/ViewModels/LoginViewModel.cs new file mode 100644 index 0000000..ad5b348 --- /dev/null +++ b/ClientApp/ViewModels/LoginViewModel.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; +using ClientApp.Utils; + +namespace ClientApp.ViewModels +{ + class LoginViewModel : ObservableObject + { + } +} diff --git a/ClientApp/ViewModels/MainViewModel.cs b/ClientApp/ViewModels/MainViewModel.cs new file mode 100644 index 0000000..952439c --- /dev/null +++ b/ClientApp/ViewModels/MainViewModel.cs @@ -0,0 +1,18 @@ +using ClientApp.Utils; +using System; +using System.Collections.Generic; +using System.Text; + +namespace ClientApp.ViewModels +{ + class MainViewModel : ObservableObject + { + + public ObservableObject SelectedViewModel { get; set; } + + public MainViewModel() + { + SelectedViewModel = new LoginViewModel(); + } + } +} diff --git a/ClientApp/Views/LoginView.xaml b/ClientApp/Views/LoginView.xaml new file mode 100644 index 0000000..a24b69c --- /dev/null +++ b/ClientApp/Views/LoginView.xaml @@ -0,0 +1,18 @@ + + + +