NucuCar/NucuCar.Sensors/Telemetry/SensorTelemetry.cs

30 lines
807 B
C#
Raw Normal View History

using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NucuCar.Domain.Telemetry;
2019-12-28 15:09:17 +00:00
// ReSharper disable ClassWithVirtualMembersNeverInherited.Global
namespace NucuCar.Sensors.Telemetry
{
public class SensorTelemetry
{
public TelemetryPublisher Publisher { get; set; }
public SensorTelemetry()
{
}
2019-12-28 15:09:17 +00:00
public SensorTelemetry(ILogger<SensorTelemetry> logger, IOptions<TelemetryConfig> options)
{
if (options.Value.ServiceEnabled)
{
2019-12-28 15:09:17 +00:00
Publisher = TelemetryPublisherFactory.Create(options.Value.Publisher, options.Value.ConnectionString,
"NucuCar.Sensors", logger);
}
else
{
Publisher = null;
}
}
}
}