NucuCar/NucuCar.Sensors/Program.cs

33 lines
1.2 KiB
C#
Raw Normal View History

using Microsoft.AspNetCore.Hosting;
2019-11-09 13:34:49 +00:00
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using NucuCar.Sensors.Environment;
using NucuCar.Sensors.Telemetry;
2019-11-09 13:34:49 +00:00
namespace NucuCar.Sensors
2019-11-09 13:34:49 +00:00
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
2019-11-09 13:34:49 +00:00
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureServices((hostContext, services) =>
{
services.Configure<TelemetryConfig>(hostContext.Configuration.GetSection("Telemetry"));
services.Configure<Bme680Config>(hostContext.Configuration.GetSection("EnvironmentSensor"));
// Singletons
services.AddSingleton<SensorTelemetry>();
2019-11-30 16:55:55 +00:00
services.AddSingleton<ISensor<Bme680Sensor>, Bme680Sensor>();
// Workers
services.AddHostedService<TelemetryWorker>();
services.AddHostedService<Bme680Worker>();
})
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<GrpcStartup>(); });
2019-11-09 13:34:49 +00:00
}
}