BikeSimulater Start

This commit is contained in:
fabjuuuh
2020-09-09 15:02:10 +02:00
parent 9c55b545dd
commit 149c327f7e
2 changed files with 34 additions and 7 deletions

View File

@@ -1,13 +1,17 @@
using System; using LibNoise.Primitive;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
namespace Hardware.Simulators namespace Hardware.Simulators
{ {
class BikeSimulator class BikeSimulator
{ {
IDataConverter dataConverter; IDataConverter dataConverter;
private int eventCounter = 0;
public BikeSimulator(IDataConverter dataConverter) public BikeSimulator(IDataConverter dataConverter)
{ {
@@ -17,21 +21,40 @@ namespace Hardware.Simulators
{ {
//4A-09-4E-05-19-16-00-FF-28-00-00-20-F0 //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) 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 //0x10 message
dataConverter.Bike(array); /*foreach(byte s in array)
{
Console.Write("{0:X}",s);
}*/
dataConverter.Bike(GenerateBike(improvedPerlin.GetValue(x)+1));
//0x19 message //0x19 message
dataConverter.Bike(array); //dataConverter.Bike(array);
//Heartbeat message //Heartbeat message
dataConverter.BPM(array); //dataConverter.BPM(array);
Thread.Sleep(1000); 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;
}
} }
} }

View File

@@ -4,6 +4,10 @@
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="LibNoise" Version="0.2.0" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="BLELibrary"> <Reference Include="BLELibrary">
<HintPath>.\dll\BLELibrary.dll</HintPath> <HintPath>.\dll\BLELibrary.dll</HintPath>