From 2f34f16a09a5700149322c47191c12f8df8fd6f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Nu=C8=9Biu?= Date: Tue, 17 Dec 2019 21:44:15 +0200 Subject: [PATCH] Refactor GenericSensor: rename IntializeSensor to Initialize --- NucuCar.Domain/Sensors/Bme680MeasurementData.cs | 1 + NucuCar.Domain/Sensors/GenericSensor.cs | 2 +- NucuCar.Sensors/EnvironmentSensor/Bme680Sensor.cs | 2 +- NucuCar.Sensors/EnvironmentSensor/Bme680Worker.cs | 4 ++-- .../EnvironmentSensor.Tests/TestBme680Sensor.cs | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/NucuCar.Domain/Sensors/Bme680MeasurementData.cs b/NucuCar.Domain/Sensors/Bme680MeasurementData.cs index 7518f32..02ce614 100644 --- a/NucuCar.Domain/Sensors/Bme680MeasurementData.cs +++ b/NucuCar.Domain/Sensors/Bme680MeasurementData.cs @@ -1,5 +1,6 @@ namespace NucuCar.Domain.Sensors { + // TODO Make generic, reuse nucucarsensor response or modify this. public class Bme680MeasurementData { public double Temperature { get; set; } diff --git a/NucuCar.Domain/Sensors/GenericSensor.cs b/NucuCar.Domain/Sensors/GenericSensor.cs index 55d83e1..ff2237b 100644 --- a/NucuCar.Domain/Sensors/GenericSensor.cs +++ b/NucuCar.Domain/Sensors/GenericSensor.cs @@ -10,7 +10,7 @@ namespace NucuCar.Domain.Sensors protected ILogger Logger; protected SensorStateEnum SensorStateEnum; - public abstract void InitializeSensor(); + public abstract void Initialize(); public abstract Task TakeMeasurementAsync(); public abstract Bme680MeasurementData GetMeasurement(); public abstract SensorStateEnum GetState(); diff --git a/NucuCar.Sensors/EnvironmentSensor/Bme680Sensor.cs b/NucuCar.Sensors/EnvironmentSensor/Bme680Sensor.cs index 8fb69b3..896d2f4 100644 --- a/NucuCar.Sensors/EnvironmentSensor/Bme680Sensor.cs +++ b/NucuCar.Sensors/EnvironmentSensor/Bme680Sensor.cs @@ -57,7 +57,7 @@ namespace NucuCar.Sensors.EnvironmentSensor _bme680?.Dispose(); } - public override void InitializeSensor() + public override void Initialize() { if (SensorStateEnum == SensorStateEnum.Initialized || SensorStateEnum == SensorStateEnum.Disabled) { diff --git a/NucuCar.Sensors/EnvironmentSensor/Bme680Worker.cs b/NucuCar.Sensors/EnvironmentSensor/Bme680Worker.cs index c541473..2e367a4 100644 --- a/NucuCar.Sensors/EnvironmentSensor/Bme680Worker.cs +++ b/NucuCar.Sensors/EnvironmentSensor/Bme680Worker.cs @@ -33,7 +33,7 @@ namespace NucuCar.Sensors.EnvironmentSensor _logger.LogInformation("Starting sensor worker"); _telemetryPublisher?.RegisterTelemeter(_bme680Sensor.Object); - _bme680Sensor.Object.InitializeSensor(); + _bme680Sensor.Object.Initialize(); while (!stoppingToken.IsCancellationRequested) { /* If sensor is ok attempt to read. */ @@ -46,7 +46,7 @@ namespace NucuCar.Sensors.EnvironmentSensor _bme680Sensor.Object.GetState() == SensorStateEnum.Error) { await Task.Delay(10000, stoppingToken); - _bme680Sensor.Object.InitializeSensor(); + _bme680Sensor.Object.Initialize(); } await Task.Delay(_measurementInterval, stoppingToken); diff --git a/NucuCar.UnitTests/NucuCar.Sensors.Tests/EnvironmentSensor.Tests/TestBme680Sensor.cs b/NucuCar.UnitTests/NucuCar.Sensors.Tests/EnvironmentSensor.Tests/TestBme680Sensor.cs index 1c1c6ab..519a8a3 100644 --- a/NucuCar.UnitTests/NucuCar.Sensors.Tests/EnvironmentSensor.Tests/TestBme680Sensor.cs +++ b/NucuCar.UnitTests/NucuCar.Sensors.Tests/EnvironmentSensor.Tests/TestBme680Sensor.cs @@ -13,7 +13,7 @@ namespace NucuCar.UnitTests.NucuCar.Sensors.Tests.EnvironmentSensor.Tests return Task.CompletedTask; } - public override void InitializeSensor() + public override void Initialize() { }