NUC-43: Update readme.md & rename SensorTelemetry to Telemetry.
This commit is contained in:
parent
af9e5d4bf9
commit
69c3a80d34
7 changed files with 27 additions and 14 deletions
|
@ -5,11 +5,11 @@ namespace NucuCar.Sensors.Environment
|
|||
{
|
||||
public class Bme680Worker : SensorWorker
|
||||
{
|
||||
public Bme680Worker(ILogger<Bme680Worker> logger, SensorTelemetry sensorTelemetry, ISensor<Bme680Sensor> sensor)
|
||||
public Bme680Worker(ILogger<Bme680Worker> logger, Telemetry.Telemetry telemetry, ISensor<Bme680Sensor> sensor)
|
||||
{
|
||||
Logger = logger;
|
||||
MeasurementInterval = 3000;
|
||||
TelemetryPublisher = sensorTelemetry.Publisher;
|
||||
TelemetryPublisher = telemetry.Publisher;
|
||||
Sensor = sensor.Object;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,11 +5,11 @@ namespace NucuCar.Sensors.Health
|
|||
{
|
||||
public class CpuTempWorker : SensorWorker
|
||||
{
|
||||
public CpuTempWorker(ILogger<CpuTempWorker> logger, SensorTelemetry sensorTelemetry, ISensor<CpuTempSensor> sensor)
|
||||
public CpuTempWorker(ILogger<CpuTempWorker> logger, Telemetry.Telemetry telemetry, ISensor<CpuTempSensor> sensor)
|
||||
{
|
||||
Logger = logger;
|
||||
MeasurementInterval = 3000;
|
||||
TelemetryPublisher = sensorTelemetry.Publisher;
|
||||
TelemetryPublisher = telemetry.Publisher;
|
||||
Sensor = sensor.Object;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace NucuCar.Sensors
|
|||
services.Configure<CpuTempConfig>(hostContext.Configuration.GetSection("HealthSensor"));
|
||||
|
||||
// Singletons
|
||||
services.AddSingleton<SensorTelemetry>();
|
||||
services.AddSingleton<Telemetry.Telemetry>();
|
||||
services.AddSingleton<ISensor<Bme680Sensor>, Bme680Sensor>();
|
||||
services.AddSingleton<ISensor<CpuTempSensor>, CpuTempSensor>();
|
||||
|
||||
|
|
|
@ -6,15 +6,19 @@ using NucuCar.Domain.Telemetry;
|
|||
|
||||
namespace NucuCar.Telemetry
|
||||
{
|
||||
public class SensorTelemetry
|
||||
public class Telemetry
|
||||
{
|
||||
public TelemetryPublisher Publisher { get; set; }
|
||||
|
||||
public SensorTelemetry()
|
||||
/// <summary>
|
||||
/// Class used together with the DI, holds a Publisher instance that's being create by options from
|
||||
/// TelemetryConfig.
|
||||
/// </summary>
|
||||
public Telemetry()
|
||||
{
|
||||
}
|
||||
|
||||
public SensorTelemetry(ILogger<SensorTelemetry> logger, IOptions<TelemetryConfig> options)
|
||||
public Telemetry(ILogger<Telemetry> logger, IOptions<TelemetryConfig> options)
|
||||
{
|
||||
if (options.Value.ServiceEnabled)
|
||||
{
|
|
@ -19,12 +19,12 @@ namespace NucuCar.Telemetry
|
|||
private readonly TelemetryPublisher _telemetryPublisher;
|
||||
|
||||
public TelemetryWorker(ILogger<TelemetryWorker> logger, IOptions<TelemetryConfig> 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)
|
||||
|
|
|
@ -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<ILogger<Bme680Worker>> _mockLogger;
|
||||
private readonly Mock<IOptions<Bme680Config>> _mockOptions;
|
||||
private readonly Mock<SensorTelemetry> _mockSensorTelemetry;
|
||||
private readonly Mock<global::NucuCar.Telemetry.Telemetry> _mockSensorTelemetry;
|
||||
private readonly Mock<TestBme680Sensor> _mockTestBme680Sensor;
|
||||
private readonly Mock<ISensor<Bme680Sensor>> _mockBme680ISensor;
|
||||
private readonly CancellationTokenSource _cts;
|
||||
|
@ -25,7 +24,7 @@ namespace NucuCar.UnitTests.NucuCar.Sensors.Tests.EnvironmentSensor.Tests
|
|||
_cts = new CancellationTokenSource();
|
||||
_mockLogger = new Mock<ILogger<Bme680Worker>>();
|
||||
_mockOptions = new Mock<IOptions<Bme680Config>>();
|
||||
_mockSensorTelemetry = new Mock<SensorTelemetry>();
|
||||
_mockSensorTelemetry = new Mock<global::NucuCar.Telemetry.Telemetry>();
|
||||
_mockTestBme680Sensor = new Mock<TestBme680Sensor>();
|
||||
_mockBme680ISensor = new Mock<ISensor<Bme680Sensor>>();
|
||||
|
||||
|
|
12
Readme.md
12
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.
|
||||
|
|
Loading…
Reference in a new issue