merge Develop into master #9
@@ -4,6 +4,7 @@ using System.Text;
|
||||
using Avans.TI.BLE;
|
||||
using System.Threading;
|
||||
using System.Security.Cryptography;
|
||||
using ProftaakRH;
|
||||
|
||||
namespace Hardware
|
||||
{
|
||||
@@ -12,7 +13,7 @@ namespace Hardware
|
||||
/// </summary>
|
||||
class BLEHandler
|
||||
{
|
||||
IDataConverter dataConverter;
|
||||
IDataReceiver dataReceiver;
|
||||
private BLE bleBike;
|
||||
private BLE bleHeart;
|
||||
public bool Running { get; set; }
|
||||
@@ -20,10 +21,10 @@ namespace Hardware
|
||||
/// <summary>
|
||||
/// Makes a new BLEHandler object
|
||||
/// </summary>
|
||||
/// <param name="dataConverter">the dataconverter object</param>
|
||||
public BLEHandler(IDataConverter dataConverter)
|
||||
/// <param name="dataReceiver">the dataconverter object</param>
|
||||
public BLEHandler(IDataReceiver dataReceiver)
|
||||
{
|
||||
this.dataConverter = dataConverter;
|
||||
this.dataReceiver = dataReceiver;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -124,11 +125,11 @@ namespace Hardware
|
||||
{
|
||||
byte[] payload = new byte[8];
|
||||
Array.Copy(e.Data, 4, payload, 0, 8);
|
||||
this.dataConverter.Bike(payload);
|
||||
this.dataReceiver.Bike(payload);
|
||||
}
|
||||
else if (e.ServiceName == "00002a37-0000-1000-8000-00805f9b34fb")
|
||||
{
|
||||
this.dataConverter.BPM(e.Data);
|
||||
this.dataReceiver.BPM(e.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using LibNoise.Primitive;
|
||||
using ProftaakRH;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -11,7 +12,7 @@ namespace Hardware.Simulators
|
||||
{
|
||||
class BikeSimulator : IHandler
|
||||
{
|
||||
IDataConverter dataConverter;
|
||||
IDataReceiver dataReceiver;
|
||||
private int elapsedTime = 0;
|
||||
private int eventCounter = 0;
|
||||
private double distanceTraveled = 0;
|
||||
@@ -29,9 +30,9 @@ namespace Hardware.Simulators
|
||||
|
||||
|
||||
|
||||
public BikeSimulator(IDataConverter dataConverter)
|
||||
public BikeSimulator(IDataReceiver dataReceiver)
|
||||
{
|
||||
this.dataConverter = dataConverter;
|
||||
this.dataReceiver = dataReceiver;
|
||||
}
|
||||
public void StartSimulation()
|
||||
{
|
||||
@@ -48,9 +49,9 @@ namespace Hardware.Simulators
|
||||
CalculateVariables(improvedPerlin.GetValue(x) + 1);
|
||||
|
||||
//Simulate sending data
|
||||
dataConverter.Bike(GenerateBike0x19());
|
||||
dataConverter.Bike(GenerateBike0x10());
|
||||
dataConverter.BPM(GenerateHeart());
|
||||
dataReceiver.Bike(GenerateBike0x19());
|
||||
dataReceiver.Bike(GenerateBike0x10());
|
||||
dataReceiver.BPM(GenerateHeart());
|
||||
|
||||
Thread.Sleep(1000);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using ProftaakRH;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -7,7 +8,7 @@ namespace Hardware
|
||||
/// <summary>
|
||||
/// DataConverter class that handles all conversion of received data from the BLE bike.
|
||||
/// </summary>
|
||||
class DataConverter : IDataConverter
|
||||
class DataConverter : IDataReceiver
|
||||
{
|
||||
/// <summary>
|
||||
/// Receives, parses and displays any incoming data from the bike.
|
||||
@@ -103,13 +104,4 @@ namespace Hardware
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dataconverter interface for handling data received from the bike
|
||||
/// </summary>
|
||||
interface IDataConverter
|
||||
{
|
||||
void BPM(byte[] bytes);
|
||||
void Bike(byte[] bytes);
|
||||
}
|
||||
}
|
||||
|
||||
12
ProftaakRH/IDataReceiver.cs
Normal file
12
ProftaakRH/IDataReceiver.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ProftaakRH
|
||||
{
|
||||
interface IDataReceiver
|
||||
{
|
||||
void BPM(byte[] bytes);
|
||||
void Bike(byte[] bytes);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user