diff --git a/NucuCar.Sensors/Environment/Bme680Worker.cs b/NucuCar.Sensors/Environment/Bme680Worker.cs index 47db676..536b7ce 100644 --- a/NucuCar.Sensors/Environment/Bme680Worker.cs +++ b/NucuCar.Sensors/Environment/Bme680Worker.cs @@ -5,11 +5,11 @@ namespace NucuCar.Sensors.Environment { public class Bme680Worker : SensorWorker { - public Bme680Worker(ILogger logger, SensorTelemetry sensorTelemetry, ISensor sensor) + public Bme680Worker(ILogger logger, Telemetry.Telemetry telemetry, ISensor sensor) { Logger = logger; MeasurementInterval = 3000; - TelemetryPublisher = sensorTelemetry.Publisher; + TelemetryPublisher = telemetry.Publisher; Sensor = sensor.Object; } } diff --git a/NucuCar.Sensors/Health/CpuTempWorker.cs b/NucuCar.Sensors/Health/CpuTempWorker.cs index 89d18a5..471c40d 100644 --- a/NucuCar.Sensors/Health/CpuTempWorker.cs +++ b/NucuCar.Sensors/Health/CpuTempWorker.cs @@ -5,11 +5,11 @@ namespace NucuCar.Sensors.Health { public class CpuTempWorker : SensorWorker { - public CpuTempWorker(ILogger logger, SensorTelemetry sensorTelemetry, ISensor sensor) + public CpuTempWorker(ILogger logger, Telemetry.Telemetry telemetry, ISensor sensor) { Logger = logger; MeasurementInterval = 3000; - TelemetryPublisher = sensorTelemetry.Publisher; + TelemetryPublisher = telemetry.Publisher; Sensor = sensor.Object; } } diff --git a/NucuCar.Sensors/Program.cs b/NucuCar.Sensors/Program.cs index 4268762..cfd0fe0 100644 --- a/NucuCar.Sensors/Program.cs +++ b/NucuCar.Sensors/Program.cs @@ -24,7 +24,7 @@ namespace NucuCar.Sensors services.Configure(hostContext.Configuration.GetSection("HealthSensor")); // Singletons - services.AddSingleton(); + services.AddSingleton(); services.AddSingleton, Bme680Sensor>(); services.AddSingleton, CpuTempSensor>(); diff --git a/NucuCar.Telemetry/SensorTelemetry.cs b/NucuCar.Telemetry/Telemetry.cs similarity index 66% rename from NucuCar.Telemetry/SensorTelemetry.cs rename to NucuCar.Telemetry/Telemetry.cs index 4549da7..f7137b3 100644 --- a/NucuCar.Telemetry/SensorTelemetry.cs +++ b/NucuCar.Telemetry/Telemetry.cs @@ -6,15 +6,19 @@ using NucuCar.Domain.Telemetry; namespace NucuCar.Telemetry { - public class SensorTelemetry + public class Telemetry { public TelemetryPublisher Publisher { get; set; } - public SensorTelemetry() + /// + /// Class used together with the DI, holds a Publisher instance that's being create by options from + /// TelemetryConfig. + /// + public Telemetry() { } - public SensorTelemetry(ILogger logger, IOptions options) + public Telemetry(ILogger logger, IOptions options) { if (options.Value.ServiceEnabled) { diff --git a/NucuCar.Telemetry/TelemetryWorker.cs b/NucuCar.Telemetry/TelemetryWorker.cs index 9676b59..bcc53f8 100644 --- a/NucuCar.Telemetry/TelemetryWorker.cs +++ b/NucuCar.Telemetry/TelemetryWorker.cs @@ -19,12 +19,12 @@ namespace NucuCar.Telemetry private readonly TelemetryPublisher _telemetryPublisher; public TelemetryWorker(ILogger logger, IOptions options, - SensorTelemetry sensorTelemetry) + Telemetry telemetry) { _logger = logger; _interval = options.Value.PublishInterval; _serviceEnabled = options.Value.ServiceEnabled; - _telemetryPublisher = sensorTelemetry.Publisher; + _telemetryPublisher = telemetry.Publisher; } protected override async Task ExecuteAsync(CancellationToken stoppingToken) diff --git a/NucuCar.UnitTests/NucuCar.Sensors.Tests/EnvironmentSensor.Tests/Bme680WorkerTests.cs b/NucuCar.UnitTests/NucuCar.Sensors.Tests/EnvironmentSensor.Tests/Bme680WorkerTests.cs index bf02d44..a5635ae 100644 --- a/NucuCar.UnitTests/NucuCar.Sensors.Tests/EnvironmentSensor.Tests/Bme680WorkerTests.cs +++ b/NucuCar.UnitTests/NucuCar.Sensors.Tests/EnvironmentSensor.Tests/Bme680WorkerTests.cs @@ -5,7 +5,6 @@ using Microsoft.Extensions.Options; using Moq; using NucuCar.Sensors; using NucuCar.Sensors.Environment; -using NucuCar.Telemetry; using NucuCarSensorsProto; using Xunit; @@ -15,7 +14,7 @@ namespace NucuCar.UnitTests.NucuCar.Sensors.Tests.EnvironmentSensor.Tests { private readonly Mock> _mockLogger; private readonly Mock> _mockOptions; - private readonly Mock _mockSensorTelemetry; + private readonly Mock _mockSensorTelemetry; private readonly Mock _mockTestBme680Sensor; private readonly Mock> _mockBme680ISensor; private readonly CancellationTokenSource _cts; @@ -25,7 +24,7 @@ namespace NucuCar.UnitTests.NucuCar.Sensors.Tests.EnvironmentSensor.Tests _cts = new CancellationTokenSource(); _mockLogger = new Mock>(); _mockOptions = new Mock>(); - _mockSensorTelemetry = new Mock(); + _mockSensorTelemetry = new Mock(); _mockTestBme680Sensor = new Mock(); _mockBme680ISensor = new Mock>(); diff --git a/Readme.md b/Readme.md index 4ea98b1..0a2f648 100644 --- a/Readme.md +++ b/Readme.md @@ -11,10 +11,20 @@ https://docs.microsoft.com/en-us/dotnet/core/install/ ### NucuCar.Domain -Holds common classes and interfaces that are required by the other projects. +Holds common classes and interfaces that are required by the projects. It provides all the types that are generated via protocol buffers. +### NucuCar.Common + +Contains implementations for common logic, contains wrappers. +Usually utility classes and methods that are not necessarily tied to this solution +and can be reused. + +### NucuCar.Telemetry + +Holds concrete implementation for telemetry publishers and workers. + ### NucuCar.Sensors Manages all the car sensors. For more info see the readme file located in the project directory.