2019-11-10 12:38:40 +00:00
|
|
|
using Microsoft.AspNetCore.Hosting;
|
2019-11-24 15:47:17 +00:00
|
|
|
using Microsoft.Extensions.Configuration;
|
2019-11-09 13:34:49 +00:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.Hosting;
|
2019-11-24 16:40:42 +00:00
|
|
|
using NucuCar.Sensors.EnvironmentSensor;
|
|
|
|
using NucuCar.Sensors.Telemetry;
|
2019-11-09 13:34:49 +00:00
|
|
|
|
2019-11-09 17:23:07 +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-10 12:38:40 +00:00
|
|
|
|
2019-11-09 13:34:49 +00:00
|
|
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
|
|
|
Host.CreateDefaultBuilder(args)
|
2019-11-11 11:28:52 +00:00
|
|
|
.ConfigureServices((hostContext, services) =>
|
|
|
|
{
|
2019-11-24 16:40:42 +00:00
|
|
|
// Transient
|
|
|
|
services.AddTransient<TelemetryConfig>();
|
|
|
|
services.AddTransient<Bme680Config>();
|
|
|
|
|
2019-11-24 15:47:17 +00:00
|
|
|
// Singletons
|
2019-11-24 16:40:42 +00:00
|
|
|
services.AddSingleton<SensorTelemetry>();
|
|
|
|
services.AddSingleton<Bme680Sensor>();
|
2019-11-24 15:47:17 +00:00
|
|
|
|
|
|
|
// Workers
|
2019-11-24 16:40:42 +00:00
|
|
|
services.AddHostedService<TelemetryWorker>();
|
|
|
|
services.AddHostedService<Bme680Worker>();
|
2019-11-11 11:28:52 +00:00
|
|
|
})
|
2019-11-24 16:03:46 +00:00
|
|
|
.ConfigureWebHostDefaults(webBuilder =>
|
|
|
|
{
|
|
|
|
webBuilder.UseStartup<GrpcStartup>();
|
|
|
|
});
|
2019-11-09 13:34:49 +00:00
|
|
|
}
|
|
|
|
}
|