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