From 149c327f7e55eabbdfc5b79472381a5e2509740e Mon Sep 17 00:00:00 2001 From: fabjuuuh Date: Wed, 9 Sep 2020 15:02:10 +0200 Subject: [PATCH] BikeSimulater Start --- ProftaakRH/BikeSimulator.cs | 37 +++++++++++++++++++++++++++++------- ProftaakRH/ProftaakRH.csproj | 4 ++++ 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/ProftaakRH/BikeSimulator.cs b/ProftaakRH/BikeSimulator.cs index 6ea68d3..e1c058f 100644 --- a/ProftaakRH/BikeSimulator.cs +++ b/ProftaakRH/BikeSimulator.cs @@ -1,13 +1,17 @@ -using System; +using LibNoise.Primitive; +using System; using System.Collections.Generic; using System.Text; using System.Threading; + + namespace Hardware.Simulators { class BikeSimulator { IDataConverter dataConverter; + private int eventCounter = 0; public BikeSimulator(IDataConverter dataConverter) { @@ -16,22 +20,41 @@ namespace Hardware.Simulators public void StartSimulation() { //4A-09-4E-05-19-16-00-FF-28-00-00-20-F0 + + float x = 0.0f; + + ImprovedPerlin improvedPerlin = new ImprovedPerlin(0,LibNoise.NoiseQuality.Best); while (true) { - byte[] array = { 0x19, 0x16, 0x00, 0xFF, 0x28, 0x00, 0x00, 0x20, 0xF0 }; - + byte[] array = { 0x19, 0x16, 0x00, 0xFF, 0x28, 0x00, 0x00, 0x20 }; + Console.WriteLine(improvedPerlin.GetValue(x)+1); //0x10 message - dataConverter.Bike(array); + /*foreach(byte s in array) + { + Console.Write("{0:X}",s); + }*/ + dataConverter.Bike(GenerateBike(improvedPerlin.GetValue(x)+1)); //0x19 message - dataConverter.Bike(array); + //dataConverter.Bike(array); //Heartbeat message - dataConverter.BPM(array); + //dataConverter.BPM(array); Thread.Sleep(1000); - + x += 1f; + eventCounter++; } } + private byte[] GenerateBike(float perlin) + { + byte[] bikeByte = {0x19,0x} + return new byte[1]; + } + + private double Random(double x) + { + return (Math.Sin(2 * x) + Math.Sin(Math.PI * x) + 2) / 4; + } } } diff --git a/ProftaakRH/ProftaakRH.csproj b/ProftaakRH/ProftaakRH.csproj index ca49088..8f98a2c 100644 --- a/ProftaakRH/ProftaakRH.csproj +++ b/ProftaakRH/ProftaakRH.csproj @@ -4,6 +4,10 @@ Exe netcoreapp3.1 + + + + .\dll\BLELibrary.dll